Deki 1.3.0
Modular C++ 2D engine for embedded displays and desktop
Loading...
Searching...
No Matches

Base class for components with lifecycle methods. More...

#include <DekiBehaviour.h>

Inherits DekiComponent.

Inherited by PlatformSetupComponent, and SetupComponent.

Public Member Functions

 DekiBehaviour ()
virtual ~DekiBehaviour ()=default
ComponentType GetType () const override
ComponentType GetBaseType () const override
DekiBehaviourAsBehaviour () override
virtual void Awake ()
 Called once after AssetRefs and ObjectRefs are resolved.
virtual void Start ()
 Called once before first Update, after ALL Awake calls complete.
virtual void Update ()
 Called every frame (only if needs_update is true).
bool HasAwoken () const
bool HasStarted () const
void MarkAwoken ()
void MarkStarted ()
virtual bool NeedsUpdate () const
 Runtime opt-out for Update() calls.
void SetNeedsUpdate (bool needs)
 Enable or disable per-frame Update() calls.
Public Member Functions inherited from DekiComponent
 DekiComponent ()
virtual ~DekiComponent ()=default
 DekiComponent (const DekiComponent &)=delete
DekiComponentoperator= (const DekiComponent &)=delete
virtual bool DeclaresUpdate () const
 Does this class (or a reflected base) declare Update()?
DekiObjectGetOwner () const
void SetOwner (DekiObject *owner)
virtual void LoadAssets ()
 Load assets needed by this component.
virtual void UnloadAssets ()
 Unload/clear assets held by this component.
virtual void RuntimeUpdate (float deltaTime)
 Update this component (runtime only).
virtual void OnAssetRefResolved (const char *propertyName, void *asset, const char *guid)
 Called after an AssetRef property is resolved by LifecycleManager.
virtual bool NeedsAssetLoading () const
 Check if this component needs asset loading.
virtual bool NeedsRuntimeUpdate () const
 Check if this component needs runtime updates.
virtual bool Deserialize (SceneFormat::SceneMsgPackParser &parser, uint32_t mapSize)
 Deserialize component data from MessagePack.
virtual void ResolveObjectRefs (class Scene *scene)
 Resolve all ObjectRef properties in this component.
virtual void RemapObjectRefs (const std::unordered_map< uint32_t, uint32_t > &idRemap)
 Remap ObjectRef IDs after cloning/instantiation.
bool HasRefsResolved () const
void MarkRefsResolved ()
void ResetRefsResolved ()
virtual void OnPropertyChanged (const char *propertyName)
 Called when a property is modified via the editor.

Static Public Attributes

static constexpr ComponentType StaticType = DekiHashString("DekiBehaviour")
Static Public Attributes inherited from DekiComponent
static constexpr ComponentType StaticType = 0

Additional Inherited Members

Protected Attributes inherited from DekiComponent
DekiObjectm_Owner
bool m_RefsResolved

Detailed Description

Base class for components with lifecycle methods.

DekiBehaviour extends DekiComponent with:

Lifecycle order:

  1. InternalAwake (engine) - Resolves AssetRefs and ObjectRefs
  2. Awake() - Component initialization, called once after refs are resolved
  3. Start() - Called once before first Update, after ALL Awake calls complete
  4. Update() - Called every frame
  5. Render (handled by RendererComponent)

Use DekiComponent for data-only components. Use DekiBehaviour for components that need engine processing.

Constructor & Destructor Documentation

◆ DekiBehaviour()

DekiBehaviour::DekiBehaviour ( )
inline

◆ ~DekiBehaviour()

virtual DekiBehaviour::~DekiBehaviour ( )
virtualdefault

Member Function Documentation

◆ GetType()

ComponentType DekiBehaviour::GetType ( ) const
inlineoverridevirtual

Implements DekiComponent.

◆ GetBaseType()

ComponentType DekiBehaviour::GetBaseType ( ) const
inlineoverridevirtual

Reimplemented from DekiComponent.

◆ AsBehaviour()

DekiBehaviour * DekiBehaviour::AsBehaviour ( )
inlineoverridevirtual

Reimplemented from DekiComponent.

◆ Awake()

virtual void DekiBehaviour::Awake ( )
inlinevirtual

Called once after AssetRefs and ObjectRefs are resolved.

Use for component self-initialization. All asset references are available at this point.

◆ Start()

virtual void DekiBehaviour::Start ( )
inlinevirtual

Called once before first Update, after ALL Awake calls complete.

Use for cross-component setup. Safe to access other components since all components have been awakened.

Reimplemented in PlatformSetupComponent.

◆ Update()

virtual void DekiBehaviour::Update ( )
inlinevirtual

Called every frame (only if needs_update is true).

Reimplemented in PlatformSetupComponent.

◆ HasAwoken()

bool DekiBehaviour::HasAwoken ( ) const
inline

◆ HasStarted()

bool DekiBehaviour::HasStarted ( ) const
inline

◆ MarkAwoken()

void DekiBehaviour::MarkAwoken ( )
inline

◆ MarkStarted()

void DekiBehaviour::MarkStarted ( )
inline

◆ NeedsUpdate()

virtual bool DekiBehaviour::NeedsUpdate ( ) const
inlinevirtual

Runtime opt-out for Update() calls.

Returns
false to skip Update() this frame

Whether Update() exists at all is DeclaresUpdate(), generated from the class declaration. This flag is the per-instance switch on top of that: true by default, so declaring Update() is enough to be ticked; a behaviour that is idle can SetNeedsUpdate(false) to drop out of the per-frame loop and back in later.

◆ SetNeedsUpdate()

void DekiBehaviour::SetNeedsUpdate ( bool needs)
inline

Enable or disable per-frame Update() calls.

Parameters
needsSet to false to stop receiving Update() calls

Member Data Documentation

◆ StaticType

ComponentType DekiBehaviour::StaticType = DekiHashString("DekiBehaviour")
staticconstexpr

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