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

Public Types

enum class  ChildIndexType : uint16
 
using ChildIndex = TypedInteger< ChildIndexType >
 
using ConstChildContainerAccessor = OtherTypedRange< ChildIndex, const Node & >
 
using ChildContainerAccessor = OtherTypedRange< ChildIndex, Node & >
 

Public Member Functions

 Node (const NodeKey &nodeKey=NodeKey::Invalid())
 
bool HasParent (void) const
 
Node & GetParent (void) const
 
void ClearChildren (void)
 
ChildIndex AddChild (const NodeKey &nodeKey=NodeKey::Invalid(), const String &name="")
 
ChildIndex AddChild (std::unique_ptr< Node > &&childNode)
 
ChildIndex AddChild (Node &childNode)
 
const ChildIndex GetNumberOfChildren (void) const
 
const Node & GetChild (const ChildIndex childIndex) const
 
Node & GetChild (const ChildIndex childIndex)
 
ConstChildContainerAccessor AllChildren (void) const
 
ChildContainerAccessor AllChildren (void)
 
NodeImplementation::NodeHierarchyAccessor< const Node > RecurseTree (const NodeKey &nodeKey, Recursive recursive=Recursive::Yes) const
 
NodeImplementation::NodeHierarchyAccessor< const Node > RecurseTree (Recursive recursive=Recursive::Yes) const
 
NodeImplementation::NodeHierarchyAccessor< Node > RecurseTree (const NodeKey &nodeKey, Recursive recursive=Recursive::Yes)
 
NodeImplementation::NodeHierarchyAccessor< Node > RecurseTree (Recursive recursive=Recursive::Yes)
 
const Node * FindChildByName (const String &childName, Recursive recursive=Recursive::No) const
 
Node * FindChildByName (const String &childName, Recursive recursive=Recursive::No)
 
const Node * FindChildByKey (const NodeKey &childNodeKey, Recursive recursive=Recursive::No) const
 
Node * FindChildByKey (const NodeKey &childNodeKey, Recursive recursive=Recursive::No)
 
ChildIndex FindChildIndexByName (const String &childName) const
 
ChildIndex FindChildIndexByKey (const NodeKey &childNodeKey) const
 
void RemoveAllComponents (void)
 
Component * AddComponent (ComponentPointer &&component)
 
template<typename ComponentType >
ComponentType * AddComponent (void)
 
const Component * GetComponent (const ComponentKey &componentKey) const
 
Component * GetComponent (const ComponentKey &componentKey)
 
const Component * GetComponentByType (const ComponentTypeKey &componentTypeKey) const
 
Component * GetComponentByType (const ComponentTypeKey &componentTypeKey)
 
template<typename ComponentType >
const ComponentType * GetComponent (void) const
 
template<typename ComponentType >
ComponentType * GetComponent (void)
 
template<typename ComponentType >
const std::vector< const ComponentType * > GetComponents (void) const
 
template<typename ComponentType >
std::vector< ComponentType * > GetComponents (void)
 
size_t GetNumberOfComponents (void) const
 
const Component & GetComponent (const size_t componentIndex) const
 
Component & GetMutableComponent (const size_t componentIndex)
 
bool IsActive (void) const
 
bool IsActiveSelf (void) const
 
void SetActive (const bool active)
 
const String & GetName (void) const
 
void SetName (const String &name)
 
const NodeKey & GetKey (void) const
 
const tbMath::Matrix4 & GetObjectToWorld (void) const
 
void SetObjectToWorld (const tbMath::Matrix4 &objectToWorld)
 
const tbMath::Matrix4 & GetObjectToParent (void) const
 
void SetObjectToParent (const tbMath::Matrix4 &objectToParent)
 
tbMath::Vector3 GetPosition (void) const
 
tbMath::Vector3 GetLocalPosition (void) const
 
tbMath::Vector3 GetRight (void) const
 
tbMath::Vector3 GetUp (void) const
 
tbMath::Vector3 GetForward (void) const
 
tbMath::Vector3 GetScale (const Space space=Space::Local) const
 
void SetScale (const tbMath::Vector3 &localScale)
 
tbMath::Matrix3 GetOrientation (const Space space=Space::Local) const
 
void Rotate (const tbMath::Vector3 &eulerAngles, const Space space=Space::Local)
 
void Translate (const tbMath::Vector3 &amount, const Space space=Space::Local)
 
void Simulate (void)
 
void Update (const float deltaTime)
 
void Render (void) const
 

Static Public Member Functions

static constexpr ChildIndex InvalidChild (void)
 

Protected 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 deltaTime)
 
virtual void OnRender (void) const
 

Member Function Documentation

◆ AddChild()

ChildIndex TurtleBrains::Core::Node::AddChild ( Node &  childNode)
Note
Like other AddGraphic/AddThing functions the version taking a reference will not manage the object,

◆ HasParent()

bool TurtleBrains::Core::Node::HasParent ( void  ) const
inline

Child/Parent Stuffs

◆ RemoveAllComponents()

void TurtleBrains::Core::Node::RemoveAllComponents ( void  )

Component Stuffs

◆ SetActive()

void TurtleBrains::Core::Node::SetActive ( const bool  active)
Note
Active / Enabled states are currently completely ignoring any parent/child chains. So a child may be active/enabled even without the parent being active/enabled. This obviously goes against the future plans, so, tread lightly!
Can not make the Node/object active when a parent above is not active. Will call OnActivate() or OnDeactive() only if the current state of the Node changed.