* add notification for dependent wearables being dropped * fix dropped item popup redundancy - did a check to see if any item was dropped, instead of making a notification for each item being dropped. * change popup to client-only variant * fix redundant messages, add plural locale string * fix conventions, fix locale input to be more intuitive --------- Co-authored-by: Justin <justinbrick1@gmail.com>
This commit is contained in:
@@ -365,6 +365,25 @@ public abstract partial class InventorySystem
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
{
|
||||
var itemsDropped = 0;
|
||||
return TryUnequip(actor, target, slot, out removedItem, ref itemsDropped,
|
||||
silent, force, predicted, inventory, clothing, reparent, checkDoafter);
|
||||
}
|
||||
|
||||
private bool TryUnequip(
|
||||
EntityUid actor,
|
||||
EntityUid target,
|
||||
string slot,
|
||||
[NotNullWhen(true)] out EntityUid? removedItem,
|
||||
ref int itemsDropped,
|
||||
bool silent = false,
|
||||
bool force = false,
|
||||
bool predicted = false,
|
||||
InventoryComponent? inventory = null,
|
||||
ClothingComponent? clothing = null,
|
||||
bool reparent = true,
|
||||
bool checkDoafter = false)
|
||||
{
|
||||
removedItem = null;
|
||||
|
||||
@@ -423,17 +442,27 @@ public abstract partial class InventorySystem
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force, reparent: reparent))
|
||||
return false;
|
||||
|
||||
// this is in order to keep track of whether this is the first instance of a recursion call
|
||||
var firstRun = itemsDropped == 0;
|
||||
++itemsDropped;
|
||||
|
||||
foreach (var slotDef in inventory.Slots)
|
||||
{
|
||||
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, out _, ref itemsDropped, true, true, predicted, inventory, reparent: reparent);
|
||||
}
|
||||
}
|
||||
|
||||
if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force, reparent: reparent))
|
||||
return false;
|
||||
// we check if any items were dropped, and make a popup if they were.
|
||||
// the reason we check for > 1 is because the first item is always the one we are trying to unequip,
|
||||
// whereas we only want to notify for extra dropped items.
|
||||
if (!silent && _gameTiming.IsFirstTimePredicted && firstRun && itemsDropped > 1)
|
||||
_popup.PopupClient(Loc.GetString("inventory-component-dropped-from-unequip", ("items", itemsDropped - 1)), target, target);
|
||||
|
||||
// TODO: Inventory needs a hot cleanup hoo boy
|
||||
// Check if something else (AKA toggleable) dumped it into a container.
|
||||
|
||||
@@ -2,3 +2,9 @@ inventory-component-can-equip-cannot = You can't equip this!
|
||||
inventory-component-can-equip-does-not-fit = This doesn't fit!
|
||||
|
||||
inventory-component-can-unequip-cannot = You can't unequip this!
|
||||
|
||||
inventory-component-dropped-from-unequip =
|
||||
You dropped {$items ->
|
||||
[1] an item!
|
||||
*[other] some items!
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user