From 47984b726b1d93a658d897d4ddf0b7762a4f1c1f Mon Sep 17 00:00:00 2001 From: Whatstone Date: Wed, 13 Nov 2024 11:19:38 -0500 Subject: [PATCH 1/2] Drop events for dependent slot contents --- .../Inventory/InventorySystem.Equip.cs | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 762561ed322..eb6b91071fe 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -6,6 +6,7 @@ using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; using Content.Shared.Interaction; +using Content.Shared.Interaction.Events; using Content.Shared.Inventory.Events; using Content.Shared.Item; using Content.Shared.Movement.Systems; @@ -319,9 +320,10 @@ public bool TryUnequip( InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool reparent = true, - bool checkDoafter = false) + bool checkDoafter = false, + bool child = 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, child); // Frontier: add child } public bool TryUnequip( @@ -334,9 +336,10 @@ public bool TryUnequip( InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool reparent = true, - bool checkDoafter = false) + bool checkDoafter = false, + bool child = false) // Frontier: spawn DroppedEvent on all children { - 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, child); // Frontier: add child } public bool TryUnequip( @@ -349,9 +352,10 @@ public bool TryUnequip( InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool reparent = true, - bool checkDoafter = false) + bool checkDoafter = false, + bool child = false) // Frontier: spawn DroppedEvent on all children { - 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, child); // Frontier: add child } public bool TryUnequip( @@ -365,7 +369,8 @@ public bool TryUnequip( InventoryComponent? inventory = null, ClothingComponent? clothing = null, bool reparent = true, - bool checkDoafter = false) + bool checkDoafter = false, + bool child = false) // Frontier: spawn DroppedEvent on all children { removedItem = null; @@ -429,13 +434,17 @@ public bool TryUnequip( if (slotDef != slotDefinition && slotDef.DependsOn == slotDefinition.Name) { //this recursive call might be risky - TryUnequip(actor, target, slotDef.Name, true, true, predicted, inventory, reparent: reparent); + TryUnequip(actor, target, slotDef.Name, true, true, predicted, inventory, reparent: reparent, child: true); // Frontier: add child } } if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force, reparent: reparent)) return false; + // Frontier: spawn dropped events for children + if (child) + RaiseLocalEvent(removedItem.Value, new DroppedEvent(actor), true); // Gas tank internals etc. + // TODO: Inventory needs a hot cleanup hoo boy // Check if something else (AKA toggleable) dumped it into a container. if (!_containerSystem.IsEntityInContainer(removedItem.Value)) From 5a6ce93c284c2d745fab67b00c05fe736bd49bf3 Mon Sep 17 00:00:00 2001 From: Whatstone Date: Wed, 13 Nov 2024 11:23:54 -0500 Subject: [PATCH 2/2] Fix comments --- Content.Shared/Inventory/InventorySystem.Equip.cs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index eb6b91071fe..9d49ee8bce2 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -321,7 +321,7 @@ public bool TryUnequip( ClothingComponent? clothing = null, bool reparent = true, bool checkDoafter = false, - bool child = false) + bool child = false) // Frontier: raise DroppedEvent on all children { return TryUnequip(uid, uid, slot, silent, force, predicted, inventory, clothing, reparent, checkDoafter, child); // Frontier: add child } @@ -337,7 +337,7 @@ public bool TryUnequip( ClothingComponent? clothing = null, bool reparent = true, bool checkDoafter = false, - bool child = false) // Frontier: spawn DroppedEvent on all children + bool child = false) // Frontier: raise DroppedEvent on all children { return TryUnequip(actor, target, slot, out _, silent, force, predicted, inventory, clothing, reparent, checkDoafter, child); // Frontier: add child } @@ -353,7 +353,7 @@ public bool TryUnequip( ClothingComponent? clothing = null, bool reparent = true, bool checkDoafter = false, - bool child = false) // Frontier: spawn DroppedEvent on all children + bool child = false) // Frontier: raise DroppedEvent on all children { return TryUnequip(uid, uid, slot, out removedItem, silent, force, predicted, inventory, clothing, reparent, checkDoafter, child); // Frontier: add child } @@ -370,7 +370,7 @@ public bool TryUnequip( ClothingComponent? clothing = null, bool reparent = true, bool checkDoafter = false, - bool child = false) // Frontier: spawn DroppedEvent on all children + bool child = false) // Frontier: raise DroppedEvent on all children { removedItem = null; @@ -443,7 +443,8 @@ public bool TryUnequip( // Frontier: spawn dropped events for children if (child) - RaiseLocalEvent(removedItem.Value, new DroppedEvent(actor), true); // Gas tank internals etc. + RaiseLocalEvent(removedItem.Value, new DroppedEvent(actor), true); + // End Frontier // TODO: Inventory needs a hot cleanup hoo boy // Check if something else (AKA toggleable) dumped it into a container.