Entity
Entity is a object withint the Scene which can have components added to it.
It also has some built-in properties which cannot be removed, but you can modify their values.
ID
Unique ID is used to identify each Entity in the Scene.
You can get it using u64 GetID()
.
Name
Each Entity has a name for easier organization and management.
You can get the name of Entity using const char* GetName()
Layer
Every Entity is assigned to a Layer. Layers are organized in a Collision matrix which is used to specify if objects should interract with each other.
Currently this is used by Physics to determine which objects should collide and which not.
Tsar currently supports 31 layers (soon 64). First layer is "Default" and you cannot change that, which leaves you with 30 free layers.
You can find more information about layers here
-
u32 GetLayerID()
Returns ID of the layer the Entity is assigned to. -
void SetLayerID(u32 layerID)
Assign Entity to a layer using its ID -
string GetLayerName()
Get name of the layer the Entity is assigned to -
u32 LayerNameToID(const string& layerName)
Get layer ID using name -
string LayerIDToName(u32 layerID)
Get layer name using ID
Components
The purpose of ECS is to have freedom working with flexible behaviour matching your needs.
You can add, remove and update components using Entity.
-
bool HasComponent<T>()
Check if Entity has component of type T -
T GetComponent<T>()
Returns component of type T if it exists, if Entity doesn't have such component an empty/new is returned. -
T AddComponent<T>()
Adds component of type T and returns it. If component already exists it is returned instead. -
bool RemoveComponent<T>()
Tries to remove component of type T, returns true if removed and false if no remove was performed(Entity already didn't have such component). -
bool ChildHasComponent<T>()
Check if any child of Entity has component of type T. -
Entity FindEntityByName(const char* name)
Get Entity using its name, if Entity not found returned Entity will have ID=0. -
T* GetScript<T>()
Get class/script of type T