Class Entity
Main class for game entities.
Inheritance
Namespace: Chroma
Assembly: Chroma.Mono.dll
Syntax
public class Entity
Constructors
Entity()
Declaration
protected Entity()
Properties
ID
Numeric ID for the entity.
Declaration
public ulong ID { get; }
Property Value
| Type | Description |
|---|---|
| System.UInt64 |
Name
Name of the entity.
Declaration
public string Name { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
Methods
CreateComponent<T>()
Creates a component of the given type and attaches it to this entity.
Declaration
public T CreateComponent<T>()
where T : Component, new()
Returns
| Type | Description |
|---|---|
| T |
Type Parameters
| Name | Description |
|---|---|
| T |
CreateCoroutine()
Creates a coroutine and attaches it to this entity.
Declaration
public Coroutine CreateCoroutine()
Returns
| Type | Description |
|---|---|
| Coroutine |
CreateCoroutine(Coroutine.CoroutineFunction)
Creates a coroutine, sets the function provided, and attaches it to this entity.
Declaration
public Coroutine CreateCoroutine(Coroutine.CoroutineFunction function)
Parameters
| Type | Name | Description |
|---|---|---|
| Coroutine.CoroutineFunction | function | Function for the coroutine to execute. |
Returns
| Type | Description |
|---|---|
| Coroutine |
EarlyStart()
Declaration
public virtual void EarlyStart()
EarlyUpdate()
Early-Update function. Called once per frame at the begining of the frame.
Declaration
public virtual void EarlyUpdate()
Finalize()
Declaration
protected void Finalize()
FindEntityByName(String)
Gets an entity its name. Returns null if an entity with the given name does not exist.
Declaration
public static Entity FindEntityByName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Returns
| Type | Description |
|---|---|
| Entity |
GetAbsolutePosition()
Calculates the absolute position of an entity. This applies if this entity has a parent.
Declaration
public Vector2 GetAbsolutePosition()
Returns
| Type | Description |
|---|---|
| Vector2 |
GetChildByName(String)
Gets a child of this entity by its name. Returns null if no such child exists.
Declaration
public Entity GetChildByName(string name)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | name |
Returns
| Type | Description |
|---|---|
| Entity |
GetChildren()
Gets a list of this entities' children.
Declaration
public List<Entity> GetChildren()
Returns
| Type | Description |
|---|---|
| System.Collections.Generic.List<Entity> |
GetComponent<T>()
Gets this entity's component of a specific type.
Declaration
public T GetComponent<T>()
where T : Component, new()
Returns
| Type | Description |
|---|---|
| T | Returns component of type |
Type Parameters
| Name | Description |
|---|---|
| T | Type of component. |
GetFirstChild()
Gets the first child of this entity. Returns null if no children exist.
Declaration
public Entity GetFirstChild()
Returns
| Type | Description |
|---|---|
| Entity |
HasChildren()
Checks whether the given entity has children.
Declaration
public bool HasChildren()
Returns
| Type | Description |
|---|---|
| System.Boolean |
HasComponent(Type)
Checks whether this entity has a component of a given type.
Declaration
public bool HasComponent(Type type)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Type | type | Type of component. |
Returns
| Type | Description |
|---|---|
| System.Boolean |
HasComponent<T>()
Checks whether this entity has a component of a given type.
Declaration
public bool HasComponent<T>()
where T : Component, new()
Returns
| Type | Description |
|---|---|
| System.Boolean |
Type Parameters
| Name | Description |
|---|---|
| T | Type of component. |
Init()
Initialization function. Called directly after PreInit().
Declaration
public virtual void Init()
LateStart()
Declaration
public virtual void LateStart()
LateUpdate()
Late-Update function. Called once per frame, directly after Update().
Declaration
public virtual void LateUpdate()
NumberChildren()
Gets the number of children for this entity.
Declaration
public uint NumberChildren()
Returns
| Type | Description |
|---|---|
| System.UInt32 |
PostInit()
Post-initialization function. Called directly after Init().
Declaration
public virtual void PostInit()
PreInit()
Pre-initialization function. Called before init, after the scene is loaded.
Declaration
public virtual void PreInit()
SetAbsolutePosition(Vector2)
Sets an absolute position of an entity. If this entity has a parent, this will set this entity's transform relative to the parent's transform.
Declaration
public void SetAbsolutePosition(Vector2 position)
Parameters
| Type | Name | Description |
|---|---|---|
| Vector2 | position |
Start()
Declaration
public virtual void Start()
Update()
Update function. Called once per frame, directly after EarlyUpdate().
Declaration
public virtual void Update()