Api for manipulating game object components (WIP)
Namespace: | dmGameObject |
Include: | #include <dmsdk/gameobject/component.h> |
TYPES | |
---|---|
ComponentAddToUpdate | Component add to update function. Only components ... |
ComponentCreate | Component create function. Should allocate all nec... |
ComponentDeleteWorld | Component world destroy function |
ComponentDestroy | Component destroy function. Should deallocate all ... |
ComponentFinal | Component finalize function. Should clean up as it... |
ComponentGet | A simple way to get the component instance from th... |
ComponentGetProperty | Callback for retrieving a property value of the co... |
ComponentInit | Component init function. Should set the components... |
ComponentIterProperties | Callback when iterating over the properties for a ... |
ComponentNewWorld | Component world create function |
ComponentOnInput | Component on-input function. Called when input is ... |
ComponentOnMessage | Component on-message function. Called when message... |
ComponentSetProperties | Set a property set for the component. |
ComponentSetProperty | Callback for setting a property value of the compo... |
ComponentsFixedUpdate | Component fixed update function. Updates all compo... |
ComponentsPostUpdate | Component post update function. The component stat... |
ComponentsRender | Component render function. |
ComponentsUpdate | Component update function. Updates all component o... |
HComponentType | Component type handle. It holds the life time func... |
STRUCTS | |
---|---|
struct ComponentAddToUpdateParams | Parameters to ComponentAddToUpdate callback. |
struct ComponentCreateParams | Parameters to ComponentCreate callback. |
struct ComponentDeleteWorldParams | Parameters to ComponentDeleteWorld callback. |
struct ComponentDestroyParams | Parameters to ComponentDestroy callback. |
struct ComponentFinalParams | Parameters to ComponentFinal callback. |
struct ComponentGetParams | Parameters to ComponentGet callback. |
struct ComponentGetPropertyParams | Parameters to ComponentGetProperty callback. |
struct ComponentInitParams | Parameters to ComponentInit callback. |
struct ComponentNewWorldParams | Parameters to ComponentNewWorld callback. |
struct ComponentOnInputParams | Parameters to ComponentOnInput callback. |
struct ComponentOnMessageParams | Parameters to ComponentOnMessage callback. |
struct ComponentOnReloadParams | Parameters to ComponentOnReload callback. |
struct ComponentSetPropertiesParams | Parameters to ComponentSetProperties callback. |
struct ComponentSetPropertyParams | Parameters to ComponentSetProperty callback. |
struct ComponentsPostUpdateParams | Parameters for ComponentsPostUpdate callback. |
struct ComponentsRenderParams | Parameters to ComponentsRender callback. |
struct ComponentsUpdateParams | Parameters to ComponentsUpdate callback. |
struct ComponentsUpdateResult | Parameters to ComponentsUpdate callback. |
struct ComponentTypeCreateCtx | Context used when registering a new component type |
MACROS | |
---|---|
DM_DECLARE_COMPONENT_TYPE(symbol, name, create_fn, destroy_fn) | Register a new component type |
void ComponentOnReload(const dmGameObject::ComponentOnReloadParams& params)
Called when the resource the component is based on has been reloaded.
PARAMETERS
const dmGameObject::ComponentOnReloadParams& |
params |
the parameters |
void* ComponentTypeGetContext(HComponentType type)
get the component type global context
PARAMETERS
HComponentType |
type |
the type |
RETURNS
void* |
component type global context |
uint32_t ComponentTypeGetTypeIndex(HComponentType type)
Get the component type index. Used for with e.g. dmGameObject::GetWorld()/GetContext()
PARAMETERS
HComponentType |
type |
the type |
RETURNS
uint32_t |
The type index. |
void ComponentTypeSetAddToUpdateFn(HComponentType type, ComponentAddToUpdate fn)
Set the component add-to-update callback. Called for each component instal, when the game object is spawned.
PARAMETERS
HComponentType |
type |
the type |
ComponentAddToUpdate |
fn |
callback |
void ComponentTypeSetChildIteratorFn(HComponentType type, dmGameObject::FIteratorChildren fn)
set the component child iterator function. Called during inspection
PARAMETERS
HComponentType |
type |
the type |
dmGameObject::FIteratorChildren |
fn |
child iterator function |
void ComponentTypeSetContext(HComponentType type, void* context)
Set the component type global context. Usually set when registering the component type.
PARAMETERS
HComponentType |
type |
the type |
void* |
context |
component type global context |
void ComponentTypeSetCreateFn(HComponentType type, ComponentCreate fn)
Set the component create callback. Called when a component instance is created.
PARAMETERS
HComponentType |
type |
the type |
ComponentCreate |
fn |
callback |
void ComponentTypeSetDeleteWorldFn(HComponentType type, ComponentDeleteWorld fn)
Set the world destroy callback. Called when a collection (i.e. a "world") is destroyed.
PARAMETERS
HComponentType |
type |
the type |
ComponentDeleteWorld |
fn |
callback |
void ComponentTypeSetDestroyFn(HComponentType type, ComponentDestroy fn)
Set the component destroy callback. Called when a component instance is destroyed.
PARAMETERS
HComponentType |
type |
the type |
ComponentDestroy |
fn |
callback |
void ComponentTypeSetFinalFn(HComponentType type, ComponentFinal fn)
Set the component finalize callback. Called on each gameobject's components, during a gameobject's finalization.
PARAMETERS
HComponentType |
type |
the type |
ComponentFinal |
fn |
callback |
void ComponentTypeSetFixedUpdateFn(HComponentType type, ComponentsFixedUpdate fn)
Set the component update callback. Called when it's time to update all component instances.
PARAMETERS
HComponentType |
type |
the type |
ComponentsFixedUpdate |
fn |
callback |
void ComponentTypeSetGetFn(HComponentType type, ComponentGet fn)
Set the component get callback. Called when the scripts want to retrieve the individual component user data given an url.
PARAMETERS
HComponentType |
type |
the type |
ComponentGet |
fn |
callback |
void ComponentTypeSetGetPropertyFn(HComponentType type, ComponentGetProperty fn)
Set the component get property callback. Called when accessing a property via go.get()
PARAMETERS
HComponentType |
type |
the type |
ComponentGetProperty |
fn |
callback |
void ComponentTypeSetHasUserData(HComponentType type, bool has_user_data)
Set the component type need for a per component instance user data. Defaults to true.
PARAMETERS
HComponentType |
type |
the type |
bool |
has_user_data |
does each component instance need user data |
void ComponentTypeSetInitFn(HComponentType type, ComponentInit fn)
Set the component init callback. Called on each gameobject's components, during a gameobject's initialization.
PARAMETERS
HComponentType |
type |
the type |
ComponentInit |
fn |
callback |
void ComponentTypeSetNewWorldFn(HComponentType type, ComponentNewWorld fn)
Set the new world callback. Called when a collection (i.e. a "world") is created.
PARAMETERS
HComponentType |
type |
the type |
ComponentNewWorld |
fn |
callback |
void ComponentTypeSetOnInputFn(HComponentType type, ComponentOnInput fn)
Set the component on-input callback. Called once per frame, before the Update function.
PARAMETERS
HComponentType |
type |
the type |
ComponentOnInput |
fn |
callback |
void ComponentTypeSetOnMessageFn(HComponentType type, ComponentOnMessage fn)
Set the component on-message callback. Called multiple times per frame, to flush messages.
PARAMETERS
HComponentType |
type |
the type |
ComponentOnMessage |
fn |
callback |
void ComponentTypeSetOnReloadFn(HComponentType type, ComponentOnReload fn)
Set the component on-reload callback. Called when the resource of a component instance is reloaded.
PARAMETERS
HComponentType |
type |
the type |
ComponentOnReload |
fn |
callback |
void ComponentTypeSetPostUpdateFn(HComponentType type, ComponentsPostUpdate fn)
Set the component post update callback. Called for each collection after the update, before the render.
PARAMETERS
HComponentType |
type |
the type |
ComponentsPostUpdate |
fn |
callback |
void ComponentTypeSetPrio(HComponentType type, uint16_t prio)
Set the component type prio order. Defines the update order of the component types.
PARAMETERS
HComponentType |
type |
the type |
uint16_t |
prio |
prio order |
void ComponentTypeSetPropertyIteratorFn(HComponentType type, dmGameObject::FIteratorProperties fn)
set the component property iterator function. Called during inspection
PARAMETERS
HComponentType |
type |
the type |
dmGameObject::FIteratorProperties |
fn |
property iterator function |
void ComponentTypeSetReadsTransforms(HComponentType type, bool reads_transforms)
Set the component type transform dependency flag. If this flag is set, it might trigger an dmGameObject::UpdateTransforms() (if there are dirty transforms)
PARAMETERS
HComponentType |
type |
the type |
bool |
reads_transforms |
transform dependency flag |
void ComponentTypeSetRenderFn(HComponentType type, ComponentsRender fn)
Set the component render callback. Called when it's time to render all component instances.
PARAMETERS
HComponentType |
type |
the type |
ComponentsRender |
fn |
callback |
void ComponentTypeSetSetPropertiesFn(HComponentType type, ComponentSetProperties fn)
Set the component set properties callback. Called when the component instance is being spwned.
PARAMETERS
HComponentType |
type |
the type |
ComponentSetProperties |
fn |
callback |
void ComponentTypeSetSetPropertyFn(HComponentType type, ComponentSetProperty fn)
Set the component set property callback. Called when accessing a property via go.set()
PARAMETERS
HComponentType |
type |
the type |
ComponentSetProperty |
fn |
callback |
void ComponentTypeSetUpdateFn(HComponentType type, ComponentsUpdate fn)
Set the component update callback. Called when it's time to update all component instances.
PARAMETERS
HComponentType |
type |
the type |
ComponentsUpdate |
fn |
callback |
TYPE
struct ComponentAddToUpdateParams
Parameters to ComponentAddToUpdate callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
HInstance |
m_Instance |
Game object instance |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentCreateParams
Parameters to ComponentCreate callback.
MEMBERS
HInstance |
m_Instance |
Game object instance |
dmVMath::Point3 |
m_Position |
Local component position |
dmVMath::Quat |
m_Rotation |
Local component rotation |
dmVMath::Vector3 |
m_Scale |
Local component scale |
PropertySet |
m_PropertySet |
Set of properties |
void* |
m_Resource |
Component resource |
void* |
m_World |
Component world, as created in the ComponentNewWorld callback |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
uint16_t |
m_ComponentIndex |
Index of the component type being created (among all component types) |
TYPE
struct ComponentDeleteWorldParams
Parameters to ComponentDeleteWorld callback.
MEMBERS
|
m_Context |
[type void*] Context for the component type |
|
m_World |
[type void*] The pointer to the world to destroy |
TYPE
struct ComponentDestroyParams
Parameters to ComponentDestroy callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
HInstance |
m_Instance |
Game object instance |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentFinalParams
Parameters to ComponentFinal callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
HInstance |
m_Instance |
Game object instance |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentGetParams
Parameters to ComponentGet callback.
MEMBERS
HComponentWorld |
m_World |
Component world |
HComponentInternal |
m_UserData |
Component internal representation |
TYPE
struct ComponentGetPropertyParams
Parameters to ComponentGetProperty callback.
MEMBERS
void* |
m_Context |
Context for the component type |
void* |
m_World |
Component world |
HInstance |
m_Instance |
Game object instance |
dmhash_t |
m_PropertyId |
Id of the property |
uintptr_t* |
m_UserData |
User data storage pointer |
PropertyOptions |
m_Options |
Options for getting the property |
TYPE
struct ComponentInitParams
Parameters to ComponentInit callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
HInstance |
m_Instance |
Game object instance |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentNewWorldParams
Parameters to ComponentNewWorld callback.
MEMBERS
void* |
m_Context |
Context for the component type |
uint8_t |
m_ComponentIndex |
Component type index that can be used later with GetWorld() |
uint32_t |
m_MaxInstances |
Max component game object instance count (if applicable) |
void** |
m_World |
Out-parameter of the pointer in which to store the created world |
uint32_t |
m_MaxComponentInstances |
Max components count of this type in current collection counted at the build stage. If component in factory then value is 0xFFFFFFFF |
TYPE
struct ComponentOnInputParams
Parameters to ComponentOnInput callback.
MEMBERS
HInstance |
m_Instance |
Instance handle |
const InputAction* |
m_InputAction |
Information about the input that occurred (note that input being released is also treated as input) |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentOnMessageParams
Parameters to ComponentOnMessage callback.
MEMBERS
HInstance |
m_Instance |
Instance handle |
void* |
m_World |
World |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
dmMessage::Message* |
m_Message |
Message |
TYPE
struct ComponentOnReloadParams
Parameters to ComponentOnReload callback.
MEMBERS
HInstance |
m_Instance |
Instance handle |
void* |
m_Resource |
Resource that was reloaded |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentSetPropertiesParams
Parameters to ComponentSetProperties callback.
MEMBERS
HInstance |
m_Instance |
Instance handle |
PropertySet |
m_PropertySet |
Property set to use |
uintptr_t* |
m_UserData |
User data storage pointer |
TYPE
struct ComponentSetPropertyParams
Parameters to ComponentSetProperty callback.
MEMBERS
void* |
m_Context |
Context for the component type |
void* |
m_World |
Component world |
HInstance |
m_Instance |
Game object instance |
dmhash_t |
m_PropertyId |
Id of the property |
uintptr_t* |
m_UserData |
User data storage pointer |
PropertyVar |
m_Value |
New value of the property |
PropertyOptions |
m_Options |
Options for setting the property |
TYPE
struct ComponentsPostUpdateParams
Parameters for ComponentsPostUpdate callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
TYPE
struct ComponentsRenderParams
Parameters to ComponentsRender callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
TYPE
struct ComponentsUpdateParams
Parameters to ComponentsUpdate callback.
MEMBERS
HCollection |
m_Collection |
Collection handle |
const UpdateContext* |
m_UpdateContext |
Update context |
void* |
m_World |
Component world |
void* |
m_Context |
User context |
TYPE
struct ComponentsUpdateResult
Parameters to ComponentsUpdate callback.
MEMBERS
bool |
m_TransformsUpdated |
True if a component type updated any game object transforms |
TYPE
struct ComponentTypeCreateCtx
Context used when registering a new component type
MEMBERS
dmConfigFile::HConfig |
m_Config |
The config file |
dmResource::HFactory |
m_Factory |
The resource factory |
dmGameObject::HRegister |
m_Register |
The game object registry |
dmScript::HContext |
m_Script |
The shared script context |
dmHashTable64 |
m_Contexts |
Mappings between names and contextx |
Component add to update function. Only components called with this function should be included in the update passes.
Component create function. Should allocate all necessary resources for the component. The game object instance is guaranteed to have its id, scene hierarchy and transform data updated when this is called.
Component world destroy function
Component destroy function. Should deallocate all necessary resources.
Component finalize function. Should clean up as it is called when the component is disabled.
A simple way to get the component instance from the user_data (which was set during creation)
Callback for retrieving a property value of the component.
Component init function. Should set the components initial state as it is called when the component is enabled.
Callback when iterating over the properties for a component.
Component world create function
Component on-input function. Called when input is sent to this component
Component on-message function. Called when message is sent to this component
Set a property set for the component.
Callback for setting a property value of the component.
Component fixed update function. Updates all component of this type for all game objects
Component post update function. The component state should never be modified in this function.
Component render function.
Component update function. Updates all component of this type for all game objects
Component type handle. It holds the life time functions for a type.
Register a new component type
symbol |
The unique C++ symbol name |
name |
name of the component type (i.e. the resource suffix) |
create_fn |
The type configuration function. May not be 0. |
destroy_fn |
The type destruction function. May be 0. |