]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make EscapeInventorySystem respect Unremovable (fix glued hamster deletion) (#24488)
authorTayrtahn <tayrtahn@gmail.com>
Thu, 25 Jan 2024 14:01:13 +0000 (09:01 -0500)
committerGitHub <noreply@github.com>
Thu, 25 Jan 2024 14:01:13 +0000 (09:01 -0500)
* Made EscapeInventorySystem respect Unremovable

* Oh look, there's a helper method

* Let's fix this too

Content.Server/Glue/GlueSystem.cs
Content.Server/Resist/EscapeInventorySystem.cs
Resources/Locale/en-US/resist/components/escape-inventory-component.ftl

index 2b7f0060bc4f6a2299ac3d73799e2b28a78ef8e4..9409a423c44e0fbbceb3e3b87bc0c4691ecbe97d 100644 (file)
@@ -99,7 +99,8 @@ public sealed class GlueSystem : SharedGlueSystem
 
     private void OnHandPickUp(Entity<GluedComponent> entity, ref GotEquippedHandEvent args)
     {
-        EnsureComp<UnremoveableComponent>(entity);
+        var comp = EnsureComp<UnremoveableComponent>(entity);
+        comp.DeleteOnDrop = false;
         entity.Comp.Until = _timing.CurTime + entity.Comp.Duration;
     }
 }
index 1249269de5625629f9338b8ab0c1d81f3fa2e43d..56e0684aae80ba54248c693f2255b4959b16e2c5 100644 (file)
@@ -41,6 +41,13 @@ public sealed class EscapeInventorySystem : EntitySystem
         if (!_containerSystem.TryGetContainingContainer(uid, out var container) || !_actionBlockerSystem.CanInteract(uid, container.Owner))
             return;
 
+        // Make sure there's nothing stopped the removal (like being glued)
+        if (!_containerSystem.CanRemove(uid, container))
+        {
+            _popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-failed-resisting"), uid, uid);
+            return;
+        }
+
         // Contested
         if (_handsSystem.IsHolding(container.Owner, uid, out var inHand))
         {
@@ -53,7 +60,10 @@ public sealed class EscapeInventorySystem : EntitySystem
                 contestResults = 1;
 
             if (contestResults >= MaximumMassDisadvantage)
+            {
+                _popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-failed-resisting"), uid, uid);
                 return;
+            }
 
             AttemptEscape(uid, container.Owner, component, contestResults);
             return;
@@ -80,7 +90,6 @@ public sealed class EscapeInventorySystem : EntitySystem
         if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
             return;
 
-        Dirty(user, component);
         _popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
         _popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container);
     }
@@ -88,7 +97,6 @@ public sealed class EscapeInventorySystem : EntitySystem
     private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
     {
         component.DoAfter = null;
-        Dirty(uid, component);
 
         if (args.Handled || args.Cancelled)
             return;
index d5d681626fdd753b4dd83c7ffbc72424d37a05ba..b99ce327bed905a82ad74326a391e0aa2aab3b0f 100644 (file)
@@ -1,2 +1,3 @@
 escape-inventory-component-start-resisting = You start struggling to escape!
 escape-inventory-component-start-resisting-target = Something is struggling to get out of your inventory!
+escape-inventory-component-failed-resisting = Can't escape!