Typedef in ldk_component.h

LDKComponentAttachFn

Callback used when a component is attached to an entity.

typedef bool(*LDKComponentAttachFn)(LDKEntityRegistry *entity_registry, LDKComponentRegistry *component_registry, LDKEntity entity, void *component, u32 component_index, const void *initial_value, void *user);

Parameters

entity_registry
Entity registry used by this operation.
component_registry
Component registry used by this operation.
entity
Entity to inspect or modify.
component
Component used by this operation.
component_index
Zero-based index of the component entry.
initial_value
Initial value used by this operation.
user
Opaque caller-supplied data passed to the callback.

Returns

True if the operation succeeds; false otherwise.

Typedef in ldk_component.h

LDKComponentDestroyFn

Callback used when component instance data is destroyed.

typedef void(*LDKComponentDestroyFn)(LDKEntityRegistry *entity_registry, LDKComponentRegistry *component_registry, LDKEntity entity, void *component, u32 component_index, void *user);

Parameters

entity_registry
Entity registry used by this operation.
component_registry
Component registry used by this operation.
entity
Entity to inspect or modify.
component
Component used by this operation.
component_index
Zero-based index of the component entry.
user
Opaque caller-supplied data passed to the callback.
Enum in ldk_component.h

LDKComponentFlags

A descriptor that identifies a Component. Components are plain data structures that can be attached to entities. Component types needs to be registered before they are used.

typedef enum LDKComponentFlags{
  LDK_COMPONENT_FLAG_NONE=0,
  LDK_COMPONENT_FLAG_HIDE_IN_INSPECTOR=1<<0
}LDKComponentFlags;
Struct in ldk_component.h

LDKComponentDesc

typedef struct LDKComponentDesc{
  const char *name;
  u32 type;
  u32 entry_size;
  u32 initial_capacity;
  u32 flags;
  const u32 *required_components;
  u32 required_component_count;
  LDKComponentAttachFn attach;
  LDKComponentDestroyFn destroy;
  void *user;
}LDKComponentDesc;
Struct in ldk_component.h

LDKRegisteredComponent

typedef struct LDKRegisteredComponent{
  LDKComponentDesc desc;
  XArray *store;
  XArray *owners;
}LDKRegisteredComponent;
Struct in ldk_component.h

LDKComponentRegistry

typedef struct LDKComponentRegistry{
  XHashtable_u32_registered_component *table;
}LDKComponentRegistry;
Function in ldk_component.h

ldk_component_registry_initialize

Initialize the component registry.

LDK_API bool ldk_component_registry_initialize(LDKComponentRegistry *registry);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_component.h

ldk_component_is_registered

Check whether a component type is registered.

LDK_API bool ldk_component_is_registered(
 LDKComponentRegistry *registry,
 u32 type
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
u32 type
Type identifier or kind used by the operation.

Returns

True when the queried condition holds; false otherwise.

Function in ldk_component.h

ldk_component_store_get

Get the component store.

LDK_API XArray * ldk_component_store_get(
 LDKComponentRegistry *registry,
 u32 type
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
u32 type
Type identifier or kind used by the operation.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_component.h

ldk_component_owners_get

Get the component owners.

LDK_API XArray * ldk_component_owners_get(
 LDKComponentRegistry *registry,
 u32 type
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
u32 type
Type identifier or kind used by the operation.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_component.h

ldk_component_detach

Detach a component from an entity.

LDK_API bool ldk_component_detach(
 LDKComponentRegistry *registry,
 LDKEntityRegistry *entity_system,
 LDKEntity entity,
 u32 component_type
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
LDKEntityRegistry *entity_system
Entity system used by this operation.
LDKEntity entity
Entity to inspect or modify.
u32 component_type
Registered ECS component type identifier.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_component.h

ldk_component_registry_remove_all

Removes (destroys) ALL components, including core engine components like Transform. Intended for entity destruction only.

LDK_API void ldk_component_registry_remove_all(
 LDKComponentRegistry *registry,
 LDKEntityRegistry *entity_system,
 LDKEntity entity
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
LDKEntityRegistry *entity_system
Entity system used by this operation.
LDKEntity entity
Entity to inspect or modify.
Function in ldk_component.h

ldk_component_create

Create the component.

LDK_API void * ldk_component_create(
 LDKComponentRegistry *module,
 u32 component_type,
 u32 *component_index
);

Parameters

LDKComponentRegistry *module
Module used by this operation.
u32 component_type
Registered ECS component type identifier.
u32 *component_index
Zero-based index of the component entry.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_component.h

ldk_component_get

Get the component.

LDK_API void * ldk_component_get(
 LDKComponentRegistry *module,
 u32 component_type,
 u32 component_index
);

Parameters

LDKComponentRegistry *module
Module used by this operation.
u32 component_type
Registered ECS component type identifier.
u32 component_index
Zero-based index of the component entry.

Returns

Pointer to the requested object or data; NULL when unavailable.

Function in ldk_component.h

ldk_component_destroy

Destroy the component.

LDK_API bool ldk_component_destroy(
 LDKComponentRegistry *module,
 LDKEntityRegistry *entity_module,
 u32 component_type,
 u32 component_index
);

Parameters

LDKComponentRegistry *module
Module used by this operation.
LDKEntityRegistry *entity_module
Entity module used by this operation.
u32 component_type
Registered ECS component type identifier.
u32 component_index
Zero-based index of the component entry.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_component.h

ldk_component_attach

Attach a component to an entity.

LDK_API bool ldk_component_attach(
 LDKComponentRegistry *registry,
 LDKEntityRegistry *entity_registry,
 LDKEntity entity,
 u32 component_type,
 u32 component_index,
 const void *initial_value
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
LDKEntityRegistry *entity_registry
Entity registry used by this operation.
LDKEntity entity
Entity to inspect or modify.
u32 component_type
Registered ECS component type identifier.
u32 component_index
Zero-based index of the component entry.
const void *initial_value
Initial value used by this operation.

Returns

True if the operation succeeds; false otherwise.

Function in ldk_component.h

ldk_component_destroy_data

Release data associated with a component instance.

LDK_API void ldk_component_destroy_data(
 LDKComponentRegistry *registry,
 LDKEntityRegistry *entity_registry,
 LDKEntity entity,
 u32 component_type,
 u32 component_index
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
LDKEntityRegistry *entity_registry
Entity registry used by this operation.
LDKEntity entity
Entity to inspect or modify.
u32 component_type
Registered ECS component type identifier.
u32 component_index
Zero-based index of the component entry.
Function in ldk_component.h

ldk_component_name_get

Get the registered name of a component type.

LDK_API const char * ldk_component_name_get(
 LDKComponentRegistry *registry,
 u32 type
);

Parameters

LDKComponentRegistry *registry
Registry on which the operation is performed.
u32 type
Type identifier or kind used by the operation.

Returns

Pointer to the requested object or data; NULL when unavailable.