Skip to content

Commit

Permalink
rollback to hotfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Rxup committed Oct 6, 2023
1 parent 4f6f739 commit 66c1402
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
4 changes: 2 additions & 2 deletions Content.Shared/Follower/Components/FollowedComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ namespace Content.Shared.Follower.Components;
/// <summary>
/// Attached to entities that are currently being followed by a ghost.
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState]
[RegisterComponent, NetworkedComponent]
[Access(typeof(FollowerSystem))]
public sealed partial class FollowedComponent : Component
{
[DataField, AutoNetworkedField]
[DataField]
public HashSet<EntityUid> Following = new();
}
28 changes: 28 additions & 0 deletions Content.Shared/Follower/FollowerSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,13 @@
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.Physics;
using Robust.Shared.Physics.Systems;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

namespace Content.Shared.Follower;
Expand All @@ -38,6 +40,32 @@ public override void Initialize()
SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);

SubscribeLocalEvent<FollowedComponent, ComponentGetState>(OnFollowedGetState);
SubscribeLocalEvent<FollowedComponent, ComponentHandleState>(OnFollowedHandleState);
}

[Serializable, NetSerializable]
private sealed class FollowedComponentState : ComponentState
{
public HashSet<NetEntity> Following = new();
}

private void OnFollowedGetState(EntityUid uid, FollowedComponent component, ref ComponentGetState args)
{
component.Following.RemoveWhere(x => TerminatingOrDeleted(x));
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)
Expand Down

0 comments on commit 66c1402

Please sign in to comment.