Add actions

This commit is contained in:
2023-12-17 09:06:14 +01:00
parent 5c1859cf1b
commit 4f2ac9a0eb
14 changed files with 213 additions and 31 deletions

View File

@@ -108,8 +108,12 @@ bool init(void *userData) {
game->stackAlloc = bzStackAllocCreate(10 * 1000 * 1000); // 10 MB
// init pools
game->pools.pathData = bzObjectPoolCreate(&(BzObjectPoolDesc) {
.objectSize=sizeof(PathData),
.objectsPerPage=512
.objectSize = sizeof(PathData),
.objectsPerPage = 512
});
game->pools.actions = bzObjectPoolCreate(&(BzObjectPoolDesc) {
.objectSize = sizeof(UnitAction),
.objectsPerPage = 1024,
});
@@ -171,7 +175,8 @@ bool init(void *userData) {
ECS_SYSTEM(ECS, entityMoveToTarget, EcsOnUpdate, Position, Rotation, Velocity, TargetPosition, Steering);
ECS_SYSTEM(ECS, entityFollowPath, EcsOnUpdate, Path);
ECS_SYSTEM(ECS, entityHarvestTaskSystem, EcsOnUpdate, Position, Rotation, HarvestTask);
//ECS_SYSTEM(ECS, entityHarvestTaskSystem, EcsOnUpdate, Position, Rotation, HarvestTask);
ECS_SYSTEM(ECS, updateUnitActions, EcsOnUpdate, UnitAction);
//ECS_SYSTEM(ECS, entityUpdateAnimationState, EcsOnUpdate, Velocity, AnimationType);
ECS_SYSTEM(ECS, entityUpdateAnimation, EcsOnUpdate, Animation, TextureRegion);
@@ -213,6 +218,7 @@ void deinit(void *userData) {
bzStackAllocDestroy(&gameCopy.stackAlloc);
bzObjectPoolDestroy(gameCopy.pools.pathData);
bzObjectPoolDestroy(gameCopy.pools.actions);
bzSpatialGridDestroy(gameCopy.entityGrid);
}
@@ -271,7 +277,8 @@ void imguiRender(float dt, void *userData) {
createWorker((Position) {1100, 400}, (Size) {10, 10}, game->entityGrid,
&game->map.tilesets[2], 1322);
}
igText("Num paths from pool available: %llu", bzObjectPoolGetNumFree(game->pools.pathData));
igText("PathData pool available: %llu", bzObjectPoolGetNumFree(game->pools.pathData));
igText("Action pool available: %llu", bzObjectPoolGetNumFree(game->pools.actions));
const char *inputState = "NONE";
switch (input->state) {
case INPUT_NONE: