Move systems into subdirectory, add tree shake animation

This commit is contained in:
2023-12-29 14:46:11 +01:00
parent aa3bfbf823
commit 31a9289770
15 changed files with 352 additions and 105 deletions

View File

@@ -3,7 +3,7 @@
#include <flecs.h>
#include "components.h"
#include "../components.h"
typedef struct Game Game;
@@ -36,6 +36,30 @@ void updateUnitAISystem(ecs_iter_t *it);
*/
void updateUnitActionsSystem(ecs_iter_t *it);
/*
* 1: Easing
* 2: Position
* 3: Size
* 4: Rotation
*/
void updateEasingSystem(ecs_iter_t *it);
/**********************************
* Animation Systems
**********************************/
/*
* 1: Animation
* 2: TextureRegion
*/
void updateAnimationState(ecs_iter_t *it);
/*
* 0:
* 1: Animation
* 2: TextureRegion
*/
void updateAnimation(ecs_iter_t *it);
/**********************************
* Entity Systems
@@ -81,19 +105,6 @@ void entityMoveToTarget(ecs_iter_t *it);
void entityFollowPath(ecs_iter_t *it);
/*
* 1: Animation
* 2: TextureRegion
*/
void entityUpdateAnimationState(ecs_iter_t *it);
/*
* 0:
* 1: Animation
* 2: TextureRegion
*/
void entityUpdateAnimation(ecs_iter_t *it);
/*
* 1: Position
* 2: Size
@@ -147,4 +158,33 @@ void drawPlayerInputUI();
* UI systems
**********************************/
/**********************************
* MISC
**********************************/
static void setupSystems(ecs_world_t *ecs) {
ECS_OBSERVER(ecs, entityPathRemove, EcsOnRemove, Path);
ECS_SYSTEM(ecs, entityUpdateSpatialID, EcsOnUpdate, Position, Size, Velocity, SpatialGridID);
ECS_SYSTEM(ecs, entityUpdateKinematic, EcsOnUpdate, Position, Rotation, Velocity, Steering);
ECS_SYSTEM(ecs, entityMoveToTarget, EcsOnUpdate, Position, Rotation, Velocity, TargetPosition, Steering);
ECS_SYSTEM(ecs, entityFollowPath, EcsOnUpdate, Path);
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, renderRotationDirection, EcsOnUpdate, Position, Rotation);
}
#endif //PIXELDEFENSE_SYSTEMS_H