Make EscapeInventorySystem respect Unremovable (fix glued hamster deletion) (#24488)

* Made EscapeInventorySystem respect Unremovable

* Oh look, there's a helper method

* Let's fix this too
This commit is contained in:
Tayrtahn
2024-01-25 09:01:13 -05:00
committed by GitHub
parent c771ea830c
commit 060fbcfbc8
3 changed files with 13 additions and 3 deletions

View 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;