Tramway SDK v0.1.1
Public Member Functions | Protected Member Functions | Protected Attributes | Friends | List of all members
tram::EntityComponent Class Referenceabstract

Component base class. More...

#include <framework/entitycomponent.h>

Inheritance diagram for tram::EntityComponent:
tram::AnimationComponent tram::AudioComponent tram::ControllerComponent tram::DecalComponent tram::Ext::Kitchensink::AnimationStateComponent tram::LightComponent tram::ParticleComponent tram::PhysicsComponent tram::PlayerComponent tram::RenderComponent tram::SpriteComponent tram::TemplateComponent tram::TriggerComponent

Public Member Functions

 EntityComponent ()=default
 
virtual ~EntityComponent ()=default
 
virtual void Init ()
 Initializes an entity component. More...
 
virtual void EventHandler (Event &event)=0
 
bool IsReady ()
 Returns the component's readiness. More...
 
bool IsInit ()
 Returns the component's init status. More...
 
EntityGetParent ()
 
void SetParent (Entity *parent)
 

Protected Member Functions

void ResourceReady ()
 Notifies the component of a streamed-in resource. More...
 
virtual void Start ()=0
 

Protected Attributes

size_t resources_waiting = 0
 
bool is_ready = false
 
bool is_init = false
 
Entityparent = nullptr
 

Friends

template<typename T >
class ResourceProxy
 
void Async::FinishResources ()
 

Detailed Description

Component base class.

Usually the way that components work is that a user creates a component, i.e. constructs an instance of a component, then they call setter methods on it to feed it parameters and finally they call the Init() method in the component.

In turn, the base component class checks whether all of the component's requested resources have been loaded and then calls the component's Start() method.

Constructor & Destructor Documentation

◆ EntityComponent()

tram::EntityComponent::EntityComponent ( )
default

◆ ~EntityComponent()

virtual tram::EntityComponent::~EntityComponent ( )
virtualdefault

Member Function Documentation

◆ EventHandler()

virtual void tram::EntityComponent::EventHandler ( Event event)
pure virtual

◆ GetParent()

Entity * tram::EntityComponent::GetParent ( )
inline

◆ Init()

void tram::EntityComponent::Init ( )
virtual

Initializes an entity component.

If an entity component has all of its resources already loaded, this will immediately Start() the component.

Reimplemented in tram::LightComponent, tram::PlayerComponent, and tram::TemplateComponent.

◆ IsInit()

tram::EntityComponent::IsInit ( )
inline

Returns the component's init status.

Returns
True if the Init() method has been called.
See also
https://racenis.github.io/tram-sdk/documentation/framework/entitycomponent.html

◆ IsReady()

tram::EntityComponent::IsReady ( )
inline

Returns the component's readiness.

The component is considered ready when it's Init() method has been called, all of it's Resource dependencies have been loaded and its Start() method has been called.

Returns
True if the component's Start() method has been called.

◆ ResourceReady()

void tram::EntityComponent::ResourceReady ( )
protected

Notifies the component of a streamed-in resource.

◆ SetParent()

void tram::EntityComponent::SetParent ( Entity parent)
inline

◆ Start()

virtual void tram::EntityComponent::Start ( )
protectedpure virtual

Friends And Related Function Documentation

◆ Async::FinishResources

void Async::FinishResources ( )
friend

◆ ResourceProxy

template<typename T >
friend class ResourceProxy
friend

Member Data Documentation

◆ is_init

bool tram::EntityComponent::is_init = false
protected

◆ is_ready

bool tram::EntityComponent::is_ready = false
protected

◆ parent

Entity* tram::EntityComponent::parent = nullptr
protected

◆ resources_waiting

size_t tram::EntityComponent::resources_waiting = 0
protected

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