Stash initial prototype
This commit is contained in:
@@ -10,6 +10,7 @@ import io.anuke.mindustry.*;
|
||||
import io.anuke.mindustry.ctype.ContentList;
|
||||
import io.anuke.mindustry.entities.*;
|
||||
import io.anuke.mindustry.entities.bullet.*;
|
||||
import io.anuke.mindustry.entities.traits.BuilderTrait;
|
||||
import io.anuke.mindustry.entities.type.*;
|
||||
import io.anuke.mindustry.gen.*;
|
||||
import io.anuke.mindustry.graphics.*;
|
||||
@@ -104,6 +105,11 @@ public class Blocks implements ContentList{
|
||||
}
|
||||
return variantRegions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuilderTrait.BuildRequest req, Eachable<BuilderTrait.BuildRequest> list) {
|
||||
//
|
||||
}
|
||||
};
|
||||
|
||||
//create special blockpart variants
|
||||
|
||||
@@ -32,6 +32,7 @@ import io.anuke.mindustry.ui.fragments.*;
|
||||
import io.anuke.mindustry.world.*;
|
||||
import io.anuke.mindustry.world.blocks.*;
|
||||
import io.anuke.mindustry.world.blocks.BuildBlock.*;
|
||||
import io.anuke.mindustry.world.blocks.power.PowerNode;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@@ -534,6 +535,30 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
final int[] i = {0};
|
||||
final Array<Tile> chain = new Array<Tile>();
|
||||
lineRequests.each(req -> {
|
||||
if(!(req.block instanceof PowerNode)) return;
|
||||
|
||||
if(i[0]++ == 0 || i[0] == lineRequests.size){
|
||||
// beginning & end should always be placed
|
||||
}else{
|
||||
final boolean[] overlaps = {false};
|
||||
chain.each(tile -> {
|
||||
if(((PowerNode) req.block).overlaps(req.tile(), tile)){
|
||||
overlaps[0] = true;
|
||||
};
|
||||
});
|
||||
|
||||
if(overlaps[0]){
|
||||
req.block = Blocks.air;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
chain.add(req.tile());
|
||||
});
|
||||
}
|
||||
|
||||
protected void updateLine(int x1, int y1){
|
||||
@@ -806,12 +831,18 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
void iterateLine(int startX, int startY, int endX, int endY, Cons<PlaceLine> cons){
|
||||
Array<Point2> points;
|
||||
boolean diagonal = Core.input.keyDown(Binding.diagonal_placement);
|
||||
|
||||
// place powernodes diagonally by default
|
||||
if((block != null && block.powernodePlacement)){
|
||||
diagonal = !diagonal;
|
||||
}
|
||||
|
||||
if(Core.settings.getBool("swapdiagonal") && mobile){
|
||||
diagonal = !diagonal;
|
||||
}
|
||||
|
||||
if(diagonal){
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, startX, startY, endX, endY);
|
||||
points = Placement.pathfindLine(block != null && block.conveyorPlacement, block != null && block.powernodePlacement, startX, startY, endX, endY);
|
||||
}else{
|
||||
points = Placement.normalizeLine(startX, startY, endX, endY);
|
||||
}
|
||||
|
||||
@@ -22,7 +22,7 @@ public class Placement{
|
||||
private static IntSet closed = new IntSet();
|
||||
|
||||
/** Normalize a diagonal line into points. */
|
||||
public static Array<Point2> pathfindLine(boolean conveyors, int startX, int startY, int endX, int endY){
|
||||
public static Array<Point2> pathfindLine(boolean conveyors, boolean powernodes, int startX, int startY, int endX, int endY){
|
||||
Pools.freeAll(points);
|
||||
|
||||
points.clear();
|
||||
|
||||
@@ -93,6 +93,8 @@ public class Block extends BlockStorage{
|
||||
public boolean posConfig;
|
||||
/** Whether this block uses conveyor-type placement mode.*/
|
||||
public boolean conveyorPlacement;
|
||||
/** Whether this block uses powernode-type placement mode.*/
|
||||
public boolean powernodePlacement;
|
||||
/**
|
||||
* The color of this block when displayed on the minimap or map preview.
|
||||
* Do not set manually! This is overriden when loading for most blocks.
|
||||
|
||||
@@ -32,6 +32,7 @@ public class PowerNode extends PowerBlock{
|
||||
configurable = true;
|
||||
consumesPower = false;
|
||||
outputsPower = false;
|
||||
powernodePlacement = true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -302,6 +303,10 @@ public class PowerNode extends PowerBlock{
|
||||
return overlaps(src.drawx(), src.drawy(), other, range);
|
||||
}
|
||||
|
||||
public boolean overlaps(Tile src, Tile other){
|
||||
return overlaps(src.drawx(), src.drawy(), other, laserRange * tilesize);
|
||||
}
|
||||
|
||||
protected void drawLaser(Tile tile, Tile target){
|
||||
int opacityPercentage = Core.settings.getInt("lasersopacity");
|
||||
if(opacityPercentage == 0) return;
|
||||
|
||||
Reference in New Issue
Block a user