Beam node balance

This commit is contained in:
Anuken 2021-10-30 15:15:06 -04:00
parent abf13874fa
commit 87a8453871
3 changed files with 28 additions and 13 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 591 B

After

Width:  |  Height:  |  Size: 658 B

View File

@ -36,6 +36,14 @@ public class BeamNode extends PowerBlock{
envEnabled |= Env.space;
}
@Override
public void setBars(){
super.setBars();
bars.add("power", PowerNode.makePowerBalance());
bars.add("batteries", PowerNode.makeBatteryBalance());
}
@Override
public void init(){
super.init();

View File

@ -100,19 +100,8 @@ public class PowerNode extends PowerBlock{
@Override
public void setBars(){
super.setBars();
bars.add("power", entity -> new Bar(() ->
Core.bundle.format("bar.powerbalance",
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((long)(entity.power.graph.getPowerBalance() * 60)))),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())
));
bars.add("batteries", entity -> new Bar(() ->
Core.bundle.format("bar.powerstored",
(UI.formatAmount((long)entity.power.graph.getLastPowerStored())), UI.formatAmount((long)entity.power.graph.getLastCapacity())),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity())
));
bars.add("power", makePowerBalance());
bars.add("batteries", makeBatteryBalance());
bars.add("connections", entity -> new Bar(() ->
Core.bundle.format("bar.powerlines", entity.power.links.size, maxNodes),
@ -121,6 +110,24 @@ public class PowerNode extends PowerBlock{
));
}
public static Func<Building, Bar> makePowerBalance(){
return entity -> new Bar(() ->
Core.bundle.format("bar.powerbalance",
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((long)(entity.power.graph.getPowerBalance() * 60)))),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())
);
}
public static Func<Building, Bar> makeBatteryBalance(){
return entity -> new Bar(() ->
Core.bundle.format("bar.powerstored",
(UI.formatAmount((long)entity.power.graph.getLastPowerStored())), UI.formatAmount((long)entity.power.graph.getLastCapacity())),
() -> Pal.powerBar,
() -> Mathf.clamp(entity.power.graph.getLastPowerStored() / entity.power.graph.getLastCapacity())
);
}
@Override
public void setStats(){
super.setStats();