diff --git a/game/ai_actions.c b/game/ai_actions.c index 312beb0..68d99d4 100644 --- a/game/ai_actions.c +++ b/game/ai_actions.c @@ -17,8 +17,10 @@ float shortestArc(float a, float b) { BzBTStatus aiMoveTo(AIBlackboard *data, f32 dt) { Game *game = ecs_singleton_get_mut(ECS, Game); const Vector2 pos = *ecs_get(ECS, data->entity, Position); + const HitBox hb = *ecs_get(ECS, data->entity, HitBox); const Vector2 target = data->moveToPos; - f32 dst = Vector2Distance(pos, target); + Vector2 center = entityGetCenter(pos, hb); + f32 dst = Vector2Distance(center, target); if (dst < data->proximity) { ecs_remove(ECS, data->entity, Path); return BZ_BT_SUCCESS; @@ -31,7 +33,7 @@ BzBTStatus aiMoveTo(AIBlackboard *data, f32 dt) { if (ecs_has(ECS, data->entity, Orientation)) { Orientation *orientation = ecs_get_mut(ECS, data->entity, Orientation); f32 currentAngle = *orientation; - f32 targetAngle = Vector2Angle(pos, target); + f32 targetAngle = Vector2Angle(center, target); f32 dif = shortestArc(currentAngle, targetAngle); dif = Clamp(dif, -1, 1) * dt * 10; *orientation += dif; diff --git a/game/map_init.c b/game/map_init.c index f65d2a4..16293f7 100644 --- a/game/map_init.c +++ b/game/map_init.c @@ -383,7 +383,7 @@ void loadMap(Game *game, const char *path, bool mainMenu) { .harvestTarget = nearest.entity, .harvestPos = nearest.pos }, - .proximity = 8.0f, + .proximity = 4.0f, }); Worker *worker = ecs_get_mut(ECS, workers[i].entity, Worker); worker->carryRes = resType; diff --git a/game/systems/s_ai.c b/game/systems/s_ai.c index ae51fe2..41f2898 100644 --- a/game/systems/s_ai.c +++ b/game/systems/s_ai.c @@ -41,8 +41,8 @@ void setAIBehaviour(ecs_entity_t entity, const BzBTNode *root, if (blackboard) { AIBlackboard *b = ecs_get_mut(ECS, entity, AIBlackboard); *b = *blackboard; - if (b->proximity < 4.0f) - b->proximity = 4.0f; + if (b->proximity < 2.0f) + b->proximity = 2.0f; } BzBTState *state = ecs_get_mut(ECS, entity, BzBTState); diff --git a/game/systems/s_input.c b/game/systems/s_input.c index 9b2f97d..a164dae 100644 --- a/game/systems/s_input.c +++ b/game/systems/s_input.c @@ -155,10 +155,10 @@ void inputUnitAction(Game *game, InputState *input) { if (!hasNext) break; Position target = *ecs_get(ECS, harvestEntity, Position); + HitBox targetHB = *ecs_get(ECS, harvestEntity, HitBox); + target = entityGetCenter(target, targetHB); - f32 proximity = 8.0f; - if (resource.type == RES_FOOD) - proximity = 2.0f; + f32 proximity = 4.0f; Worker *worker = ecs_get_mut(ECS, entity, Worker); worker->carryRes = resource.type;