From 920d7068e5987e45a62e4beb2c8c17190cd62bce Mon Sep 17 00:00:00 2001 From: KISS <59531932+YuriyKiss@users.noreply.github.com> Date: Fri, 5 Jan 2024 07:04:11 +0200 Subject: [PATCH] Fixed client console flooding with warnings on RGB color slider changes (#21333) added reparent bool for this kinds of unequips Co-authored-by: Yurii Kis --- .../Lobby/UI/LobbyCharacterPreviewPanel.cs | 3 +- .../Inventory/InventorySystem.Equip.cs | 62 +++++++++++++++---- 2 files changed, 53 insertions(+), 12 deletions(-) diff --git a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs index 86989cd561..f9481caa3b 100644 --- a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs +++ b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs @@ -148,7 +148,8 @@ namespace Content.Client.Lobby.UI foreach (var slot in slots) { var itemType = gear.GetGear(slot.Name, profile); - if (invSystem.TryUnequip(dummy, slot.Name, out var unequippedItem, true, true)) + + if (invSystem.TryUnequip(dummy, slot.Name, out var unequippedItem, silent: true, force: true, reparent: false)) { entMan.DeleteEntity(unequippedItem.Value); } diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index 848c8c3558..5e740ec2ea 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -276,18 +276,58 @@ public abstract partial class InventorySystem return true; } - public bool TryUnequip(EntityUid uid, string slot, bool silent = false, bool force = false, bool predicted = false, - InventoryComponent? inventory = null, ClothingComponent? clothing = null) => TryUnequip(uid, uid, slot, silent, force, predicted, inventory, clothing); + public bool TryUnequip( + EntityUid uid, + string slot, + bool silent = false, + bool force = false, + bool predicted = false, + InventoryComponent? inventory = null, + ClothingComponent? clothing = null, + bool reparent = true) + { + return TryUnequip(uid, uid, slot, silent, force, predicted, inventory, clothing, reparent); + } - public bool TryUnequip(EntityUid actor, EntityUid target, string slot, bool silent = false, - bool force = false, bool predicted = false, InventoryComponent? inventory = null, ClothingComponent? clothing = null) => - TryUnequip(actor, target, slot, out _, silent, force, predicted, inventory, clothing); + public bool TryUnequip( + EntityUid actor, + EntityUid target, + string slot, + bool silent = false, + bool force = false, + bool predicted = false, + InventoryComponent? inventory = null, + ClothingComponent? clothing = null, + bool reparent = true) + { + return TryUnequip(actor, target, slot, out _, silent, force, predicted, inventory, clothing, reparent); + } - public bool TryUnequip(EntityUid uid, string slot, [NotNullWhen(true)] out EntityUid? removedItem, bool silent = false, bool force = false, bool predicted = false, - InventoryComponent? inventory = null, ClothingComponent? clothing = null) => TryUnequip(uid, uid, slot, out removedItem, silent, force, predicted, inventory, clothing); + public bool TryUnequip( + EntityUid uid, + string slot, + [NotNullWhen(true)] out EntityUid? removedItem, + bool silent = false, + bool force = false, + bool predicted = false, + InventoryComponent? inventory = null, + ClothingComponent? clothing = null, + bool reparent = true) + { + return TryUnequip(uid, uid, slot, out removedItem, silent, force, predicted, inventory, clothing, reparent); + } - public bool TryUnequip(EntityUid actor, EntityUid target, string slot, [NotNullWhen(true)] out EntityUid? removedItem, bool silent = false, - bool force = false, bool predicted = false, InventoryComponent? inventory = null, ClothingComponent? clothing = null) + public bool TryUnequip( + EntityUid actor, + EntityUid target, + string slot, + [NotNullWhen(true)] out EntityUid? removedItem, + bool silent = false, + bool force = false, + bool predicted = false, + InventoryComponent? inventory = null, + ClothingComponent? clothing = null, + bool reparent = true) { removedItem = null; @@ -329,11 +369,11 @@ public abstract partial class InventorySystem if (slotDef != slotDefinition && slotDef.DependsOn == slotDefinition.Name) { //this recursive call might be risky - TryUnequip(actor, target, slotDef.Name, true, true, predicted, inventory); + TryUnequip(actor, target, slotDef.Name, true, true, predicted, inventory, reparent: reparent); } } - if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force)) + if (!_containerSystem.Remove(removedItem.Value, slotContainer, force: force, reparent: reparent)) return false; // TODO: Inventory needs a hot cleanup hoo boy