Skip to content

Commit

Permalink
feat: multi field association API (#243)
Browse files Browse the repository at this point in the history
  • Loading branch information
zaucy authored May 23, 2024
1 parent 95ffc34 commit e3682e8
Show file tree
Hide file tree
Showing 3 changed files with 115 additions and 0 deletions.
6 changes: 6 additions & 0 deletions ecsact/runtime/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ ECSACT_TYPED_ID(ecsact_transient_id);
ECSACT_TYPED_ID(ecsact_enum_id);
ECSACT_TYPED_ID(ecsact_enum_value_id);
ECSACT_TYPED_ID(ecsact_field_id);
ECSACT_TYPED_ID(ecsact_system_assoc_id);
ECSACT_TYPED_ID(ecsact_variant_id);
ECSACT_TYPED_ID(ecsact_registry_id);
ECSACT_TYPED_ID(ecsact_entity_id);
Expand Down Expand Up @@ -222,6 +223,11 @@ typedef enum {
} ecsact_execute_systems_error;

typedef enum {
/**
* System has no capabilities for this component.
*/
ECSACT_SYS_CAP_NONE = 0,

/**
* System may read component
*/
Expand Down
47 changes: 47 additions & 0 deletions ecsact/runtime/dynamic.h
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,44 @@ ECSACT_DYNAMIC_API_FN(void, ecsact_unset_system_capability)
ecsact_component_like_id
);

ECSACT_DYNAMIC_API_FN(ecsact_system_assoc_id, ecsact_add_system_assoc)
( //
ecsact_system_like_id
);

ECSACT_DYNAMIC_API_FN(void, ecsact_remove_system_assoc)
( //
ecsact_system_like_id,
ecsact_system_assoc_id
);

ECSACT_DYNAMIC_API_FN(void, ecsact_add_system_assoc_field)
( //
ecsact_system_like_id,
ecsact_system_assoc_id,
ecsact_component_like_id,
ecsact_field_id
);

ECSACT_DYNAMIC_API_FN(void, ecsact_remove_system_assoc_field)
( //
ecsact_system_like_id,
ecsact_system_assoc_id,
ecsact_component_like_id,
ecsact_field_id
);

ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_assoc_capbility)
( //
ecsact_system_like_id,
ecsact_system_assoc_id,
ecsact_component_like_id,
ecsact_system_capability
);

/**
* @deprecated use ecsact_set_system_assoc_capbility instead
*/
ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_association_capability)
( //
ecsact_system_like_id,
Expand All @@ -387,6 +425,10 @@ ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_association_capability)
ecsact_system_capability
);

/**
* @deprecated use ecsact_set_system_assoc_capbility with ECSACT_SYS_CAP_NONE
* instead
*/
ECSACT_DYNAMIC_API_FN(void, ecsact_unset_system_association_capability)
( //
ecsact_system_like_id,
Expand Down Expand Up @@ -499,6 +541,11 @@ ECSACT_DYNAMIC_API_FN(void, ecsact_set_system_notify_component_setting)
fn(ecsact_remove_enum_value, __VA_ARGS__); \
fn(ecsact_set_system_capability, __VA_ARGS__); \
fn(ecsact_unset_system_capability, __VA_ARGS__); \
fn(ecsact_add_system_assoc, __VA_ARGS__); \
fn(ecsact_remove_system_assoc, __VA_ARGS__); \
fn(ecsact_add_system_assoc_field, __VA_ARGS__); \
fn(ecsact_remove_system_assoc_field, __VA_ARGS__); \
fn(ecsact_set_system_assoc_capbility, __VA_ARGS__); \
fn(ecsact_set_system_association_capability, __VA_ARGS__); \
fn(ecsact_unset_system_association_capability, __VA_ARGS__); \
fn(ecsact_add_system_generates, __VA_ARGS__); \
Expand Down
62 changes: 62 additions & 0 deletions ecsact/runtime/meta.h
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,62 @@ ECSACT_META_API_FN(void, ecsact_meta_system_capabilities)
int32_t* out_capabilities_count
);

ECSACT_META_API_FN(int32_t, ecsact_meta_system_assoc_count)
( //
ecsact_system_like_id system_id
);

ECSACT_META_API_FN(int32_t, ecsact_meta_system_assoc_ids)
( //
ecsact_system_like_id system_id,
int32_t max_assoc_count,
ecsact_system_assoc_id* out_assoc_ids,
int32_t* out_assoc_count
);

ECSACT_META_API_FN(int32_t, ecsact_meta_system_assoc_fields_count)
( //
ecsact_system_like_id system_id,
ecsact_system_assoc_id assoc_id
);

ECSACT_META_API_FN(int32_t, ecsact_meta_system_assoc_fields)
( //
ecsact_system_like_id system_id,
ecsact_system_assoc_id assoc_id,
int32_t max_fields_count,
ecsact_field_id* out_fields,
int32_t* out_fields_count
);

ECSACT_META_API_FN(int32_t, ecsact_meta_system_assoc_capabilities_count)
( //
ecsact_system_like_id system_id,
ecsact_system_assoc_id assoc_id
);

ECSACT_META_API_FN(void, ecsact_meta_system_assoc_capabilities)
( //
ecsact_system_like_id system_id,
ecsact_system_assoc_id assoc_id,
int32_t max_capabilities_count,
ecsact_component_like_id* out_capability_component_ids,
ecsact_system_capability* out_capabilities,
int32_t* out_capabilities_count
);

/**
* @deprecated use ecsact_meta_system_assoc_* fns instead
*/
ECSACT_META_API_FN(int32_t, ecsact_meta_system_association_fields_count)
( //
ecsact_system_like_id system_id,
ecsact_component_like_id component_id
);

/**
* @deprecated use ecsact_meta_system_assoc_* fns instead
*/
ECSACT_META_API_FN(void, ecsact_meta_system_association_fields)
( //
ecsact_system_like_id system_id,
Expand All @@ -299,13 +349,19 @@ ECSACT_META_API_FN(void, ecsact_meta_system_association_fields)
int32_t* out_fields_count
);

/**
* @deprecated use ecsact_meta_system_assoc_* fns instead
*/
ECSACT_META_API_FN(int32_t, ecsact_meta_system_association_capabilities_count)
( //
ecsact_system_like_id system_id,
ecsact_component_like_id component_id,
ecsact_field_id field_id
);

/**
* @deprecated use ecsact_meta_system_assoc_* fns instead
*/
ECSACT_META_API_FN(void, ecsact_meta_system_association_capabilities)
( //
ecsact_system_like_id system_id,
Expand Down Expand Up @@ -477,6 +533,12 @@ ECSACT_META_API_FN(void, ecsact_meta_system_notify_settings)
fn(ecsact_meta_system_name, __VA_ARGS__); \
fn(ecsact_meta_system_capabilities_count, __VA_ARGS__); \
fn(ecsact_meta_system_capabilities, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_count, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_ids, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_fields_count, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_fields, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_capabilities_count, __VA_ARGS__); \
fn(ecsact_meta_system_assoc_capabilities, __VA_ARGS__); \
fn(ecsact_meta_system_association_fields_count, __VA_ARGS__); \
fn(ecsact_meta_system_association_fields, __VA_ARGS__); \
fn(ecsact_meta_system_association_capabilities_count, __VA_ARGS__); \
Expand Down

0 comments on commit e3682e8

Please # to comment.