Pathfinding recalculation improvements
This commit is contained in:
@@ -430,7 +430,7 @@ public class ControlPathfinder{
|
|||||||
|
|
||||||
int rayPathIndex = -1;
|
int rayPathIndex = -1;
|
||||||
IntSeq result = new IntSeq();
|
IntSeq result = new IntSeq();
|
||||||
float raycastTimer;
|
volatile float raycastTimer;
|
||||||
|
|
||||||
PathfindQueue frontier = new PathfindQueue();
|
PathfindQueue frontier = new PathfindQueue();
|
||||||
//node index -> node it came from
|
//node index -> node it came from
|
||||||
@@ -451,7 +451,7 @@ public class ControlPathfinder{
|
|||||||
|
|
||||||
void update(long maxUpdateNs){
|
void update(long maxUpdateNs){
|
||||||
if(curId != lastId){
|
if(curId != lastId){
|
||||||
clear();
|
clear(true);
|
||||||
}
|
}
|
||||||
lastId = curId;
|
lastId = curId;
|
||||||
|
|
||||||
@@ -459,10 +459,7 @@ public class ControlPathfinder{
|
|||||||
if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){
|
if(Time.timeSinceMillis(lastTime) > 1000 * 3 && (worldUpdateId != lastWorldUpdate || !destination.epsilonEquals(lastDestination, 2f))){
|
||||||
lastTime = Time.millis();
|
lastTime = Time.millis();
|
||||||
lastWorldUpdate = worldUpdateId;
|
lastWorldUpdate = worldUpdateId;
|
||||||
pathIndex = 0;
|
clear(false);
|
||||||
rayPathIndex = -1;
|
|
||||||
result.clear();
|
|
||||||
clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(done) return;
|
if(done) return;
|
||||||
@@ -512,8 +509,12 @@ public class ControlPathfinder{
|
|||||||
}
|
}
|
||||||
|
|
||||||
lastTime = Time.millis();
|
lastTime = Time.millis();
|
||||||
|
raycastTimer = 9999f;
|
||||||
result.clear();
|
result.clear();
|
||||||
|
|
||||||
|
pathIndex = 0;
|
||||||
|
rayPathIndex = -1;
|
||||||
|
|
||||||
if(foundEnd){
|
if(foundEnd){
|
||||||
int cur = goal;
|
int cur = goal;
|
||||||
while(cur != start){
|
while(cur != start){
|
||||||
@@ -549,7 +550,7 @@ public class ControlPathfinder{
|
|||||||
result.size = output + 1;
|
result.size = output + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear(){
|
void clear(boolean resetCurrent){
|
||||||
done = false;
|
done = false;
|
||||||
|
|
||||||
frontier = new PathfindQueue(20);
|
frontier = new PathfindQueue(20);
|
||||||
@@ -565,8 +566,11 @@ public class ControlPathfinder{
|
|||||||
frontier.add(start, 0);
|
frontier.add(start, 0);
|
||||||
|
|
||||||
foundEnd = false;
|
foundEnd = false;
|
||||||
result.clear();
|
|
||||||
lastDestination.set(destination);
|
lastDestination.set(destination);
|
||||||
|
|
||||||
|
if(resetCurrent){
|
||||||
|
result.clear();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2934,7 +2934,7 @@ public class UnitTypes{
|
|||||||
|
|
||||||
unitSpawned = new MissileUnitType("quell-missile"){{
|
unitSpawned = new MissileUnitType("quell-missile"){{
|
||||||
speed = 3.8f;
|
speed = 3.8f;
|
||||||
maxRange = 15f;
|
maxRange = 6f;
|
||||||
lifetime = 60f * 1.2f;
|
lifetime = 60f * 1.2f;
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
health = 45;
|
health = 45;
|
||||||
@@ -3393,10 +3393,6 @@ public class UnitTypes{
|
|||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
//payloadDrone = new UnitType("payload-drone"){{
|
|
||||||
|
|
||||||
//}};
|
|
||||||
|
|
||||||
//endregion
|
//endregion
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ public class MissileUnitType extends UnitType{
|
|||||||
speed = 4f;
|
speed = 4f;
|
||||||
lifetime = 60f * 1.7f;
|
lifetime = 60f * 1.7f;
|
||||||
rotateSpeed = 2.5f;
|
rotateSpeed = 2.5f;
|
||||||
range = 15f;
|
range = 6f;
|
||||||
targetPriority = -1f;
|
targetPriority = -1f;
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
//TODO weapon configs, etc?
|
//TODO weapon configs, etc?
|
||||||
|
|||||||
Reference in New Issue
Block a user