mirror of
https://github.com/Anuken/Mindustry.git
synced 2024-09-21 13:28:12 +03:00
Power node placement fixes
This commit is contained in:
parent
d66d7e09e3
commit
1bd4c96ee8
@ -536,15 +536,19 @@ public class UI implements ApplicationListener, Loadable{
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static String formatAmount(int number){
|
public static String formatAmount(int number){
|
||||||
|
//prevent overflow
|
||||||
|
if(number == Integer.MIN_VALUE) number ++;
|
||||||
|
|
||||||
int mag = Math.abs(number);
|
int mag = Math.abs(number);
|
||||||
|
String sign = number < 0 ? "-" : "";
|
||||||
if(mag >= 1_000_000_000){
|
if(mag >= 1_000_000_000){
|
||||||
return Strings.fixed(number / 1_000_000_000f, 1) + "[gray]" + Core.bundle.get("unit.billions") + "[]";
|
return sign + Strings.fixed(mag / 1_000_000_000f, 1) + "[gray]" + Core.bundle.get("unit.billions") + "[]";
|
||||||
}else if(mag >= 1_000_000){
|
}else if(mag >= 1_000_000){
|
||||||
return Strings.fixed(number / 1_000_000f, 1) + "[gray]" + Core.bundle.get("unit.millions") + "[]";
|
return sign + Strings.fixed(mag / 1_000_000f, 1) + "[gray]" + Core.bundle.get("unit.millions") + "[]";
|
||||||
}else if(mag >= 10_000){
|
}else if(mag >= 10_000){
|
||||||
return number / 1000 + "[gray]" + Core.bundle.get("unit.thousands") + "[]";
|
return number / 1000 + "[gray]" + Core.bundle.get("unit.thousands") + "[]";
|
||||||
}else if(mag >= 1000){
|
}else if(mag >= 1000){
|
||||||
return Strings.fixed(number / 1000f, 1) + "[gray]" + Core.bundle.get("unit.thousands") + "[]";
|
return sign + Strings.fixed(mag / 1000f, 1) + "[gray]" + Core.bundle.get("unit.thousands") + "[]";
|
||||||
}else{
|
}else{
|
||||||
return number + "";
|
return number + "";
|
||||||
}
|
}
|
||||||
|
@ -84,10 +84,12 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
create(tile.block(), team);
|
create(tile.block(), team);
|
||||||
}else{
|
}else{
|
||||||
if(block.hasPower){
|
if(block.hasPower){
|
||||||
|
power.init = false;
|
||||||
//reinit power graph
|
//reinit power graph
|
||||||
new PowerGraph().add(self());
|
new PowerGraph().add(self());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
proximity.clear();
|
||||||
this.rotation = rotation;
|
this.rotation = rotation;
|
||||||
this.tile = tile;
|
this.tile = tile;
|
||||||
|
|
||||||
@ -757,6 +759,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** in overrides, this does the exact same thing as onProximityUpdate, use that instead */
|
||||||
public void onProximityAdded(){
|
public void onProximityAdded(){
|
||||||
if(block.hasPower) updatePowerGraph();
|
if(block.hasPower) updatePowerGraph();
|
||||||
}
|
}
|
||||||
@ -1216,6 +1219,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
|
|||||||
other.proximity.remove(self(), true);
|
other.proximity.remove(self(), true);
|
||||||
other.onProximityUpdate();
|
other.onProximityUpdate();
|
||||||
}
|
}
|
||||||
|
proximity.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateProximity(){
|
public void updateProximity(){
|
||||||
|
@ -363,8 +363,6 @@ public class PowerNode extends PowerBlock{
|
|||||||
@Override
|
@Override
|
||||||
public void dropped(){
|
public void dropped(){
|
||||||
power.links.clear();
|
power.links.clear();
|
||||||
//create new power graph to manually unlink (this may be redundant)
|
|
||||||
new PowerGraph().add(this);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user