mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-10 18:57:39 +07:00
Improved power node link preview check
This commit is contained in:
parent
5037c4e00e
commit
44d10a355e
@ -494,7 +494,7 @@ public class DesktopInput extends InputHandler{
|
||||
}else if(selected != null){
|
||||
//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
|
||||
&& !((!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;
|
||||
}
|
||||
}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 true if these tiles are right next to eacho ther. */
|
||||
public boolean adjacentTo(Tile tile){
|
||||
return relativeTo(tile) != -1;
|
||||
}
|
||||
|
||||
protected void preChanged(){
|
||||
if(build != null){
|
||||
//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 &&
|
||||
(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()
|
||||
&& !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();
|
||||
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){
|
||||
graphs.add(tile.build.power.graph);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user