Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Raise DroppedEvent on items in pockets/suit storage. #2400

Merged
merged 2 commits into from
Nov 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 18 additions & 8 deletions Content.Shared/Inventory/InventorySystem.Equip.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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) // Frontier: raise DroppedEvent on all children
{
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(
Expand All @@ -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: raise 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(
Expand All @@ -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: raise 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(
Expand All @@ -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: raise DroppedEvent on all children
{
removedItem = null;

Expand Down Expand Up @@ -429,13 +434,18 @@ 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);
// End Frontier

// TODO: Inventory needs a hot cleanup hoo boy
// Check if something else (AKA toggleable) dumped it into a container.
if (!_containerSystem.IsEntityInContainer(removedItem.Value))
Expand Down
Loading