Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -1,9 +1,6 @@
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
@@ -11,33 +8,6 @@ namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
[Dependency] private readonly IGameTiming _timing = default!;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<MovementSpeedModifierComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, MovementSpeedModifierComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MovementSpeedModifierComponentState
|
||||
{
|
||||
BaseWalkSpeed = component.BaseWalkSpeed,
|
||||
BaseSprintSpeed = component.BaseSprintSpeed,
|
||||
WalkSpeedModifier = component.WalkSpeedModifier,
|
||||
SprintSpeedModifier = component.SprintSpeedModifier,
|
||||
};
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, MovementSpeedModifierComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not MovementSpeedModifierComponentState state) return;
|
||||
component.BaseWalkSpeed = state.BaseWalkSpeed;
|
||||
component.BaseSprintSpeed = state.BaseSprintSpeed;
|
||||
component.WalkSpeedModifier = state.WalkSpeedModifier;
|
||||
component.SprintSpeedModifier = state.SprintSpeedModifier;
|
||||
}
|
||||
|
||||
public void RefreshMovementSpeedModifiers(EntityUid uid, MovementSpeedModifierComponent? move = null)
|
||||
{
|
||||
if (!Resolve(uid, ref move, false))
|
||||
@@ -68,15 +38,6 @@ namespace Content.Shared.Movement.Systems
|
||||
move.Acceleration = acceleration;
|
||||
Dirty(move);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class MovementSpeedModifierComponentState : ComponentState
|
||||
{
|
||||
public float BaseWalkSpeed;
|
||||
public float BaseSprintSpeed;
|
||||
public float WalkSpeedModifier;
|
||||
public float SprintSpeedModifier;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user