Implement harvest worker AI

This commit is contained in:
2023-12-17 14:20:13 +01:00
parent 5564df4768
commit 33b28b620d
14 changed files with 338 additions and 40 deletions

View File

@@ -3,6 +3,9 @@
#include "input.h"
#include "buildings.h"
#include "pathfinding.h"
#include "unit_ai.h"
#include "unit_actions.h"
#include <rlImGui.h>
#include <raymath.h>
#include <rlgl.h>
@@ -84,11 +87,17 @@ void inputUnitAction(Game *game, InputState *input) {
for (i32 i = 0; i < it.count; i++) {
const ecs_entity_t entity = it.entities[i];
const Position target = *ecs_get(ECS, taskEntity, Position);
addAction(entity, game, &(const Action) {
.type = ACTION_MOVE_TO,
.as.moveTo.target = target,
.as.moveTo.proximityThreshold = 10.0f,
setUnitAI(entity, game, &(const UnitAI) {
.type = AI_WORKER_HARVEST,
.as.workerHarvest.resource = RES_WOOD,
.as.workerHarvest.target = taskEntity,
.as.workerHarvest.targetPosition = target
});
//addAction(entity, game, &(const Action) {
// .type = ACTION_MOVE_TO,
// .as.moveTo.target = target,
// .as.moveTo.proximityThreshold = 10.0f,
//});
//ecs_set(ECS, entity, HarvestTask, {taskEntity});
goto while_break;
}