Fixed armored duct blending / Fixed some pathfinding bugs

This commit is contained in:
Anuken
2024-10-07 12:36:40 -04:00
parent ef33a05cb8
commit 1f62892e10
5 changed files with 18 additions and 12 deletions
+10 -4
View File
@@ -1100,6 +1100,10 @@ public class ControlPathfinder implements Runnable{
} }
public boolean getPathPosition(Unit unit, Vec2 destination, Vec2 mainDestination, Vec2 out, @Nullable boolean[] noResultFound){ public boolean getPathPosition(Unit unit, Vec2 destination, Vec2 mainDestination, Vec2 out, @Nullable boolean[] noResultFound){
if(noResultFound != null){
noResultFound[0] = false;
}
int costId = unit.type.pathCostId; int costId = unit.type.pathCostId;
PathCost cost = idToCost(costId); PathCost cost = idToCost(costId);
@@ -1253,7 +1257,11 @@ public class ControlPathfinder implements Runnable{
return true; return true;
} }
} }
}else if(request == null){ }else{
//destroy the old one immediately, it's invalid now
if(request != null){
request.lastUpdateId = -1000;
}
//queue new request. //queue new request.
unitRequests.put(unit, request = new PathRequest(unit, team, costId, destPos)); unitRequests.put(unit, request = new PathRequest(unit, team, costId, destPos));
@@ -1266,9 +1274,7 @@ public class ControlPathfinder implements Runnable{
recalculatePath(f); recalculatePath(f);
}); });
out.set(destination); return false;
return true;
} }
if(noResultFound != null){ if(noResultFound != null){
@@ -189,14 +189,14 @@ public interface Autotiler{
default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ default boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotatedOutput(otherx, othery) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null && || ((!otherblock.rotatedOutput(otherx, othery, tile) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) ||
(otherblock.rotatedOutput(otherx, othery) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); (otherblock.rotatedOutput(otherx, othery, tile) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
} }
/** @return whether this other block is *not* looking at this one. */ /** @return whether this other block is *not* looking at this one. */
default boolean notLookingAt(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ default boolean notLookingAt(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return !(otherblock.rotatedOutput(otherx, othery) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)); return !(otherblock.rotatedOutput(otherx, othery, tile) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y));
} }
/** @return whether this tile is looking at the other tile, or the other tile is looking at this one. /** @return whether this tile is looking at the other tile, or the other tile is looking at this one.
@@ -21,9 +21,9 @@ public class ArmoredConveyor extends Conveyor{
@Override @Override
public boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ public boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotatedOutput(otherx, othery) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null && || ((!otherblock.rotatedOutput(otherx, othery, tile) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) ||
(otherblock instanceof Conveyor && otherblock.rotatedOutput(otherx, othery) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); (otherblock instanceof Conveyor && otherblock.rotatedOutput(otherx, othery, tile) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
} }
public class ArmoredConveyorBuild extends ConveyorBuild{ public class ArmoredConveyorBuild extends ConveyorBuild{
@@ -82,10 +82,10 @@ public class Duct extends Block implements Autotiler{
@Override @Override
public boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ public boolean blendsArmored(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){
return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) return Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery)
|| ((!otherblock.rotatedOutput(otherx, othery) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null && || ((!otherblock.rotatedOutput(otherx, othery, tile) && Edges.getFacingEdge(otherblock, otherx, othery, tile) != null &&
Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) || Edges.getFacingEdge(otherblock, otherx, othery, tile).relativeTo(tile) == rotation) ||
((otherblock.rotatedOutput(otherx, othery)) && (otherblock.isDuct) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); ((otherblock.rotatedOutput(otherx, othery, tile)) && (otherblock.isDuct) && Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y)));
} }
@Override @Override
+1 -1
View File
@@ -26,4 +26,4 @@ org.gradle.caching=true
org.gradle.internal.http.socketTimeout=100000 org.gradle.internal.http.socketTimeout=100000
org.gradle.internal.http.connectionTimeout=100000 org.gradle.internal.http.connectionTimeout=100000
android.enableR8.fullMode=false android.enableR8.fullMode=false
archash=89c7f1aee6 archash=a39155a23e