[Trait] Wheelchair bound (#18785)

* Init commit

* move to shared and remove all from component

* maybe that

* Use SharedBuckleSystem

* Rename to WheelchairBound

* Move Carriage to prototype

* Update sprite to TG, add folded sprite, rename carriage to wheelchair

* Fix wheelchair rsi path

* Add stand & down for buckling

* Add wheelchair inhand sprites

* Move wheelchair down in file & fix fold sprite & add suffix Vehicle

* Use new wheelchair id

* Add standing & speed reset on component remove

* Split system to leg paralyzed and wheelchair bound

* Rename to LegsParalyzed

* Rename in prototype

* Move LegsParalyzed to shared

---------

Co-authored-by: Ray <vigersray@gmail.com>
This commit is contained in:
Morb
2023-08-08 03:28:59 +03:00
committed by GitHub
parent 38e7ce16af
commit 8187e00072
12 changed files with 179 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
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 class WheelchairBoundComponent : Component
{
[ViewVariables(VVAccess.ReadWrite)]
[DataField("wheelchairPrototype", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
public string WheelchairPrototype = "VehicleWheelchair";
}

View File

@@ -0,0 +1,21 @@
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);
RemComp<WheelchairBoundComponent>(uid);
}
}

View File

@@ -0,0 +1,12 @@
using Robust.Shared.GameStates;
namespace Content.Shared.Traits.Assorted;
/// <summary>
/// Set player speed to zero and standing state to down, simulating leg paralysis.
/// Used for Wheelchair bound trait.
/// </summary>
[RegisterComponent, NetworkedComponent, Access(typeof(LegsParalyzedSystem))]
public sealed class LegsParalyzedComponent : Component
{
}

View File

@@ -0,0 +1,46 @@
using Content.Shared.Body.Systems;
using Content.Shared.Buckle.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Systems;
using Content.Shared.Standing;
namespace Content.Shared.Traits.Assorted;
public sealed class LegsParalyzedSystem : EntitySystem
{
[Dependency] private readonly MovementSpeedModifierSystem _movementSpeedModifierSystem = default!;
[Dependency] private readonly StandingStateSystem _standingSystem = default!;
[Dependency] private readonly SharedBodySystem _bodySystem = default!;
public override void Initialize()
{
SubscribeLocalEvent<LegsParalyzedComponent, ComponentStartup>(OnStartup);
SubscribeLocalEvent<LegsParalyzedComponent, ComponentShutdown>(OnShutdown);
SubscribeLocalEvent<LegsParalyzedComponent, BuckleChangeEvent>(OnBuckleChange);
}
private void OnStartup(EntityUid uid, LegsParalyzedComponent component, ComponentStartup args)
{
// TODO: In future probably must be surgery related wound
var movementSpeed = EnsureComp<MovementSpeedModifierComponent>(uid);
_movementSpeedModifierSystem.ChangeBaseSpeed(uid, 0, 0, 20, movementSpeed);
}
private void OnShutdown(EntityUid uid, LegsParalyzedComponent component, ComponentShutdown args)
{
_standingSystem.Stand(uid);
_bodySystem.UpdateMovementSpeed(uid);
}
private void OnBuckleChange(EntityUid uid, LegsParalyzedComponent component, ref BuckleChangeEvent args)
{
if (args.Buckling)
{
_standingSystem.Stand(args.BuckledEntity);
}
else
{
_standingSystem.Down(args.BuckledEntity);
}
}
}

View File

@@ -28,3 +28,6 @@ trait-archaic-accent-desc = You speak in a way that many others find outdated
trait-accentless-name = Accentless
trait-accentless-desc = You don't have the accent that your species would usually have
trait-wheelchair-bound-name = Wheelchair Bound
trait-wheelchair-bound-desc = You cannot move without your wheelchair. Wheelchair included.

View File

@@ -428,3 +428,51 @@
components:
- type: Foldable
folded: true
- type: entity
id: VehicleWheelchair
parent: [BaseVehicle, BaseFoldable, BaseItem]
name: Wheelchair
description: A chair with big wheels. It looks like you can move in this on your own.
components:
- type: Vehicle
northOver: true
hasKey: true
northOverride: 0
southOverride: 0
- type: Sprite
sprite: Objects/Vehicles/wheelchair.rsi
layers:
- state: vehicle
map: ["enum.VehicleVisualLayers.AutoAnimate", "unfoldedLayer"]
- state: vehicle_folded
map: ["foldedLayer"]
visible: false
netsync: false
noRot: true
- type: MovementSpeedModifier
baseWalkSpeed: 2
baseSprintSpeed: 2
- type: Strap
buckleOffset: "0,0"
maxBuckleDistance: 1
- type: Fixtures
fixtures:
fix1:
shape:
!type:PhysShapeCircle
radius: 0.2
density: 360
restitution: 0.0
mask:
- MobMask
layer:
- TableLayer
- type: entity
parent: VehicleWheelchair
id: VehicleWheelchairFolded
suffix: folded
components:
- type: Foldable
folded: true

View File

@@ -49,3 +49,11 @@
description: trait-uncloneable-desc
components:
- type: Uncloneable
- type: trait
id: WheelchairBound
name: trait-wheelchair-bound-name
description: trait-wheelchair-bound-desc
components:
- type: WheelchairBound
- type: LegsParalyzed

Binary file not shown.

After

Width:  |  Height:  |  Size: 676 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 629 B

View File

@@ -0,0 +1,26 @@
{
"version": 1,
"size": {
"x": 32,
"y": 32
},
"license": "CC-BY-SA-3.0",
"copyright": "Taken from tgstation at commit https://github.com/tgstation/tgstation/commit/8f6e48e30ff85cb58b5b0a91add4a1741b971f0f",
"states": [
{
"name": "vehicle",
"directions": 4
},
{
"name": "vehicle_folded"
},
{
"name": "inhand-left",
"directions": 4
},
{
"name": "inhand-right",
"directions": 4
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 584 B