Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -3,22 +3,22 @@ using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Standing
|
||||
{
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(StandingStateSystem))]
|
||||
[RegisterComponent, NetworkedComponent]
|
||||
public sealed partial class StandingStateComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("downSound")]
|
||||
[DataField]
|
||||
public SoundSpecifier DownSound { get; private set; } = new SoundCollectionSpecifier("BodyFall");
|
||||
|
||||
[DataField("standing")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public bool Standing { get; set; } = true;
|
||||
|
||||
/// <summary>
|
||||
/// List of fixtures that had their collision mask changed when the entity was downed.
|
||||
/// Required for re-adding the collision mask.
|
||||
/// </summary>
|
||||
[DataField("changedFixtures")]
|
||||
[DataField, AutoNetworkedField(true)]
|
||||
public List<string> ChangedFixtures = new();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ using Content.Shared.Hands.Components;
|
||||
using Content.Shared.Physics;
|
||||
using Content.Shared.Rotation;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared.Standing
|
||||
{
|
||||
@@ -18,26 +16,6 @@ namespace Content.Shared.Standing
|
||||
// If StandingCollisionLayer value is ever changed to more than one layer, the logic needs to be edited.
|
||||
private const int StandingCollisionLayer = (int) CollisionGroup.MidImpassable;
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
SubscribeLocalEvent<StandingStateComponent, ComponentGetState>(OnGetState);
|
||||
SubscribeLocalEvent<StandingStateComponent, ComponentHandleState>(OnHandleState);
|
||||
}
|
||||
|
||||
private void OnHandleState(EntityUid uid, StandingStateComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not StandingComponentState state)
|
||||
return;
|
||||
|
||||
component.Standing = state.Standing;
|
||||
component.ChangedFixtures = new List<string>(state.ChangedFixtures);
|
||||
}
|
||||
|
||||
private void OnGetState(EntityUid uid, StandingStateComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new StandingComponentState(component.Standing, component.ChangedFixtures);
|
||||
}
|
||||
|
||||
public bool IsDown(EntityUid uid, StandingStateComponent? standingState = null)
|
||||
{
|
||||
if (!Resolve(uid, ref standingState, false))
|
||||
@@ -151,20 +129,6 @@ namespace Content.Shared.Standing
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// I'm not calling it StandingStateComponentState
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class StandingComponentState : ComponentState
|
||||
{
|
||||
public bool Standing { get; }
|
||||
public List<string> ChangedFixtures { get; }
|
||||
|
||||
public StandingComponentState(bool standing, List<string> changedFixtures)
|
||||
{
|
||||
Standing = standing;
|
||||
ChangedFixtures = changedFixtures;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class DropHandItemsEvent : EventArgs
|
||||
|
||||
Reference in New Issue
Block a user