Resolved some of the power-related TODOs
This commit is contained in:
@@ -40,7 +40,6 @@ public class DebugBlocks extends BlockList implements ContentList{
|
|||||||
public void load(){
|
public void load(){
|
||||||
powerVoid = new PowerBlock("powervoid"){
|
powerVoid = new PowerBlock("powervoid"){
|
||||||
{
|
{
|
||||||
// TODO Adapt to new power system if necessary
|
|
||||||
consumes.powerDirect(Float.MAX_VALUE);
|
consumes.powerDirect(Float.MAX_VALUE);
|
||||||
shadow = "shadow-round-1";
|
shadow = "shadow-round-1";
|
||||||
}
|
}
|
||||||
@@ -54,8 +53,7 @@ public class DebugBlocks extends BlockList implements ContentList{
|
|||||||
@Override
|
@Override
|
||||||
public void init(){
|
public void init(){
|
||||||
super.init();
|
super.init();
|
||||||
// TODO Adapt to new power system if necessary
|
stats.remove(BlockStat.powerUse);
|
||||||
//stats.remove(BlockStat.powerCapacity);
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -67,7 +65,6 @@ public class DebugBlocks extends BlockList implements ContentList{
|
|||||||
shadow = "shadow-round-1";
|
shadow = "shadow-round-1";
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Adapt to new power system if necessary
|
|
||||||
@Override
|
@Override
|
||||||
public float getPowerProduction(Tile tile){
|
public float getPowerProduction(Tile tile){
|
||||||
return 10000f;
|
return 10000f;
|
||||||
|
|||||||
@@ -22,8 +22,6 @@ public class LiquidBlocks extends BlockList implements ContentList{
|
|||||||
pumpAmount = 0.2f;
|
pumpAmount = 0.2f;
|
||||||
consumes.powerDirect(0.015f);
|
consumes.powerDirect(0.015f);
|
||||||
liquidCapacity = 30f;
|
liquidCapacity = 30f;
|
||||||
// TODO Verify: No longer buffered
|
|
||||||
consumes.powerDirect(20f / 60f);
|
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
size = 2;
|
size = 2;
|
||||||
tier = 1;
|
tier = 1;
|
||||||
@@ -35,8 +33,6 @@ public class LiquidBlocks extends BlockList implements ContentList{
|
|||||||
consumes.powerDirect(0.03f);
|
consumes.powerDirect(0.03f);
|
||||||
liquidCapacity = 40f;
|
liquidCapacity = 40f;
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
// TODO Verify: No longer buffered
|
|
||||||
consumes.powerDirect(20f / 60f);
|
|
||||||
size = 2;
|
size = 2;
|
||||||
tier = 2;
|
tier = 2;
|
||||||
}};
|
}};
|
||||||
|
|||||||
@@ -4,17 +4,17 @@ import com.badlogic.gdx.graphics.Color;
|
|||||||
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
import com.badlogic.gdx.graphics.g2d.TextureRegion;
|
||||||
import io.anuke.mindustry.entities.TileEntity;
|
import io.anuke.mindustry.entities.TileEntity;
|
||||||
import io.anuke.mindustry.world.Tile;
|
import io.anuke.mindustry.world.Tile;
|
||||||
import io.anuke.mindustry.world.blocks.production.GenericCrafter.GenericCrafterEntity;
|
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
|
||||||
import io.anuke.mindustry.world.meta.StatUnit;
|
|
||||||
import io.anuke.ucore.core.Graphics;
|
import io.anuke.ucore.core.Graphics;
|
||||||
import io.anuke.ucore.core.Timers;
|
import io.anuke.ucore.core.Timers;
|
||||||
import io.anuke.ucore.graphics.Draw;
|
import io.anuke.ucore.graphics.Draw;
|
||||||
import io.anuke.ucore.util.Mathf;
|
import io.anuke.ucore.util.Mathf;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class FusionReactor extends PowerGenerator{
|
public class FusionReactor extends PowerGenerator{
|
||||||
protected int plasmas = 4;
|
protected int plasmas = 4;
|
||||||
protected float maxPowerProduced = 2f;
|
|
||||||
protected float warmupSpeed = 0.001f;
|
protected float warmupSpeed = 0.001f;
|
||||||
|
|
||||||
protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
|
protected Color plasma1 = Color.valueOf("ffd06b"), plasma2 = Color.valueOf("ff361b");
|
||||||
@@ -24,35 +24,25 @@ public class FusionReactor extends PowerGenerator{
|
|||||||
super(name);
|
super(name);
|
||||||
hasPower = true;
|
hasPower = true;
|
||||||
hasLiquids = true;
|
hasLiquids = true;
|
||||||
// TODO Adapt to new power system
|
powerProduction = 2.0f;
|
||||||
//powerCapacity = 100f;
|
|
||||||
liquidCapacity = 30f;
|
liquidCapacity = 30f;
|
||||||
hasItems = true;
|
hasItems = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void setStats(){
|
|
||||||
super.setStats();
|
|
||||||
|
|
||||||
// TODO Verify for new power system
|
|
||||||
stats.remove(BlockStat.basePowerGeneration);
|
|
||||||
stats.add(BlockStat.basePowerGeneration, maxPowerProduced * 60f, StatUnit.powerSecond);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(Tile tile){
|
public void update(Tile tile){
|
||||||
FusionReactorEntity entity = tile.entity();
|
FusionReactorEntity entity = tile.entity();
|
||||||
|
|
||||||
|
float increaseOrDecrease = 1.0f;
|
||||||
if(entity.cons.valid()){
|
if(entity.cons.valid()){
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 1f, warmupSpeed);
|
||||||
}else{
|
}else{
|
||||||
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.01f);
|
entity.warmup = Mathf.lerpDelta(entity.warmup, 0f, 0.01f);
|
||||||
|
increaseOrDecrease = -1.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO Adapt to new power system
|
float efficiencyAdded = Mathf.pow(entity.warmup, 4f) * Timers.delta();
|
||||||
//float powerAdded = Math.min(powerCapacity - entity.power.amount, maxPowerProduced * Mathf.pow(entity.warmup, 4f) * Timers.delta());
|
entity.productionEfficiency = Mathf.clamp(entity.productionEfficiency + efficiencyAdded * increaseOrDecrease);
|
||||||
//entity.power.amount += powerAdded;
|
|
||||||
entity.totalProgress += entity.warmup * Timers.delta();
|
|
||||||
|
|
||||||
tile.entity.power.graph.update();
|
tile.entity.power.graph.update();
|
||||||
}
|
}
|
||||||
@@ -100,7 +90,7 @@ public class FusionReactor extends PowerGenerator{
|
|||||||
|
|
||||||
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
Draw.rect(name + "-top", tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
Draw.color(ind1, ind2, entity.warmup + Mathf.absin(entity.totalProgress, 3f, entity.warmup * 0.5f));
|
Draw.color(ind1, ind2, entity.warmup + Mathf.absin(entity.productionEfficiency, 3f, entity.warmup * 0.5f));
|
||||||
Draw.rect(name + "-light", tile.drawx(), tile.drawy());
|
Draw.rect(name + "-light", tile.drawx(), tile.drawy());
|
||||||
|
|
||||||
Draw.color();
|
Draw.color();
|
||||||
@@ -127,7 +117,19 @@ public class FusionReactor extends PowerGenerator{
|
|||||||
//TODO catastrophic failure
|
//TODO catastrophic failure
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class FusionReactorEntity extends GenericCrafterEntity{
|
public static class FusionReactorEntity extends GeneratorEntity{
|
||||||
|
public float warmup;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
super.write(stream);
|
||||||
|
stream.writeFloat(warmup);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(DataInput stream) throws IOException{
|
||||||
|
super.read(stream);
|
||||||
|
warmup = stream.readFloat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,6 +10,10 @@ import io.anuke.mindustry.world.Tile;
|
|||||||
import io.anuke.mindustry.world.meta.BlockFlag;
|
import io.anuke.mindustry.world.meta.BlockFlag;
|
||||||
import io.anuke.mindustry.world.meta.BlockStat;
|
import io.anuke.mindustry.world.meta.BlockStat;
|
||||||
|
|
||||||
|
import java.io.DataInput;
|
||||||
|
import java.io.DataOutput;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
public class PowerGenerator extends PowerDistributor{
|
public class PowerGenerator extends PowerDistributor{
|
||||||
/** The amount of power produced per tick. */
|
/** The amount of power produced per tick. */
|
||||||
protected float powerProduction;
|
protected float powerProduction;
|
||||||
@@ -58,5 +62,15 @@ public class PowerGenerator extends PowerDistributor{
|
|||||||
public static class GeneratorEntity extends TileEntity{
|
public static class GeneratorEntity extends TileEntity{
|
||||||
public float generateTime;
|
public float generateTime;
|
||||||
public float productionEfficiency = 0.0f;
|
public float productionEfficiency = 0.0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(DataOutput stream) throws IOException{
|
||||||
|
stream.writeFloat(productionEfficiency);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(DataInput stream) throws IOException{
|
||||||
|
productionEfficiency = stream.readFloat();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user