#include "systems.h" #include "../game_state.h" ecs_entity_t renderCollidersSystem; ecs_entity_t renderOrientDirSystem; ecs_entity_t renderArmPositionSystem; ecs_entity_t renderDebugPathSystem; ECS_DTOR(SpatialGridID, gridID, { Game *game = ecs_singleton_get_mut(ECS, Game); bzSpatialGridRemove(game->entityGrid, *gridID); }) ECS_MOVE(SpatialGridID, dst, src, { *dst = *src; }) ECS_DTOR(Path, path, { Game *game = ecs_singleton_get_mut(ECS, Game); BzObjectPool *pool = game->pools.pathData; PathData *cur = path[i].paths; while (cur) { bzObjectPoolRelease(pool, cur); cur = cur->next; } }) ECS_MOVE(Path, dst, src, { *dst = *src; }) ECS_DTOR(Arms, arms, { if (arms->primary) ecs_delete(ECS, arms->primary); if (arms->secondary) ecs_delete(ECS, arms->secondary); }); void setupSystems() { ecs_set_hooks(ECS, SpatialGridID, { .dtor = ecs_dtor(SpatialGridID), .move_dtor = ecs_move(SpatialGridID) }); ecs_set_hooks(ECS, Path, { .dtor = ecs_dtor(Path), .move_dtor = ecs_move(Path) }); ecs_set_hooks(ECS, Arms, { .dtor = ecs_dtor(Arms) }); ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path); ECS_SYSTEM(ECS, entityUpdateSpatialID, EcsOnUpdate, Position, Size, Velocity, SpatialGridID); ECS_SYSTEM(ECS, entityUpdateKinematic, EcsOnUpdate, Position, Velocity, Steering, Unit); ECS_SYSTEM(ECS, entityMoveToTarget, EcsOnUpdate, Position, Velocity, TargetPosition, Steering); ECS_SYSTEM(ECS, entityFollowPath, EcsOnUpdate, Path); ECS_SYSTEM(ECS, entityUpdateArms, EcsOnUpdate, Position, Velocity, Rotation, Orientation, Arms); ECS_SYSTEM(ECS, handleUnitActionsSystem, EcsOnUpdate, UnitAction); ECS_SYSTEM(ECS, updateUnitAISystem, EcsOnUpdate, UnitAI, UnitAction); // Needs to be called after AI update, since it removes finished actions ECS_SYSTEM(ECS, updateUnitActionsSystem, EcsOnUpdate, UnitAction); ECS_SYSTEM(ECS, updateAnimationState, EcsOnUpdate, Animation, TextureRegion); ECS_SYSTEM(ECS, updateAnimation, EcsOnUpdate, Animation, TextureRegion); ECS_SYSTEM(ECS, updateEasingSystem, EcsOnUpdate, Easing, Position, Size, Rotation); ECS_SYSTEM(ECS, renderDebugPath, EcsOnUpdate, Path); ECS_SYSTEM(ECS, renderColliders, EcsOnUpdate, Position, Size); ECS_SYSTEM(ECS, renderOrientationDirection, EcsOnUpdate, Position, Orientation); ECS_SYSTEM(ECS, renderArmPosition, EcsOnUpdate, Position, Arm); renderDebugPathSystem = renderDebugPath; renderOrientDirSystem = renderOrientationDirection; renderArmPositionSystem = renderArmPosition; renderCollidersSystem = renderColliders; //ecs_enable(ECS, renderOrientDirSystem, false); //ecs_enable(ECS, renderArmPositionSystem, false); }