Minor pathfinding tweaks
This commit is contained in:
@@ -64,8 +64,17 @@ public class ControlPathfinder{
|
|||||||
start();
|
start();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//only update the world when a solid block is removed or placed, everything else doesn't matter
|
||||||
|
Events.on(TilePreChangeEvent.class, e -> {
|
||||||
|
if(e.tile.solid()){
|
||||||
|
worldUpdateId ++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
Events.on(TileChangeEvent.class, e -> {
|
Events.on(TileChangeEvent.class, e -> {
|
||||||
worldUpdateId ++;
|
if(e.tile.solid()){
|
||||||
|
worldUpdateId ++;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
Events.on(ResetEvent.class, event -> stop());
|
Events.on(ResetEvent.class, event -> stop());
|
||||||
@@ -447,7 +456,7 @@ public class ControlPathfinder{
|
|||||||
lastId = curId;
|
lastId = curId;
|
||||||
|
|
||||||
//re-do everything when world updates
|
//re-do everything when world updates
|
||||||
if(Time.timeSinceMillis(lastTime) > 1000 * 2 && (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;
|
pathIndex = 0;
|
||||||
|
|||||||
@@ -280,7 +280,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}
|
}
|
||||||
|
|
||||||
//validate commanding units
|
//validate commanding units
|
||||||
selectedUnits.removeAll(u -> !u.isCommandable());
|
selectedUnits.removeAll(u -> !u.isCommandable() || !u.isValid());
|
||||||
|
|
||||||
if(!scene.hasMouse() && !locked){
|
if(!scene.hasMouse() && !locked){
|
||||||
if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){
|
if(Core.input.keyDown(Binding.control) && Core.input.keyTap(Binding.select)){
|
||||||
|
|||||||
Reference in New Issue
Block a user