Rework wheelchairbound (#24173)
* Rework wheelchairbound Fixes the save/load bug and fixes it being a singleton. * weh
This commit is contained in:
14
Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs
Normal file
14
Content.Server/Traits/Assorted/BuckleOnMapInitComponent.cs
Normal file
@@ -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;
|
||||
}
|
||||
19
Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs
Normal file
19
Content.Server/Traits/Assorted/BuckleOnMapInitSystem.cs
Normal file
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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";
|
||||
}
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user