Component

Namespace: dmGameObject Language: C++ Type: Defold C++ File: component.h Source: engine/gameobject/src/dmsdk/gameobject/component.h Include: dmsdk/gameobject/component.h

Api for manipulating game object components (WIP)

API

ComponentAddToUpdate

Type: TYPEDEF Component add to update function. Only components called with this function should be included in the update passes.

Parameters

Returns

ComponentAddToUpdateParams

Type: STRUCT Parameters to ComponentAddToUpdate callback.

Members

ComponentCreate

Type: TYPEDEF 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.

Parameters

Returns

ComponentCreateParams

Type: STRUCT Parameters to ComponentCreate callback.

Members

ComponentDeleteWorld

Type: TYPEDEF Component world destroy function

Parameters

Returns

ComponentDeleteWorldParams

Type: STRUCT Parameters to ComponentDeleteWorld callback.

Members

ComponentDestroy

Type: TYPEDEF Component destroy function. Should deallocate all necessary resources.

Parameters

Returns

ComponentDestroyParams

Type: STRUCT Parameters to ComponentDestroy callback.

Members

ComponentFinal

Type: TYPEDEF Component finalize function. Should clean up as it is called when the component is disabled.

Parameters

Returns

ComponentFinalParams

Type: STRUCT Parameters to ComponentFinal callback.

Members

ComponentGet

Type: TYPEDEF A simple way to get the component instance from the user_data (which was set during creation)

Parameters

Returns

ComponentGetParams

Type: STRUCT Parameters to ComponentGet callback.

Members

ComponentGetProperty

Type: TYPEDEF Callback for retrieving a property value of the component.

Parameters

Returns

ComponentGetPropertyParams

Type: STRUCT Parameters to ComponentGetProperty callback.

Members

ComponentInit

Type: TYPEDEF Component init function. Should set the components initial state as it is called when the component is enabled.

Parameters

Returns

ComponentInitParams

Type: STRUCT Parameters to ComponentInit callback.

Members

ComponentIterProperties

Type: TYPEDEF Callback when iterating over the properties for a component.

Notes

Parameters

ComponentNewWorld

Type: TYPEDEF Component world create function

Parameters

Returns

ComponentNewWorldParams

Type: STRUCT Parameters to ComponentNewWorld callback.

Members

ComponentOnInput

Type: TYPEDEF Component on-input function. Called when input is sent to this component

Parameters

Returns

ComponentOnInputParams

Type: STRUCT Parameters to ComponentOnInput callback.

Members

ComponentOnMessage

Type: TYPEDEF Component on-message function. Called when message is sent to this component

Parameters

Returns

ComponentOnMessageParams

Type: STRUCT Parameters to ComponentOnMessage callback.

Members

ComponentOnReload

Type: FUNCTION Called when the resource the component is based on has been reloaded.

Parameters

ComponentOnReloadParams

Type: STRUCT Parameters to ComponentOnReload callback.

Members

ComponentSetProperties

Type: TYPEDEF Set a property set for the component.

Parameters

Returns

ComponentSetPropertiesParams

Type: STRUCT Parameters to ComponentSetProperties callback.

Members

ComponentSetProperty

Type: TYPEDEF Callback for setting a property value of the component.

Parameters

Returns

ComponentSetPropertyParams

Type: STRUCT Parameters to ComponentSetProperty callback.

Members

ComponentsPostUpdate

Type: TYPEDEF Component post update function. The component state should never be modified in this function.

Parameters

Returns

ComponentsPostUpdateParams

Type: STRUCT Parameters for ComponentsPostUpdate callback.

Members

ComponentsRender

Type: TYPEDEF Component render function.

Parameters

Returns

ComponentsRenderParams

Type: STRUCT Parameters to ComponentsRender callback.

Members

ComponentsUpdate

Type: TYPEDEF Component update function. Updates all component of this type for all game objects

Parameters

Returns

ComponentsUpdateParams

Type: STRUCT Parameters to ComponentsUpdate callback.

Members

ComponentsUpdateResult

Type: STRUCT Parameters to ComponentsUpdate callback.

Members

ComponentTypeCreateCtx

Type: STRUCT Context used when registering a new component type

Members

ComponentTypeGetContext

Type: FUNCTION get the component type global context

Parameters

Returns

ComponentTypeGetTypeIndex

Type: FUNCTION Get the component type index. Used for with e.g. dmGameObject::GetWorld()/GetContext()

Parameters

Returns

ComponentTypeSetAddToUpdateFn

Type: FUNCTION Set the component add-to-update callback. Called for each component instal, when the game object is spawned.

Parameters

ComponentTypeSetChildIteratorFn

Type: FUNCTION set the component child iterator function. Called during inspection

Parameters

ComponentTypeSetContext

Type: FUNCTION Set the component type global context. Usually set when registering the component type.

Parameters

ComponentTypeSetCreateFn

Type: FUNCTION Set the component create callback. Called when a component instance is created.

Parameters

ComponentTypeSetDeleteWorldFn

Type: FUNCTION Set the world destroy callback. Called when a collection (i.e. a “world”) is destroyed.

Parameters

ComponentTypeSetDestroyFn

Type: FUNCTION Set the component destroy callback. Called when a component instance is destroyed.

Parameters

ComponentTypeSetFinalFn

Type: FUNCTION Set the component finalize callback. Called on each gameobject’s components, during a gameobject’s finalization.

Parameters

ComponentTypeSetFixedUpdateFn

Type: FUNCTION Set the component update callback. Called when it’s time to update all component instances.

Parameters

ComponentTypeSetGetFn

Type: FUNCTION Set the component get callback. Called when the scripts want to retrieve the individual component user data given an url.

Parameters

ComponentTypeSetGetPropertyFn

Type: FUNCTION Set the component get property callback. Called when accessing a property via go.get()

Parameters

ComponentTypeSetHasUserData

Type: FUNCTION Set the component type need for a per component instance user data. Defaults to true.

Parameters

ComponentTypeSetInitFn

Type: FUNCTION Set the component init callback. Called on each gameobject’s components, during a gameobject’s initialization.

Parameters

ComponentTypeSetLateUpdateFn

Type: FUNCTION Set the component late update callback. Called after regular update of all component instances but before render and before post update.

Parameters

ComponentTypeSetNewWorldFn

Type: FUNCTION Set the new world callback. Called when a collection (i.e. a “world”) is created.

Parameters

ComponentTypeSetOnInputFn

Type: FUNCTION Set the component on-input callback. Called once per frame, before the Update function.

Parameters

ComponentTypeSetOnMessageFn

Type: FUNCTION Set the component on-message callback. Called multiple times per frame, to flush messages.

Parameters

ComponentTypeSetOnReloadFn

Type: FUNCTION Set the component on-reload callback. Called when the resource of a component instance is reloaded.

Parameters

ComponentTypeSetPostUpdateFn

Type: FUNCTION Set the component post update callback. Called for each collection after the update, before the render.

Parameters

ComponentTypeSetPrio

Type: FUNCTION Set the component type prio order. Defines the update order of the component types.

Parameters

ComponentTypeSetPropertyIteratorFn

Type: FUNCTION set the component property iterator function. Called during inspection

Parameters

ComponentTypeSetReadsTransforms

Type: FUNCTION Set the component type transform dependency flag. If this flag is set, it might trigger an dmGameObject::UpdateTransforms() (if there are dirty transforms)

Parameters

ComponentTypeSetRenderFn

Type: FUNCTION Set the component render callback. Called when it’s time to render all component instances.

Parameters

ComponentTypeSetSetPropertiesFn

Type: FUNCTION Set the component set properties callback. Called when the component instance is being spwned.

Parameters

ComponentTypeSetSetPropertyFn

Type: FUNCTION Set the component set property callback. Called when accessing a property via go.set()

Parameters

ComponentTypeSetUpdateFn

Type: FUNCTION Set the component update callback. Called when it’s time to update all component instances.

Parameters

DM_DECLARE_COMPONENT_TYPE

Type: MACRO Register a new component type

Parameters

HComponentType

Type: TYPEDEF Component type handle. It holds the life time functions for a type.