Move systems into subdirectory, add tree shake animation
This commit is contained in:
19
game/main.c
19
game/main.c
@@ -4,7 +4,7 @@
|
||||
#include <raymath.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "systems.h"
|
||||
#include "systems/systems.h"
|
||||
#include "components.h"
|
||||
#include "game_state.h"
|
||||
#include "game_tileset.h"
|
||||
@@ -228,9 +228,10 @@ bool init(void *userData) {
|
||||
ecs_set_hooks(ECS, Path, {
|
||||
.dtor = ecs_dtor(Path)
|
||||
});
|
||||
ECS_OBSERVER(ECS, entityPathRemove, EcsOnRemove, Path);
|
||||
|
||||
//ECS_OBSERVER(ECS, entitySetAnimationState, EcsOnSet, Animation, AnimationType);
|
||||
//setupSystems(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);
|
||||
@@ -238,14 +239,14 @@ 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, 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, entityUpdateAnimationState, EcsOnUpdate, Animation, TextureRegion);
|
||||
ECS_SYSTEM(ECS, entityUpdateAnimation, EcsOnUpdate, Animation, TextureRegion);
|
||||
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);
|
||||
|
||||
@@ -348,7 +349,9 @@ static void renderGame(Game *game, float dt) {
|
||||
TextureRegion *t = ecs_field(&it, TextureRegion, 4);
|
||||
for (i32 i = 0; i < it.count; i++) {
|
||||
Rectangle dst = {p[i].x, p[i].y, s[i].x, s[i].y};
|
||||
Vector2 origin = {dst.width * 0.5f, dst.height * 0.5f};
|
||||
Vector2 origin = {dst.width * 0.5f, dst.height};
|
||||
dst.x += origin.x - dst.width * 0.5f;
|
||||
dst.y += origin.y - dst.height * 0.5f;
|
||||
Rectangle src = t[i].rec;
|
||||
if (t[i].flipX) src.width *= -1.0f;
|
||||
if (t[i].flipY) src.height *= -1.0f;
|
||||
@@ -357,7 +360,7 @@ static void renderGame(Game *game, float dt) {
|
||||
.src = src,
|
||||
.dst = dst,
|
||||
.origin = origin,
|
||||
.rotation = t[i].rotation
|
||||
.rotation = r[i]
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user