From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 11 Aug 2024 02:26:32 +0000 (+1000) Subject: Make followed session-specific (#30770) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=9be61bfaa5a4bee1ca4f3d5e5c40a69d66e4cc2a;p=space-station-14.git Make followed session-specific (#30770) * Make followed session-specific * misimport --- diff --git a/Content.Shared/Follower/Components/FollowedComponent.cs b/Content.Shared/Follower/Components/FollowedComponent.cs index 7c2ca0efbf..b06e445417 100644 --- a/Content.Shared/Follower/Components/FollowedComponent.cs +++ b/Content.Shared/Follower/Components/FollowedComponent.cs @@ -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 Following = new(); } diff --git a/Content.Shared/Follower/FollowerSystem.cs b/Content.Shared/Follower/FollowerSystem.cs index 8c35617e2c..0c7bc99c46 100644 --- a/Content.Shared/Follower/FollowerSystem.cs +++ b/Content.Shared/Follower/FollowerSystem.cs @@ -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(OnPullStarted); SubscribeLocalEvent(OnFollowerTerminating); + SubscribeLocalEvent(OnFollowedAttempt); SubscribeLocalEvent(OnGotEquippedHand); SubscribeLocalEvent(OnFollowedTerminating); SubscribeLocalEvent(OnBeforeSave); } + private void OnFollowedAttempt(Entity 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(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