Class Entity
This class represents a game entity, essentially a container of Component types, which provide the actual game logic. Entity types are contained in Scene types, 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 one entity containing others, and so on.
Examples
This is an example of how to create an Entity. Keep in mind 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 | Thrown if the 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[] |
IsUpdatingPrefab
Indicates whether the prefab is being updated.
Declaration
public bool IsUpdatingPrefab
Field Value
Type | Description |
---|---|
bool |
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 character used in the 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 child Entity instances 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 which 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 conforms to the path in the EntityManager to obtain the instance.
Declaration
public string EntityPath { get; }
Property Value
Type | Description |
---|---|
string |
IsPrefabInstanceRoot
Gets a value indicating whether this entity is the root of a prefab instance.
Declaration
public bool IsPrefabInstanceRoot { get; }
Property Value
Type | Description |
---|---|
bool |
IsStatic
Gets or sets a value indicating whether this instance is static. Once an entity is initialized, it 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 has 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, making consecutive operations on the same instance simpler.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the entity is null. |
InvalidOperationException | If the entity is added to itself. |
InvalidOperationException | If the entity is already added to another Entity. |
InvalidOperationException | If an Entity with the same name as the entity is already 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, making it simpler to perform consecutive operations on the same instance.
Exceptions
Type | Condition |
---|---|
ArgumentException | If component is null. |
InvalidOperationException | If component was already added to another Entity. |
InvalidOperationException | If a Component of the same type as the component was already added to this instance. |
DetachChild(Entity)
Detaches the child Entity.
Declaration
public Entity DetachChild(Entity entity)
Parameters
Type | Name | Description |
---|---|---|
Entity | entity | The name of the entity. |
Returns
Type | Description |
---|---|
Entity | The detached entity, or null otherwise. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the 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, if detached, or null otherwise. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown 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 childName 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 and can be used with method chaining, making it easier to perform consecutive operations on the same instance.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | componentType or component is null. |
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 on the same instance is simpler.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | componentType or componentType is null. |
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, making it simpler to perform consecutive operations on the same instance.
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 at the path. |
FindChild(Guid, bool)
Finds a child Entity in this instance by an 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 id 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 is found. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If entityName is null or empty. |
FindChildrenByTag(string, bool, bool)
Finds 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 | Ignores the owner entity. |
Returns
Type | Description |
---|---|
IEnumerable<Entity> | A collection of Entity with all children that match the specified Tag. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown 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 | Filters entities by this tag. |
Returns
Type | Description |
---|---|
Component | The Component, or null if no Component with the specified type is 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 | Filters 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 is 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 | Filters entities by this tag. |
Returns
Type | Description |
---|---|
T | The Component or null if no Component with the specified type is found. |
Type Parameters
Name | Description |
---|---|
T | The type of the Component to find. |
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The 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 | Filters 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 excluded from the search. |
bool | isRecursive | If set to |
Returns
Type | Description |
---|---|
IEnumerable<Component> | The Component or null if no Component with the specified type is 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 | Filters 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 | Filters 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 | Filters entities by this tag. |
Returns
Type | Description |
---|---|
IEnumerable<T> | The Component or null if no Component with the specified type is 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)
Finds 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 by. |
bool | isRecursive | If set to |
bool | skipOwner | Specifies whether to ignore the owner entity. |
Returns
Type | Description |
---|---|
IEnumerable<Entity> | A collection of Entity containing all children that match the specified tag. |
Exceptions
Type | Condition |
---|---|
ArgumentNullException | Thrown 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)
Checks an entity name.
Declaration
public static bool IsValidName(string name)
Parameters
Type | Name | Description |
---|---|---|
string | name | The entity name. |
Returns
Type | Description |
---|---|
bool | Whether it is valid or not. |
NextDefaultName()
Returns a default entity name.
Declaration
public static string NextDefaultName()
Returns
Type | Description |
---|---|
string | The entity name. |
OnActivated()
Invoked when the object is activated once it 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 everything is OK. |
Overrides
OnDeactivated()
Invoked when the object is deactivated.
Declaration
protected override void OnDeactivated()
Overrides
OnDestroy()
Invoked when the object is about 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()
Reattaches all components.
Declaration
public void ReattachComponents()
RefreshPrefab(Prefab)
Handles the prefab source update.
Declaration
protected override void RefreshPrefab(Prefab newValue)
Parameters
Type | Name | Description |
---|---|---|
Prefab | newValue |
Overrides
RemoveAllComponentsOfType(Type, bool)
Removes all components of the 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
This method returns this instance. It can be used with method chaining, making consecutive operations on the same instance simpler.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | componentType is null. |
RemoveAllComponentsOfType<T>(bool)
Removes all components of the 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
This method returns this instance. It can be used with method chaining, making consecutive operations on the same instance simpler.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | componentType is null. |
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, allowing method chaining for simpler consecutive operations on the same instance.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If the 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
This method returns this instance. It can be used with method chaining, making it simpler to perform consecutive operations on the same instance.
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, making it simpler to perform consecutive operations on the same instance.
Exceptions
Type | Condition |
---|---|
ArgumentNullException | If childName 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, making performing consecutive operations on the same instance simpler.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | component is null. |
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
This method returns this instance. It can be used with method chaining, making consecutive operations over the same instance simpler.
Exceptions
Type | Condition |
---|---|
ObjectDisposedException | The entity is disposed. |
NullReferenceException | componentType is null. |
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, enabling method chaining to simplify performing consecutive operations on the same instance.
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 | Thrown 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 | The entity name is null. |
Events
CheckValidName
Occurs when a valid name is assigned to an entity.
Declaration
public event EventHandler<ValidNameEventArgs> CheckValidName
Event Type
Type | Description |
---|---|
EventHandler<ValidNameEventArgs> |
ChildAdded
Occurs when an Entity is added as a 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 a child order of an Entity 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 is changed.
Declaration
public event EventHandler<ValueChanged<string>> TagChanged
Event Type
Type | Description |
---|---|
EventHandler<ValueChanged<string>> |