Overload  1.1
Game engine with editor
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
OvCore::ECS::Actor Class Reference

#include <Actor.h>

Inheritance diagram for OvCore::ECS::Actor:
OvCore::API::ISerializable

Public Member Functions

 Actor (int64_t p_actorID, const std::string &p_name, const std::string &p_tag, bool &p_playing)
 
 ~Actor ()
 
const std::string & GetName () const
 
const std::string & GetTag () const
 
void SetName (const std::string &p_name)
 
void SetTag (const std::string &p_tag)
 
void SetActive (bool p_active)
 
bool IsSelfActive () const
 
bool IsActive () const
 
void SetID (int64_t p_id)
 
int64_t GetID () const
 
void SetParent (Actor &p_parent)
 
void DetachFromParent ()
 
bool HasParent () const
 
ActorGetParent () const
 
int64_t GetParentID () const
 
std::vector< Actor * > & GetChildren ()
 
void MarkAsDestroy ()
 
bool IsAlive () const
 
void SetSleeping (bool p_sleeping)
 
void OnAwake ()
 
void OnStart ()
 
void OnEnable ()
 
void OnDisable ()
 
void OnDestroy ()
 
void OnUpdate (float p_deltaTime)
 
void OnFixedUpdate (float p_deltaTime)
 
void OnLateUpdate (float p_deltaTime)
 
void OnCollisionEnter (Components::CPhysicalObject &p_otherObject)
 
void OnCollisionStay (Components::CPhysicalObject &p_otherObject)
 
void OnCollisionExit (Components::CPhysicalObject &p_otherObject)
 
void OnTriggerEnter (Components::CPhysicalObject &p_otherObject)
 
void OnTriggerStay (Components::CPhysicalObject &p_otherObject)
 
void OnTriggerExit (Components::CPhysicalObject &p_otherObject)
 
template<typename T , typename ... Args>
T & AddComponent (Args &&... p_args)
 
template<typename T >
bool RemoveComponent ()
 
bool RemoveComponent (OvCore::ECS::Components::AComponent &p_component)
 
template<typename T >
T * GetComponent ()
 
std::vector< std::shared_ptr< Components::AComponent > > & GetComponents ()
 
Components::BehaviourAddBehaviour (const std::string &p_name)
 
bool RemoveBehaviour (Components::Behaviour &p_behaviour)
 
bool RemoveBehaviour (const std::string &p_name)
 
Components::BehaviourGetBehaviour (const std::string &p_name)
 
std::unordered_map< std::string, Components::Behaviour > & GetBehaviours ()
 
virtual void OnSerialize (tinyxml2::XMLDocument &p_doc, tinyxml2::XMLNode *p_actorsRoot) override
 
virtual void OnDeserialize (tinyxml2::XMLDocument &p_doc, tinyxml2::XMLNode *p_actorsRoot) override
 

Public Attributes

OvTools::Eventing::Event< Components::AComponent & > ComponentAddedEvent
 
OvTools::Eventing::Event< Components::AComponent & > ComponentRemovedEvent
 
OvTools::Eventing::Event< Components::Behaviour & > BehaviourAddedEvent
 
OvTools::Eventing::Event< Components::Behaviour & > BehaviourRemovedEvent
 
Components::CTransformtransform
 

Static Public Attributes

static OvTools::Eventing::Event< Actor & > DestroyedEvent
 
static OvTools::Eventing::Event< Actor & > CreatedEvent
 
static OvTools::Eventing::Event< Actor &, Actor & > AttachEvent
 
static OvTools::Eventing::Event< Actor & > DettachEvent
 

Detailed Description

The Actor is the main class of the ECS, it corresponds to the entity and is composed of componenents and behaviours (scripts)

Constructor & Destructor Documentation

◆ Actor()

OvCore::ECS::Actor::Actor ( int64_t  p_actorID,
const std::string &  p_name,
const std::string &  p_tag,
bool &  p_playing 
)

Constructor of the actor. It will automatically add a transform component

Parameters
p_actorID
p_name
p_tag
p_playing

◆ ~Actor()

OvCore::ECS::Actor::~Actor ( )

Destructor of the actor instance. Force invoke ComponentRemovedEvent and BehaviourRemovedEvent for every components and behaviours

Member Function Documentation

◆ AddBehaviour()

OvCore::ECS::Components::Behaviour & OvCore::ECS::Actor::AddBehaviour ( const std::string &  p_name)

Add a behaviour to the actor

Parameters
p_name

◆ AddComponent()

template<typename T , typename ... Args>
T & OvCore::ECS::Actor::AddComponent ( Args &&...  p_args)
inline

Add a component to the actor (Or return the component if already existing)

Parameters
p_args(Parameter pack forwared to the component constructor)

◆ DetachFromParent()

void OvCore::ECS::Actor::DetachFromParent ( )

Detach from the parent

◆ GetBehaviour()

OvCore::ECS::Components::Behaviour * OvCore::ECS::Actor::GetBehaviour ( const std::string &  p_name)

Try to get the given behaviour (Returns nullptr on failure)

Parameters
p_name

◆ GetBehaviours()

std::unordered_map< std::string, OvCore::ECS::Components::Behaviour > & OvCore::ECS::Actor::GetBehaviours ( )

Returns a reference to the vector of behaviours

◆ GetChildren()

std::vector< OvCore::ECS::Actor * > & OvCore::ECS::Actor::GetChildren ( )

Returns the children of this actor

◆ GetComponent()

template<typename T >
T * OvCore::ECS::Actor::GetComponent ( )
inline

Try to get the given component (Returns nullptr on failure)

◆ GetComponents()

std::vector< std::shared_ptr< OvCore::ECS::Components::AComponent > > & OvCore::ECS::Actor::GetComponents ( )

Returns a reference to the vector of components

◆ GetID()

int64_t OvCore::ECS::Actor::GetID ( ) const

Returns the ID of the actor

◆ GetName()

const std::string & OvCore::ECS::Actor::GetName ( ) const

Return the current name of the actor

◆ GetParent()

OvCore::ECS::Actor * OvCore::ECS::Actor::GetParent ( ) const

Returns the parents of this actor (Or nullptr if no parent)

◆ GetParentID()

int64_t OvCore::ECS::Actor::GetParentID ( ) const

Returns the ID of the parent of this actor

◆ GetTag()

const std::string & OvCore::ECS::Actor::GetTag ( ) const

Return the current tag of the actor

◆ HasParent()

bool OvCore::ECS::Actor::HasParent ( ) const

Returns true if the actor has a parent

◆ IsActive()

bool OvCore::ECS::Actor::IsActive ( ) const

Returns true if the actor is and his recursive parents (if any) are active

◆ IsAlive()

bool OvCore::ECS::Actor::IsAlive ( ) const

Returns true if the actor is not marked as destroyed

◆ IsSelfActive()

bool OvCore::ECS::Actor::IsSelfActive ( ) const

Returns true if the actor is active, ignoring his parent (if any) active state

◆ MarkAsDestroy()

void OvCore::ECS::Actor::MarkAsDestroy ( )

Mark the Actor as "Destroyed". A "Destroyed" actor will be removed from the scene by the scene itself

◆ OnAwake()

void OvCore::ECS::Actor::OnAwake ( )

Called when the scene start or when the actor gets enabled for the first time during play mode This method will always be called in an ordered triple:

◆ OnCollisionEnter()

void OvCore::ECS::Actor::OnCollisionEnter ( Components::CPhysicalObject p_otherObject)

Called when the actor enter in collision with another physical object

Parameters
p_otherObject

◆ OnCollisionExit()

void OvCore::ECS::Actor::OnCollisionExit ( Components::CPhysicalObject p_otherObject)

Called when the actor exit from collision with another physical object

Parameters
p_otherObject

◆ OnCollisionStay()

void OvCore::ECS::Actor::OnCollisionStay ( Components::CPhysicalObject p_otherObject)

Called when the actor is in collision with another physical object

Parameters
p_otherObject

◆ OnDeserialize()

void OvCore::ECS::Actor::OnDeserialize ( tinyxml2::XMLDocument &  p_doc,
tinyxml2::XMLNode *  p_actorsRoot 
)
overridevirtual

Deserialize all the components

Implements OvCore::API::ISerializable.

◆ OnDestroy()

void OvCore::ECS::Actor::OnDestroy ( )

Called when the actor gets destroyed if it has been awaked Conditions:

  • Play mode only

◆ OnDisable()

void OvCore::ECS::Actor::OnDisable ( )

Called when the actor hierarchical active state changed to false or gets destroyed while being hierarchically active Conditions:

  • Play mode only

◆ OnEnable()

void OvCore::ECS::Actor::OnEnable ( )

Called when the actor gets enabled (SetActive set to true) or at scene start if the actor is hierarchically active. This method can be called in an ordered triple at scene start:

  • OnAwake()
  • OnEnable()
  • OnStart() Or can be called solo if the actor hierarchical active state changed to true and the actor already gets awaked Conditions:
  • Play mode only

◆ OnFixedUpdate()

void OvCore::ECS::Actor::OnFixedUpdate ( float  p_deltaTime)

Called every physics frame

Parameters
p_deltaTime

◆ OnLateUpdate()

void OvCore::ECS::Actor::OnLateUpdate ( float  p_deltaTime)

Called every frame after OnUpdate

Parameters
p_deltaTime

◆ OnSerialize()

void OvCore::ECS::Actor::OnSerialize ( tinyxml2::XMLDocument &  p_doc,
tinyxml2::XMLNode *  p_actorsRoot 
)
overridevirtual

Serialize all the components

Implements OvCore::API::ISerializable.

◆ OnStart()

void OvCore::ECS::Actor::OnStart ( )

Called when the scene start or when the actor gets enabled for the first time during play mode This method will always be called in an ordered triple:

◆ OnTriggerEnter()

void OvCore::ECS::Actor::OnTriggerEnter ( Components::CPhysicalObject p_otherObject)

Called when the actor enter in trigger with another physical object

Parameters
p_otherObject

◆ OnTriggerExit()

void OvCore::ECS::Actor::OnTriggerExit ( Components::CPhysicalObject p_otherObject)

Called when the actor exit from trigger with another physical object

Parameters
p_otherObject

◆ OnTriggerStay()

void OvCore::ECS::Actor::OnTriggerStay ( Components::CPhysicalObject p_otherObject)

Called when the actor is in trigger with another physical object

Parameters
p_otherObject

◆ OnUpdate()

void OvCore::ECS::Actor::OnUpdate ( float  p_deltaTime)

Called every frame

Parameters
p_deltaTime

◆ RemoveBehaviour() [1/2]

bool OvCore::ECS::Actor::RemoveBehaviour ( Components::Behaviour p_behaviour)

Remove a behaviour by refering to the given instance

Parameters
p_behaviour

◆ RemoveBehaviour() [2/2]

bool OvCore::ECS::Actor::RemoveBehaviour ( const std::string &  p_name)

Remove a behaviour by refering to his name

Parameters
p_name

◆ RemoveComponent() [1/2]

template<typename T >
bool OvCore::ECS::Actor::RemoveComponent ( )
inline

Remove the given component

◆ RemoveComponent() [2/2]

bool OvCore::ECS::Actor::RemoveComponent ( OvCore::ECS::Components::AComponent p_component)

Remove the component by refering to the given instance

Parameters
p_component

◆ SetActive()

void OvCore::ECS::Actor::SetActive ( bool  p_active)

Enable or disable the actor

Parameters
p_active

◆ SetID()

void OvCore::ECS::Actor::SetID ( int64_t  p_id)

Defines a new ID for the actor

Parameters
p_id

◆ SetName()

void OvCore::ECS::Actor::SetName ( const std::string &  p_name)

Defines a new name for the actor

Parameters
p_name

◆ SetParent()

void OvCore::ECS::Actor::SetParent ( Actor p_parent)

Set an actor as the parent of this actor

Parameters
p_parent

◆ SetSleeping()

void OvCore::ECS::Actor::SetSleeping ( bool  p_sleeping)

Defines if the actor is sleeping or not. A sleeping actor will not trigger methods suchs as OnEnable, OnDisable and OnDestroyed

Parameters
p_sleeping

◆ SetTag()

void OvCore::ECS::Actor::SetTag ( const std::string &  p_tag)

Defines a new tag for the actor

Parameters
p_tag

Member Data Documentation

◆ AttachEvent

OvTools::Eventing::Event< OvCore::ECS::Actor &, OvCore::ECS::Actor & > OvCore::ECS::Actor::AttachEvent
static

◆ BehaviourAddedEvent

OvTools::Eventing::Event<Components::Behaviour&> OvCore::ECS::Actor::BehaviourAddedEvent

◆ BehaviourRemovedEvent

OvTools::Eventing::Event<Components::Behaviour&> OvCore::ECS::Actor::BehaviourRemovedEvent

◆ ComponentAddedEvent

OvTools::Eventing::Event<Components::AComponent&> OvCore::ECS::Actor::ComponentAddedEvent

◆ ComponentRemovedEvent

OvTools::Eventing::Event<Components::AComponent&> OvCore::ECS::Actor::ComponentRemovedEvent

◆ CreatedEvent

OvTools::Eventing::Event< OvCore::ECS::Actor & > OvCore::ECS::Actor::CreatedEvent
static

◆ DestroyedEvent

OvTools::Eventing::Event< OvCore::ECS::Actor & > OvCore::ECS::Actor::DestroyedEvent
static

@project: Overload

Author
: Overload Tech. @restrictions: This software may not be resold, redistributed or otherwise conveyed to a third party.

◆ DettachEvent

OvTools::Eventing::Event< OvCore::ECS::Actor & > OvCore::ECS::Actor::DettachEvent
static

◆ transform

Components::CTransform& OvCore::ECS::Actor::transform

The documentation for this class was generated from the following files: