Conveyor upgrade system (#3912)
* conveyor/conduit upgrading system * style
This commit is contained in:
@@ -32,6 +32,7 @@ import mindustry.ui.fragments.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.ConstructBlock.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
import mindustry.world.blocks.payloads.*;
|
||||
import mindustry.world.blocks.power.*;
|
||||
import mindustry.world.blocks.storage.CoreBlock.*;
|
||||
@@ -1161,7 +1162,15 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
|
||||
if(diagonal){
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
|
||||
Tile start = world.tile(startX, startY);
|
||||
Tile end = world.tile(endX, endY);
|
||||
if(block != null && block instanceof Autotiler
|
||||
&& start.build instanceof ChainedBuilding && end.build instanceof ChainedBuilding
|
||||
&& block.canReplace(end.build.block) && block.canReplace(start.build.block)){
|
||||
points = Placement.upgradeLine(startX, startY, endX, endY);
|
||||
}else{
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
|
||||
}
|
||||
}else{
|
||||
points = Placement.normalizeLine(startX, startY, endX, endY);
|
||||
}
|
||||
|
||||
@@ -5,7 +5,9 @@ import arc.math.*;
|
||||
import arc.math.geom.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.pooling.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
@@ -23,7 +25,6 @@ public class Placement{
|
||||
/** Normalize a diagonal line into points. */
|
||||
public static Seq<Point2> pathfindLine(boolean conveyors, int startX, int startY, int endX, int endY){
|
||||
Pools.freeAll(points);
|
||||
|
||||
points.clear();
|
||||
if(conveyors && Core.settings.getBool("conveyorpathfinding")){
|
||||
if(astar(startX, startY, endX, endY)){
|
||||
@@ -54,6 +55,20 @@ public class Placement{
|
||||
return points;
|
||||
}
|
||||
|
||||
public static Seq<Point2> upgradeLine(int startX, int startY, int endX, int endY){
|
||||
Pools.freeAll(points);
|
||||
points.clear();
|
||||
Building building = world.tile(startX, startY).build;
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(startX, startY));
|
||||
while(building.tile.x != endX || building.tile.y != endY){
|
||||
ChainedBuilding chained = (ChainedBuilding)building;
|
||||
if(chained.next() == null) return pathfindLine(true, startX, startY, endX, endY);
|
||||
building = chained.next();
|
||||
points.add(Pools.obtain(Point2.class, Point2::new).set(building.tile.x, building.tile.y));
|
||||
}
|
||||
return points;
|
||||
}
|
||||
|
||||
private static float tileHeuristic(Tile tile, Tile other){
|
||||
Block block = control.input.block;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user