]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Predict pipe anchoring and unanchroing (#35977)
authorbeck-thompson <107373427+beck-thompson@users.noreply.github.com>
Fri, 21 Mar 2025 09:43:35 +0000 (02:43 -0700)
committerGitHub <noreply@github.com>
Fri, 21 Mar 2025 09:43:35 +0000 (12:43 +0300)
* yay prediction

* Added cool popups

* bruh

* this is better!

Content.Server/SubFloor/SubFloorHideSystem.cs
Content.Shared/SubFloor/SharedSubFloorHideSystem.cs
Resources/Locale/en-US/subfloor/subfloor.ftl [new file with mode: 0644]

index 54f4be86a019fe89c9f86fbcb7285f9db66dbd16..304fa6d7c1323d1869415499f3340c553bf14152 100644 (file)
@@ -1,9 +1,7 @@
-using Content.Shared.Construction.Components;
 using Content.Shared.Eye;
 using Content.Shared.SubFloor;
 using Robust.Server.Player;
 using Robust.Shared.Enums;
-using Robust.Shared.Map.Components;
 using Robust.Shared.Player;
 
 namespace Content.Server.SubFloor;
@@ -18,8 +16,6 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem
     public override void Initialize()
     {
         base.Initialize();
-        SubscribeLocalEvent<SubFloorHideComponent, AnchorAttemptEvent>(OnAnchorAttempt);
-        SubscribeLocalEvent<SubFloorHideComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
         SubscribeNetworkEvent<ShowSubfloorRequestEvent>(OnShowSubfloor);
         SubscribeLocalEvent<GetVisMaskEvent>(OnGetVisibility);
 
@@ -72,24 +68,4 @@ public sealed class SubFloorHideSystem : SharedSubFloorHideSystem
             Value = ev.Value,
         }, args.SenderSession);
     }
-
-    private void OnAnchorAttempt(EntityUid uid, SubFloorHideComponent component, AnchorAttemptEvent args)
-    {
-        // No teleporting entities through floor tiles when anchoring them.
-        var xform = Transform(uid);
-
-        if (TryComp<MapGridComponent>(xform.GridUid, out var grid)
-            && HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates)))
-        {
-            args.Cancel();
-        }
-    }
-
-    private void OnUnanchorAttempt(EntityUid uid, SubFloorHideComponent component, UnanchorAttemptEvent args)
-    {
-        // No un-anchoring things under the floor. Only required for something like vents, which are still interactable
-        // despite being partially under the floor.
-        if (component.IsUnderCover)
-            args.Cancel();
-    }
 }
index d15055875af95663f057caae9708ec26fff26d2f..9a7ce0d1df5f79bb92d9598e32782057cb848e6f 100644 (file)
@@ -1,8 +1,10 @@
 using Content.Shared.Audio;
+using Content.Shared.Construction.Components;
 using Content.Shared.Explosion;
 using Content.Shared.Eye;
 using Content.Shared.Interaction.Events;
 using Content.Shared.Maps;
+using Content.Shared.Popups;
 using JetBrains.Annotations;
 using Robust.Shared.Map;
 using Robust.Shared.Map.Components;
@@ -21,6 +23,7 @@ namespace Content.Shared.SubFloor
         [Dependency] protected readonly SharedMapSystem Map = default!;
         [Dependency] protected readonly SharedAppearanceSystem Appearance = default!;
         [Dependency] private readonly SharedVisibilitySystem _visibility = default!;
+        [Dependency] protected readonly SharedPopupSystem _popup = default!;
 
         private EntityQuery<SubFloorHideComponent> _hideQuery;
 
@@ -38,6 +41,32 @@ namespace Content.Shared.SubFloor
             SubscribeLocalEvent<SubFloorHideComponent, GettingInteractedWithAttemptEvent>(OnInteractionAttempt);
             SubscribeLocalEvent<SubFloorHideComponent, GettingAttackedAttemptEvent>(OnAttackAttempt);
             SubscribeLocalEvent<SubFloorHideComponent, GetExplosionResistanceEvent>(OnGetExplosionResistance);
+            SubscribeLocalEvent<SubFloorHideComponent, AnchorAttemptEvent>(OnAnchorAttempt);
+            SubscribeLocalEvent<SubFloorHideComponent, UnanchorAttemptEvent>(OnUnanchorAttempt);
+        }
+
+        private void OnAnchorAttempt(EntityUid uid, SubFloorHideComponent component, AnchorAttemptEvent args)
+        {
+            // No teleporting entities through floor tiles when anchoring them.
+            var xform = Transform(uid);
+
+            if (TryComp<MapGridComponent>(xform.GridUid, out var grid)
+                && HasFloorCover(xform.GridUid.Value, grid, Map.TileIndicesFor(xform.GridUid.Value, grid, xform.Coordinates)))
+            {
+                _popup.PopupClient(Loc.GetString("subfloor-anchor-failure", ("entity", uid)), args.User);
+                args.Cancel();
+            }
+        }
+
+        private void OnUnanchorAttempt(EntityUid uid, SubFloorHideComponent component, UnanchorAttemptEvent args)
+        {
+            // No un-anchoring things under the floor. Only required for something like vents, which are still interactable
+            // despite being partially under the floor.
+            if (component.IsUnderCover)
+            {
+                _popup.PopupClient(Loc.GetString("subfloor-unanchor-failure", ("entity", uid)), args.User);
+                args.Cancel();
+            }
         }
 
         private void OnGetExplosionResistance(EntityUid uid, SubFloorHideComponent component, ref GetExplosionResistanceEvent args)
diff --git a/Resources/Locale/en-US/subfloor/subfloor.ftl b/Resources/Locale/en-US/subfloor/subfloor.ftl
new file mode 100644 (file)
index 0000000..90d7711
--- /dev/null
@@ -0,0 +1,2 @@
+subfloor-anchor-failure = {CAPITALIZE(THE($entity))} can't be anchored here!
+subfloor-unanchor-failure = {CAPITALIZE(THE($entity))} can't be unanchored here!