InventoryComponent now returns null if comp is deleted (#1227)
Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
@@ -78,7 +78,14 @@ namespace Content.Server.GameObjects
|
|||||||
}
|
}
|
||||||
public T GetSlotItem<T>(Slots slot) where T : ItemComponent
|
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
|
public bool TryGetSlotItem<T>(Slots slot, out T itemComponent) where T : ItemComponent
|
||||||
|
|||||||
Reference in New Issue
Block a user