forked from space-syndicate/space-station-14
Make followed session-specific (#30770)
* Make followed session-specific * misimport
This commit is contained in:
@@ -10,6 +10,8 @@ namespace Content.Shared.Follower.Components;
|
||||
[Access(typeof(FollowerSystem))]
|
||||
public sealed partial class FollowedComponent : Component
|
||||
{
|
||||
public override bool SessionSpecific => true;
|
||||
|
||||
[DataField, AutoNetworkedField]
|
||||
public HashSet<EntityUid> Following = new();
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ using Content.Shared.Movement.Pulling.Events;
|
||||
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;
|
||||
@@ -38,11 +39,27 @@ public sealed class FollowerSystem : EntitySystem
|
||||
SubscribeLocalEvent<FollowerComponent, PullStartedMessage>(OnPullStarted);
|
||||
SubscribeLocalEvent<FollowerComponent, EntityTerminatingEvent>(OnFollowerTerminating);
|
||||
|
||||
SubscribeLocalEvent<FollowedComponent, ComponentGetStateAttemptEvent>(OnFollowedAttempt);
|
||||
SubscribeLocalEvent<FollowerComponent, GotEquippedHandEvent>(OnGotEquippedHand);
|
||||
SubscribeLocalEvent<FollowedComponent, EntityTerminatingEvent>(OnFollowedTerminating);
|
||||
SubscribeLocalEvent<BeforeSaveEvent>(OnBeforeSave);
|
||||
}
|
||||
|
||||
private void OnFollowedAttempt(Entity<FollowedComponent> ent, ref ComponentGetStateAttemptEvent args)
|
||||
{
|
||||
if (args.Cancelled)
|
||||
return;
|
||||
|
||||
// Clientside VV stay losing
|
||||
var playerEnt = args.Player?.AttachedEntity;
|
||||
|
||||
if (playerEnt == null ||
|
||||
!ent.Comp.Following.Contains(playerEnt.Value) && !HasComp<GhostComponent>(playerEnt.Value))
|
||||
{
|
||||
args.Cancelled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBeforeSave(BeforeSaveEvent ev)
|
||||
{
|
||||
// Some followers will not be map savable. This ensures that maps don't get saved with empty/invalid
|
||||
|
||||
Reference in New Issue
Block a user