From 243491dd596ffad3698d1d00a645195f2224386f Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Fri, 19 Jan 2024 16:18:19 +1100 Subject: [PATCH] Rework wheelchairbound (#24173) * Rework wheelchairbound Fixes the save/load bug and fixes it being a singleton. * weh --- .../Assorted/BuckleOnMapInitComponent.cs | 14 +++++++++++++ .../Traits/Assorted/BuckleOnMapInitSystem.cs | 19 ++++++++++++++++++ .../Assorted/WheelchairBoundComponent.cs | 15 -------------- .../Traits/Assorted/WheelchairBoundSystem.cs | 20 ------------------- Resources/Prototypes/Traits/disabilities.yml | 3 ++- 5 files changed, 35 insertions(+), 36 deletions(-) create mode 100644 Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs create mode 100644 Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs delete mode 100644 Content.Server/Traits/Assorted/WheelchairBoundComponent.cs delete mode 100644 Content.Server/Traits/Assorted/WheelchairBoundSystem.cs diff --git a/Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs b/Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs new file mode 100644 index 0000000000..3e540391cb --- /dev/null +++ b/Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs @@ -0,0 +1,14 @@ +using Robust.Shared.Prototypes; + +namespace Content.Server.Traits.Assorted; + +/// +/// Upon MapInit buckles the attached entity to a newly spawned prototype. +/// +[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 index 0000000000..7857f20bc3 --- /dev/null +++ b/Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs @@ -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(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 index 44608ba4ac..0000000000 --- a/Content.Server/Traits/Assorted/WheelchairBoundComponent.cs +++ /dev/null @@ -1,15 +0,0 @@ -using Robust.Shared.Prototypes; -using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; - -namespace Content.Server.Traits.Assorted; - -/// -/// On adding spawns wheelchair prototype and tries buckle player to it, then self removing -/// -[RegisterComponent, Access(typeof(WheelchairBoundSystem))] -public sealed partial class WheelchairBoundComponent : Component -{ - [ViewVariables(VVAccess.ReadWrite)] - [DataField("wheelchairPrototype", customTypeSerializer: typeof(PrototypeIdSerializer))] - public string WheelchairPrototype = "VehicleWheelchair"; -} diff --git a/Content.Server/Traits/Assorted/WheelchairBoundSystem.cs b/Content.Server/Traits/Assorted/WheelchairBoundSystem.cs deleted file mode 100644 index 11721c4070..0000000000 --- a/Content.Server/Traits/Assorted/WheelchairBoundSystem.cs +++ /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(OnStartup); - } - - private void OnStartup(EntityUid uid, WheelchairBoundComponent component, ComponentStartup args) - { - var wheelchair = Spawn(component.WheelchairPrototype, Transform(uid).Coordinates); - _buckleSystem.TryBuckle(uid, uid, wheelchair); - } -} diff --git a/Resources/Prototypes/Traits/disabilities.yml b/Resources/Prototypes/Traits/disabilities.yml index 73476e101d..14f6330580 100644 --- a/Resources/Prototypes/Traits/disabilities.yml +++ b/Resources/Prototypes/Traits/disabilities.yml @@ -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 -- 2.51.2