Update trivial components to use auto comp states (#20539)
This commit is contained in:
@@ -6,10 +6,10 @@ namespace Content.Shared.Follower.Components;
|
||||
/// <summary>
|
||||
/// Attached to entities that are currently being followed by a ghost.
|
||||
/// </summary>
|
||||
[RegisterComponent, Access(typeof(FollowerSystem))]
|
||||
[NetworkedComponent]
|
||||
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
|
||||
[Access(typeof(FollowerSystem))]
|
||||
public sealed partial class FollowedComponent : Component
|
||||
{
|
||||
[DataField("following")]
|
||||
[DataField, AutoNetworkedField]
|
||||
public HashSet<EntityUid> Following = new();
|
||||
}
|
||||
|
||||
@@ -8,14 +8,12 @@ using Content.Shared.Physics.Pull;
|
||||
using Content.Shared.Tag;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameStates;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Map.Events;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Physics;
|
||||
using Robust.Shared.Physics.Systems;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
|
||||
namespace Content.Shared.Follower;
|
||||
|
||||
@@ -38,25 +36,6 @@ public sealed class FollowerSystem : EntitySystem
|
||||
SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
|
||||
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
|
||||
SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
|
||||
|
||||
SubscribeLocalEvent<FollowedComponent, ComponentGetState>(OnFollowedGetState);
|
||||
SubscribeLocalEvent<FollowedComponent, ComponentHandleState>(OnFollowedHandleState);
|
||||
}
|
||||
|
||||
private void OnFollowedGetState(EntityUid uid, FollowedComponent component, ref ComponentGetState args)
|
||||
{
|
||||
args.State = new FollowedComponentState()
|
||||
{
|
||||
Following = GetNetEntitySet(component.Following),
|
||||
};
|
||||
}
|
||||
|
||||
private void OnFollowedHandleState(EntityUid uid, FollowedComponent component, ref ComponentHandleState args)
|
||||
{
|
||||
if (args.Current is not FollowedComponentState state)
|
||||
return;
|
||||
|
||||
component.Following = EnsureEntitySet<FollowedComponent>(state.Following, uid);
|
||||
}
|
||||
|
||||
private void OnBeforeSave(BeforeSaveEvent ev)
|
||||
@@ -242,12 +221,6 @@ public sealed class FollowerSystem : EntitySystem
|
||||
StopFollowingEntity(player, uid, followed);
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
private sealed class FollowedComponentState : ComponentState
|
||||
{
|
||||
public HashSet<NetEntity> Following = new();
|
||||
}
|
||||
}
|
||||
|
||||
public abstract class FollowEvent : EntityEventArgs
|
||||
|
||||
Reference in New Issue
Block a user