fix stripping (#5983)

This commit is contained in:
Leon Friedrich
2022-01-02 06:03:29 +13:00
committed by GitHub
parent 1b581f1a9b
commit 4acb8c12af
6 changed files with 23 additions and 13 deletions

View File

@@ -116,7 +116,7 @@ namespace Content.Server.Strip
return false; return false;
} }
if (!invSystem.CanEquip(Owner, item.Owner, slot, out _)) if (!invSystem.CanEquip(user, Owner, item.Owner, slot, out _))
{ {
user.PopupMessageCursor(Loc.GetString("strippable-component-cannot-equip-message",("owner", Owner))); user.PopupMessageCursor(Loc.GetString("strippable-component-cannot-equip-message",("owner", Owner)));
return false; return false;
@@ -141,7 +141,7 @@ namespace Content.Server.Strip
if (result != DoAfterStatus.Finished) return; if (result != DoAfterStatus.Finished) return;
userHands.Drop(item!.Owner, false); userHands.Drop(item!.Owner, false);
invSystem.TryEquip(Owner, item.Owner, slot); invSystem.TryEquip(user, Owner, item.Owner, slot);
UpdateState(); UpdateState();
} }
@@ -258,7 +258,7 @@ namespace Content.Server.Strip
var result = await doAfterSystem.WaitDoAfter(doAfterArgs); var result = await doAfterSystem.WaitDoAfter(doAfterArgs);
if (result != DoAfterStatus.Finished) return; if (result != DoAfterStatus.Finished) return;
if (invSystem.TryGetSlotEntity(Owner, slot, out var item) && invSystem.TryUnequip(Owner, slot)) if (invSystem.TryGetSlotEntity(Owner, slot, out var item) && invSystem.TryUnequip(user, Owner, slot))
{ {
userHands.PutInHandOrDrop(item.Value); userHands.PutInHandOrDrop(item.Value);
} }

View File

@@ -63,11 +63,15 @@ namespace Content.Shared.Cuffs
private void OnEquipAttempt(EntityUid uid, SharedCuffableComponent component, IsEquippingAttemptEvent args) private void OnEquipAttempt(EntityUid uid, SharedCuffableComponent component, IsEquippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Equipee == uid)
CheckAct(uid, component, args); CheckAct(uid, component, args);
} }
private void OnUnequipAttempt(EntityUid uid, SharedCuffableComponent component, IsUnequippingAttemptEvent args) private void OnUnequipAttempt(EntityUid uid, SharedCuffableComponent component, IsUnequippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Unequipee == uid)
CheckAct(uid, component, args); CheckAct(uid, component, args);
} }

View File

@@ -1,11 +1,11 @@
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Shared.Inventory.Events; namespace Content.Shared.Inventory.Events;
public abstract class EquipAttemptBase : CancellableEntityEventArgs public abstract class EquipAttemptBase : CancellableEntityEventArgs
{ {
/// <summary> /// <summary>
/// The entity equipping. /// The entity performing the action. NOT necessarily the one actually "receiving" the equipment.
/// </summary> /// </summary>
public readonly EntityUid Equipee; public readonly EntityUid Equipee;

View File

@@ -1,11 +1,11 @@
using Robust.Shared.GameObjects; using Robust.Shared.GameObjects;
namespace Content.Shared.Inventory.Events; namespace Content.Shared.Inventory.Events;
public class UnequipAttemptEventBase : CancellableEntityEventArgs public class UnequipAttemptEventBase : CancellableEntityEventArgs
{ {
/// <summary> /// <summary>
/// The entity unequipping. /// The entity performing the action. NOT necessarily the same as the entity whose equipment is being removed..
/// </summary> /// </summary>
public readonly EntityUid Unequipee; public readonly EntityUid Unequipee;

View File

@@ -79,6 +79,8 @@ namespace Content.Shared.MobState.EntitySystems
private void OnEquipAttempt(EntityUid uid, MobStateComponent component, IsEquippingAttemptEvent args) private void OnEquipAttempt(EntityUid uid, MobStateComponent component, IsEquippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Equipee == uid)
CheckAct(uid, component, args); CheckAct(uid, component, args);
} }
@@ -89,6 +91,8 @@ namespace Content.Shared.MobState.EntitySystems
private void OnUnequipAttempt(EntityUid uid, MobStateComponent component, IsUnequippingAttemptEvent args) private void OnUnequipAttempt(EntityUid uid, MobStateComponent component, IsUnequippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Unequipee == uid)
CheckAct(uid, component, args); CheckAct(uid, component, args);
} }

View File

@@ -258,12 +258,14 @@ namespace Content.Shared.Stunnable
private void OnEquipAttempt(EntityUid uid, StunnedComponent stunned, IsEquippingAttemptEvent args) private void OnEquipAttempt(EntityUid uid, StunnedComponent stunned, IsEquippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Equipee == uid) if (args.Equipee == uid)
args.Cancel(); args.Cancel();
} }
private void OnUnequipAttempt(EntityUid uid, StunnedComponent stunned, IsUnequippingAttemptEvent args) private void OnUnequipAttempt(EntityUid uid, StunnedComponent stunned, IsUnequippingAttemptEvent args)
{ {
// is this a self-equip, or are they being stripped?
if (args.Unequipee == uid) if (args.Unequipee == uid)
args.Cancel(); args.Cancel();
} }