From 4d1c3ae66ad1f18a2a77e144ea7e7070ff473262 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Sun, 10 Sep 2023 21:46:36 +1000 Subject: [PATCH] =?UTF-8?q?Revert=20"Remove=20IContainer=20and=20move=20fu?= =?UTF-8?q?nctions=20to=20the=20container=20system.=E2=80=A6=20(#19975)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Content.Client/Actions/ActionsSystem.cs | 4 ++-- .../Inventory/InventoryUIController.cs | 3 +-- .../Click/InteractionSystemTests.cs | 2 +- .../Unit/EntitySystems/DisposableSystem.cs | 2 +- .../Unit/EntitySystems/DisposalUnitSystem.cs | 4 ++-- .../Explosion/EntitySystems/TriggerSystem.cs | 2 +- .../EntitySystems/EventHorizonSystem.cs | 6 +++--- .../EntityConsumedByEventHorizonEvent.cs | 4 ++-- .../Events/EventHorizonConsumedEntityEvent.cs | 4 ++-- Content.Shared/Actions/SharedActionsSystem.cs | 8 ++++---- .../Body/Systems/SharedBodySystem.Organs.cs | 4 +--- .../Body/Systems/SharedBodySystem.Parts.cs | 2 +- .../Containers/ItemSlot/ItemSlotsSystem.cs | 13 +++++------- .../EntitySystems/SharedHandsSystem.Drop.cs | 10 ++++------ .../EntitySystems/SharedHandsSystem.Pickup.cs | 2 +- .../Implants/SharedImplanterSystem.cs | 2 +- .../Helpers/SharedUnoccludedExtensions.cs | 20 +++++++++---------- .../Inventory/InventorySystem.Equip.cs | 8 +++++--- .../Borgs/Components/BorgChassisComponent.cs | 2 +- 19 files changed, 48 insertions(+), 54 deletions(-) diff --git a/Content.Client/Actions/ActionsSystem.cs b/Content.Client/Actions/ActionsSystem.cs index 709bd09483..2d9b777abd 100644 --- a/Content.Client/Actions/ActionsSystem.cs +++ b/Content.Client/Actions/ActionsSystem.cs @@ -72,7 +72,7 @@ namespace Content.Client.Actions _actionHoldersQueue.Enqueue(uid); } - protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder) + protected override void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) { // 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., @@ -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, BaseContainer? actionContainer = null) + public override void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) { if (!Resolve(holderId, ref holder, false)) return; diff --git a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs index 7b71cc28df..23b6a026ef 100644 --- a/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs +++ b/Content.Client/UserInterface/Systems/Inventory/InventoryUIController.cs @@ -27,7 +27,6 @@ public sealed class InventoryUIController : UIController, IOnStateEntered(hoverEntity); var fits = _inventorySystem.CanEquip(player.Value, held, control.SlotName, out _, slotDef) && - _container.CanInsert(held, container); + container.CanInsert(held, _entities); hoverSprite.CopyFrom(sprite); hoverSprite.Color = fits ? new Color(0, 255, 0, 127) : new Color(255, 0, 0, 127); diff --git a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs index b05f273265..402569981a 100644 --- a/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs +++ b/Content.IntegrationTests/Tests/Interaction/Click/InteractionSystemTests.cs @@ -341,7 +341,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click EntityUid target = default; EntityUid item = default; EntityUid containerEntity = default; - BaseContainer container = null; + IContainer container = null; await server.WaitAssertion(() => { diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs index 3edc2a5fa7..83e079746e 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposableSystem.cs @@ -57,7 +57,7 @@ namespace Content.Server.Disposal.Unit.EntitySystems if (!Resolve(uid, ref holder)) return false; - if (!_containerSystem.CanInsert(toInsert, holder.Container)) + if (!holder.Container.CanInsert(toInsert)) { return false; } diff --git a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs index 53e058c73e..e97215f646 100644 --- a/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs +++ b/Content.Server/Disposal/Unit/EntitySystems/DisposalUnitSystem.cs @@ -753,10 +753,10 @@ public sealed class DisposalUnitSystem : SharedDisposalUnitSystem public override bool CanInsert(EntityUid uid, SharedDisposalUnitComponent component, EntityUid entity) { - if (!base.CanInsert(uid, component, entity)) + if (!base.CanInsert(uid, component, entity) || component is not SharedDisposalUnitComponent serverComp) return false; - return _containerSystem.CanInsert(entity, component.Container); + return serverComp.Container.CanInsert(entity); } /// diff --git a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs index 427edf21e3..e5d8f69850 100644 --- a/Content.Server/Explosion/EntitySystems/TriggerSystem.cs +++ b/Content.Server/Explosion/EntitySystems/TriggerSystem.cs @@ -236,7 +236,7 @@ namespace Content.Server.Explosion.EntitySystems if (user != null) { // Check if entity is bomb/mod. grenade/etc - if (_container.TryGetContainer(uid, "payload", out BaseContainer? container) && + if (_container.TryGetContainer(uid, "payload", out IContainer? container) && container.ContainedEntities.Count > 0 && TryComp(container.ContainedEntities[0], out ChemicalPayloadComponent? chemicalPayloadComponent)) { diff --git a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs index fd9eb3e8c6..69d1fd7c34 100644 --- a/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs +++ b/Content.Server/Singularity/EntitySystems/EventHorizonSystem.cs @@ -120,7 +120,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// /// Makes an event horizon consume a given entity. /// - public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) + public void ConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) { if (!EntityManager.IsQueuedForDeletion(morsel) // I saw it log twice a few times for some reason? && (HasComp(morsel) @@ -140,7 +140,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// /// Makes an event horizon attempt to consume a given entity. /// - public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) + public bool AttemptConsumeEntity(EntityUid hungry, EntityUid morsel, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) { if (!CanConsumeEntity(hungry, morsel, eventHorizon)) return false; @@ -192,7 +192,7 @@ public sealed class EventHorizonSystem : SharedEventHorizonSystem /// 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. /// - public void ConsumeEntitiesInContainer(EntityUid hungry, BaseContainer container, EventHorizonComponent eventHorizon, BaseContainer? outerContainer = null) + public void ConsumeEntitiesInContainer(EntityUid hungry, IContainer container, EventHorizonComponent eventHorizon, IContainer? outerContainer = null) { // Removing the immune entities from the container needs to be deferred until after iteration or the iterator raises an error. List immune = new(); diff --git a/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs b/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs index ce5184c717..84e8a8ff2b 100644 --- a/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs +++ b/Content.Server/Singularity/Events/EntityConsumedByEventHorizonEvent.cs @@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events; /// [ByRefEvent] public readonly record struct EntityConsumedByEventHorizonEvent -(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container) +(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) { /// /// 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. /// Used to correctly dump out the contents containers that are consumed by the event horizon. /// - public readonly BaseContainer? Container = container; + public readonly IContainer? Container = container; } diff --git a/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs b/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs index d71b1da7e7..1934219517 100644 --- a/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs +++ b/Content.Server/Singularity/Events/EventHorizonConsumedEntityEvent.cs @@ -8,7 +8,7 @@ namespace Content.Server.Singularity.Events; /// [ByRefEvent] public readonly record struct EventHorizonConsumedEntityEvent -(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container) +(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container) { /// /// 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. /// Used to correctly dump out the contents containers that are consumed by the event horizon. /// - public readonly BaseContainer? Container = container; + public readonly IContainer? Container = container; } diff --git a/Content.Shared/Actions/SharedActionsSystem.cs b/Content.Shared/Actions/SharedActionsSystem.cs index b281249c55..12e5c2260a 100644 --- a/Content.Shared/Actions/SharedActionsSystem.cs +++ b/Content.Shared/Actions/SharedActionsSystem.cs @@ -177,7 +177,7 @@ public abstract class SharedActionsSystem : EntitySystem protected bool TryGetContainer( EntityUid holderId, - [NotNullWhen(true)] out BaseContainer? container, + [NotNullWhen(true)] out IContainer? container, ContainerManagerComponent? containerManager = null) { return _containerSystem.TryGetContainer(holderId, ActionContainerId, out container, containerManager); @@ -185,7 +185,7 @@ public abstract class SharedActionsSystem : EntitySystem protected bool TryGetProvidedContainer( EntityUid providerId, - [NotNullWhen(true)] out BaseContainer? container, + [NotNullWhen(true)] out IContainer? container, ContainerManagerComponent? containerManager = null) { return _containerSystem.TryGetContainer(providerId, ProvidedActionContainerId, out container, containerManager); @@ -550,7 +550,7 @@ public abstract class SharedActionsSystem : EntitySystem /// Component of /// Component of /// Action container of - public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, BaseContainer? actionContainer = null) + public virtual void AddAction(EntityUid holderId, EntityUid actionId, EntityUid? provider, ActionsComponent? holder = null, BaseActionComponent? action = null, bool dirty = true, IContainer? actionContainer = null) { action ??= GetActionData(actionId); // TODO remove when action subscriptions are split up @@ -572,7 +572,7 @@ public abstract class SharedActionsSystem : EntitySystem Dirty(holderId, holder); } - protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, BaseContainer container, ActionsComponent holder) + protected virtual void AddActionInternal(EntityUid holderId, EntityUid actionId, IContainer container, ActionsComponent holder) { container.Insert(actionId); holder.Actions.Add(actionId); diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs index 292864839a..dbfadc6a0f 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Organs.cs @@ -12,8 +12,6 @@ namespace Content.Shared.Body.Systems; public partial class SharedBodySystem { - [Dependency] private readonly SharedContainerSystem _container = default!; - private void InitializeOrgans() { SubscribeLocalEvent(OnOrganGetState); @@ -37,7 +35,7 @@ public partial class SharedBodySystem slot.Child == null && Resolve(organId.Value, ref organ, false) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && - _container.CanInsert(organId.Value, container); + container.CanInsert(organId.Value); } private void OnOrganGetState(EntityUid uid, OrganComponent organ, ref ComponentGetState args) diff --git a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs index f86c4a8bfc..8c55fe9cdd 100644 --- a/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs +++ b/Content.Shared/Body/Systems/SharedBodySystem.Parts.cs @@ -171,7 +171,7 @@ public partial class SharedBodySystem Resolve(partId.Value, ref part, false) && (slot.Type == null || slot.Type == part.PartType) && Containers.TryGetContainer(slot.Parent, BodyContainerId, out var container) && - _container.CanInsert(partId.Value, container); + container.CanInsert(partId.Value); } public virtual bool AttachPart( diff --git a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs index 594479d0df..1d491a01ba 100644 --- a/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs +++ b/Content.Shared/Containers/ItemSlot/ItemSlotsSystem.cs @@ -246,9 +246,6 @@ namespace Content.Shared.Containers.ItemSlots /// 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; } /// @@ -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; } /// diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs index e43f2561a1..87edd47282 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs @@ -8,8 +8,6 @@ namespace Content.Shared.Hands.EntitySystems; public abstract partial class SharedHandsSystem : EntitySystem { - [Dependency] private readonly SharedContainerSystem _container = default!; - private void InitializeDrop() { SubscribeLocalEvent(HandleEntityRemoved); @@ -34,10 +32,10 @@ public abstract partial class SharedHandsSystem : EntitySystem /// public bool CanDropHeld(EntityUid uid, Hand hand, bool checkActionBlocker = true) { - if (hand.Container?.ContainedEntity is not {} held) + if (hand.HeldEntity == null) return false; - if (!_container.CanRemove(held, hand.Container)) + if (!hand.Container!.CanRemove(hand.HeldEntity.Value, EntityManager)) return false; if (checkActionBlocker && !_actionBlocker.CanDrop(uid)) @@ -112,7 +110,7 @@ public abstract partial class SharedHandsSystem : EntitySystem /// /// 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. /// - public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, BaseContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null) + public bool TryDropIntoContainer(EntityUid uid, EntityUid entity, IContainer targetContainer, bool checkActionBlocker = true, HandsComponent? handsComp = null) { if (!Resolve(uid, ref handsComp)) return false; @@ -123,7 +121,7 @@ public abstract partial class SharedHandsSystem : EntitySystem if (!CanDropHeld(uid, hand, checkActionBlocker)) return false; - if (!_container.CanInsert(entity, targetContainer)) + if (!targetContainer.CanInsert(entity, EntityManager)) return false; DoDrop(uid, hand, false, handsComp); diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs index e62723df06..eaa10ed077 100644 --- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs +++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs @@ -181,7 +181,7 @@ public abstract partial class SharedHandsSystem : EntitySystem return false; // check can insert (including raising attempt events). - return _containerSystem.CanInsert(entity, handContainer); + return handContainer.CanInsert(entity, EntityManager); } /// diff --git a/Content.Shared/Implants/SharedImplanterSystem.cs b/Content.Shared/Implants/SharedImplanterSystem.cs index 1cf9f44663..6d0a65f238 100644 --- a/Content.Shared/Implants/SharedImplanterSystem.cs +++ b/Content.Shared/Implants/SharedImplanterSystem.cs @@ -111,7 +111,7 @@ public abstract class SharedImplanterSystem : EntitySystem continue; //Don't remove a permanent implant and look for the next that can be drawn - if (!_container.CanRemove(implant, implantContainer)) + if (!implantContainer.CanRemove(implant)) { var implantName = Identity.Entity(implant, EntityManager); var targetName = Identity.Entity(target, EntityManager); diff --git a/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs b/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs index 9ea48a89c8..0a13fc4f1b 100644 --- a/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs +++ b/Content.Shared/Interaction/Helpers/SharedUnoccludedExtensions.cs @@ -32,7 +32,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this EntityUid origin, - BaseContainer other, + IContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -90,7 +90,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this IComponent origin, - BaseContainer other, + IContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -130,7 +130,7 @@ namespace Content.Shared.Interaction.Helpers #region Containers public static bool InRangeUnOccluded( - this BaseContainer origin, + this IContainer origin, EntityUid other, float range = InteractionRange, Ignored? predicate = null, @@ -143,7 +143,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this BaseContainer origin, + this IContainer origin, IComponent other, float range = InteractionRange, Ignored? predicate = null, @@ -155,8 +155,8 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this BaseContainer origin, - BaseContainer other, + this IContainer origin, + IContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -169,7 +169,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this BaseContainer origin, + this IContainer origin, EntityCoordinates other, float range = InteractionRange, Ignored? predicate = null, @@ -181,7 +181,7 @@ namespace Content.Shared.Interaction.Helpers } public static bool InRangeUnOccluded( - this BaseContainer origin, + this IContainer origin, MapCoordinates other, float range = InteractionRange, Ignored? predicate = null, @@ -226,7 +226,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this EntityCoordinates origin, - BaseContainer other, + IContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) @@ -304,7 +304,7 @@ namespace Content.Shared.Interaction.Helpers public static bool InRangeUnOccluded( this MapCoordinates origin, - BaseContainer other, + IContainer other, float range = InteractionRange, Ignored? predicate = null, bool ignoreInsideBlocker = true) diff --git a/Content.Shared/Inventory/InventorySystem.Equip.cs b/Content.Shared/Inventory/InventorySystem.Equip.cs index f3181a87b1..25dcf56921 100644 --- a/Content.Shared/Inventory/InventorySystem.Equip.cs +++ b/Content.Shared/Inventory/InventorySystem.Equip.cs @@ -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 && !_containerSystem.CanRemove(removedItem.Value, slotContainer)) + if (!force && !slotContainer.CanRemove(removedItem.Value)) return false; foreach (var slotDef in GetSlots(target, inventory)) @@ -426,12 +426,14 @@ public abstract partial class InventorySystem if ((containerSlot == null || slotDefinition == null) && !TryGetSlotContainer(target, slot, out containerSlot, out slotDefinition, inventory)) return false; - if (containerSlot.ContainedEntity is not {} itemUid) + if (containerSlot.ContainedEntity == null) return false; - if (!_containerSystem.CanRemove(itemUid, containerSlot)) + if (!containerSlot.ContainedEntity.HasValue || !containerSlot.CanRemove(containerSlot.ContainedEntity.Value)) return false; + var itemUid = containerSlot.ContainedEntity.Value; + // make sure the user can actually reach the target if (!CanAccess(actor, target, itemUid)) { diff --git a/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs b/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs index 71d3a7bd16..36441b50ad 100644 --- a/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs +++ b/Content.Shared/Silicons/Borgs/Components/BorgChassisComponent.cs @@ -33,7 +33,7 @@ public sealed partial class BorgChassisComponent : Component public string BrainContainerId = "borg_brain"; [ViewVariables(VVAccess.ReadWrite)] - public ContainerSlot BrainContainer = default!; + public ContainerSlot BrainContainer = new(); public EntityUid? BrainEntity => BrainContainer.ContainedEntity; #endregion