Revert "Remove IContainer and move functions to the container system.… (#19975)

This commit is contained in:
metalgearsloth
2023-09-10 21:46:36 +10:00
committed by GitHub
parent 24810d916b
commit 4d1c3ae66a
19 changed files with 48 additions and 54 deletions

View File

@@ -246,9 +246,6 @@ namespace Content.Shared.Containers.ItemSlots
/// </remarks>
public bool CanInsert(EntityUid uid, EntityUid usedUid, EntityUid? user, ItemSlot slot, bool swap = false, EntityUid? popup = null)
{
if (slot.ContainerSlot == null)
return false;
if (slot.Locked)
return false;
@@ -268,7 +265,7 @@ namespace Content.Shared.Containers.ItemSlots
if (ev.Cancelled)
return false;
return _containers.CanInsert(usedUid, slot.ContainerSlot, assumeEmpty: true);
return slot.ContainerSlot?.CanInsertIfEmpty(usedUid, EntityManager) ?? false;
}
/// <summary>
@@ -328,16 +325,16 @@ namespace Content.Shared.Containers.ItemSlots
public bool CanEject(EntityUid uid, EntityUid? user, ItemSlot slot)
{
if (slot.Locked || slot.ContainerSlot?.ContainedEntity is not {} item)
if (slot.Locked || slot.Item == null)
return false;
var ev = new ItemSlotEjectAttemptEvent(uid, item, user, slot);
var ev = new ItemSlotEjectAttemptEvent(uid, slot.Item.Value, user, slot);
RaiseLocalEvent(uid, ref ev);
RaiseLocalEvent(item, ref ev);
RaiseLocalEvent(slot.Item.Value, ref ev);
if (ev.Cancelled)
return false;
return _containers.CanRemove(item, slot.ContainerSlot);
return slot.ContainerSlot?.CanRemove(slot.Item.Value, EntityManager) ?? false;
}
/// <summary>