Skip to content

Commit

Permalink
Updating max ecs system per hook and adding assertions.
Browse files Browse the repository at this point in the history
  • Loading branch information
Chukobyte committed Feb 25, 2024
1 parent 6145a80 commit 6dea426
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
12 changes: 11 additions & 1 deletion seika/ecs/ec_system.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "seika/utils/se_assert.h"

//--- EC System Manager ---//
#define MAX_ENTITY_SYSTEMS_PER_HOOK 6
#define MAX_ENTITY_SYSTEMS_PER_HOOK 12

typedef struct EntitySystemData {
size_t entity_systems_count;
Expand Down Expand Up @@ -133,35 +133,45 @@ void ska_ecs_system_destroy(SkaECSSystem* entitySystem) {

void ska_ecs_system_register(SkaECSSystem* system) {
SE_ASSERT_FMT(system != NULL, "Passed in system is NULL!");
SE_ASSERT_FMT(entitySystemData.entity_systems_count + 1 < SKA_ECS_MAX_COMPONENTS, "At system limit of '%d'", SKA_ECS_MAX_COMPONENTS);
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) {
SE_ASSERT_FMT(entitySystemData.on_entity_start_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'on_entity_start_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.on_entity_start_systems[entitySystemData.on_entity_start_systems_count++] = system;
}
if (system->on_entity_end_func != NULL) {
SE_ASSERT_FMT(entitySystemData.on_entity_end_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'on_entity_end_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.on_entity_end_systems[entitySystemData.on_entity_end_systems_count++] = system;
}
if (system->on_entity_entered_scene_func != NULL) {
SE_ASSERT_FMT(entitySystemData.on_entity_entered_scene_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'on_entity_entered_scene_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.on_entity_entered_scene_systems[entitySystemData.on_entity_entered_scene_systems_count++] = system;
}
if (system->render_func != NULL) {
SE_ASSERT_FMT(entitySystemData.render_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'render_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.render_systems[entitySystemData.render_systems_count++] = system;
}
if (system->pre_update_all_func != NULL) {
SE_ASSERT_FMT(entitySystemData.pre_update_all_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'pre_update_all_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.pre_update_all_systems[entitySystemData.pre_update_all_systems_count++] = system;
}
if (system->post_update_all_func != NULL) {
SE_ASSERT_FMT(entitySystemData.post_update_all_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'post_update_all_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.post_update_all_systems[entitySystemData.post_update_all_systems_count++] = system;
}
if (system->update_func != NULL) {
SE_ASSERT_FMT(entitySystemData.update_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'update_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.update_systems[entitySystemData.update_systems_count++] = system;
}
if (system->fixed_update_func != NULL) {
SE_ASSERT_FMT(entitySystemData.fixed_update_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'fixed_update_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.fixed_update_systems[entitySystemData.fixed_update_systems_count++] = system;
}
if (system->network_callback_func != NULL) {
SE_ASSERT_FMT(entitySystemData.network_callback_systems_count + 1 < MAX_ENTITY_SYSTEMS_PER_HOOK, "At system 'network_callback_func' limit of '%d'", MAX_ENTITY_SYSTEMS_PER_HOOK);
entitySystemData.network_callback_systems[entitySystemData.network_callback_systems_count++] = system;
}
}
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.40",
"version": "0.0.41",
"dependencies": [
{
"name": "sdl2",
Expand Down

0 comments on commit 6dea426

Please sign in to comment.