NAP
Public Member Functions | List of all members
ComponentInstance Class Reference

#include <component.h>

Public Member Functions

 ComponentInstance (EntityInstance &entity, Component &resource)
 
virtual void update (double deltaTime)
 
nap::EntityInstancegetEntityInstance () const
 
nap::ComponentgetComponent () const
 
template<typename T >
T * getComponent () const
 
virtual bool init (utility::ErrorState &errorState)
 
virtual bool init (utility::ErrorState &errorState)
 
- Public Member Functions inherited from Object
 Object ()
 
virtual ~Object ()
 
virtual void onDestroy ()
 
 Object (Object &)=delete
 
Objectoperator= (const Object &)=delete
 
 Object (Object &&)=delete
 
Objectoperator= (Object &&)=delete
 

Additional Inherited Members

- Static Public Member Functions inherited from Object
static bool isIDProperty (rtti::Instance &object, const rtti::Property &property)
 
- Public Attributes inherited from Object
std::string mID
 Property: 'mID' unique name of the object. Used as an identifier by the system. More...
 

Description

Runtime version of a Component. Adds behavior to an entity and allows for operations on a per frame basis. Override the init and update methods in derived classes Every runtime version of a component receives on construction the resource it was created from and the entity instance it belongs to.

Inheritance diagram for ComponentInstance:
[legend]
Collaboration diagram for ComponentInstance:
[legend]

Constructor & Destructor Documentation

◆ ComponentInstance()

ComponentInstance ( EntityInstance entity,
Component resource 
)

Constructor

Parameters
entityinstance the entity this component instance belongs to
resourcethe resource this component was created from

Member Function Documentation

◆ getComponent() [1/2]

nap::Component* getComponent ( ) const
Returns
the resource this component was created from

◆ getComponent() [2/2]

T * getComponent
Returns
the resource this component was created from as type T This will return a nullptr if the component is not derived from T

◆ getEntityInstance()

nap::EntityInstance* getEntityInstance ( ) const
Returns
the entity this component belongs to

◆ init() [1/2]

virtual bool init

Override this method to initialize the object after de-serialization. When called it is safe to assume that all dependencies have been resolved up to this point.

Parameters
errorStateshould contain the error message when initialization fails.
Returns
if initialization succeeded or failed.

◆ init() [2/2]

virtual bool init ( utility::ErrorState errorState)
virtual

◆ update()

virtual void update ( double  deltaTime)
virtual