Move flecs out of engine, reorganize systems
This commit is contained in:
23
game/main.c
23
game/main.c
@@ -12,6 +12,8 @@
|
||||
|
||||
ECS_COMPONENT_DECLARE(Game);
|
||||
|
||||
ecs_world_t *ECS = NULL;
|
||||
|
||||
bool init(void *userData);
|
||||
void deinit(void *userData);
|
||||
|
||||
@@ -33,14 +35,15 @@ bool bzMain(BzAppDesc *appDesc, int argc, const char **argv) {
|
||||
appDesc->imguiRender = (BzAppRenderFunc) imguiRender;
|
||||
|
||||
appDesc->userData = NULL;
|
||||
appDesc->useFlecs = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool init(void *userData) {
|
||||
BZ_UNUSED(userData);
|
||||
SetExitKey(-1);
|
||||
SetExitKey(KEY_ESCAPE);
|
||||
|
||||
ECS = ecs_init();
|
||||
|
||||
ECS_COMPONENT_DEFINE(ECS, Game);
|
||||
initComponentIDs(ECS);
|
||||
|
||||
@@ -114,12 +117,10 @@ bool init(void *userData) {
|
||||
bzTileMapOverrideObjectGroup(&game->map, OBJECTS_GAME, initGameObjectsLayer);
|
||||
bzTileMapOverrideObjectGroup(&game->map, OBJECTS_ENTITIES, initEntityObjectsLayer);
|
||||
|
||||
ECS_SYSTEM(ECS, uiTask, EcsOnUpdate, 0);
|
||||
ECS_SYSTEM(ECS, updateAnimations, EcsOnUpdate, Animation, TextureRegion);
|
||||
ECS_SYSTEM(ECS, updatePos, EcsOnUpdate, Position, TargetPosition, TextureRegion);
|
||||
ECS_SYSTEM(ECS, entityUpdatePhysics, EcsOnUpdate, Position, Size, SpatialGridID);
|
||||
ECS_OBSERVER(ECS, entitySpatialRemoved, EcsOnRemove, Position, SpatialGridID);
|
||||
ECS_OBSERVER(ECS, pathRemoved, EcsOnRemove, Path);
|
||||
|
||||
ECS_SYSTEM(ECS, drawDebugPath, EcsOnUpdate, Path);
|
||||
ECS_SYSTEM(ECS, renderDebugPath, EcsOnUpdate, Path);
|
||||
|
||||
ECS_SYSTEM(ECS, renderTerrain, EcsOnUpdate, Position, Size, Rotation, TextureRegion, TextureTerrain);
|
||||
ECS_SYSTEM(ECS, renderBuildings, EcsOnUpdate, Position, Size, Rotation, TextureRegion, TextureBuildings);
|
||||
@@ -127,8 +128,6 @@ bool init(void *userData) {
|
||||
|
||||
ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, Size);
|
||||
|
||||
ECS_OBSERVER(ECS, targetFinish, EcsOnRemove, TargetPosition);
|
||||
ECS_OBSERVER(ECS, startPath, EcsOnSet, Path);
|
||||
return true;
|
||||
}
|
||||
void deinit(void *userData) {
|
||||
@@ -140,11 +139,11 @@ void deinit(void *userData) {
|
||||
bzTilesetDestroy(&game->buildingsTileset);
|
||||
bzTilesetDestroy(&game->entitiesTileset);
|
||||
|
||||
ecs_fini(ECS);
|
||||
ECS = NULL;
|
||||
|
||||
bzObjectPoolDestroy(game->pools.pathData);
|
||||
bzSpatialGridDestroy(game->entityGrid);
|
||||
|
||||
ecs_singleton_remove(ECS, Game);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user