DEKI/ENGINE docs
manual api reference
Deki 0.40.1
Modular C++ engine with a visual editor, for 2D and 3D
Loading...
Searching...
No Matches
Deki::SetupComponent Class Referenceabstract

Base class for components that need asynchronous setup at boot. More...

#include <deki/SetupComponent.h>

Inherits Deki::Component.

Public Types

using EditorAutoFactory = SetupComponent* (*)()
using SetupCallback = std::function<void(bool success)>
enum class  SetupPhase { EditorLoad , PlayStart }

Public Member Functions

 SetupComponent ()=default
virtual ~SetupComponent ()=default
virtual const char * GetSetupName () const =0
 Readable name for the log.
virtual void Setup (SetupCallback onComplete)=0
 Starts the setup.
Public Member Functions inherited from Deki::Component
 Component ()
 Component (const Component &)=delete
virtual ~Component ()=default
virtual void Awake ()
 Called once, after AssetRefs and ObjectRefs are resolved.
bool DeclaresUpdate () const
 True when this class (or a reflected base) declares Update(), as the codegen read it from the class declaration.
bool Deserialize (SceneFormat::SceneMsgPackParser &parser, uint32_t mapSize)
 Reads this component's fields from the MessagePack map the parser is at (mapSize key-value pairs), through the codegen's hash-switch deserializer.
ComponentType GetBaseType () const
 The direct component base's type id, so GetComponent<Base>() finds subclasses.
Object * GetOwner () const
ComponentType GetType () const
 The class's type id (TypeId<T>()), 0 for an instance with no type info.
const ComponentTypeInfo * GetTypeInfo () const
 The class entry this instance runs through.
bool HasAwoken () const
bool HasRefsResolved () const
bool HasStarted () const
bool IsRemoved () const
 True once RemoveComponent() has been called and the component is waiting for the end of the lifecycle phase to be deleted.
virtual void LoadAssets ()
 Loads the assets this component needs (sprites, fonts, ...).
void MarkAwoken ()
void MarkRefsResolved ()
void MarkRemoved ()
void MarkStarted ()
virtual bool NeedsAssetLoading () const
 True when LoadAssets() should be called.
virtual bool NeedsRuntimeUpdate () const
 True when RuntimeUpdate() should be called each frame.
virtual void OnAssetRefResolved (const char *propertyName, void *asset, const char *guid)
 Called after LifecycleManager resolves the AssetRef field propertyName to asset, loaded from guid.
virtual void OnPropertyChanged (const char *propertyName)
 Called when the editor changes the field propertyName, after both Execute() and Undo() of ModifyComponentPropertyCommand.
Component & operator= (const Component &)=delete
void RemapObjectRefs (const std::unordered_map< uint32_t, uint32_t > &idRemap)
 Rewrites ObjectRef ids through idRemap (old id -> new id), after Instantiate() gave the copies new ids.
void ResetRefsResolved ()
void ResolveObjectRefs (Scene *scene)
 Points every ObjectRef field at its object in scene (ObjectRef.id -> ObjectRef.resolved).
virtual void RuntimeUpdate (float deltaTime)
 Engine-driven per-frame work (physics, animation, ...), separate from the script-facing Update(): it runs in every mode, including the editor in edit mode, on components whose NeedsRuntimeUpdate() is true.
void SetOwner (Object *owner)
void SetTypeInfo (const ComponentTypeInfo *info)
 Attaches the class entry.
virtual void Start ()
 Called once before the first Update, after every component's Awake has run.
virtual void UnloadAssets ()
 Drops this component's asset pointers before shutdown.
virtual void Update ()
 Called every frame, only on classes that declare it.

Static Public Member Functions

static SETUP_COMPONENT_API void ClearEditorAutoFactories ()
static SETUP_COMPONENT_API void RegisterEditorAutoFactory (EditorAutoFactory factory, SetupPhase phase=SetupPhase::EditorLoad)
static SETUP_COMPONENT_API void RunEditorAutoSetups (SetupPhase phase)

Additional Inherited Members

Protected Attributes inherited from Deki::Component
bool m_HasAwoken
bool m_HasStarted
Object * m_Owner
bool m_RefsResolved
bool m_Removed
const ComponentTypeInfo * m_TypeInfo

Detailed Description

Base class for components that need asynchronous setup at boot.

Derive from it to take part in the boot sequence; PlatformSetupComponent lists them with ObjectRef<SetupComponent> and runs them in order.

DEKI_CATEGORY("System") class MyHardwareComponent : public Deki::SetupComponent { public: void Setup(SetupCallback onComplete) override { bool success = InitializeHardware(); onComplete(success); }

const char* GetSetupName() const override { return "My Hardware"; } };

Member Typedef Documentation

◆ EditorAutoFactory

◆ SetupCallback

using Deki::SetupComponent::SetupCallback = std::function<void(bool success)>

Member Enumeration Documentation

◆ SetupPhase

Enumerator
EditorLoad 
PlayStart 

Constructor & Destructor Documentation

◆ SetupComponent()

Deki::SetupComponent::SetupComponent ( )
default

◆ ~SetupComponent()

virtual Deki::SetupComponent::~SetupComponent ( )
virtualdefault

Member Function Documentation

◆ ClearEditorAutoFactories()

SETUP_COMPONENT_API void Deki::SetupComponent::ClearEditorAutoFactories ( )
static

◆ GetSetupName()

virtual const char * Deki::SetupComponent::GetSetupName ( ) const
pure virtual

Readable name for the log.

◆ RegisterEditorAutoFactory()

SETUP_COMPONENT_API void Deki::SetupComponent::RegisterEditorAutoFactory ( EditorAutoFactory factory,
SetupPhase phase = SetupPhase::EditorLoad )
static

◆ RunEditorAutoSetups()

SETUP_COMPONENT_API void Deki::SetupComponent::RunEditorAutoSetups ( SetupPhase phase)
static

◆ Setup()

virtual void Deki::SetupComponent::Setup ( SetupCallback onComplete)
pure virtual

Starts the setup.

When it finishes, call onComplete with true on success or false on failure.


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