Fix and integrate BT
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include "../input.h"
|
||||
#include "../buildings.h"
|
||||
#include "../pathfinding.h"
|
||||
#include "../unit_ai.h"
|
||||
#include "../unit_actions.h"
|
||||
|
||||
#include <rlImGui.h>
|
||||
#include <raymath.h>
|
||||
@@ -92,12 +90,22 @@ 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);
|
||||
setAIBehaviour(entity, game->BTs.workerHarvest, &(AIBlackboard) {
|
||||
.as.worker = {
|
||||
.harvestType = RES_WOOD,
|
||||
.harvestTarget = taskEntity,
|
||||
.harvestPos = target,
|
||||
},
|
||||
.proximity = 6.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,
|
||||
@@ -128,12 +136,18 @@ void inputUnitAction(Game *game, InputState *input) {
|
||||
while (ecs_iter_next(&it)) {
|
||||
for (i32 i = 0; i < it.count; i++) {
|
||||
const ecs_entity_t entity = it.entities[i];
|
||||
setAIBehaviour(entity, game->BTs.moveTo, &(AIBlackboard) {
|
||||
.moveToPos = target,
|
||||
.proximity = 6.0f,
|
||||
});
|
||||
/*
|
||||
clearActions(entity, game);
|
||||
addAction(entity, game, &(const Action) {
|
||||
.type = ACTION_MOVE_TO,
|
||||
.as.moveTo.target = target,
|
||||
.as.moveTo.proximityThreshold = 6.0f,
|
||||
});
|
||||
*/
|
||||
}
|
||||
}
|
||||
ecs_defer_end(ECS);
|
||||
|
||||
Reference in New Issue
Block a user