Remove IContainer and move functions to the container system. (#19834)

This commit is contained in:
Leon Friedrich
2023-09-10 14:16:37 +12:00
committed by GitHub
parent 2d71eec6f9
commit b45e53603d
19 changed files with 54 additions and 48 deletions

View File

@@ -360,7 +360,7 @@ public abstract partial class InventorySystem
}
//we need to do this to make sure we are 100% removing this entity, since we are now dropping dependant slots
if (!force && !slotContainer.CanRemove(removedItem.Value))
if (!force && !_containerSystem.CanRemove(removedItem.Value, slotContainer))
return false;
foreach (var slotDef in GetSlots(target, inventory))
@@ -426,14 +426,12 @@ public abstract partial class InventorySystem
if ((containerSlot == null || slotDefinition == null) && !TryGetSlotContainer(target, slot, out containerSlot, out slotDefinition, inventory))
return false;
if (containerSlot.ContainedEntity == null)
if (containerSlot.ContainedEntity is not {} itemUid)
return false;
if (!containerSlot.ContainedEntity.HasValue || !containerSlot.CanRemove(containerSlot.ContainedEntity.Value))
if (!_containerSystem.CanRemove(itemUid, containerSlot))
return false;
var itemUid = containerSlot.ContainedEntity.Value;
// make sure the user can actually reach the target
if (!CanAccess(actor, target, itemUid))
{