Merge remote-tracking branch 'origin/master'
This commit is contained in:
@@ -71,8 +71,8 @@ public class PowerDiode extends Block{
|
|||||||
// prevent sending more than the front can handle
|
// prevent sending more than the front can handle
|
||||||
amount = Mathf.clamp(amount, 0, frontGraph.getTotalBatteryCapacity() * (1 - frontStored));
|
amount = Mathf.clamp(amount, 0, frontGraph.getTotalBatteryCapacity() * (1 - frontStored));
|
||||||
|
|
||||||
backGraph.useBatteries(amount);
|
backGraph.transferPower(-amount);
|
||||||
frontGraph.chargeBatteries(amount);
|
frontGraph.transferPower(amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ public class PowerGraph{
|
|||||||
private final WindowedMean powerBalance = new WindowedMean(60);
|
private final WindowedMean powerBalance = new WindowedMean(60);
|
||||||
private float lastPowerProduced, lastPowerNeeded, lastPowerStored;
|
private float lastPowerProduced, lastPowerNeeded, lastPowerStored;
|
||||||
private float lastScaledPowerIn, lastScaledPowerOut, lastCapacity;
|
private float lastScaledPowerIn, lastScaledPowerOut, lastCapacity;
|
||||||
|
//diodes workaround for correct energy production info
|
||||||
|
private float energyDelta = 0f;
|
||||||
|
|
||||||
private long lastFrameUpdated = -1;
|
private long lastFrameUpdated = -1;
|
||||||
private final int graphID;
|
private final int graphID;
|
||||||
@@ -62,6 +64,15 @@ public class PowerGraph{
|
|||||||
return lastPowerStored;
|
return lastPowerStored;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void transferPower(float amount){
|
||||||
|
if(amount > 0){
|
||||||
|
chargeBatteries(amount);
|
||||||
|
}else{
|
||||||
|
useBatteries(-amount);
|
||||||
|
}
|
||||||
|
energyDelta += amount;
|
||||||
|
}
|
||||||
|
|
||||||
public float getSatisfaction(){
|
public float getSatisfaction(){
|
||||||
if(Mathf.zero(lastPowerProduced)){
|
if(Mathf.zero(lastPowerProduced)){
|
||||||
return 0f;
|
return 0f;
|
||||||
@@ -218,7 +229,8 @@ public class PowerGraph{
|
|||||||
lastCapacity = getTotalBatteryCapacity();
|
lastCapacity = getTotalBatteryCapacity();
|
||||||
lastPowerStored = getBatteryStored();
|
lastPowerStored = getBatteryStored();
|
||||||
|
|
||||||
powerBalance.add((lastPowerProduced - lastPowerNeeded) / Time.delta);
|
powerBalance.add((lastPowerProduced - lastPowerNeeded + energyDelta) / Time.delta);
|
||||||
|
energyDelta = 0f;
|
||||||
|
|
||||||
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
|
if(!(consumers.size == 0 && producers.size == 0 && batteries.size == 0)){
|
||||||
|
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ public class PowerNode extends PowerBlock{
|
|||||||
super.setBars();
|
super.setBars();
|
||||||
bars.add("power", entity -> new Bar(() ->
|
bars.add("power", entity -> new Bar(() ->
|
||||||
Core.bundle.format("bar.powerbalance",
|
Core.bundle.format("bar.powerbalance",
|
||||||
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + Strings.fixed(entity.power.graph.getPowerBalance() * 60, 1))),
|
((entity.power.graph.getPowerBalance() >= 0 ? "+" : "") + UI.formatAmount((int)(entity.power.graph.getPowerBalance() * 60)))),
|
||||||
() -> Pal.powerBar,
|
() -> Pal.powerBar,
|
||||||
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())));
|
() -> Mathf.clamp(entity.power.graph.getLastPowerProduced() / entity.power.graph.getLastPowerNeeded())));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user