Initial Efficiency is now zero. Blocks display efficiency.

This commit is contained in:
Timmeey86
2018-11-28 13:19:52 +01:00
parent cf3d2c3def
commit 2972780bed
5 changed files with 45 additions and 11 deletions

View File

@@ -4,6 +4,7 @@ import io.anuke.mindustry.content.Liquids;
import io.anuke.mindustry.content.fx.BlockFx;
import io.anuke.mindustry.game.ContentList;
import io.anuke.mindustry.world.Block;
import io.anuke.mindustry.world.Tile;
import io.anuke.mindustry.world.blocks.power.*;
public class PowerBlocks extends BlockList implements ContentList{
@@ -41,14 +42,26 @@ public class PowerBlocks extends BlockList implements ContentList{
itemDuration = 220f;
}};
solarPanel = new PowerGenerator("solar-panel"){{
powerProduction = 0.0045f;
}};
// TODO: Maybe reintroduce a class for the initial production efficiency
solarPanel = new PowerGenerator("solar-panel"){
{
powerProduction = 0.0045f;
}
@Override
public void update(Tile tile){
tile.<GeneratorEntity>entity().productionEfficiency = 1.0f;
}
};
largeSolarPanel = new PowerGenerator("solar-panel-large"){{
powerProduction = 0.055f;
size = 3;
}};
largeSolarPanel = new PowerGenerator("solar-panel-large"){
{
powerProduction = 0.055f;
}
@Override
public void update(Tile tile){
tile.<GeneratorEntity>entity().productionEfficiency = 1.0f;
}
};
thoriumReactor = new NuclearReactor("thorium-reactor"){{
size = 3;

View File

@@ -337,9 +337,8 @@ public class Block extends BaseBlock {
}
public void setBars(){
if(consumes.has(ConsumePower.class)){
if(consumes.has(ConsumePower.class))
bars.add(new BlockBar(BarType.power, true, tile -> tile.entity.power.satisfaction));
}
if(hasLiquids)
bars.add(new BlockBar(BarType.liquid, true, tile -> tile.entity.liquids.total() / liquidCapacity));
if(hasItems)

View File

@@ -1,5 +1,7 @@
package io.anuke.mindustry.world.blocks.power;
import io.anuke.mindustry.world.BarType;
import io.anuke.mindustry.world.meta.BlockBar;
import io.anuke.mindustry.world.meta.StatUnit;
import io.anuke.ucore.util.EnumSet;
@@ -11,6 +13,11 @@ import io.anuke.mindustry.world.meta.BlockStat;
public class PowerGenerator extends PowerDistributor{
/** The amount of power produced per tick. */
protected float powerProduction;
/** The maximum possible efficiency for this generator. Supply values larger than 1.0f if more than 100% is possible.
* This could be the case when e.g. an item with 100% flammability is the reference point, but a more effective liquid
* can be supplied as an alternative.
*/
protected float maxEfficiency = 1.0f;
public BlockStat generationType = BlockStat.basePowerGeneration;
public PowerGenerator(String name){
@@ -40,8 +47,16 @@ public class PowerGenerator extends PowerDistributor{
return new GeneratorEntity();
}
@Override
public void setBars(){
super.setBars();
if(hasPower){
bars.add(new BlockBar(BarType.power, true, tile -> tile.<GeneratorEntity>entity().productionEfficiency / maxEfficiency));
}
}
public static class GeneratorEntity extends TileEntity{
public float generateTime;
public float productionEfficiency = 1;
public float productionEfficiency = 0.0f;
}
}

View File

@@ -86,7 +86,9 @@ public class ConsumePower extends Consume{
* @return The amount of power which is requested per tick.
*/
public float requestedPower(Block block, TileEntity entity){
// TODO Is it possible to make the block not consume power while items/liquids are missing?
// TODO Make the block not consume power on the following conditions, either here or in PowerGraph:
// - Other consumers are not valid, e.g. additional input items/liquids are missing
// - Buffer is full
return powerPerTick;
}