Class Entity
This class represents a game entity, which is basically a container of Component types, which are the ones that provide the actual game logic. Entity types are contained in Scene ones, which handle how to update and draw them.
Implements
Inherited Members
Namespace: Evergine.Framework
Assembly: Evergine.Framework.dll
Syntax
public class Entity : PrefabInstanceObject, IDependencyObject
  Remarks
Entity types can be organized in trees, with an entity containing others and so on.
Examples
This is an example on how to create an Entity. Take into account that the AddComponent() and RemoveComponent() methods are designed to allow method chaining, so this type of code can be written when creating or configuring an Entity:
var primitive = new Entity("Primitive")
                    .AddComponent(new Transform3D())
                    .AddComponent(new Spinner() { AxisTotalIncreases = new Vector3(0.01f, 0.02f, 0.01f) })
                    .AddComponent(new CubeMesh())
                    .AddComponent(new MeshRenderer())
                    .AddComponent(new MaterialComponent() { Material = myMaterial });
Recipes and samples.
- [Component based Architecture recipe](../recipes/Basic/Component-based-Architecture.md)
 
Constructors
Entity()
Declaration
public Entity()
  Entity(string)
Declaration
public Entity(string name)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | name | The name of the entity.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If name is null or empty.  | 
      
Fields
Flags
Special entity behavior flags.
Declaration
public HideFlags Flags
  Field Value
| Type | Description | 
|---|---|
| HideFlags | 
InvalidEntityNameStrings
Strings that are not valid in an entity name.
Declaration
public static readonly string[] InvalidEntityNameStrings
  Field Value
| Type | Description | 
|---|---|
| string[] | 
PathParent
The separator string.
Declaration
public static readonly string PathParent
  Field Value
| Type | Description | 
|---|---|
| string | 
PathSelf
The separator string.
Declaration
public static readonly string PathSelf
  Field Value
| Type | Description | 
|---|---|
| string | 
PathSeparatorChar
The separator char used in EntityPath property.
Declaration
public static readonly char PathSeparatorChar
  Field Value
| Type | Description | 
|---|---|
| char | 
PathSeparatorString
The separator string.
Declaration
public static readonly string PathSeparatorString
  Field Value
| Type | Description | 
|---|---|
| string | 
Properties
ChildEntities
Gets the children Entity of this instance.
Declaration
public IEnumerable<Entity> ChildEntities { get; }
  Property Value
| Type | Description | 
|---|---|
| IEnumerable<Entity> | 
Components
Gets the Component collection of this instance.
Declaration
public IEnumerable<Component> Components { get; }
  Property Value
| Type | Description | 
|---|---|
| IEnumerable<Component> | 
EntityManager
Gets the EntityManager that contains this instance.
Declaration
public EntityManager EntityManager { get; }
  Property Value
| Type | Description | 
|---|---|
| EntityManager | 
EntityPath
Gets the Entity path. The entity path is a string that conform the path in the EntityManager to obtain the instance.
Declaration
public string EntityPath { get; }
  Property Value
| Type | Description | 
|---|---|
| string | 
IsStatic
Gets or sets a value indicating whether this instance is static. Once an entity is initialized, this cannot be displaced, rotated or scaled.
Declaration
public bool IsStatic { get; set; }
  Property Value
| Type | Description | 
|---|---|
| bool | 
  | 
      
Name
Gets or sets the name of the instance.
Declaration
public string Name { get; set; }
  Property Value
| Type | Description | 
|---|---|
| string | 
NumChildren
Gets the number of children Entity actually contained in this instance.
Declaration
public int NumChildren { get; }
  Property Value
| Type | Description | 
|---|---|
| int | 
Parent
Gets or sets the parent Entity.
Declaration
public Entity Parent { get; set; }
  Property Value
| Type | Description | 
|---|---|
| Entity | 
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity have been disposed.  | 
      
Scene
Gets the Scene that contains this instance.
Declaration
public Scene Scene { get; }
  Property Value
| Type | Description | 
|---|---|
| Scene | 
ShouldBeActivated
Gets a value indicating whether this object should be activated.
Declaration
protected override bool ShouldBeActivated { get; }
  Property Value
| Type | Description | 
|---|---|
| bool | 
Overrides
Tag
Gets or sets the Tag of the instance.
Declaration
public string Tag { get; set; }
  Property Value
| Type | Description | 
|---|---|
| string | 
Methods
AddChild(Entity)
Adds a child Entity to this instance.
Declaration
public Entity AddChild(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The Entity to add.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
| InvalidOperationException | If entity was added to itself.  | 
      
| InvalidOperationException | If entity was already added to another Entity.  | 
      
| InvalidOperationException | If there already was an Entity with the same name as entity added to this instance.  | 
      
AddComponent(Component)
Adds a Component to this instance.
Declaration
public Entity AddComponent(Component component)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Component | component | The Component to add.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentException | If component is null.  | 
      
| InvalidOperationException | If component was already added to another Entity.  | 
      
| InvalidOperationException | If there already was a Component of the same type as component added to this instance.  | 
      
DetachChild(Entity)
Detaches the child Entity.
Declaration
public Entity DetachChild(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | Name of the entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The entity detached or null otherwise.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null or empty.  | 
      
DetachChild(Guid)
Detaches the child Entity.
Declaration
public Entity DetachChild(Guid id)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | Id of the entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The entity detached or null otherwise.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
DetachChild(string)
Detaches the child Entity.
Declaration
public Entity DetachChild(string childName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | childName | Name of the child Entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The entity detached or null otherwise.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
DetachComponent(Component)
Removes a Component from this instance.
Declaration
public Entity DetachComponent(Component component)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Component | component | The component to remove.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
DetachComponent(Type, out Component, bool)
Removes a Component from this instance.
Declaration
public Entity DetachComponent(Type componentType, out Component detachedComponent, bool isExactType = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | componentType | Type of the component.  | 
      
| Component | detachedComponent | The detached component instance.  | 
      
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
DetachComponent<T>(out T, bool)
Removes a Component from this instance.
Declaration
public Entity DetachComponent<T>(out T detachedComponent, bool isExactType = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| T | detachedComponent | The detached component instance.  | 
      
| bool | isExactType | if set to  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the Component to remove.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Find(string)
Finds the first child Entity in this instance with a given entity path.
Declaration
public Entity Find(string entityPath)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityPath | The path to the entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The entity of the path.  | 
      
FindChild(Guid, bool)
Finds a child Entity in this instance with a id.
Declaration
public Entity FindChild(Guid id, bool isRecursive = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | Id of the child Entity.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The searched child Entity, or null if no matching child was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
FindChild(string, bool)
Finds the first child Entity in this instance with a given name.
Declaration
public Entity FindChild(string entityName, bool isRecursive = false)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityName | Name of the child Entity.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | The searched child Entity, or null if no matching child was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
FindChildrenByTag(string, bool, bool)
Find children Entity in this instance by Tag.
Declaration
public IEnumerable<Entity> FindChildrenByTag(string tag, bool isRecursive = false, bool skipOwner = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | tag | The tag to filter.  | 
      
| bool | isRecursive | If set to   | 
      
| bool | skipOwner | Ignore the owner entity.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Entity> | A collection of Entity, with all children that match the specified Tag.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If tag is null or empty.  | 
      
FindComponent(Type, bool, string)
Finds a Component in this instance with the specified type.
Declaration
public Component FindComponent(Type type, bool isExactType = true, string tag = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| Component | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentInChildren(Type, bool, string, bool, bool)
Finds a Component in this instance or any of its children with the specified type using depth first search.
Declaration
public Component FindComponentInChildren(Type type, bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| Component | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentInChildren<T>(bool, string, bool, bool)
Finds a Component in this instance or any of its children with the specified type using depth first search.
Declaration
public T FindComponentInChildren<T>(bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| T | The Component or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentInParents(Type, bool, string, bool, bool)
Finds a Component in any of the parents of this instance with the specified type using depth first search.
Declaration
public Component FindComponentInParents(Type type, bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| Component | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentInParents<T>(bool, string, bool, bool)
Finds a Component in any of the parents of this instance with the specified type using depth first search.
Declaration
public T FindComponentInParents<T>(bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| T | The Component or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponent<T>(bool, string)
Finds a Component in this instance with the specified type.
Declaration
public T FindComponent<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 | 
|---|---|
| T | The Component or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponents(Type, bool, string)
Finds a Component collection in this instance with the specified type.
Declaration
public IEnumerable<Component> FindComponents(Type type, bool isExactType = true, string tag = null)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Component> | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentsInChildren(Type, bool, string, bool, bool)
Finds a Component collection in this instance or any of its children with the specified type.
Declaration
public IEnumerable<Component> FindComponentsInChildren(Type type, bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Component> | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentsInChildren<T>(bool, string, bool, bool)
Finds a Component collection in this instance or any of its children with the specified type.
Declaration
public IEnumerable<T> FindComponentsInChildren<T>(bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<T> | The Component or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentsInParents(Type, bool, string, bool, bool)
Finds a Component collection in this instance or any of its parents with the specified type.
Declaration
public IEnumerable<Component> FindComponentsInParents(Type type, bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | type | The type of the Component to find.  | 
      
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Component> | The Component or null if no Component with the specified type was found.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponentsInParents<T>(bool, string, bool, bool)
Finds a Component collection in this instance or any of its parents with the specified type.
Declaration
public IEnumerable<T> FindComponentsInParents<T>(bool isExactType = true, string tag = null, bool skipOwner = false, bool isRecursive = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | Whether to match the exact type.  | 
      
| string | tag | Filter entities by this tag.  | 
      
| bool | skipOwner | Indicates whether the owner is included in the search.  | 
      
| bool | isRecursive | If set to   | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<T> | The Component or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindComponents<T>(bool, string)
Finds a Component collection in this instance with the specified type.
Declaration
public IEnumerable<T> FindComponents<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 or null if no Component with the specified type was found.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The type of the Component to find.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | Entity has been disposed.  | 
      
FindParentsByTag(string, bool, bool)
Find children Entity in this instance by Tag.
Declaration
public IEnumerable<Entity> FindParentsByTag(string tag, bool isRecursive = false, bool skipOwner = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | tag | The tag to filter.  | 
      
| bool | isRecursive | If set to   | 
      
| bool | skipOwner | Ignore the owner entity.  | 
      
Returns
| Type | Description | 
|---|---|
| IEnumerable<Entity> | A collection of Entity, with all children that match the specified Tag.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If tag is null or empty.  | 
      
IdHasChanged(Guid)
The Id of the object has been updated.
Declaration
protected override void IdHasChanged(Guid oldId)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | oldId | The old Id value.  | 
      
Overrides
IsValidName(string)
Check an entity name.
Declaration
public static bool IsValidName(string name)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | name | The entity name.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | If it's valid or not.  | 
      
NextDefaultName()
Return a default entity name.
Declaration
public static string NextDefaultName()
  Returns
| Type | Description | 
|---|---|
| string | The entity name.  | 
      
OnActivated()
Invoked when the object is activated once is attached.
Declaration
protected override void OnActivated()
  Overrides
OnAttached()
Invoked when the object is attached to the system.
Declaration
protected override bool OnAttached()
  Returns
| Type | Description | 
|---|---|
| bool | True if all is OK.  | 
      
Overrides
OnDeactivated()
Invoked when the object is deactivated.
Declaration
protected override void OnDeactivated()
  Overrides
OnDestroy()
Invoked when the object is going to be disposed.
Declaration
protected override void OnDestroy()
  Overrides
OnDetach()
Invoked when the object is detached.
Declaration
protected override void OnDetach()
  Overrides
OnLoaded()
Invoked when the object is loaded.
Declaration
protected override void OnLoaded()
  Overrides
ReattachComponents()
Reattach all components.
Declaration
public void ReattachComponents()
  RemoveAllComponentsOfType(Type, bool)
Removes all components of specified type from this instance.
Declaration
public Entity RemoveAllComponentsOfType(Type componentType, bool isExactType = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | componentType | Type of the component.  | 
      
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
RemoveAllComponentsOfType<T>(bool)
Removes all components of specified type from this instance.
Declaration
public Entity RemoveAllComponentsOfType<T>(bool isExactType = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | The exact type of the Component to find.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
RemoveChild(Entity)
Removes a child Entity from this instance.
Declaration
public Entity RemoveChild(Entity entity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Entity | entity | The Entity to remove.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entity is null.  | 
      
RemoveChild(Guid)
Removes a child Entity from this instance.
Declaration
public Entity RemoveChild(Guid id)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | id | Id of the child Entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
RemoveChild(string)
Removes a child Entity from this instance.
Declaration
public Entity RemoveChild(string childName)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | childName | Name of the child Entity.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If entityName is null or empty.  | 
      
RemoveComponent(Component)
Removes a Component from this instance.
Declaration
public Entity RemoveComponent(Component component)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Component | component | The component to remove.  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
RemoveComponent(Type, bool)
Removes a Component from this instance.
Declaration
public Entity RemoveComponent(Type componentType, bool isExactType = true)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Type | componentType | Type of the component.  | 
      
| bool | isExactType | if set to   | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Exceptions
| Type | Condition | 
|---|---|
| ObjectDisposedException | The entity is disposed.  | 
      
| NullReferenceException | componentType or componentType.  | 
      
RemoveComponent<T>(bool)
Removes a Component from this instance.
Declaration
public Entity RemoveComponent<T>(bool isExactType = true) where T : Component
  Parameters
| Type | Name | Description | 
|---|---|---|
| bool | isExactType | if set to  | 
      
Returns
| Type | Description | 
|---|---|
| Entity | This instance.  | 
      
Type Parameters
| Name | Description | 
|---|---|
| T | Type of the Component to remove.  | 
      
Remarks
The method returns this instance. It can be used with method chaining, so performing consecutive operations over the same instance is simpler.
Start()
Invoked to start the object.
Declaration
protected override void Start()
  Overrides
ToString()
Returns a string that represents this instance (its name).
Declaration
public override string ToString()
  Returns
| Type | Description | 
|---|---|
| string | A string that represents this instance (its name).  | 
      
Overrides
TryGetChildById(Guid, out Entity)
Gets the child entity with the specified id.
Declaration
public bool TryGetChildById(Guid entityId, out Entity childEntity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| Guid | entityId | The id of the entity to get.  | 
      
| Entity | childEntity | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | true if this Entity contains a child with the specified id; otherwise, false.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If the entity name is null.  | 
      
TryGetChildByName(string, out Entity)
Gets the first child entity with the specified name.
Declaration
public bool TryGetChildByName(string entityName, out Entity childEntity)
  Parameters
| Type | Name | Description | 
|---|---|---|
| string | entityName | The name of the entity to get.  | 
      
| Entity | childEntity | When this method returns, contains the value associated with the specified key, if the key is found; otherwise, the default value for the type of the value parameter. This parameter is passed uninitialized.  | 
      
Returns
| Type | Description | 
|---|---|
| bool | true if this Entity contains the first child with the specified name; otherwise, false.  | 
      
Exceptions
| Type | Condition | 
|---|---|
| ArgumentNullException | If the entity name is null.  | 
      
Events
CheckValidName
Occurs when a valid name is set to an entity.
Declaration
public event EventHandler<ValidNameEventArgs> CheckValidName
  Event Type
| Type | Description | 
|---|---|
| EventHandler<ValidNameEventArgs> | 
ChildAdded
Occurs when an Entity is added as child of this entity.
Declaration
public event EventHandler<Entity> ChildAdded
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Entity> | 
ChildDetached
Occurs when an Entity child is detached from this entity.
Declaration
public event EventHandler<Entity> ChildDetached
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Entity> | 
ChildOrderChanged
Occurs when an Entity child order has been changed.
Declaration
public event EventHandler<Entity> ChildOrderChanged
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Entity> | 
ComponentAdded
Occurs when a Component is added to this entity.
Declaration
public event EventHandler<Component> ComponentAdded
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Component> | 
ComponentDetached
Occurs when a Component is detached from this entity.
Declaration
public event EventHandler<Component> ComponentDetached
  Event Type
| Type | Description | 
|---|---|
| EventHandler<Component> | 
NameChanged
Occurs when the entity's name changes.
Declaration
public event EventHandler<NameEventArgs> NameChanged
  Event Type
| Type | Description | 
|---|---|
| EventHandler<NameEventArgs> | 
TagChanged
Fired when the entity tag has been changed.
Declaration
public event EventHandler<ValueChanged<string>> TagChanged
  Event Type
| Type | Description | 
|---|---|
| EventHandler<ValueChanged<string>> |