testing winMM
This commit is contained in:
@@ -48,7 +48,6 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
/** Maximum line length. */
|
||||
final static int maxLength = 100;
|
||||
final static Rect r1 = new Rect(), r2 = new Rect();
|
||||
final static Seq<Point2> tmpPoints = new Seq<>(), tmpPoints2 = new Seq<>();
|
||||
|
||||
public final OverlayFragment frag = new OverlayFragment();
|
||||
|
||||
@@ -1144,7 +1143,7 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
diagonal = !diagonal;
|
||||
}
|
||||
|
||||
if(block instanceof PowerNode){
|
||||
if(block != null && block.swapDiagonalPlacement){
|
||||
diagonal = !diagonal;
|
||||
}
|
||||
|
||||
@@ -1161,39 +1160,8 @@ public abstract class InputHandler implements InputProcessor, GestureListener{
|
||||
points = Placement.normalizeLine(startX, startY, endX, endY);
|
||||
}
|
||||
|
||||
if(block instanceof PowerNode node){
|
||||
var base = tmpPoints2;
|
||||
var result = tmpPoints.clear();
|
||||
|
||||
base.selectFrom(points, p -> p == points.first() || p == points.peek() || Build.validPlace(block, player.team(), p.x, p.y, rotation, false));
|
||||
boolean addedLast = false;
|
||||
|
||||
outer:
|
||||
for(int i = 0; i < base.size;){
|
||||
var point = base.get(i);
|
||||
result.add(point);
|
||||
if(i == base.size - 1) addedLast = true;
|
||||
|
||||
//find the furthest node that overlaps this one
|
||||
for(int j = base.size - 1; j > i; j--){
|
||||
var other = base.get(j);
|
||||
boolean over = node.overlaps(world.tile(point.x, point.y), world.tile(other.x, other.y));
|
||||
|
||||
if(over){
|
||||
//add node to list and start searching for node that overlaps the next one
|
||||
i = j;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
//if it got here, that means nothing was found. try to proceed to the next node anyway
|
||||
i ++;
|
||||
}
|
||||
|
||||
if(!addedLast) result.add(base.peek());
|
||||
|
||||
points.clear();
|
||||
points.addAll(result);
|
||||
if(block != null){
|
||||
block.changePlacementPath(points, rotation);
|
||||
}
|
||||
|
||||
float angle = Angles.angle(startX, startY, endX, endY);
|
||||
|
||||
@@ -143,6 +143,8 @@ public class Block extends UnlockableContent{
|
||||
public boolean sync;
|
||||
/** Whether this block uses conveyor-type placement mode. */
|
||||
public boolean conveyorPlacement;
|
||||
/** Whether to swap the diagonal placement modes. */
|
||||
public boolean swapDiagonalPlacement;
|
||||
/**
|
||||
* The color of this block when displayed on the minimap or map preview.
|
||||
* Do not set manually! This is overridden when loading for most blocks.
|
||||
@@ -386,6 +388,11 @@ public class Block extends UnlockableContent{
|
||||
return this;
|
||||
}
|
||||
|
||||
/** Mutates the given list of points used during line placement. */
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation){
|
||||
|
||||
}
|
||||
|
||||
public Object nextConfig(){
|
||||
if(saveConfig && lastConfig != null){
|
||||
return lastConfig;
|
||||
|
||||
@@ -25,7 +25,8 @@ public class PowerNode extends PowerBlock{
|
||||
protected static boolean returnValue = false;
|
||||
protected static BuildPlan otherReq;
|
||||
|
||||
protected final ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected final static ObjectSet<PowerGraph> graphs = new ObjectSet<>();
|
||||
protected final static Seq<Point2> tmpPoints = new Seq<>(), tmpPoints2 = new Seq<>();
|
||||
|
||||
public @Load("laser") TextureRegion laser;
|
||||
public @Load("laser-end") TextureRegion laserEnd;
|
||||
@@ -40,6 +41,7 @@ public class PowerNode extends PowerBlock{
|
||||
consumesPower = false;
|
||||
outputsPower = false;
|
||||
canOverdrive = false;
|
||||
swapDiagonalPlacement = true;
|
||||
|
||||
config(Integer.class, (entity, value) -> {
|
||||
PowerModule power = entity.power;
|
||||
@@ -149,6 +151,42 @@ public class PowerNode extends PowerBlock{
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void changePlacementPath(Seq<Point2> points, int rotation){
|
||||
var base = tmpPoints2;
|
||||
var result = tmpPoints.clear();
|
||||
|
||||
base.selectFrom(points, p -> p == points.first() || p == points.peek() || Build.validPlace(this, player.team(), p.x, p.y, rotation, false));
|
||||
boolean addedLast = false;
|
||||
|
||||
outer:
|
||||
for(int i = 0; i < base.size;){
|
||||
var point = base.get(i);
|
||||
result.add(point);
|
||||
if(i == base.size - 1) addedLast = true;
|
||||
|
||||
//find the furthest node that overlaps this one
|
||||
for(int j = base.size - 1; j > i; j--){
|
||||
var other = base.get(j);
|
||||
boolean over = overlaps(world.tile(point.x, point.y), world.tile(other.x, other.y));
|
||||
|
||||
if(over){
|
||||
//add node to list and start searching for node that overlaps the next one
|
||||
i = j;
|
||||
continue outer;
|
||||
}
|
||||
}
|
||||
|
||||
//if it got here, that means nothing was found. try to proceed to the next node anyway
|
||||
i ++;
|
||||
}
|
||||
|
||||
if(!addedLast) result.add(base.peek());
|
||||
|
||||
points.clear();
|
||||
points.addAll(result);
|
||||
}
|
||||
|
||||
protected void setupColor(float satisfaction){
|
||||
float fract = 1f - satisfaction;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user