PowerGraph now handles delta
Also power bars are displayed for non-buffered consumers as well
This commit is contained in:
@@ -338,7 +338,7 @@ public class Block extends BaseBlock {
|
|||||||
|
|
||||||
//TODO make this easier to config.
|
//TODO make this easier to config.
|
||||||
public void setBars(){
|
public void setBars(){
|
||||||
if(consumes.has(ConsumePower.class) && consumes.get(ConsumePower.class).isBuffered){
|
if(consumes.has(ConsumePower.class)){
|
||||||
bars.add(new BlockBar(BarType.power, true, tile -> tile.entity.power.satisfaction));
|
bars.add(new BlockBar(BarType.power, true, tile -> tile.entity.power.satisfaction));
|
||||||
}
|
}
|
||||||
if(hasLiquids)
|
if(hasLiquids)
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ public class PowerGenerator extends PowerDistributor{
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public float getPowerProduction(Tile tile){
|
public float getPowerProduction(Tile tile){
|
||||||
return powerProduction * tile.<GeneratorEntity>entity().productionEfficiency * tile.entity.delta();
|
return powerProduction * tile.<GeneratorEntity>entity().productionEfficiency;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ public class PowerGraph{
|
|||||||
public float getPowerProduced(){
|
public float getPowerProduced(){
|
||||||
float powerProduced = 0f;
|
float powerProduced = 0f;
|
||||||
for(Tile producer : producers){
|
for(Tile producer : producers){
|
||||||
powerProduced += producer.block().getPowerProduction(producer);
|
powerProduced += producer.block().getPowerProduction(producer) * producer.entity.delta();
|
||||||
}
|
}
|
||||||
return powerProduced;
|
return powerProduced;
|
||||||
}
|
}
|
||||||
@@ -47,7 +47,7 @@ public class PowerGraph{
|
|||||||
for(Tile consumer : consumers){
|
for(Tile consumer : consumers){
|
||||||
Consumers consumes = consumer.block().consumes;
|
Consumers consumes = consumer.block().consumes;
|
||||||
if(consumes.has(ConsumePower.class)){
|
if(consumes.has(ConsumePower.class)){
|
||||||
powerNeeded += consumes.get(ConsumePower.class).requestedPower(consumer.block(), consumer.entity);
|
powerNeeded += consumes.get(ConsumePower.class).requestedPower(consumer.block(), consumer.entity) * consumer.entity.delta();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return powerNeeded;
|
return powerNeeded;
|
||||||
@@ -69,7 +69,7 @@ public class PowerGraph{
|
|||||||
for(Tile battery : batteries){
|
for(Tile battery : batteries){
|
||||||
Consumers consumes = battery.block().consumes;
|
Consumers consumes = battery.block().consumes;
|
||||||
if(consumes.has(ConsumePower.class)){
|
if(consumes.has(ConsumePower.class)){
|
||||||
totalCapacity += consumes.get(ConsumePower.class).requestedPower(battery.block(), battery.entity);
|
totalCapacity += consumes.get(ConsumePower.class).requestedPower(battery.block(), battery.entity) * battery.entity.delta();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return totalCapacity;
|
return totalCapacity;
|
||||||
@@ -218,6 +218,8 @@ public class PowerGraph{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// Update the graph once so direct consumers without any connected producer lose their power
|
||||||
|
graph.update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user