Add gold mining
This commit is contained in:
@@ -82,41 +82,37 @@ void inputUnitAction(Game *game, InputState *input) {
|
||||
input->cursor = CURSOR_NONE;
|
||||
ecs_entity_t taskEntity;
|
||||
if ((taskEntity = queryEntity(game->entityGrid, input->mouseWorld, Harvestable))) {
|
||||
input->cursor = CURSOR_COLLECT_WOOD;
|
||||
Resource resource = *ecs_get(ECS, taskEntity, Resource);
|
||||
switch (resource.type) {
|
||||
case RES_WOOD:
|
||||
input->cursor = CURSOR_COLLECT_WOOD;
|
||||
break;
|
||||
case RES_GOLD:
|
||||
input->cursor = CURSOR_COLLECT_GOLD;
|
||||
break;
|
||||
case RES_FOOD:
|
||||
//input->cursor = CURSOR_COLLECT_FOOD;
|
||||
break;
|
||||
default:;
|
||||
}
|
||||
if (isInputBtnJustUp(input, actionBtn)) {
|
||||
ecs_defer_begin(ECS);
|
||||
ecs_iter_t it = ecs_query_iter(ECS, query);
|
||||
while (ecs_query_next(&it)) {
|
||||
for (i32 i = 0; i < it.count; i++) {
|
||||
const ecs_entity_t entity = it.entities[i];
|
||||
const Position target = *ecs_get(ECS, taskEntity, Position);
|
||||
ecs_entity_t entity = it.entities[i];
|
||||
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,
|
||||
.as.worker = {
|
||||
.harvestType = resource.type,
|
||||
.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,
|
||||
// .as.moveTo.proximityThreshold = 10.0f,
|
||||
//});
|
||||
//ecs_set(ECS, entity, HarvestTask, {taskEntity});
|
||||
goto while_break;
|
||||
}
|
||||
}
|
||||
while_break:
|
||||
ecs_iter_fini(&it);
|
||||
ecs_defer_end(ECS);
|
||||
}
|
||||
return;
|
||||
@@ -348,6 +344,12 @@ void drawPlayerInputUI() {
|
||||
DrawText("Collect wood", point.x, point.y, 10.0f, RED);
|
||||
break;
|
||||
}
|
||||
case CURSOR_COLLECT_GOLD: {
|
||||
const Vector2 point = input->mouseWorld;
|
||||
DrawCircle(point.x, point.y, 2.0f, RED);
|
||||
DrawText("Collect gold", point.x, point.y, 10.0f, RED);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user