Class Entity
- Namespace
- AstraEngine.Core
- Assembly
- AstraEngine.Core.dll
An Entity is an container that represents an object within the game world. Entities serve as containers for Components, which define their behavior, properties, and interactions.
public class Entity
- Inheritance
-
Entity
- Inherited Members
Properties
Children
An enumerable containing all of the children of this Entity
public IEnumerable<Entity> Children { get; init; }
Property Value
Components
public IEnumerable<Component> Components { get; init; }
Property Value
IsActive
Whether or not this Entity is active
public bool IsActive { get; set; }
Property Value
Name
Name for this Entity
public string Name { get; set; }
Property Value
Parent
This Entity's parent
public Entity? Parent { get; set; }
Property Value
Methods
AddChild(Entity)
Adds the specified Entity as a child of this component
public bool AddChild(Entity child)
Parameters
Returns
- bool
true if the child was added and false if the child was already present
AttachComponent(Component)
public bool AttachComponent(Component component)
Parameters
Returns
DetachComponent(Component)
public bool DetachComponent(Component component)
Parameters
Returns
Exit()
Executed when this Entity exits the game
public void Exit()
GetChild(string)
Retrieves a child with the specified name.
public Entity? GetChild(string name)
Parameters
namestringThe name to search for
Returns
GetChildren(string)
Returns an enumerable of all children with the specified name
public IEnumerable<Entity> GetChildren(string name)
Parameters
namestringName to filter by
Returns
- IEnumerable<Entity>
IEnumerable‹Entity›
GetComponent<T>()
public T? GetComponent<T>() where T : Component
Returns
- T
T if a Component of the specified type was found and null otherwise
Type Parameters
TThe type of Component to retrieve.
GetComponentsInChildren<T>()
Returns an enumerable of all Components of the specified type attached to this Entity and all of its children
public IEnumerable<T> GetComponentsInChildren<T>() where T : Component
Returns
- IEnumerable<T>
Type Parameters
T
GetComponents<T>()
public IEnumerable<T> GetComponents<T>() where T : Component
Returns
- IEnumerable<T>
Type Parameters
T
GetFirstChild()
Retrieves one of Entity's children
public Entity? GetFirstChild()
Returns
Initialize()
Initializes all uninitialized Components. Runs before Tick.
public void Initialize()
RemoveChild(Entity)
Removes the specified Entity as a child of this component. To replace the child's parent, set child.Parent instead.
public bool RemoveChild(Entity child)
Parameters
childEntityChild to remove
Returns
- bool
true if the child was found and removed and false otherwise.
Tick(double)
Apply's time based changes to this Entity by first performing a tick on each of its Components then calling tick on each child.
public void Tick(double deltaTime)
Parameters
deltaTimedoubleThe amount of time in seconds that has passed
TryGetChild(string, out Entity?)
Retrieves a child with the specified name.
public bool TryGetChild(string name, out Entity? child)
Parameters
Returns
TryGetComponent<T>(out T?)
public bool TryGetComponent<T>(out T? component) where T : Component
Parameters
componentTThe Component that was found
Returns
Type Parameters
TThe type of Component to retrieve.