testing winMM

This commit is contained in:
Anuken
2020-12-18 09:42:57 -05:00
parent 6815f3305f
commit a4f9518d1e
3 changed files with 49 additions and 36 deletions

View File

@@ -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;

View File

@@ -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;