using System; using System.Collections.Generic; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.Shared.Maths; using Robust.Shared.Network; using Robust.Shared.Physics.Components; using Robust.Shared.Serialization.Manager.Attributes; namespace Robust.Shared.Containers { /// /// A container is a way to "contain" entities inside other entities, in a logical way. /// This is alike BYOND's contents system, except more advanced. /// /// ///

/// Containers are logical separations of entities contained inside another entity. /// for example, a crate with two separated compartments would have two separate containers. /// If an entity inside compartment A drops something, /// the dropped entity would be placed in compartment A too, /// and compartment B would be completely untouched. ///

///

/// Containers are managed by an entity's , /// and have an ID to be referenced by. ///

///
/// [PublicAPI] [ImplicitDataDefinitionForInheritors] public partial interface IContainer { /// /// Readonly collection of all the entities contained within this specific container /// IReadOnlyList ContainedEntities { get; } List ExpectedEntities { get; } /// /// The type of this container. /// string ContainerType { get; } /// /// True if the container has been shut down via /// bool Deleted { get; } /// /// The ID of this container. /// string ID { get; } /// /// Prevents light from escaping the container, from ex. a flashlight. /// bool OccludesLight { get; set; } /// /// The entity owning this container. /// EntityUid Owner { get; } /// /// Should the contents of this container be shown? False for closed containers like lockers, true for /// things like glass display cases. /// bool ShowContents { get; set; } /// /// Checks if the entity can be inserted into this container. /// /// The entity to attempt to insert. /// /// True if the entity can be inserted, false otherwise. bool CanInsert(EntityUid toinsert, IEntityManager? entMan = null); /// /// Attempts to insert the entity into this container. /// /// /// If the insertion is successful, the inserted entity will end up parented to the /// container entity, and the inserted entity's local position will be set to the zero vector. /// /// The entity to insert. /// /// False if the entity could not be inserted. /// /// Thrown if this container is a child of the entity, /// which would cause infinite loops. /// bool Insert(EntityUid toinsert, IEntityManager? entMan = null, TransformComponent? transform = null, TransformComponent? ownerTransform = null, MetaDataComponent? meta = null, PhysicsComponent? physics = null, bool force = false); /// /// Checks if the entity can be removed from this container. /// /// The entity to check. /// /// True if the entity can be removed, false otherwise. bool CanRemove(EntityUid toremove, IEntityManager? entMan = null); /// /// Attempts to remove the entity from this container. /// /// If false, this operation will not rigger a move or parent change event. Ignored if /// destination is not null /// If true, this will not perform can-remove checks. /// Where to place the entity after removing. Avoids unnecessary broadphase updates. /// If not specified, and reparent option is true, then the entity will either be inserted into a parent /// container, the grid, or the map. /// Optional final local rotation after removal. Avoids redundant move events. bool Remove( EntityUid toremove, IEntityManager? entMan = null, TransformComponent? xform = null, MetaDataComponent? meta = null, bool reparent = true, bool force = false, EntityCoordinates? destination = null, Angle? localRotation = null); [Obsolete("use force option in Remove()")] void ForceRemove(EntityUid toRemove, IEntityManager? entMan = null, MetaDataComponent? meta = null); /// /// Checks if the entity is contained in this container. /// This is not recursive, so containers of children are not checked. /// /// The entity to check. /// True if the entity is immediately contained in this container, false otherwise. bool Contains(EntityUid contained); /// /// Clears the container and marks it as deleted. /// void Shutdown(IEntityManager? entMan = null, INetManager? netMan = null); } }