Move systems into subdirectory, add tree shake animation
This commit is contained in:
28
game/systems/s_event.c
Normal file
28
game/systems/s_event.c
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user