mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-06 00:49:14 +07:00
More misc pathfinding improvements
This commit is contained in:
parent
7536bbfeb0
commit
95609a90be
@ -263,6 +263,8 @@ public class ControlPathfinder{
|
||||
|
||||
req.pathIndex = Math.max(dst <= range * range ? i + 1 : i, req.pathIndex);
|
||||
minDst = Math.min(dst, minDst);
|
||||
}else if(dst <= 1f){
|
||||
req.pathIndex = Math.min(Math.max(i + 1, req.pathIndex), len - 1);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,7 +17,7 @@ import mindustry.world.meta.*;
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class CommandAI extends AIController{
|
||||
protected static final int maxCommandQueueSize = 50, avoidInterval = 5;
|
||||
protected static final int maxCommandQueueSize = 50, avoidInterval = 10;
|
||||
protected static final Vec2 vecOut = new Vec2(), vecMovePos = new Vec2();
|
||||
protected static final boolean[] noFound = {false};
|
||||
|
||||
@ -223,14 +223,20 @@ public class CommandAI extends AIController{
|
||||
ControlPathfinder.isNearObstacle(unit, unit.tileX(), unit.tileY(), u.tileX(), u.tileY()));
|
||||
}
|
||||
|
||||
float maxBlockTime = 60f * 5f;
|
||||
|
||||
if(blockingUnit){
|
||||
timeSpentBlocked += Time.delta;
|
||||
|
||||
if(timeSpentBlocked >= maxBlockTime*2f){
|
||||
timeSpentBlocked = 0f;
|
||||
}
|
||||
}else{
|
||||
timeSpentBlocked = 0f;
|
||||
}
|
||||
|
||||
//if you've spent 3 seconds stuck, something is wrong, move regardless
|
||||
move = Vars.controlPath.getPathPosition(unit, pathId, vecMovePos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > 60f * 3f);
|
||||
move = Vars.controlPath.getPathPosition(unit, pathId, vecMovePos, vecOut, noFound) && (!blockingUnit || timeSpentBlocked > maxBlockTime);
|
||||
//we've reached the final point if the returned coordinate is equal to the supplied input
|
||||
isFinalPoint &= vecMovePos.epsilonEquals(vecOut, 4.1f);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user