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>
|
||||
|
||||
@@ -5,7 +5,6 @@ using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Popups;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
@@ -31,8 +30,6 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
|
||||
SubscribeLocalEvent<JetpackUserComponent, CanWeightlessMoveEvent>(OnJetpackUserCanWeightless);
|
||||
SubscribeLocalEvent<JetpackUserComponent, EntParentChangedMessage>(OnJetpackUserEntParentChanged);
|
||||
SubscribeLocalEvent<JetpackUserComponent, ComponentGetState>(OnJetpackUserGetState);
|
||||
SubscribeLocalEvent<JetpackUserComponent, ComponentHandleState>(OnJetpackUserHandleState);
|
||||
|
||||
SubscribeLocalEvent<GravityChangedEvent>(OnJetpackUserGravityChanged);
|
||||
}
|
||||
@@ -60,22 +57,6 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
}
|
||||
}
|
||||
|
||||
private void OnJetpackUserHandleState(EntityUid uid, JetpackUserComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not JetpackUserComponentState state)
|
||||
return;
|
||||
|
||||
component.Jetpack = EnsureEntity<JetpackUserComponent>(state.Jetpack, uid);
|
||||
}
|
||||
|
||||
private void OnJetpackUserGetState(EntityUid uid, JetpackUserComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new JetpackUserComponentState()
|
||||
{
|
||||
Jetpack = GetNetEntity(component.Jetpack),
|
||||
};
|
||||
}
|
||||
|
||||
private void OnJetpackDropped(EntityUid uid, JetpackComponent component, DroppedEvent args)
|
||||
{
|
||||
SetEnabled(uid, component, false, args.User);
|
||||
@@ -204,12 +185,6 @@ public abstract class SharedJetpackSystem : EntitySystem
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
protected sealed class JetpackUserComponentState : ComponentState
|
||||
{
|
||||
public NetEntity Jetpack;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public abstract partial class SharedMoverController
|
||||
{
|
||||
private void InitializeFootsteps()
|
||||
{
|
||||
SubscribeLocalEvent<FootstepModifierComponent, ComponentGetState>(OnFootGetState);
|
||||
SubscribeLocalEvent<FootstepModifierComponent, ComponentHandleState>(OnFootHandleState);
|
||||
}
|
||||
|
||||
private void OnFootHandleState(EntityUid uid, FootstepModifierComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not FootstepModifierComponentState state) return;
|
||||
component.Sound = state.Sound;
|
||||
}
|
||||
|
||||
private void OnFootGetState(EntityUid uid, FootstepModifierComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new FootstepModifierComponentState()
|
||||
{
|
||||
Sound = component.Sound,
|
||||
};
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class FootstepModifierComponentState : ComponentState
|
||||
{
|
||||
public SoundSpecifier Sound = default!;
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,6 @@ using Content.Shared.Follower.Components;
|
||||
using Content.Shared.Input;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Input.Binding;
|
||||
using Robust.Shared.Players;
|
||||
@@ -49,8 +48,7 @@ namespace Content.Shared.Movement.Systems
|
||||
.Register<SharedMoverController>();
|
||||
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentInit>(OnInputInit);
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentGetState>(OnInputGetState);
|
||||
SubscribeLocalEvent<InputMoverComponent, ComponentHandleState>(OnInputHandleState);
|
||||
SubscribeLocalEvent<InputMoverComponent, AfterAutoHandleStateEvent>(OnInputHandleState);
|
||||
SubscribeLocalEvent<InputMoverComponent, EntParentChangedMessage>(OnInputParentChange);
|
||||
|
||||
SubscribeLocalEvent<AutoOrientComponent, EntParentChangedMessage>(OnAutoParentChange);
|
||||
@@ -75,31 +73,10 @@ namespace Content.Shared.Movement.Systems
|
||||
Dirty(component);
|
||||
}
|
||||
|
||||
private void OnInputHandleState(EntityUid uid, InputMoverComponent component, ref ComponentHandleState args)
|
||||
private void OnInputHandleState(EntityUid uid, InputMoverComponent component, ref AfterAutoHandleStateEvent args)
|
||||
{
|
||||
if (args.Current is not InputMoverComponentState state)
|
||||
return;
|
||||
|
||||
component.HeldMoveButtons = state.Buttons;
|
||||
component.LastInputTick = GameTick.Zero;
|
||||
component.LastInputSubTick = 0;
|
||||
component.CanMove = state.CanMove;
|
||||
|
||||
component.RelativeRotation = state.RelativeRotation;
|
||||
component.TargetRelativeRotation = state.TargetRelativeRotation;
|
||||
component.RelativeEntity = EnsureEntity<InputMoverComponent>(state.RelativeEntity, uid);
|
||||
component.LerpTarget = state.LerpAccumulator;
|
||||
}
|
||||
|
||||
private void OnInputGetState(EntityUid uid, InputMoverComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new InputMoverComponentState(
|
||||
component.HeldMoveButtons,
|
||||
component.CanMove,
|
||||
component.RelativeRotation,
|
||||
component.TargetRelativeRotation,
|
||||
GetNetEntity(component.RelativeEntity),
|
||||
component.LerpTarget);
|
||||
}
|
||||
|
||||
private void ShutdownInput()
|
||||
@@ -564,35 +541,6 @@ namespace Content.Shared.Movement.Systems
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class InputMoverComponentState : ComponentState
|
||||
{
|
||||
public MoveButtons Buttons { get; }
|
||||
public readonly bool CanMove;
|
||||
|
||||
/// <summary>
|
||||
/// Our current rotation for movement purposes. This is lerping towards <see cref="TargetRelativeRotation"/>
|
||||
/// </summary>
|
||||
public Angle RelativeRotation;
|
||||
|
||||
/// <summary>
|
||||
/// Target rotation relative to the <see cref="RelativeEntity"/>. Typically 0
|
||||
/// </summary>
|
||||
public Angle TargetRelativeRotation;
|
||||
public NetEntity? RelativeEntity;
|
||||
public TimeSpan LerpAccumulator;
|
||||
|
||||
public InputMoverComponentState(MoveButtons buttons, bool canMove, Angle relativeRotation, Angle targetRelativeRotation, NetEntity? relativeEntity, TimeSpan lerpTarget)
|
||||
{
|
||||
Buttons = buttons;
|
||||
CanMove = canMove;
|
||||
RelativeRotation = relativeRotation;
|
||||
TargetRelativeRotation = targetRelativeRotation;
|
||||
RelativeEntity = relativeEntity;
|
||||
LerpAccumulator = lerpTarget;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class ShuttleInputCmdHandler : InputCmdHandler
|
||||
{
|
||||
private readonly SharedMoverController _controller;
|
||||
@@ -615,6 +563,7 @@ namespace Content.Shared.Movement.Systems
|
||||
}
|
||||
|
||||
[Flags]
|
||||
[Serializable, NetSerializable]
|
||||
public enum MoveButtons : byte
|
||||
{
|
||||
None = 0,
|
||||
|
||||
@@ -1,39 +0,0 @@
|
||||
using Content.Shared.Movement.Components;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Movement.Systems;
|
||||
|
||||
public abstract partial class SharedMoverController
|
||||
{
|
||||
private void InitializeMob()
|
||||
{
|
||||
SubscribeLocalEvent<MobMoverComponent, ComponentGetState>(OnMobGetState);
|
||||
SubscribeLocalEvent<MobMoverComponent, ComponentHandleState>(OnMobHandleState);
|
||||
}
|
||||
|
||||
private void OnMobHandleState(EntityUid uid, MobMoverComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not MobMoverComponentState state) return;
|
||||
component.GrabRangeVV = state.GrabRange;
|
||||
component.PushStrengthVV = state.PushStrength;
|
||||
}
|
||||
|
||||
private void OnMobGetState(EntityUid uid, MobMoverComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new MobMoverComponentState(component.GrabRange, component.PushStrength);
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class MobMoverComponentState : ComponentState
|
||||
{
|
||||
public float GrabRange;
|
||||
public float PushStrength;
|
||||
|
||||
public MobMoverComponentState(float grabRange, float pushStrength)
|
||||
{
|
||||
GrabRange = grabRange;
|
||||
PushStrength = pushStrength;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Friction;
|
||||
using Content.Shared.Gravity;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Maps;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Content.Shared.Movement.Components;
|
||||
using Content.Shared.Movement.Events;
|
||||
using Content.Shared.Pulling.Components;
|
||||
@@ -12,15 +16,11 @@ using Robust.Shared.Configuration;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Controllers;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Utility;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using System.Numerics;
|
||||
using Content.Shared.Mobs.Systems;
|
||||
using Robust.Shared.Physics.Components;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Content.Shared.Bed.Sleep;
|
||||
|
||||
namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
@@ -88,9 +88,7 @@ namespace Content.Shared.Movement.Systems
|
||||
NoRotateQuery = GetEntityQuery<NoRotateOnMoveComponent>();
|
||||
CanMoveInAirQuery = GetEntityQuery<CanMoveInAirComponent>();
|
||||
|
||||
InitializeFootsteps();
|
||||
InitializeInput();
|
||||
InitializeMob();
|
||||
InitializeRelay();
|
||||
_configManager.OnValueChanged(CCVars.RelativeMovement, SetRelativeMovement, true);
|
||||
_configManager.OnValueChanged(CCVars.StopSpeed, SetStopSpeed, true);
|
||||
@@ -440,14 +438,14 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
if (TryComp<FootstepModifierComponent>(uid, out var moverModifier))
|
||||
{
|
||||
sound = moverModifier.Sound;
|
||||
sound = moverModifier.FootstepSoundCollection;
|
||||
return true;
|
||||
}
|
||||
|
||||
if (_inventory.TryGetSlotEntity(uid, "shoes", out var shoes) &&
|
||||
TryComp<FootstepModifierComponent>(shoes, out var modifier))
|
||||
{
|
||||
sound = modifier.Sound;
|
||||
sound = modifier.FootstepSoundCollection;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -468,7 +466,7 @@ namespace Content.Shared.Movement.Systems
|
||||
{
|
||||
if (TryComp<FootstepModifierComponent>(xform.MapUid, out var modifier))
|
||||
{
|
||||
sound = modifier.Sound;
|
||||
sound = modifier.FootstepSoundCollection;
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -494,7 +492,7 @@ namespace Content.Shared.Movement.Systems
|
||||
|
||||
if (TryComp<FootstepModifierComponent>(maybeFootstep, out var footstep))
|
||||
{
|
||||
sound = footstep.Sound;
|
||||
sound = footstep.FootstepSoundCollection;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user