Content update for NetEntities (#18935)

This commit is contained in:
metalgearsloth
2023-09-11 09:42:41 +10:00
committed by GitHub
parent 389c8d1a2c
commit 5a0fc68be2
526 changed files with 3058 additions and 2215 deletions

View File

@@ -8,12 +8,14 @@ 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;
namespace Content.Shared.Follower;
@@ -36,6 +38,25 @@ 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)
@@ -58,7 +79,7 @@ public sealed class FollowerSystem : EntitySystem
private void OnGetAlternativeVerbs(GetVerbsEvent<AlternativeVerb> ev)
{
if (ev.User == ev.Target || ev.Target.IsClientSide())
if (ev.User == ev.Target || IsClientSide(ev.Target))
return;
if (HasComp<GhostComponent>(ev.User))
@@ -221,6 +242,12 @@ 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