Fixed node connection bug

This commit is contained in:
Anuken
2018-09-20 09:24:31 -04:00
parent ecad5772d2
commit acb8496352
3 changed files with 19 additions and 7 deletions

View File

@@ -63,17 +63,13 @@ public class PowerBlocks extends BlockList implements ContentList{
health = 600;
}};
battery = new PowerDistributor("battery"){{
battery = new Battery("battery"){{
powerCapacity = 320f;
outputsPower = true;
consumesPower = true;
}};
batteryLarge = new PowerDistributor("battery-large"){{
batteryLarge = new Battery("battery-large"){{
size = 3;
powerCapacity = 2000f;
outputsPower = true;
consumesPower = true;
}};
powerNode = new PowerNode("power-node"){{

View File

@@ -150,12 +150,18 @@ public class Block extends BaseBlock {
public void powerGraphRemoved(Tile tile){
tile.entity.power.graph.remove(tile);
for(int i = 0; i < tile.entity.power.links.size; i++){
Tile other = world.tile(tile.entity.power.links.get(i));
if(other != null && other.entity != null && other.entity.power != null){
other.entity.power.links.removeValue(tile.packedPosition());
}
}
}
public Array<Tile> getPowerConnections(Tile tile, Array<Tile> out){
out.clear();
for(Tile other : tile.entity.proximity()){
if(other.entity.power != null && !(consumesPower && other.block().consumesPower)){
if(other.entity.power != null && !(consumesPower && other.block().consumesPower && !outputsPower && !other.block().outputsPower)){
out.add(other);
}
}

View File

@@ -0,0 +1,10 @@
package io.anuke.mindustry.world.blocks.power;
public class Battery extends PowerDistributor{
public Battery(String name){
super(name);
outputsPower = true;
consumesPower = true;
}
}