Fix forensics not being applied to held items (#30609)
* Initial commit * Fix merge changes * sloth comment: bitmask * fix MIA parameter --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: EmoGarbage404 <retron404@gmail.com>
This commit is contained in:
@@ -97,7 +97,7 @@ public abstract partial class InventorySystem
|
||||
// unequip the item.
|
||||
if (itemUid != null)
|
||||
{
|
||||
if (!TryUnequip(actor, ev.Slot, out var item, predicted: true, inventory: inventory, checkDoafter: true))
|
||||
if (!TryUnequip(actor, ev.Slot, out var item, predicted: true, inventory: inventory, checkDoafter: true, triggerHandContact: true))
|
||||
return;
|
||||
|
||||
_handsSystem.PickupOrDrop(actor, item.Value);
|
||||
@@ -120,15 +120,15 @@ public abstract partial class InventorySystem
|
||||
|
||||
RaiseLocalEvent(held.Value, new HandDeselectedEvent(actor));
|
||||
|
||||
TryEquip(actor, actor, held.Value, ev.Slot, predicted: true, inventory: inventory, force: true, checkDoafter: true);
|
||||
TryEquip(actor, actor, held.Value, ev.Slot, predicted: true, inventory: inventory, force: true, checkDoafter: true, triggerHandContact: true);
|
||||
}
|
||||
|
||||
public bool TryEquip(EntityUid uid, EntityUid itemUid, string slot, bool silent = false, bool force = false, bool predicted = false,
|
||||
InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool checkDoafter = false) =>
|
||||
TryEquip(uid, uid, itemUid, slot, silent, force, predicted, inventory, clothing, checkDoafter);
|
||||
InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool checkDoafter = false, bool triggerHandContact = false) =>
|
||||
TryEquip(uid, uid, itemUid, slot, silent, force, predicted, inventory, clothing, checkDoafter, triggerHandContact);
|
||||
|
||||
public bool TryEquip(EntityUid actor, EntityUid target, EntityUid itemUid, string slot, bool silent = false, bool force = false, bool predicted = false,
|
||||
InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool checkDoafter = false)
|
||||
InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool checkDoafter = false, bool triggerHandContact = false)
|
||||
{
|
||||
if (!Resolve(target, ref inventory, false))
|
||||
{
|
||||
@@ -190,6 +190,10 @@ public abstract partial class InventorySystem
|
||||
_audio.PlayPredicted(clothing.EquipSound, target, actor);
|
||||
}
|
||||
|
||||
// If new gloves are equipped, trigger OnContactInteraction for held items
|
||||
if (triggerHandContact && !((slotDefinition.SlotFlags & SlotFlags.GLOVES) == 0))
|
||||
TriggerHandContactInteraction(target);
|
||||
|
||||
Dirty(target, inventory);
|
||||
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(target);
|
||||
@@ -320,9 +324,10 @@ public abstract partial class InventorySystem
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
bool checkDoafter = false,
|
||||
bool triggerHandContact = false)
|
||||
{
|
||||
return TryUnequip(uid, uid, slot, silent, force, predicted, inventory, clothing, reparent, checkDoafter);
|
||||
return TryUnequip(uid, uid, slot, silent, force, predicted, inventory, clothing, reparent, checkDoafter, triggerHandContact);
|
||||
}
|
||||
|
||||
public bool TryUnequip(
|
||||
@@ -335,9 +340,10 @@ public abstract partial class InventorySystem
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
bool checkDoafter = false,
|
||||
bool triggerHandContact = false)
|
||||
{
|
||||
return TryUnequip(actor, target, slot, out _, silent, force, predicted, inventory, clothing, reparent, checkDoafter);
|
||||
return TryUnequip(actor, target, slot, out _, silent, force, predicted, inventory, clothing, reparent, checkDoafter, triggerHandContact);
|
||||
}
|
||||
|
||||
public bool TryUnequip(
|
||||
@@ -350,9 +356,10 @@ public abstract partial class InventorySystem
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
bool checkDoafter = false,
|
||||
bool triggerHandContact = false)
|
||||
{
|
||||
return TryUnequip(uid, uid, slot, out removedItem, silent, force, predicted, inventory, clothing, reparent, checkDoafter);
|
||||
return TryUnequip(uid, uid, slot, out removedItem, silent, force, predicted, inventory, clothing, reparent, checkDoafter, triggerHandContact);
|
||||
}
|
||||
|
||||
public bool TryUnequip(
|
||||
@@ -366,7 +373,8 @@ public abstract partial class InventorySystem
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
bool checkDoafter = false,
|
||||
bool triggerHandContact = false)
|
||||
{
|
||||
var itemsDropped = 0;
|
||||
return TryUnequip(actor, target, slot, out removedItem, ref itemsDropped,
|
||||
@@ -385,7 +393,8 @@ public abstract partial class InventorySystem
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
bool checkDoafter = false,
|
||||
bool triggerHandContact = false)
|
||||
{
|
||||
removedItem = null;
|
||||
|
||||
@@ -476,6 +485,10 @@ public abstract partial class InventorySystem
|
||||
_audio.PlayPredicted(clothing.UnequipSound, target, actor);
|
||||
}
|
||||
|
||||
// If gloves are unequipped, OnContactInteraction should trigger for held items
|
||||
if (triggerHandContact && !((slotDefinition.SlotFlags & SlotFlags.GLOVES) == 0))
|
||||
TriggerHandContactInteraction(target);
|
||||
|
||||
Dirty(target, inventory);
|
||||
|
||||
_movementSpeed.RefreshMovementSpeedModifiers(target);
|
||||
@@ -551,4 +564,12 @@ public abstract partial class InventorySystem
|
||||
entityUid = container.ContainedEntity;
|
||||
return entityUid != null;
|
||||
}
|
||||
|
||||
public void TriggerHandContactInteraction(EntityUid uid)
|
||||
{
|
||||
foreach (var item in _handsSystem.EnumerateHeld(uid))
|
||||
{
|
||||
_interactionSystem.DoContactInteraction(uid, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user