More misc pathfinding improvements
This commit is contained in:
@@ -263,6 +263,8 @@ public class ControlPathfinder{
|
|||||||
|
|
||||||
req.pathIndex = Math.max(dst <= range * range ? i + 1 : i, req.pathIndex);
|
req.pathIndex = Math.max(dst <= range * range ? i + 1 : i, req.pathIndex);
|
||||||
minDst = Math.min(dst, minDst);
|
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.*;
|
import static mindustry.Vars.*;
|
||||||
|
|
||||||
public class CommandAI extends AIController{
|
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 Vec2 vecOut = new Vec2(), vecMovePos = new Vec2();
|
||||||
protected static final boolean[] noFound = {false};
|
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()));
|
ControlPathfinder.isNearObstacle(unit, unit.tileX(), unit.tileY(), u.tileX(), u.tileY()));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float maxBlockTime = 60f * 5f;
|
||||||
|
|
||||||
if(blockingUnit){
|
if(blockingUnit){
|
||||||
timeSpentBlocked += Time.delta;
|
timeSpentBlocked += Time.delta;
|
||||||
|
|
||||||
|
if(timeSpentBlocked >= maxBlockTime*2f){
|
||||||
|
timeSpentBlocked = 0f;
|
||||||
|
}
|
||||||
}else{
|
}else{
|
||||||
timeSpentBlocked = 0f;
|
timeSpentBlocked = 0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
//if you've spent 3 seconds stuck, something is wrong, move regardless
|
//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
|
//we've reached the final point if the returned coordinate is equal to the supplied input
|
||||||
isFinalPoint &= vecMovePos.epsilonEquals(vecOut, 4.1f);
|
isFinalPoint &= vecMovePos.epsilonEquals(vecOut, 4.1f);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user