diff --git a/game/map_init.c b/game/map_init.c index 9a3c1eb..f65d2a4 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 = 3.0f, + .proximity = 8.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 41f2898..ae51fe2 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 < 2.0f) - b->proximity = 2.0f; + if (b->proximity < 4.0f) + b->proximity = 4.0f; } BzBTState *state = ecs_get_mut(ECS, entity, BzBTState); diff --git a/game/systems/s_entity.c b/game/systems/s_entity.c index 02c5e21..e68c4b2 100644 --- a/game/systems/s_entity.c +++ b/game/systems/s_entity.c @@ -239,14 +239,16 @@ void entityUpdate(ecs_iter_t *it) { void entityMoveToTarget(ecs_iter_t *it) { Position *position = ecs_field(it, Position, 1); - Velocity *velocity = ecs_field(it, Velocity, 2); + HitBox *hitbox = ecs_field(it, HitBox, 2); + Velocity *velocity = ecs_field(it, Velocity, 3); - TargetPosition *targetPos = ecs_field(it, TargetPosition, 3); - Steering *steering = ecs_field(it, Steering, 4); + TargetPosition *targetPos = ecs_field(it, TargetPosition, 4); + Steering *steering = ecs_field(it, Steering, 5); for (i32 i = 0; i < it->count; i++) { Position target = targetPos[i]; - steering[i] = Vector2Subtract(target, position[i]); + Vector2 center = entityGetCenter(position[i], hitbox[i]); + steering[i] = Vector2Subtract(target, center); f32 dst = Vector2LengthSqr(steering[i]); if (dst < 2.0f) { diff --git a/game/systems/s_input.c b/game/systems/s_input.c index 96bd5ce..9b2f97d 100644 --- a/game/systems/s_input.c +++ b/game/systems/s_input.c @@ -156,7 +156,7 @@ void inputUnitAction(Game *game, InputState *input) { if (!hasNext) break; Position target = *ecs_get(ECS, harvestEntity, Position); - f32 proximity = 6.0f; + f32 proximity = 8.0f; if (resource.type == RES_FOOD) proximity = 2.0f; diff --git a/game/systems/systems.c b/game/systems/systems.c index cf5bf78..6bfe491 100644 --- a/game/systems/systems.c +++ b/game/systems/systems.c @@ -180,7 +180,7 @@ void setupSystems() { ECS_SYSTEM(ECS, entityUpdateKinematic, EcsOnUpdate, Position, Velocity, Steering, Unit); ECS_SYSTEM(ECS, entityUpdate, EcsOnUpdate, Position, HitBox, Velocity, Unit, Owner, SpatialGridID); - ECS_SYSTEM(ECS, entityMoveToTarget, EcsOnUpdate, Position, Velocity, TargetPosition, Steering); + ECS_SYSTEM(ECS, entityMoveToTarget, EcsOnUpdate, Position, HitBox, Velocity, TargetPosition, Steering); ECS_SYSTEM(ECS, entityMoveSwarm, EcsOnUpdate, Position, Velocity, HitBox, Swarm, Owner, Steering); ECS_SYSTEM(ECS, entityFollowPath, EcsOnUpdate, Path); diff --git a/game/systems/systems.h b/game/systems/systems.h index 092910d..4ed71ab 100644 --- a/game/systems/systems.h +++ b/game/systems/systems.h @@ -137,9 +137,10 @@ void entityUpdate(ecs_iter_t *it); /* * 1: Position - * 2: Velocity - * 3: TargetPosition - * 4: Steering + * 2: HitBox + * 3: Velocity + * 4: TargetPosition + * 5: Steering */ void entityMoveToTarget(ecs_iter_t *it);