using System; using System.Collections.Generic; using JetBrains.Annotations; using Robust.Shared.GameObjects; using Robust.Shared.Serialization; 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 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; } /// /// The container manager owning this container. /// IContainerManager Manager { 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); /// /// 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. /// /// The entity to attempt to remove. /// /// True if the entity was removed, false otherwise. bool Remove(EntityUid toremove, IEntityManager? entMan = null, TransformComponent? xform = null, MetaDataComponent? meta = null); /// /// Forcefully removes an entity from the container. Normally you would want to use , /// this function should be avoided. /// /// The entity to attempt to 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(); } }