From 6f296320a100422eb5555ce0d75383e5020896e3 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Mon, 29 Jun 2020 01:44:33 +1000 Subject: [PATCH] InventoryComponent now returns null if comp is deleted (#1227) Co-authored-by: Metal Gear Sloth --- .../GameObjects/Components/GUI/InventoryComponent.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index 6f5fc254fa..fb9227697a 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -78,7 +78,14 @@ namespace Content.Server.GameObjects } public T GetSlotItem(Slots slot) where T : ItemComponent { - return SlotContainers[slot].ContainedEntity?.GetComponent(); + var containedEntity = SlotContainers[slot].ContainedEntity; + if (containedEntity?.Deleted == true) + { + SlotContainers[slot] = null; + containedEntity = null; + Dirty(); + } + return containedEntity?.GetComponent(); } public bool TryGetSlotItem(Slots slot, out T itemComponent) where T : ItemComponent