Skip to content

Commit

Permalink
Created new macro for ecs to create and register system from template.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Feb 9, 2024
1 parent b29b01f commit 259979e
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
3 changes: 3 additions & 0 deletions seika/ecs/ec_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ void ska_ecs_system_destroy(SkaECSSystem* entitySystem) {
void ska_ecs_system_register(SkaECSSystem* system) {
SE_ASSERT_FMT(system != NULL, "Passed in system is NULL!");
entitySystemData.entity_systems[entitySystemData.entity_systems_count++] = system;
if (system->on_ec_system_register != NULL) {
system->on_ec_system_register(system);
}
if (system->on_entity_start_func != NULL) {
entitySystemData.on_entity_start_systems[entitySystemData.on_entity_start_systems_count++] = system;
}
Expand Down
4 changes: 4 additions & 0 deletions seika/ecs/ec_system.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ ska_ecs_system_create_with_signature_string(NAME, #__VA_ARGS__)
#define SKA_ECS_SYSTEM_CREATE_FROM_TEMPLATE(TEMPLATE, ...) \
ska_ecs_system_create_from_template_with_signature_string(TEMPLATE, #__VA_ARGS__)

// Creates and register system from template
#define SKA_ECS_SYSTEM_REGISTER_FROM_TEMPLATE(TEMPLATE, ...) \
ska_ecs_system_register(ska_ecs_system_create_from_template_with_signature_string(TEMPLATE, #__VA_ARGS__))

struct SkaECSSystem;

typedef void (*OnECSystemRegister) (struct SkaECSSystem*);
Expand Down
3 changes: 1 addition & 2 deletions test/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -467,8 +467,7 @@ void seika_ecs_test(void) {
.fixed_update_func = NULL, \
.network_callback_func = NULL \
}
SkaECSSystem* testValueTransformEcsSystem = SKA_ECS_SYSTEM_CREATE_FROM_TEMPLATE(VALUE_TRANSFORM_SYSTEM_TEMPLATE, TestValueComponent, TestTransformComponent);
ska_ecs_system_register(testValueTransformEcsSystem);
SKA_ECS_SYSTEM_REGISTER_FROM_TEMPLATE(VALUE_TRANSFORM_SYSTEM_TEMPLATE, TestValueComponent, TestTransformComponent);
#undef VALUE_TRANSFORM_SYSTEM_TEMPLATE

// Test entity id enqueue and dequeue
Expand Down
2 changes: 1 addition & 1 deletion vcpkg.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "seika",
"version": "0.0.30",
"version": "0.0.31",
"dependencies": [
{
"name": "sdl2",
Expand Down

0 comments on commit 259979e

Please sign in to comment.