Pathfinding recalculation improvements

This commit is contained in:
Anuken
2022-02-12 23:36:57 -05:00
parent cb86156b49
commit 3039a404eb
3 changed files with 14 additions and 14 deletions

View File

@@ -430,7 +430,7 @@ public class ControlPathfinder{
int rayPathIndex = -1;
IntSeq result = new IntSeq();
float raycastTimer;
volatile float raycastTimer;
PathfindQueue frontier = new PathfindQueue();
//node index -> node it came from
@@ -451,7 +451,7 @@ public class ControlPathfinder{
void update(long maxUpdateNs){
if(curId != lastId){
clear();
clear(true);
}
lastId = curId;
@@ -459,10 +459,7 @@ public class ControlPathfinder{
if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){
lastTime = Time.millis();
lastWorldUpdate = worldUpdateId;
pathIndex = 0;
rayPathIndex = -1;
result.clear();
clear();
clear(false);
}
if(done) return;
@@ -512,8 +509,12 @@ public class ControlPathfinder{
}
lastTime = Time.millis();
raycastTimer = 9999f;
result.clear();
pathIndex = 0;
rayPathIndex = -1;
if(foundEnd){
int cur = goal;
while(cur != start){
@@ -549,7 +550,7 @@ public class ControlPathfinder{
result.size = output + 1;
}
void clear(){
void clear(boolean resetCurrent){
done = false;
frontier = new PathfindQueue(20);
@@ -565,8 +566,11 @@ public class ControlPathfinder{
frontier.add(start, 0);
foundEnd = false;
result.clear();
lastDestination.set(destination);
if(resetCurrent){
result.clear();
}
}
}
}

View File

@@ -2934,7 +2934,7 @@ public class UnitTypes{
unitSpawned = new MissileUnitType("quell-missile"){{
speed = 3.8f;
maxRange = 15f;
maxRange = 6f;
lifetime = 60f * 1.2f;
outlineColor = Pal.darkOutline;
health = 45;
@@ -3393,10 +3393,6 @@ public class UnitTypes{
);
}};
//payloadDrone = new UnitType("payload-drone"){{
//}};
//endregion
}
}

View File

@@ -30,7 +30,7 @@ public class MissileUnitType extends UnitType{
speed = 4f;
lifetime = 60f * 1.7f;
rotateSpeed = 2.5f;
range = 15f;
range = 6f;
targetPriority = -1f;
outlineColor = Pal.darkOutline;
//TODO weapon configs, etc?