]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make followed session-specific (#30770)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 11 Aug 2024 02:26:32 +0000 (12:26 +1000)
committerGitHub <noreply@github.com>
Sun, 11 Aug 2024 02:26:32 +0000 (12:26 +1000)
* Make followed session-specific

* misimport

Content.Shared/Follower/Components/FollowedComponent.cs
Content.Shared/Follower/FollowerSystem.cs

index 7c2ca0efbfef9f42acad242450403abba49b6597..b06e445417f3c5092ac5593ba111527acf92cdd4 100644 (file)
@@ -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();
 }
index 8c35617e2c3e2d711ed5fb6471e1c4909bc959c7..0c7bc99c4648b968cccd1e62a77401c4cf059d47 100644 (file)
@@ -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