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

@@ -99,7 +99,8 @@ public sealed class GlueSystem : SharedGlueSystem
private void OnHandPickUp(Entity<GluedComponent> entity, ref GotEquippedHandEvent args) 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; entity.Comp.Until = _timing.CurTime + entity.Comp.Duration;
} }
} }

View File

@@ -41,6 +41,13 @@ public sealed class EscapeInventorySystem : EntitySystem
if (!_containerSystem.TryGetContainingContainer(uid, out var container) || !_actionBlockerSystem.CanInteract(uid, container.Owner)) if (!_containerSystem.TryGetContainingContainer(uid, out var container) || !_actionBlockerSystem.CanInteract(uid, container.Owner))
return; 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 // Contested
if (_handsSystem.IsHolding(container.Owner, uid, out var inHand)) if (_handsSystem.IsHolding(container.Owner, uid, out var inHand))
{ {
@@ -53,7 +60,10 @@ public sealed class EscapeInventorySystem : EntitySystem
contestResults = 1; contestResults = 1;
if (contestResults >= MaximumMassDisadvantage) if (contestResults >= MaximumMassDisadvantage)
{
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-failed-resisting"), uid, uid);
return; return;
}
AttemptEscape(uid, container.Owner, component, contestResults); AttemptEscape(uid, container.Owner, component, contestResults);
return; return;
@@ -80,7 +90,6 @@ public sealed class EscapeInventorySystem : EntitySystem
if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter)) if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.DoAfter))
return; return;
Dirty(user, component);
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user); _popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting"), user, user);
_popupSystem.PopupEntity(Loc.GetString("escape-inventory-component-start-resisting-target"), container, container); _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) private void OnEscape(EntityUid uid, CanEscapeInventoryComponent component, EscapeInventoryEvent args)
{ {
component.DoAfter = null; component.DoAfter = null;
Dirty(uid, component);
if (args.Handled || args.Cancelled) if (args.Handled || args.Cancelled)
return; return;

View File

@@ -1,2 +1,3 @@
escape-inventory-component-start-resisting = You start struggling to escape! 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-start-resisting-target = Something is struggling to get out of your inventory!
escape-inventory-component-failed-resisting = Can't escape!