_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.,
}
}
- 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;
[UISystemDependency] private readonly ClientInventorySystem _inventorySystem = default!;
[UISystemDependency] private readonly HandsSystem _handsSystem = default!;
- [UISystemDependency] private readonly ContainerSystem _container = default!;
private EntityUid? _playerUid;
private InventorySlotsComponent? _playerInventory;
var hoverEntity = _entities.SpawnEntity("hoverentity", MapCoordinates.Nullspace);
var hoverSprite = _entities.GetComponent<SpriteComponent>(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);
EntityUid target = default;
EntityUid item = default;
EntityUid containerEntity = default;
- BaseContainer container = null;
+ IContainer container = null;
await server.WaitAssertion(() =>
{
if (!Resolve(uid, ref holder))
return false;
- if (!_containerSystem.CanInsert(toInsert, holder.Container))
+ if (!holder.Container.CanInsert(toInsert))
{
return false;
}
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);
}
/// <summary>
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))
{
/// <summary>
/// Makes an event horizon consume a given entity.
/// </summary>
- 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<MindContainerComponent>(morsel)
/// <summary>
/// Makes an event horizon attempt to consume a given entity.
/// </summary>
- 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;
/// 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.
/// </summary>
- 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<EntityUid> immune = new();
/// </summary>
[ByRefEvent]
public readonly record struct EntityConsumedByEventHorizonEvent
-(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container)
+(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container)
{
/// <summary>
/// The entity 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.
/// </summary>
- public readonly BaseContainer? Container = container;
+ public readonly IContainer? Container = container;
}
/// </summary>
[ByRefEvent]
public readonly record struct EventHorizonConsumedEntityEvent
-(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, BaseContainer? container)
+(EntityUid entity, EntityUid eventHorizonUid, EventHorizonComponent eventHorizon, IContainer? container)
{
/// <summary>
/// The entity 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.
/// </summary>
- public readonly BaseContainer? Container = container;
+ public readonly IContainer? Container = container;
}
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);
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);
/// <param name="holder">Component of <see cref="holderId"/></param>
/// <param name="action">Component of <see cref="actionId"/></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, 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
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);
public partial class SharedBodySystem
{
- [Dependency] private readonly SharedContainerSystem _container = default!;
-
private void InitializeOrgans()
{
SubscribeLocalEvent<OrganComponent, ComponentGetState>(OnOrganGetState);
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)
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(
/// </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;
if (ev.Cancelled)
return false;
- return _containers.CanInsert(usedUid, slot.ContainerSlot, assumeEmpty: true);
+ return slot.ContainerSlot?.CanInsertIfEmpty(usedUid, EntityManager) ?? false;
}
/// <summary>
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>
public abstract partial class SharedHandsSystem : EntitySystem
{
- [Dependency] private readonly SharedContainerSystem _container = default!;
-
private void InitializeDrop()
{
SubscribeLocalEvent<HandsComponent, EntRemovedFromContainerMessage>(HandleEntityRemoved);
/// </summary>
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))
/// <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.
/// </summary>
- 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;
if (!CanDropHeld(uid, hand, checkActionBlocker))
return false;
- if (!_container.CanInsert(entity, targetContainer))
+ if (!targetContainer.CanInsert(entity, EntityManager))
return false;
DoDrop(uid, hand, false, handsComp);
return false;
// check can insert (including raising attempt events).
- return _containerSystem.CanInsert(entity, handContainer);
+ return handContainer.CanInsert(entity, EntityManager);
}
/// <summary>
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);
public static bool InRangeUnOccluded(
this EntityUid origin,
- BaseContainer other,
+ IContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
public static bool InRangeUnOccluded(
this IComponent origin,
- BaseContainer other,
+ IContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
#region Containers
public static bool InRangeUnOccluded(
- this BaseContainer origin,
+ this IContainer origin,
EntityUid other,
float range = InteractionRange,
Ignored? predicate = null,
}
public static bool InRangeUnOccluded(
- this BaseContainer origin,
+ this IContainer origin,
IComponent other,
float range = InteractionRange,
Ignored? predicate = null,
}
public static bool InRangeUnOccluded(
- this BaseContainer origin,
- BaseContainer other,
+ this IContainer origin,
+ IContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
}
public static bool InRangeUnOccluded(
- this BaseContainer origin,
+ this IContainer origin,
EntityCoordinates other,
float range = InteractionRange,
Ignored? predicate = null,
}
public static bool InRangeUnOccluded(
- this BaseContainer origin,
+ this IContainer origin,
MapCoordinates other,
float range = InteractionRange,
Ignored? predicate = null,
public static bool InRangeUnOccluded(
this EntityCoordinates origin,
- BaseContainer other,
+ IContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
public static bool InRangeUnOccluded(
this MapCoordinates origin,
- BaseContainer other,
+ IContainer other,
float range = InteractionRange,
Ignored? predicate = null,
bool ignoreInsideBlocker = true)
}
//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))
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))
{
public string BrainContainerId = "borg_brain";
[ViewVariables(VVAccess.ReadWrite)]
- public ContainerSlot BrainContainer = default!;
+ public ContainerSlot BrainContainer = new();
public EntityUid? BrainEntity => BrainContainer.ContainedEntity;
#endregion