Improved power node link preview check
This commit is contained in:
@@ -494,7 +494,7 @@ public class DesktopInput extends InputHandler{
|
|||||||
}else if(selected != null){
|
}else if(selected != null){
|
||||||
//only begin shooting if there's no cursor event
|
//only begin shooting if there's no cursor event
|
||||||
if(!tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !tileTapped(selected.build) && !player.unit().activelyBuilding() && !droppingItem
|
if(!tryTapPlayer(Core.input.mouseWorld().x, Core.input.mouseWorld().y) && !tileTapped(selected.build) && !player.unit().activelyBuilding() && !droppingItem
|
||||||
&& !((!settings.getBool("doubletapmine") || selected == prevSelected && Time.timeSinceMillis(selectMillis) < 500) && tryBeginMine(selected)) && !Core.scene.hasKeyboard()){
|
&& !((!settings.getBool("doubletapmine") || (selected == prevSelected && Time.timeSinceMillis(selectMillis) < 500)) && tryBeginMine(selected)) && !Core.scene.hasKeyboard()){
|
||||||
player.shooting = shouldShoot;
|
player.shooting = shouldShoot;
|
||||||
}
|
}
|
||||||
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
|
}else if(!Core.scene.hasKeyboard()){ //if it's out of bounds, shooting is just fine
|
||||||
|
|||||||
@@ -491,6 +491,11 @@ public class Tile implements Position, QuadTreeObject, Displayable{
|
|||||||
return block.solid && block.fillsTile && !block.synthetic() ? data : 0;
|
return block.solid && block.fillsTile && !block.synthetic() ? data : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @return true if these tiles are right next to eacho ther. */
|
||||||
|
public boolean adjacentTo(Tile tile){
|
||||||
|
return relativeTo(tile) != -1;
|
||||||
|
}
|
||||||
|
|
||||||
protected void preChanged(){
|
protected void preChanged(){
|
||||||
if(build != null){
|
if(build != null){
|
||||||
//only call removed() for the center block - this only gets called once.
|
//only call removed() for the center block - this only gets called once.
|
||||||
|
|||||||
@@ -196,10 +196,23 @@ public class PowerNode extends PowerBlock{
|
|||||||
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
|
Boolf<Building> valid = other -> other != null && other.tile() != tile && other.power != null &&
|
||||||
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
|
(other.block.outputsPower || other.block.consumesPower || other.block instanceof PowerNode) &&
|
||||||
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == player.team()
|
overlaps(tile.x * tilesize + offset, tile.y * tilesize + offset, other.tile(), laserRange * tilesize) && other.team == player.team()
|
||||||
&& !other.proximity.contains(e -> e.tile == tile) && !graphs.contains(other.power.graph);
|
&& !graphs.contains(other.power.graph) &&
|
||||||
|
!Structs.contains(Edges.getEdges(size), p -> { //do not link to adjacent buildings
|
||||||
|
var t = world.tile(tile.x + p.x, tile.y + p.y);
|
||||||
|
return t != null && t.build == other;
|
||||||
|
});
|
||||||
|
|
||||||
tempTileEnts.clear();
|
tempTileEnts.clear();
|
||||||
graphs.clear();
|
graphs.clear();
|
||||||
|
|
||||||
|
//add conducting graphs to prevent double link
|
||||||
|
for(var p : Edges.getEdges(size)){
|
||||||
|
Tile other = tile.nearby(p);
|
||||||
|
if(other != null && other.team() == player.team() && other.build != null && other.build.power != null){
|
||||||
|
graphs.add(other.build.power.graph);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(tile.build != null && tile.build.power != null){
|
if(tile.build != null && tile.build.power != null){
|
||||||
graphs.add(tile.build.power.graph);
|
graphs.add(tile.build.power.graph);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user