diff --git a/include/QF/scene/scene.h b/include/QF/scene/scene.h index c589d9c62..17b06647c 100644 --- a/include/QF/scene/scene.h +++ b/include/QF/scene/scene.h @@ -77,7 +77,13 @@ typedef struct scene_s { struct lightingdata_s *lights; } scene_t; -scene_t *Scene_NewScene (void); +typedef struct scene_system_s { + struct ecs_system_s *system; + const struct component_s *components; + uint32_t component_count; +} scene_system_t; + +scene_t *Scene_NewScene (scene_system_t *extra_systems); void Scene_DeleteScene (scene_t *scene); struct entity_s Scene_CreateEntity (scene_t *scene); void Scene_DestroyEntity (scene_t *scene, struct entity_s entity); diff --git a/libs/client/cl_world.c b/libs/client/cl_world.c index 5a30e89b9..d2cfe2cee 100644 --- a/libs/client/cl_world.c +++ b/libs/client/cl_world.c @@ -64,7 +64,7 @@ worldscene_t cl_world = { void CL_World_Init (void) { - cl_world.scene = Scene_NewScene (); + cl_world.scene = Scene_NewScene (0); cl_world.scene->lights = Light_CreateLightingData (cl_world.scene); } diff --git a/libs/console/cl_debug.c b/libs/console/cl_debug.c index 285e2f150..3380940b6 100644 --- a/libs/console/cl_debug.c +++ b/libs/console/cl_debug.c @@ -293,7 +293,7 @@ Con_Debug_Init (void) IMUI_SetVisible (debug_imui, con_debug); IMUI_Style_Fetch (debug_imui, ¤t_style); - debug_scene = Scene_NewScene (); + debug_scene = Scene_NewScene (0); } void diff --git a/libs/ruamoko/rua_scene.c b/libs/ruamoko/rua_scene.c index e0a8a023a..6d38fd98b 100644 --- a/libs/ruamoko/rua_scene.c +++ b/libs/ruamoko/rua_scene.c @@ -199,7 +199,7 @@ bi_Scene_NewScene (progs_t *pr, void *_res) rua_scene_t *scene = rua_scene_new (res); - scene->scene = Scene_NewScene (); + scene->scene = Scene_NewScene (0); scene->next = res->scenes; if (res->scenes) { diff --git a/libs/scene/scene.c b/libs/scene/scene.c index 841953fcb..121bbf1da 100644 --- a/libs/scene/scene.c +++ b/libs/scene/scene.c @@ -253,12 +253,19 @@ static model_t empty_world = { }; scene_t * -Scene_NewScene (void) +Scene_NewScene (scene_system_t *extra_systems) { scene_t *scene = calloc (1, sizeof (scene_t)); scene->reg = ECS_NewRegistry (); ECS_RegisterComponents (scene->reg, scene_components, scene_comp_count); + for (auto extra = extra_systems; extra && extra->system; extra++) { + uint32_t base = ECS_RegisterComponents (scene->reg, + extra->components, + extra->component_count); + extra->system->reg = scene->reg; + extra->system->base = base; + } ECS_CreateComponentPools (scene->reg); scene->worldmodel = &empty_world;