TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Core::Component Class Reference

#include <tb_component.hpp>

Inheritance diagram for TurtleBrains::Core::Component:
TurtleBrains::Core::Noncopyable

Public Member Functions

virtual void OnAwake (void)
 
virtual void OnDestroy (void)
 
virtual void OnActivate (void)
 
virtual void OnDeactivate (void)
 
virtual void OnSimulate (void)
 
virtual void OnUpdate (const float)
 
virtual void OnRender (void) const
 
virtual void OnTriggerEnter (const Node &)
 
virtual void OnTriggerStay (const Node &)
 
virtual void OnTriggerLeave (const Node &)
 
const NodeGetNode (void) const
 
bool IsValid (void) const
 
bool IsActive (void) const
 
bool IsActiveSelf (void) const
 
void SetActive (const bool isActive)
 
const ComponentKeyGetKey (void) const
 
const ComponentTypeKeyGetTypeKey (void) const
 

Static Public Member Functions

template<typename ComponentType >
static ComponentTypeKey RegisterComponent (void)
 

Public Attributes

const NodemNode
 

Protected Member Functions

 Component (Node &node, const ComponentKey &componentKey, const ComponentTypeKey &componentTypeKey)
 

Protected Attributes

NodemMutableNode
 

Friends

class Node
 

Detailed Description

Defines a basic component for all other component types.

2024-10-10: Lets say you wanted to create a Mesh Component. First make; class MeshComponent : Component to new Component class, such as MeshComponent::ComponentTypeKey() (whether named Type or Definition) and in the source file register it like the following in static space, not within a function:

static const auto kMeshComponentRegistration = tbCore::Component::RegisterComponent<tbCore::MeshComponent>();

Generally they should be added when loading a TrackBundle, but there is an argument to be able to create them through an API. I think that API would be on the Node with a templated AddComponent<Type>() which may need to call the Creator using some template magic for ::kTypeKey... forcing the above 'customary' addition.