Implement harvest worker AI
This commit is contained in:
@@ -2,7 +2,10 @@
|
||||
|
||||
#include "game_state.h"
|
||||
|
||||
void updateUnitActions(ecs_iter_t *it) {
|
||||
#include "unit_ai.h"
|
||||
#include "unit_actions.h"
|
||||
|
||||
void handleUnitActionsSystem(ecs_iter_t *it) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
UnitAction *action = ecs_field(it, UnitAction, 1);
|
||||
|
||||
@@ -11,3 +14,31 @@ void updateUnitActions(ecs_iter_t *it) {
|
||||
handleAction(entity, &action[i], game);
|
||||
}
|
||||
}
|
||||
|
||||
void updateUnitAISystem(ecs_iter_t *it) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
UnitAI *unitAI = ecs_field(it, UnitAI, 1);
|
||||
UnitAction *action = ecs_field(it, UnitAction, 2);
|
||||
|
||||
for (i32 i = 0; i < it->count; i++) {
|
||||
ecs_entity_t entity = it->entities[i];
|
||||
|
||||
Action *firstAction = action[i].first;
|
||||
if (firstAction)
|
||||
unitAI[i].action = firstAction;
|
||||
else
|
||||
unitAI[i].action = NULL;
|
||||
|
||||
updateUnitAI(entity, &unitAI[i], game);
|
||||
}
|
||||
}
|
||||
|
||||
void updateUnitActionsSystem(ecs_iter_t *it) {
|
||||
Game *game = ecs_singleton_get_mut(ECS, Game);
|
||||
UnitAction *action = ecs_field(it, UnitAction, 1);
|
||||
|
||||
for (i32 i = 0; i < it->count; i++) {
|
||||
ecs_entity_t entity = it->entities[i];
|
||||
updateAction(&action[i], game);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user