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

@@ -72,7 +72,7 @@ namespace Content.Client.Actions
_actionHoldersQueue.Enqueue(uid); _actionHoldersQueue.Enqueue(uid);
} }
protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder)
{ {
// Sometimes the client receives actions from the server, before predicting that newly added components will add // Sometimes the client receives actions from the server, before predicting that newly added components will add
// their own shared actions. Just in case those systems ever decided to directly access action properties (e.g., // their own shared actions. Just in case those systems ever decided to directly access action properties (e.g.,
@@ -87,7 +87,7 @@ namespace Content.Client.Actions
} }
} }
public override void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) public override void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, BaseContainer? actionContainer = null)
{ {
if (!Resolve(holderId, ref holder, false)) if (!Resolve(holderId, ref holder, false))
return; return;

View File

@@ -27,6 +27,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
[UISystemDependency] private readonly ClientInventorySystem _inventorySystem = default!; [UISystemDependency] private readonly ClientInventorySystem _inventorySystem = default!;
[UISystemDependency] private readonly HandsSystem _handsSystem = default!; [UISystemDependency] private readonly HandsSystem _handsSystem = default!;
[UISystemDependency] private readonly ContainerSystem _container = default!;
private EntityUid? _playerUid; private EntityUid? _playerUid;
private InventorySlotsComponent? _playerInventory; private InventorySlotsComponent? _playerInventory;
@@ -281,7 +282,7 @@ public sealed class InventoryUIController : UIController, IOnStateEntered<Gamepl
var hoverEntity = _entities.SpawnEntity("hoverentity", MapCoordinates.Nullspace); var hoverEntity = _entities.SpawnEntity("hoverentity", MapCoordinates.Nullspace);
var hoverSprite = _entities.GetComponent<SpriteComponent>(hoverEntity); var hoverSprite = _entities.GetComponent<SpriteComponent>(hoverEntity);
var fits = _inventorySystem.CanEquip(player.Value, held, control.SlotName, out _, slotDef) && var fits = _inventorySystem.CanEquip(player.Value, held, control.SlotName, out _, slotDef) &&
container.CanInsert(held, _entities); _container.CanInsert(held, container);
hoverSprite.CopyFrom(sprite); hoverSprite.CopyFrom(sprite);
hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127); hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127);

View File

@@ -341,7 +341,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
EntityUid target = default; EntityUid target = default;
EntityUid item = default; EntityUid item = default;
EntityUid containerEntity = default; EntityUid containerEntity = default;
IContainer container = null; BaseContainer container = null;
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {

View File

@@ -57,7 +57,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems
if (!Resolve(uid, ref holder)) if (!Resolve(uid, ref holder))
return false; return false;
if (!holder.Container.CanInsert(toInsert)) if (!_containerSystem.CanInsert(toInsert, holder.Container))
{ {
return false; return false;
} }

View File

@@ -753,10 +753,10 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem
public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity) public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity)
{ {
if (!base.CanInsert(uid, component, entity) || component is not SharedDisposalUnitComponent serverComp) if (!base.CanInsert(uid, component, entity))
return false; return false;
return serverComp.Container.CanInsert(entity); return _containerSystem.CanInsert(entity, component.Container);
} }
/// <summary> /// <summary>

View File

@@ -236,7 +236,7 @@ namespace Content.Server.Explosion.EntitySystems
if (user != null) if (user != null)
{ {
// Check if entity is bomb/mod. grenade/etc // Check if entity is bomb/mod. grenade/etc
if (_container.TryGetContainer(uid, "payload", out IContainer? container) && if (_container.TryGetContainer(uid, "payload", out BaseContainer? container) &&
container.ContainedEntities.Count > 0 && container.ContainedEntities.Count > 0 &&
TryComp(container.ContainedEntities[0], out ChemicalPayloadComponent? chemicalPayloadComponent)) TryComp(container.ContainedEntities[0], out ChemicalPayloadComponent? chemicalPayloadComponent))
{ {

View File

@@ -120,7 +120,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
/// <summary> /// <summary>
/// Makes an event horizon consume a given entity. /// Makes an event horizon consume a given entity.
/// </summary> /// </summary>
public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null)
{ {
if (!EntityManager.IsQueuedForDeletion(morsel) // I saw it log twice a few times for some reason? if (!EntityManager.IsQueuedForDeletion(morsel) // I saw it log twice a few times for some reason?
&& (HasComp<MindContainerComponent>(morsel) && (HasComp<MindContainerComponent>(morsel)
@@ -140,7 +140,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
/// <summary> /// <summary>
/// Makes an event horizon attempt to consume a given entity. /// Makes an event horizon attempt to consume a given entity.
/// </summary> /// </summary>
public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null)
{ {
if (!CanConsumeEntity(hungry, morsel, eventHorizon)) if (!CanConsumeEntity(hungry, morsel, eventHorizon))
return false; return false;
@@ -192,7 +192,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem
/// Excludes the event horizon itself. /// Excludes the event horizon itself.
/// All immune entities within the container will be dumped to a given container or the map/grid if that is impossible. /// All immune entities within the container will be dumped to a given container or the map/grid if that is impossible.
/// </summary> /// </summary>
public void ConsumeEntitiesInContainer(EntityUid hungry, IContainer container, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) public void ConsumeEntitiesInContainer(EntityUid hungry, BaseContainer container, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null)
{ {
// Removing the immune entities from the container needs to be deferred until after iteration or the iterator raises an error. // Removing the immune entities from the container needs to be deferred until after iteration or the iterator raises an error.
List<EntityUid> immune = new(); List<EntityUid> immune = new();

View File

@@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events;
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public readonly record struct EntityConsumedByEventHorizonEvent public readonly record struct EntityConsumedByEventHorizonEvent
(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) (EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container)
{ {
/// <summary> /// <summary>
/// The entity being consumed by the event horizon. /// The entity being consumed by the event horizon.
@@ -29,5 +29,5 @@ public readonly record struct EntityConsumedByEventHorizonEvent
/// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon. /// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon.
/// Used to correctly dump out the contents containers that are consumed by the event horizon. /// Used to correctly dump out the contents containers that are consumed by the event horizon.
/// </summary> /// </summary>
public readonly IContainer? Container = container; public readonly BaseContainer? Container = container;
} }

View File

@@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events;
/// </summary> /// </summary>
[ByRefEvent] [ByRefEvent]
public readonly record struct EventHorizonConsumedEntityEvent public readonly record struct EventHorizonConsumedEntityEvent
(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) (EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container)
{ {
/// <summary> /// <summary>
/// The entity being consumed by the event horizon. /// The entity being consumed by the event horizon.
@@ -29,5 +29,5 @@ public readonly record struct EventHorizonConsumedEntityEvent
/// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon. /// The innermost container of the entity being consumed by the event horizon that is not also in the process of being consumed by the event horizon.
/// Used to correctly dump out the contents containers that are consumed by the event horizon. /// Used to correctly dump out the contents containers that are consumed by the event horizon.
/// </summary> /// </summary>
public readonly IContainer? Container = container; public readonly BaseContainer? Container = container;
} }

View File

@@ -177,7 +177,7 @@ public abstract class SharedActionsSystem : EntitySystem
protected bool TryGetContainer( protected bool TryGetContainer(
EntityUid holderId, EntityUid holderId,
[NotNullWhen(true)] out IContainer? container, [NotNullWhen(true)] out BaseContainer? container,
ContainerManagerComponent? containerManager = null) ContainerManagerComponent? containerManager = null)
{ {
return _containerSystem.TryGetContainer(holderId, ActionContainerId, out container, containerManager); return _containerSystem.TryGetContainer(holderId, ActionContainerId, out container, containerManager);
@@ -185,7 +185,7 @@ public abstract class SharedActionsSystem : EntitySystem
protected bool TryGetProvidedContainer( protected bool TryGetProvidedContainer(
EntityUid providerId, EntityUid providerId,
[NotNullWhen(true)] out IContainer? container, [NotNullWhen(true)] out BaseContainer? container,
ContainerManagerComponent? containerManager = null) ContainerManagerComponent? containerManager = null)
{ {
return _containerSystem.TryGetContainer(providerId, ProvidedActionContainerId, out container, containerManager); return _containerSystem.TryGetContainer(providerId, ProvidedActionContainerId, out container, containerManager);
@@ -550,7 +550,7 @@ public abstract class SharedActionsSystem : EntitySystem
/// <param name="holder">Component of <see cref="holderId"/></param> /// <param name="holder">Component of <see cref="holderId"/></param>
/// <param name="action">Component of <see cref="actionId"/></param> /// <param name="action">Component of <see cref="actionId"/></param>
/// <param name="actionContainer">Action container of <see cref="holderId"/></param> /// <param name="actionContainer">Action container of <see cref="holderId"/></param>
public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, BaseContainer? actionContainer = null)
{ {
action ??= GetActionData(actionId); action ??= GetActionData(actionId);
// TODO remove when action subscriptions are split up // TODO remove when action subscriptions are split up
@@ -572,7 +572,7 @@ public abstract class SharedActionsSystem : EntitySystem
Dirty(holderId, holder); Dirty(holderId, holder);
} }
protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder)
{ {
container.Insert(actionId); container.Insert(actionId);
holder.Actions.Add(actionId); holder.Actions.Add(actionId);

View File

@@ -12,6 +12,8 @@ namespace Content.Shared.Body.Systems;
public partial class SharedBodySystem public partial class SharedBodySystem
{ {
[Dependency] private readonly SharedContainerSystem _container = default!;
private void InitializeOrgans() private void InitializeOrgans()
{ {
SubscribeLocalEvent<OrganComponent, ComponentGetState>(OnOrganGetState); SubscribeLocalEvent<OrganComponent, ComponentGetState>(OnOrganGetState);
@@ -35,7 +37,7 @@ public partial class SharedBodySystem
slot.Child == null && slot.Child == null &&
Resolve(organId.Value, ref organ, false) && Resolve(organId.Value, ref organ, false) &&
Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) &&
container.CanInsert(organId.Value); _container.CanInsert(organId.Value, container);
} }
private void OnOrganGetState(EntityUid uid, OrganComponent organ, ref ComponentGetState args) private void OnOrganGetState(EntityUid uid, OrganComponent organ, ref ComponentGetState args)

View File

@@ -171,7 +171,7 @@ public partial class SharedBodySystem
Resolve(partId.Value, ref part, false) && Resolve(partId.Value, ref part, false) &&
(slot.Type == null || slot.Type == part.PartType) && (slot.Type == null || slot.Type == part.PartType) &&
Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) &&
container.CanInsert(partId.Value); _container.CanInsert(partId.Value, container);
} }
public virtual bool AttachPart( public virtual bool AttachPart(

View File

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

View File

@@ -8,6 +8,8 @@ namespace Content.Shared.Hands.EntitySystems;
public abstract partial class SharedHandsSystem : EntitySystem public abstract partial class SharedHandsSystem : EntitySystem
{ {
[Dependency] private readonly SharedContainerSystem _container = default!;
private void InitializeDrop() private void InitializeDrop()
{ {
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved); SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
@@ -32,10 +34,10 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// </summary> /// </summary>
public bool CanDropHeld(EntityUid uid, Hand hand, bool checkActionBlocker = true) public bool CanDropHeld(EntityUid uid, Hand hand, bool checkActionBlocker = true)
{ {
if (hand.HeldEntity == null) if (hand.Container?.ContainedEntity is not {} held)
return false; return false;
if (!hand.Container!.CanRemove(hand.HeldEntity.Value, EntityManager)) if (!_container.CanRemove(held, hand.Container))
return false; return false;
if (checkActionBlocker && !_actionBlocker.CanDrop(uid)) if (checkActionBlocker && !_actionBlocker.CanDrop(uid))
@@ -110,7 +112,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
/// <summary> /// <summary>
/// Attempts to move a held item from a hand into a container that is not another hand, without dropping it on the floor in-between. /// Attempts to move a held item from a hand into a container that is not another hand, without dropping it on the floor in-between.
/// </summary> /// </summary>
public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, IContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null) public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, BaseContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null)
{ {
if (!Resolve(uid, ref handsComp)) if (!Resolve(uid, ref handsComp))
return false; return false;
@@ -121,7 +123,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (!CanDropHeld(uid, hand, checkActionBlocker)) if (!CanDropHeld(uid, hand, checkActionBlocker))
return false; return false;
if (!targetContainer.CanInsert(entity, EntityManager)) if (!_container.CanInsert(entity, targetContainer))
return false; return false;
DoDrop(uid, hand, false, handsComp); DoDrop(uid, hand, false, handsComp);

View File

@@ -181,7 +181,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
return false; return false;
// check can insert (including raising attempt events). // check can insert (including raising attempt events).
return handContainer.CanInsert(entity, EntityManager); return _containerSystem.CanInsert(entity, handContainer);
} }
/// <summary> /// <summary>

View File

@@ -111,7 +111,7 @@ public abstract class SharedImplanterSystem : EntitySystem
continue; continue;
//Don't remove a permanent implant and look for the next that can be drawn //Don't remove a permanent implant and look for the next that can be drawn
if (!implantContainer.CanRemove(implant)) if (!_container.CanRemove(implant, implantContainer))
{ {
var implantName = Identity.Entity(implant, EntityManager); var implantName = Identity.Entity(implant, EntityManager);
var targetName = Identity.Entity(target, EntityManager); var targetName = Identity.Entity(target, EntityManager);

View File

@@ -32,7 +32,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this EntityUid origin, this EntityUid origin,
IContainer other, BaseContainer other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
@@ -90,7 +90,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IComponent origin, this IComponent origin,
IContainer other, BaseContainer other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
@@ -130,7 +130,7 @@ namespace Content.Shared.Interaction.Helpers
#region Containers #region Containers
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IContainer origin, this BaseContainer origin,
EntityUid other, EntityUid other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
@@ -143,7 +143,7 @@ namespace Content.Shared.Interaction.Helpers
} }
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IContainer origin, this BaseContainer origin,
IComponent other, IComponent other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
@@ -155,8 +155,8 @@ namespace Content.Shared.Interaction.Helpers
} }
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IContainer origin, this BaseContainer origin,
IContainer other, BaseContainer other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
@@ -169,7 +169,7 @@ namespace Content.Shared.Interaction.Helpers
} }
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IContainer origin, this BaseContainer origin,
EntityCoordinates other, EntityCoordinates other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
@@ -181,7 +181,7 @@ namespace Content.Shared.Interaction.Helpers
} }
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this IContainer origin, this BaseContainer origin,
MapCoordinates other, MapCoordinates other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
@@ -226,7 +226,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this EntityCoordinates origin, this EntityCoordinates origin,
IContainer other, BaseContainer other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)
@@ -304,7 +304,7 @@ namespace Content.Shared.Interaction.Helpers
public static bool InRangeUnOccluded( public static bool InRangeUnOccluded(
this MapCoordinates origin, this MapCoordinates origin,
IContainer other, BaseContainer other,
float range = InteractionRange, float range = InteractionRange,
Ignored? predicate = null, Ignored? predicate = null,
bool ignoreInsideBlocker = true) bool ignoreInsideBlocker = true)

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 //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; return false;
foreach (var slotDef in GetSlots(target, inventory)) 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)) if ((containerSlot == null || slotDefinition == null) && !TryGetSlotContainer(target, slot, out containerSlot, out slotDefinition, inventory))
return false; return false;
if (containerSlot.ContainedEntity == null) if (containerSlot.ContainedEntity is not {} itemUid)
return false; return false;
if (!containerSlot.ContainedEntity.HasValue || !containerSlot.CanRemove(containerSlot.ContainedEntity.Value)) if (!_containerSystem.CanRemove(itemUid, containerSlot))
return false; return false;
var itemUid = containerSlot.ContainedEntity.Value;
// make sure the user can actually reach the target // make sure the user can actually reach the target
if (!CanAccess(actor, target, itemUid)) if (!CanAccess(actor, target, itemUid))
{ {

View File

@@ -33,7 +33,7 @@ public sealed partial class BorgChassisComponent : Component
public string BrainContainerId = "borg_brain"; public string BrainContainerId = "borg_brain";
[ViewVariables(VVAccess.ReadWrite)] [ViewVariables(VVAccess.ReadWrite)]
public ContainerSlot BrainContainer = new(); public ContainerSlot BrainContainer = default!;
public EntityUid? BrainEntity => BrainContainer.ContainedEntity; public EntityUid? BrainEntity => BrainContainer.ContainedEntity;
#endregion #endregion