using System;
using System.Collections.Generic;
using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using JetBrains.Annotations;
using Robust.Shared.Containers;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Robust.Shared.GameObjects;
public partial class EntitySystem
{
#region Entity LifeStage
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Exists(EntityUid uid)
{
return EntityManager.EntityExists(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Exists([NotNullWhen(true)] EntityUid? uid)
{
return EntityManager.EntityExists(uid);
}
///
/// Retrieves whether the entity is initializing. Throws if the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Initializing(EntityUid uid, MetaDataComponent? metaData = null)
{
return LifeStage(uid, metaData) == EntityLifeStage.Initializing;
}
///
/// Retrieves whether the entity is initialized. Throws if the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Initialized(EntityUid uid, MetaDataComponent? metaData = null)
{
return LifeStage(uid, metaData) >= EntityLifeStage.Initialized;
}
///
/// Retrieves whether the entity is being terminated. Throws if the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Terminating(EntityUid uid, MetaDataComponent? metaData = null)
{
return LifeStage(uid, metaData) == EntityLifeStage.Terminating;
}
///
/// Retrieves whether the entity is deleted or is nonexistent.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Deleted(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
return true;
return metaData.EntityDeleted;
}
///
/// Checks whether the entity is being or has been deleted (or never existed in the first place).
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TerminatingOrDeleted(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
return true;
return metaData.EntityLifeStage >= EntityLifeStage.Terminating;
}
///
/// Retrieves whether the entity is deleted or is nonexistent.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Deleted(EntityUid uid, EntityQuery metaQuery)
{
if (!metaQuery.TryGetComponent(uid, out var meta))
return true;
return meta.EntityDeleted;
}
///
/// Retrieves whether the entity is deleted or is nonexistent.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Deleted([NotNullWhen(false)] EntityUid? uid)
{
return !uid.HasValue || Deleted(uid.Value);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityLifeStage LifeStage(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityLifeStage;
}
///
/// Attempts to retrieve whether the entity is initializing.
///
/// Whether it could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryInitializing(EntityUid uid, [NotNullWhen(true)] out bool? initializing, MetaDataComponent? metaData = null)
{
if (!TryLifeStage(uid, out var lifeStage, metaData))
{
initializing = null;
return false;
}
initializing = lifeStage == EntityLifeStage.Initializing;
return true;
}
///
/// Attempts to retrieve whether the entity is initialized.
///
/// Whether it could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryInitialized(EntityUid uid, [NotNullWhen(true)] out bool? initialized, MetaDataComponent? metaData = null)
{
if (!TryLifeStage(uid, out var lifeStage, metaData))
{
initialized = null;
return false;
}
initialized = lifeStage >= EntityLifeStage.Initialized;
return true;
}
///
/// Attempts to retrieve whether the entity is terminating.
///
/// Whether it could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryTerminating(EntityUid uid, [NotNullWhen(true)] out bool? terminating, MetaDataComponent? metaData = null)
{
if (!TryLifeStage(uid, out var lifeStage, metaData))
{
terminating = null;
return false;
}
terminating = lifeStage == EntityLifeStage.Terminating;
return true;
}
///
/// Attempts to retrieve the life-stage of the entity.
///
///
/// Whether it could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryLifeStage(EntityUid uid, [NotNullWhen(true)] out EntityLifeStage? lifeStage, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData))
{
lifeStage = null;
return false;
}
lifeStage = metaData.EntityLifeStage;
return true;
}
#endregion
#region Entity Metadata
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool IsPaused(EntityUid? uid, MetaDataComponent? metadata = null)
{
return EntityManager.IsPaused(uid, metadata);
}
///
/// Marks this entity as dirty so that it will be updated over the network.
///
///
/// Calling Dirty on a component will call this directly.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void DirtyEntity(EntityUid uid, MetaDataComponent? meta = null)
{
EntityManager.DirtyEntity(uid, meta);
}
///
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Obsolete("Use Dirty(EntityUid, Component, MetaDataComponent?")]
protected void Dirty(Component component, MetaDataComponent? meta = null)
{
EntityManager.Dirty(component, meta);
}
///
/// Marks a component as dirty. This also implicitly dirties the entity this component belongs to.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void Dirty(EntityUid uid, Component component, MetaDataComponent? meta = null)
{
EntityManager.Dirty(uid, component, meta);
}
///
/// Retrieves the name of an entity.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected string Name(EntityUid uid, MetaDataComponent? metaData = null)
{
if(!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityName;
}
///
/// Retrieves the description of an entity.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected string Description(EntityUid uid, MetaDataComponent? metaData = null)
{
if(!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityDescription;
}
///
/// Retrieves the prototype of an entity, if any.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityPrototype? Prototype(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityPrototype;
}
///
/// Retrieves the last the entity was modified at.
///
/// Thrown when the entity doesn't exist.
protected GameTick LastModifiedTick(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityLastModifiedTick;
}
///
/// Retrieves whether the entity is paused or not.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool Paused(EntityUid uid, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
return metaData.EntityPaused;
}
///
/// Sets the paused status on an entity.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void SetPaused(EntityUid uid, bool paused, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
throw CompNotFound(uid);
EntityManager.EntitySysManager.GetEntitySystem().SetEntityPaused(uid, paused, metaData);
}
///
/// Attempts to mark an entity as dirty.
///
/// Whether the operation succeeded.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryDirty(EntityUid uid)
{
if (!Exists(uid))
return false;
DirtyEntity(uid);
return true;
}
///
/// Attempts to retrieve the name of an entity.
///
/// Whether the name could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryName(EntityUid uid, [NotNullWhen(true)] out string? name, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
{
name = null;
return false;
}
name = metaData.EntityName;
return true;
}
///
/// Attempts to retrieve the description of an entity.
///
/// Whether the description could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryDescription(EntityUid uid, [NotNullWhen(true)] out string? description, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
{
description = null;
return false;
}
description = metaData.EntityDescription;
return true;
}
///
/// Attempts to retrieve the prototype of an entity.
///
/// Whether the prototype could be retrieved and was not null.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryPrototype(EntityUid uid, [NotNullWhen(true)] out EntityPrototype? prototype, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
{
prototype = null;
return false;
}
prototype = metaData.EntityPrototype;
return prototype != null;
}
///
/// Attempts to retrieve the last the entity was modified at.
///
/// Whether the last modified tick could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryLastModifiedTick(EntityUid uid, [NotNullWhen(true)] out GameTick? lastModifiedTick, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
{
lastModifiedTick = null;
return false;
}
lastModifiedTick = metaData.EntityLastModifiedTick;
return true;
}
///
/// Attempts to retrieve the paused status on an entity.
///
/// Whether the pause status could be retrieved.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryPaused(EntityUid uid, [NotNullWhen(true)] out bool? paused, MetaDataComponent? metaData = null)
{
if (!Resolve(uid, ref metaData, false))
{
paused = null;
return false;
}
paused = metaData.EntityPaused;
return true;
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NotNullIfNotNull("uid")]
protected EntityStringRepresentation? ToPrettyString(EntityUid? uid)
{
return EntityManager.ToPrettyString(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[return: NotNullIfNotNull("netEntity")]
protected EntityStringRepresentation? ToPrettyString(NetEntity? netEntity)
{
return EntityManager.ToPrettyString(netEntity);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityStringRepresentation ToPrettyString(EntityUid uid)
=> ToPrettyString((EntityUid?) uid).Value;
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityStringRepresentation ToPrettyString(NetEntity netEntity)
=> ToPrettyString((NetEntity?) netEntity).Value;
#endregion
#region Component Get
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected T Comp(EntityUid uid) where T : Component
{
return EntityManager.GetComponent(uid);
}
///
/// Returns the component of a specific type, or null when it's missing or the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected T? CompOrNull(EntityUid uid) where T : class, IComponent
{
return EntityManager.GetComponentOrNull(uid);
}
///
/// Returns the component of a specific type, or null when it's missing or the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected T? CompOrNull(EntityUid? uid) where T : class, IComponent
{
return uid.HasValue ? EntityManager.GetComponentOrNull(uid.Value) : null;
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryComp(EntityUid uid, [NotNullWhen(true)] out T? comp)
{
return EntityManager.TryGetComponent(uid, out comp);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TryComp([NotNullWhen(true)] EntityUid? uid, [NotNullWhen(true)] out T? comp)
{
if (!uid.HasValue)
{
comp = default;
return false;
}
return EntityManager.TryGetComponent(uid.Value, out comp);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable AllComps(EntityUid uid)
{
return EntityManager.GetComponents(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable AllComps(EntityUid uid)
{
return EntityManager.GetComponents(uid);
}
///
/// Returns the on an entity.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected TransformComponent Transform(EntityUid uid)
{
return EntityManager.GetComponent(uid);
}
///
/// Returns the on an entity.
///
/// Thrown when the entity doesn't exist.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected MetaDataComponent MetaData(EntityUid uid)
{
return EntityManager.GetComponent(uid);
}
#endregion
#region Component Has
///
/// Retrieves whether the entity has the specified component or not.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool HasComp(EntityUid uid)
{
return EntityManager.HasComponent(uid);
}
///
/// Retrieves whether the entity has the specified component or not.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool HasComp(EntityUid uid, Type type)
{
return EntityManager.HasComponent(uid, type);
}
///
/// Retrieves whether the entity has the specified component or not.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool HasComp([NotNullWhen(true)] EntityUid? uid)
{
return EntityManager.HasComponent(uid);
}
///
/// Retrieves whether the entity has the specified component or not.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool HasComp([NotNullWhen(true)] EntityUid? uid, Type type)
{
return EntityManager.HasComponent(uid, type);
}
#endregion
#region Component Add
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected T AddComp(EntityUid uid) where T : Component, new()
{
return EntityManager.AddComponent(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void AddComp(EntityUid uid, T component, bool overwrite = false) where T : Component
{
EntityManager.AddComponent(uid, component, overwrite);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected T EnsureComp(EntityUid uid) where T : Component, new()
{
return EntityManager.EnsureComponent(uid);
}
#endregion
#region Component Remove Deferred
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool RemCompDeferred(EntityUid uid) where T : class, IComponent
{
return EntityManager.RemoveComponentDeferred(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool RemCompDeferred(EntityUid uid, Type type)
{
return EntityManager.RemoveComponentDeferred(uid, type);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void RemCompDeferred(EntityUid uid, Component component)
{
EntityManager.RemoveComponentDeferred(uid, component);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void RemCompDeferred(EntityUid uid, IComponent component)
{
EntityManager.RemoveComponentDeferred(uid, component);
}
#endregion
#region Component count
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected int Count() where T : Component
{
return EntityManager.Count();
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected int Count(Type type)
{
return EntityManager.Count(type);
}
#endregion
#region Component Remove
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool RemComp(EntityUid uid) where T : class, IComponent
{
return EntityManager.RemoveComponent(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool RemComp(EntityUid uid, Type type)
{
return EntityManager.RemoveComponent(uid, type);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void RemComp(EntityUid uid, Component component)
{
EntityManager.RemoveComponent(uid, component);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void RemComp(EntityUid uid, IComponent component)
{
EntityManager.RemoveComponent(uid, component);
}
#endregion
#region Entity Delete
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void Del(EntityUid? uid)
{
EntityManager.DeleteEntity(uid);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void QueueDel(EntityUid? uid)
{
EntityManager.QueueDeleteEntity(uid);
}
#endregion
#region Entity Spawning
// This method will be obsoleted soon.
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid Spawn(string? prototype, EntityCoordinates coordinates)
{
return ((IEntityManager)EntityManager).SpawnEntity(prototype, coordinates);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid Spawn(string? prototype, MapCoordinates coordinates)
=> EntityManager.Spawn(prototype, coordinates);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid Spawn(string? prototype = null)
=> EntityManager.Spawn(prototype);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid SpawnAttachedTo(string? prototype, EntityCoordinates coordinates)
=> EntityManager.SpawnAttachedTo(prototype, coordinates);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid SpawnAtPosition(string? prototype, EntityCoordinates coordinates)
=> EntityManager.SpawnAtPosition(prototype, coordinates);
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TrySpawnInContainer(
string? protoName,
EntityUid containerUid,
string containerId,
[NotNullWhen(true)] out EntityUid? uid,
ContainerManagerComponent? containerComp = null,
ComponentRegistry? overrides = null)
{
return EntityManager.TrySpawnInContainer(protoName, containerUid, containerId, out uid, containerComp, overrides);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool TrySpawnNextTo(
string? protoName,
EntityUid target,
[NotNullWhen(true)] out EntityUid? uid,
TransformComponent? xform = null,
ComponentRegistry? overrides = null)
{
return EntityManager.TrySpawnNextTo(protoName, target, out uid, xform, overrides);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid SpawnNextToOrDrop(
string? protoName,
EntityUid target,
TransformComponent? xform = null,
ComponentRegistry? overrides = null)
{
return EntityManager.SpawnNextToOrDrop(protoName, target, xform, overrides);
}
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid SpawnInContainerOrDrop(
string? protoName,
EntityUid containerUid,
string containerId,
TransformComponent? xform = null,
ContainerManagerComponent? container = null,
ComponentRegistry? overrides = null)
{
return EntityManager.SpawnInContainerOrDrop(protoName, containerUid, containerId, xform, container, overrides);
}
#endregion
#region Utils
///
/// Utility static method to create an exception to be thrown when an entity doesn't have a specific component.
///
private static KeyNotFoundException CompNotFound(EntityUid uid)
=> new($"Entity {uid} does not have a component of type {typeof(T)}");
#endregion
#region All Entity Query
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected AllEntityQueryEnumerator AllEntityQuery() where TComp1 : Component
{
return EntityManager.AllEntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected AllEntityQueryEnumerator AllEntityQuery()
where TComp1 : Component
where TComp2 : Component
{
return EntityManager.AllEntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected AllEntityQueryEnumerator AllEntityQuery()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
{
return EntityManager.AllEntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected AllEntityQueryEnumerator AllEntityQuery()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
{
return EntityManager.AllEntityQueryEnumerator();
}
#endregion
#region Get Entity Query
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityQueryEnumerator EntityQueryEnumerator() where TComp1 : Component
{
return EntityManager.EntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityQueryEnumerator EntityQueryEnumerator()
where TComp1 : Component
where TComp2 : Component
{
return EntityManager.EntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityQueryEnumerator EntityQueryEnumerator()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
{
return EntityManager.EntityQueryEnumerator();
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityQueryEnumerator EntityQueryEnumerator()
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
{
return EntityManager.EntityQueryEnumerator();
}
#endregion
#region Entity Query
///
/// If you need the EntityUid, use
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
[Pure]
protected EntityQuery GetEntityQuery() where T : Component
{
return EntityManager.GetEntityQuery();
}
///
/// If you need the EntityUid, use
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable EntityQuery(bool includePaused = false) where TComp1 : Component
{
return EntityManager.EntityQuery(includePaused);
}
///
/// If you need the EntityUid, use
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable<(TComp1, TComp2)> EntityQuery(bool includePaused = false)
where TComp1 : Component
where TComp2 : Component
{
return EntityManager.EntityQuery(includePaused);
}
///
/// If you need the EntityUid, use
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable<(TComp1, TComp2, TComp3)> EntityQuery(bool includePaused = false)
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
{
return EntityManager.EntityQuery(includePaused);
}
///
/// If you need the EntityUid, use
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected IEnumerable<(TComp1, TComp2, TComp3, TComp4)> EntityQuery(bool includePaused = false)
where TComp1 : Component
where TComp2 : Component
where TComp3 : Component
where TComp4 : Component
{
return EntityManager.EntityQuery(includePaused);
}
#endregion
#region Networked Events
///
/// Sends a networked message to the server, while also repeatedly raising it locally for every time this tick gets re-predicted.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected void RaisePredictiveEvent(T msg) where T : EntityEventArgs
{
EntityManager.RaisePredictiveEvent(msg);
}
#endregion
#region NetEntities
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected bool IsClientSide(EntityUid entity)
{
return EntityManager.IsClientSide(entity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryGetEntity(NetEntity nEntity, [NotNullWhen(true)] out EntityUid? entity)
{
return EntityManager.TryGetEntity(nEntity, out entity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryGetEntity(NetEntity? nEntity, [NotNullWhen(true)] out EntityUid? entity)
{
return EntityManager.TryGetEntity(nEntity, out entity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryGetNetEntity(EntityUid uid, [NotNullWhen(true)] out NetEntity? netEntity, MetaDataComponent? metadata = null)
{
return EntityManager.TryGetNetEntity(uid, out netEntity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public bool TryGetNetEntity(EntityUid? uid, [NotNullWhen(true)] out NetEntity? netEntity, MetaDataComponent? metadata = null)
{
return EntityManager.TryGetNetEntity(uid, out netEntity);
}
///
/// Returns the of an entity. Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetEntity GetNetEntity(EntityUid uid, MetaDataComponent? metadata = null)
{
return EntityManager.GetNetEntity(uid, metadata);
}
///
/// Returns the of an entity. Logs an error if the entity does not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetEntity? GetNetEntity(EntityUid? uid, MetaDataComponent? metadata = null)
{
return EntityManager.GetNetEntity(uid, metadata);
}
///
/// Returns the of an entity or creates a new entity if none exists.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid EnsureEntity(NetEntity netEntity, EntityUid callerEntity)
{
return EntityManager.EnsureEntity(netEntity, callerEntity);
}
///
/// Returns the of an entity or creates a new one if not null.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid? EnsureEntity(NetEntity? netEntity, EntityUid callerEntity)
{
return EntityManager.EnsureEntity(netEntity, callerEntity);
}
///
/// Returns the of an entity or creates a new entity if none exists.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates EnsureCoordinates(NetCoordinates netCoordinates, EntityUid callerEntity)
{
return EntityManager.EnsureCoordinates(netCoordinates, callerEntity);
}
///
/// Returns the of an entity or creates a new one if not null.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates? EnsureCoordinates(NetCoordinates? netCoordinates, EntityUid callerEntity)
{
return EntityManager.EnsureCoordinates(netCoordinates, callerEntity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected HashSet EnsureEntitySet(HashSet netEntities, EntityUid callerEntity)
{
return EntityManager.EnsureEntitySet(netEntities, callerEntity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List EnsureEntityList(List netEntities, EntityUid callerEntity)
{
return EntityManager.EnsureEntityList(netEntities, callerEntity);
}
///
/// Returns the of a . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid GetEntity(NetEntity netEntity)
{
return EntityManager.GetEntity(netEntity);
}
///
/// Returns the of a . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid? GetEntity(NetEntity? netEntity)
{
return EntityManager.GetEntity(netEntity);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected HashSet GetNetEntitySet(HashSet uids)
{
return EntityManager.GetNetEntitySet(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected HashSet GetEntitySet(HashSet netEntities)
{
return EntityManager.GetEntitySet(netEntities);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetEntityList(ICollection uids)
{
return EntityManager.GetNetEntityList(uids);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetEntityList(IReadOnlyList uids)
{
return EntityManager.GetNetEntityList(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(ICollection netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetEntityList(List uids)
{
return EntityManager.GetNetEntityList(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(List netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetEntityList(List uids)
{
return EntityManager.GetNetEntityList(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(List netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetEntity[] GetNetEntityArray(EntityUid[] uids)
{
return EntityManager.GetNetEntityArray(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid[] GetEntityArray(NetEntity[] netEntities)
{
return EntityManager.GetEntityArray(netEntities);
}
///
/// Returns the versions of the supplied entities. Logs an error if the entities do not exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetEntity?[] GetNetEntityArray(EntityUid?[] uids)
{
return EntityManager.GetNetEntityArray(uids);
}
///
/// Returns the versions of the supplied . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityUid?[] GetEntityArray(NetEntity?[] netEntities)
{
return EntityManager.GetEntityArray(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetCoordinates GetNetCoordinates(EntityCoordinates coordinates, MetaDataComponent? metadata = null)
{
return EntityManager.GetNetCoordinates(coordinates, metadata);
}
///
/// Returns the of an entity. Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetCoordinates? GetNetCoordinates(EntityCoordinates? coordinates, MetaDataComponent? metadata = null)
{
return EntityManager.GetNetCoordinates(coordinates, metadata);
}
///
/// Returns the of a . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates GetCoordinates(NetCoordinates netEntity)
{
return EntityManager.GetCoordinates(netEntity);
}
///
/// Returns the of a . Returns if it doesn't exist.
///
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates? GetCoordinates(NetCoordinates? netEntity)
{
return EntityManager.GetCoordinates(netEntity);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected HashSet GetEntitySet(HashSet netEntities)
{
return EntityManager.GetEntitySet(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(List netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(ICollection netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetEntityList(List netEntities)
{
return EntityManager.GetEntityList(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates[] GetEntityArray(NetCoordinates[] netEntities)
{
return EntityManager.GetEntityArray(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected EntityCoordinates?[] GetEntityArray(NetCoordinates?[] netEntities)
{
return EntityManager.GetEntityArray(netEntities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected HashSet GetNetCoordinatesSet(HashSet entities)
{
return EntityManager.GetNetCoordinatesSet(entities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetCoordinatesList(List entities)
{
return EntityManager.GetNetCoordinatesList(entities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetCoordinatesList(ICollection entities)
{
return EntityManager.GetNetCoordinatesList(entities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected List GetNetCoordinatesList(List entities)
{
return EntityManager.GetNetCoordinatesList(entities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetCoordinates[] GetNetCoordinatesArray(EntityCoordinates[] entities)
{
return EntityManager.GetNetCoordinatesArray(entities);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
protected NetCoordinates?[] GetNetCoordinatesArray(EntityCoordinates?[] entities)
{
return EntityManager.GetNetCoordinatesArray(entities);
}
#endregion
}