Table of Contents

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

IEnumerable<Entity>

Components

An enumerable containing all of the Components attached to this Entity

public IEnumerable<Component> Components { get; init; }

Property Value

IEnumerable<Component>

IsActive

Whether or not this Entity is active

public bool IsActive { get; set; }

Property Value

bool

Name

Name for this Entity

public string Name { get; set; }

Property Value

string

Parent

This Entity's parent

public Entity? Parent { get; set; }

Property Value

Entity

Methods

AddChild(Entity)

Adds the specified Entity as a child of this component

public bool AddChild(Entity child)

Parameters

child Entity

Entity to add as a child

Returns

bool

true if the child was added and false if the child was already present

AttachComponent(Component)

Attach the specified Component to this Entity.

public bool AttachComponent(Component component)

Parameters

component Component

The Component to attach

Returns

bool

true if the Component was added and false if the Component was already present

DetachComponent(Component)

Detach the specified Component from this Entity if it is present.

public bool DetachComponent(Component component)

Parameters

component Component

The Component to detach

Returns

bool

true if the Component was found and removed and false otherwise.

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

name string

The name to search for

Returns

Entity

Entity if a child with the specified name was found and null otherwise

GetChildren(string)

Returns an enumerable of all children with the specified name

public IEnumerable<Entity> GetChildren(string name)

Parameters

name string

Name to filter by

Returns

IEnumerable<Entity>

IEnumerable‹Entity

GetComponent<T>()

Retrieves a Component of the specified type that is attached to this Entity.

public T? GetComponent<T>() where T : Component

Returns

T

T if a Component of the specified type was found and null otherwise

Type Parameters

T

The 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>()

Retrieves all Components of the specified type that are attached to this Entity.

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

Entity

Entity if this Entity's has a child else null

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

child Entity

Child 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

deltaTime double

The 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

name string

The name to search for

child Entity

The child that was found

Returns

bool

true if a Component of the specified type was found and false otherwise

TryGetComponent<T>(out T?)

Retrieves a Component of the specified type that is attached to this Entity.

public bool TryGetComponent<T>(out T? component) where T : Component

Parameters

component T

The Component that was found

Returns

bool

true if a Component of the specified type was found and false otherwise

Type Parameters

T

The type of Component to retrieve.