]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Rework wheelchairbound (#24173)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Fri, 19 Jan 2024 05:18:19 +0000 (16:18 +1100)
committerGitHub <noreply@github.com>
Fri, 19 Jan 2024 05:18:19 +0000 (00:18 -0500)
* Rework wheelchairbound

Fixes the save/load bug and fixes it being a singleton.

* weh

Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs [new file with mode: 0644]
Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs [new file with mode: 0644]
Content.Server/Traits/Assorted/WheelchairBoundComponent.cs [deleted file]
Content.Server/Traits/Assorted/WheelchairBoundSystem.cs [deleted file]
Resources/Prototypes/Traits/disabilities.yml

diff --git a/Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs b/Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs
new file mode 100644 (file)
index 0000000..3e54039
--- /dev/null
@@ -0,0 +1,14 @@
+using Robust.Shared.Prototypes;
+
+namespace Content.Server.Traits.Assorted;
+
+/// <summary>
+/// Upon MapInit buckles the attached entity to a newly spawned prototype.
+/// </summary>
+[RegisterComponent, Access(typeof(BuckleOnMapInitSystem))]
+public sealed partial class BuckleOnMapInitComponent : Component
+{
+    [ViewVariables(VVAccess.ReadWrite)]
+    [DataField(required: true)]
+    public EntProtoId Prototype;
+}
diff --git a/Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs b/Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs
new file mode 100644 (file)
index 0000000..7857f20
--- /dev/null
@@ -0,0 +1,19 @@
+using Content.Shared.Buckle;
+
+namespace Content.Server.Traits.Assorted;
+
+public sealed class BuckleOnMapInitSystem : EntitySystem
+{
+    [Dependency] private readonly SharedBuckleSystem _buckleSystem = default!;
+
+    public override void Initialize()
+    {
+        SubscribeLocalEvent<BuckleOnMapInitComponent, MapInitEvent>(OnMapInit);
+    }
+
+    private void OnMapInit(EntityUid uid, BuckleOnMapInitComponent component, MapInitEvent args)
+    {
+        var buckle = Spawn(component.Prototype, Transform(uid).Coordinates);
+        _buckleSystem.TryBuckle(uid, uid, buckle);
+    }
+}
diff --git a/Content.Server/Traits/Assorted/WheelchairBoundComponent.cs b/Content.Server/Traits/Assorted/WheelchairBoundComponent.cs
deleted file mode 100644 (file)
index 44608ba..0000000
+++ /dev/null
@@ -1,15 +0,0 @@
-using Robust.Shared.Prototypes;
-using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
-
-namespace Content.Server.Traits.Assorted;
-
-/// <summary>
-/// On adding spawns wheelchair prototype and tries buckle player to it, then self removing
-/// </summary>
-[RegisterComponent, Access(typeof(WheelchairBoundSystem))]
-public sealed partial class WheelchairBoundComponent : Component
-{
-    [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("wheelchairPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
-    public string WheelchairPrototype = "VehicleWheelchair";
-}
diff --git a/Content.Server/Traits/Assorted/WheelchairBoundSystem.cs b/Content.Server/Traits/Assorted/WheelchairBoundSystem.cs
deleted file mode 100644 (file)
index 11721c4..0000000
+++ /dev/null
@@ -1,20 +0,0 @@
-using Content.Shared.Buckle;
-using Content.Shared.Traits.Assorted;
-
-namespace Content.Server.Traits.Assorted;
-
-public sealed class WheelchairBoundSystem : EntitySystem
-{
-    [Dependency] private readonly SharedBuckleSystem _buckleSystem = default!;
-
-    public override void Initialize()
-    {
-        SubscribeLocalEvent<WheelchairBoundComponent, ComponentStartup>(OnStartup);
-    }
-
-    private void OnStartup(EntityUid uid, WheelchairBoundComponent component, ComponentStartup args)
-    {
-        var wheelchair = Spawn(component.WheelchairPrototype, Transform(uid).Coordinates);
-        _buckleSystem.TryBuckle(uid, uid, wheelchair);
-    }
-}
index 73476e101d790906cac822dee465acacd62e95fe..14f633058032d5d3ed282f1c9f96545270d51cc6 100644 (file)
@@ -49,7 +49,8 @@
   name: trait-wheelchair-bound-name
   description: trait-wheelchair-bound-desc
   components:
-    - type: WheelchairBound
+    - type: BuckleOnMapInit
+      prototype: VehicleWheelchair
     - type: LegsParalyzed
 
 - type: trait