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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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!
|
||||
|
||||
Reference in New Issue
Block a user