InventoryComponent now returns null if comp is deleted (#1227)

Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
metalgearsloth
2020-06-29 01:44:33 +10:00
committed by GitHub
parent 29f1730d71
commit 6f296320a1

View File

@@ -78,7 +78,14 @@ namespace Content.Server.GameObjects
}
public T GetSlotItem<T>(Slots slot) where T : ItemComponent
{
return SlotContainers[slot].ContainedEntity?.GetComponent<T>();
var containedEntity = SlotContainers[slot].ContainedEntity;
if (containedEntity?.Deleted == true)
{
SlotContainers[slot] = null;
containedEntity = null;
Dirty();
}
return containedEntity?.GetComponent<T>();
}
public bool TryGetSlotItem<T>(Slots slot, out T itemComponent) where T : ItemComponent