-
Notifications
You must be signed in to change notification settings - Fork 10
Game Objects
Eldar Muradov edited this page Feb 15, 2024
·
3 revisions
Game Objects in Era Engine is a basic game entity used by the game engine.
EEntity
is a base class for all game objects in Era Engine.
// Is a list of childs. Represents a part of object graph
List<EEntity> Childs;
// Is a collection of components of type EComponent
ComponentsContainer Components;
// Is a reference to parent object
EEntity? Parent;
// Is an object Id
int Id { get; init; }
// Is an object filter mask
EEntityFilter Filter { get; init; }
// Is an object name
string Name { get; init; }
// Is a property to mark an object as inited
bool IsInitialized { get; private set; }
// Is used to set object visibility
bool ActiveSelf { get; set; }
// Default constructor
EEntity() { ... }
// Used to set object's name and filter mask
EEntity(string name, EEntityFilter filter) { ... }
// Used to set up object's id, name and filter mask (optional)
EEntity(int id, string name, EEntityFilter filter = default) { ... }
// Used to get component from entity by it's type
T? GetComponent<T>() where T : EComponent, new() { ... }
// Used to create component and call it's virtual InitializeComponentInternal(...) method (only for basic components like RigidbodyComponent etc.)
T CreateComponent<T>(params object[] args) where T : EComponent, new() { ... }
// Used to remove a component. Trigger `bool sync` is used to sync it with the game engine. Don't set it to `true` for you custom components
void RemoveComponent<T>(bool sync = false) where T : EComponent, new() { ... }
// Used to instantiate a game ebject using it's template
static EEntity Instantiate(EEntity original, Vector3 position, Quaternion rotation, EEntity? parent = null) { ... }
// Used to instantiate a game ebject using it's template
static EEntity Instantiate(EEntity original, EEntity? parent = null) { ... }
// Used to copy a component by it's reference
EComponent CopyComponent(EComponent component) { ... }
// Used to remove a child object from Childs
void RemoveChild(EEntity entity) { ... }
// Used to release a game object manualy
void Release() { ... }
// Called at the beginning of the scene simulation. Calls `void Start()` from every alive component from the ComponentsContainer field
void Start() { ... }
// Called every frame by the game engine. Calls `void Update(float dt)` from every alive component from the ComponentsContainer field
void Update(float dt) { ... }
struct EEntityFilter(int Id)
is a record struct used to represent an entity's filter mask. If it's set to -1
, game object will be released by the game engine on the next scripting reload.
If you want to customize you entity object you can derrive you class from EEntity
and then override some logic.