Class EntityManager
Collects every Entity instance present in a Scene. As a collection, it supports common operations like adding and removing entities.
Implements
Inherited Members
Namespace: Evergine.Framework.Managers
Assembly: Evergine.Framework.dll
Syntax
public class EntityManager : SceneManager, IDependencyObject
  Constructors
EntityManager()
Initializes a new instance of the EntityManager class.
Declaration
public EntityManager()
  Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If adapter or scene are null.  | 
      
Properties
AllEntities
Declaration
public IEnumerable<Entity> AllEntities { get; }
  Property Value
| Type | Description | 
|---|---|
| IEnumerable<Entity> | Every Entity instance.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | EntityManager has been disposed.  | 
      
Count
Gets how many Entity instances are added to this instance.
Declaration
public int Count { get; }
  Property Value
| Type | Description | 
|---|---|
| int | How many Entity instances are added to this instance.  | 
      
EntityGraph
Gets the Entity instances
(see 
Declaration
public IEnumerable<Entity> EntityGraph { get; }
  Property Value
| Type | Description | 
|---|---|
| IEnumerable<Entity> | The Entity instances.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | EntityManager has been disposed.  | 
      
Methods
Add(Entity)
Adds a new Entity to this instance.
Declaration
public virtual void Add(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The Entity to add.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
| InvalidOperationException | If there is already an entity added to this instance with the same name.  | 
      
Add(IEnumerable<Entity>)
Adds a list of Entity to EntityManager.
Declaration
public virtual void Add(IEnumerable<Entity> newEntities)
  Parameters
| Type | Name | Description | 
|---|---|---|
| IEnumerable<Entity> | newEntities | The Entity list to add.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
| InvalidOperationException | If there is already an entity added to this instance with the same name.  | 
      
Contains(Entity)
Determines whether this instance contains the specified Entity
through its 
Declaration
public bool Contains(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The Entity to check.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | 
  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
Detach(Entity)
Detach a specific entity.
Declaration
public bool Detach(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The entity to detach.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | Whether an entity was detached.  | 
      
Remarks
The entity is disposed when it is detached from this instance.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
Find(Guid)
Looks for an Entity entity
in the 
Declaration
public Entity Find(Guid entityId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | entityId | The entity Id to find.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The Entity with the specified   | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If the entity id is an empty Guid.  | 
      
Find(string, Entity)
Find the first entity in the EntityGraph with the given entity path.
Declaration
public Entity Find(string entityPath, Entity sourceEntity = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityPath | Path of the entity to look for. If   | 
      
| Entity | sourceEntity | The source entity for a relative path.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The Entity with the specified   | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If name is null or empty.  | 
      
FindAllByTag(string)
Finds all entities with the same tag
in the 
Declaration
public IEnumerable<Entity> FindAllByTag(string tag)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | tag | The tag.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Entity> | All entities with the same   | 
      
FindComponentFromEntityPath<T>(string, bool)
Return the first component inside of the first entity with the given entity path.
Declaration
public T FindComponentFromEntityPath<T>(string entityPath, bool isExactType = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityPath | Entity Path.  | 
      
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| T | Component inside of entity.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Component Type.  | 
      
FindComponentsFromEntityPath<T>(string, bool)
Return the components inside of the first entity with the given entity path.
Declaration
public IEnumerable<T> FindComponentsFromEntityPath<T>(string entityPath, bool isExactType = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityPath | Entity Path.  | 
      
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<T> | Components collection.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Component Type.  | 
      
FindComponentsOfType(Type, bool, string)
Iterate through the entire entity hierarchy and return all component instances of the specified type.
Declaration
public IEnumerable<Component> FindComponentsOfType(Type type, bool isExactType = true, string tag = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The component type.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Component> | The component enumerable.  | 
      
Remarks
This method is extremely low, try to not use inside an Update method.
FindComponentsOfType<T>(bool, string)
Iterate through the entire entity hierarchy and return all component instances of the specified type.
Declaration
public IEnumerable<T> FindComponentsOfType<T>(bool isExactType = true, string tag = null) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<T> | The component enumerable.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The component type.  | 
      
Remarks
This method is extremely low, try to not use inside an Update method.
FindFirstComponentOfType(Type, bool, string)
Iterate through the entire entity hierarchy and return the first component instance of the specified type.
Declaration
public Component FindFirstComponentOfType(Type type, bool isExactType = true, string tag = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The component type.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| Component | The component.  | 
      
Remarks
This method is extremely low, try to not use inside an Update method.
FindFirstComponentOfType<T>(bool, string)
Iterate through the entire entity hierarchy and return the first component instance of the specified type.
Declaration
public T FindFirstComponentOfType<T>(bool isExactType = true, string tag = null) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | if set to   | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| T | The component.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The component type.  | 
      
Remarks
This method is extremely low, try to not use inside an Update method.
GetEntityTagCollection(string)
Gets a collection of entities filtered by the specified tag.
Declaration
public virtual EntityManager.EntityTagCollection GetEntityTagCollection(string tag)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | tag | The tag.  | 
      
Returns
| Type | Description | 
|---|---|
| EntityManager.EntityTagCollection | The entity tag collection instance.  | 
      
OnActivated()
Invoked when the object is activated once is attached.
Declaration
protected override void OnActivated()
  Overrides
OnDetach()
Invoked when the object is detached.
Declaration
protected override void OnDetach()
  Overrides
Remove(Entity)
Removes a specific entity.
Declaration
public virtual bool Remove(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The entity to remove.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | Whether an entity was removed.  | 
      
Remarks
The entity is disposed when it is removed from this instance.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
Start()
Invoked to start the object.
Declaration
protected override void Start()
  Overrides
Events
EntityAdded
Occurs when an Entity is added.
Declaration
public event EventHandler<Entity> EntityAdded
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Entity> | 
EntityDetached
Occurs when an Entity is detached.
Notice that even when removing an entity, the entity is detached first. So this event will be fired for removed entities too.
Declaration
public event EventHandler<Entity> EntityDetached
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Entity> |