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

28
game/systems/s_event.c Normal file
View File

@@ -0,0 +1,28 @@
#include "systems.h"
#include "../game_state.h"
i32 harvestEvent(ecs_entity_t entity, HarvestEvent event) {
BZ_ASSERT(ecs_has_id(ECS, entity, Harvestable));
BZ_ASSERT(ecs_has(ECS, entity, Resource));
ecs_set(ECS, entity, Easing, {
.type = EASE_ROTATION,
.easingFunc = BZ_EASE_OUT_ELASTIC,
.duration = 0.4f,
// 45 * (1.0f + (-1.0f) * x)
.target = 45,
.easeTarget = -1.0f,
.easeStart = 1.0f
});
Resource *res = ecs_get_mut(ECS, entity, Resource);
event.amount = BZ_MIN(event.amount, res->amount);
res->amount -= event.amount;
if (res->amount <= 0)
ecs_delete(ECS, entity);
return event.amount;
}