diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 7ccac6343399..e459484013b5 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -2637,6 +2637,7 @@ public static void load(){ itemDuration = 360f; powerProduction = 15f; heating = 0.02f; + scaleHeat = false; consumeItem(Items.thorium); consumeLiquid(Liquids.cryofluid, heating / coolantPower).update(false); diff --git a/core/src/mindustry/world/blocks/heat/HeatProducer.java b/core/src/mindustry/world/blocks/heat/HeatProducer.java index e07cc083a4c2..e6f27bb95efb 100644 --- a/core/src/mindustry/world/blocks/heat/HeatProducer.java +++ b/core/src/mindustry/world/blocks/heat/HeatProducer.java @@ -12,6 +12,8 @@ public class HeatProducer extends GenericCrafter{ public float heatOutput = 10f; public float warmupRate = 0.15f; + /** Whether to scale heat output with timescale. */ + public boolean scaleHeat = true; public HeatProducer(String name){ super(name); @@ -19,7 +21,7 @@ public HeatProducer(String name){ drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput()); rotateDraw = false; rotate = true; - canOverdrive = false; + canOverdrive = true; drawArrow = true; //it doesn't count as a standard crafter flags = EnumSet.of(); @@ -36,23 +38,27 @@ public void setStats(){ public void setBars(){ super.setBars(); - addBar("heat", (HeatProducerBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat / heatOutput)); + addBar("heat", (HeatProducerBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> Mathf.clamp(entity.heat / entity.heatOutScaled))); } public class HeatProducerBuild extends GenericCrafterBuild implements HeatBlock{ public float heat; + public float heatOutScaled = heatOutput; @Override public void updateTile(){ super.updateTile(); - //heat approaches target at the same speed regardless of efficiency - heat = Mathf.approachDelta(heat, heatOutput * efficiency, warmupRate * delta()); + float approachHeat = heatOutput * (scaleHeat ? timeScale : 1f); + + //heat approaches target at the same speed regardless of efficiency. HeatOutput is scaled smoothly just like heat + heat = Mathf.approachDelta(heat, approachHeat * efficiency, warmupRate * delta()); + heatOutScaled = Mathf.approachDelta(heatOutScaled, approachHeat, warmupRate * delta()); } @Override public float heatFrac(){ - return heat / heatOutput; + return heat / heatOutScaled; } @Override @@ -60,16 +66,23 @@ public float heat(){ return heat; } + @Override + public byte version(){ + return 1; + } + @Override public void write(Writes write){ super.write(write); write.f(heat); + write.f(heatOutScaled); } @Override public void read(Reads read, byte revision){ super.read(read, revision); heat = read.f(); + if(revision >= 1) heatOutScaled = read.f(); } } } diff --git a/core/src/mindustry/world/blocks/power/HeaterGenerator.java b/core/src/mindustry/world/blocks/power/HeaterGenerator.java index 53350f9fd5a0..cf1f32530764 100644 --- a/core/src/mindustry/world/blocks/power/HeaterGenerator.java +++ b/core/src/mindustry/world/blocks/power/HeaterGenerator.java @@ -11,6 +11,8 @@ public class HeaterGenerator extends ConsumeGenerator{ public float heatOutput = 10f; public float warmupRate = 0.15f; + /** Whether to scale heat output with timescale. */ + public boolean scaleHeat = true; public HeaterGenerator(String name){ super(name); @@ -18,7 +20,7 @@ public HeaterGenerator(String name){ drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput()); rotateDraw = false; rotate = true; - canOverdrive = false; + canOverdrive = true; drawArrow = true; } @@ -38,23 +40,27 @@ public boolean rotatedOutput(int x, int y){ public void setBars(){ super.setBars(); - addBar("heat", (HeaterGeneratorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat / heatOutput)); + addBar("heat", (HeaterGeneratorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> Mathf.clamp(entity.heat / entity.heatOutScaled))); } public class HeaterGeneratorBuild extends ConsumeGeneratorBuild implements HeatBlock{ public float heat; + public float heatOutScaled = heatOutput; @Override public void updateTile(){ super.updateTile(); - //heat approaches target at the same speed regardless of efficiency - heat = Mathf.approachDelta(heat, heatOutput * efficiency, warmupRate * delta()); + float approachHeat = heatOutput * (scaleHeat ? timeScale : 1f); + + //heat approaches target at the same speed regardless of efficiency. HeatOutput is scaled smoothly just like heat + heat = Mathf.approachDelta(heat, approachHeat * efficiency, warmupRate * delta()); + heatOutScaled = Mathf.approachDelta(heatOutScaled, approachHeat, warmupRate * delta()); } @Override public float heatFrac(){ - return heat / heatOutput; + return heat / heatOutScaled; } @Override @@ -62,16 +68,23 @@ public float heat(){ return heat; } + @Override + public byte version(){ + return 2; + } + @Override public void write(Writes write){ super.write(write); write.f(heat); + write.f(heatOutScaled); } @Override public void read(Reads read, byte revision){ super.read(read, revision); heat = read.f(); + if(revision >= 2) heatOutScaled = read.f(); } } } diff --git a/core/src/mindustry/world/blocks/power/NuclearReactor.java b/core/src/mindustry/world/blocks/power/NuclearReactor.java index 3701ee5d84f8..11a8817d6abb 100644 --- a/core/src/mindustry/world/blocks/power/NuclearReactor.java +++ b/core/src/mindustry/world/blocks/power/NuclearReactor.java @@ -32,6 +32,8 @@ public class NuclearReactor extends PowerGenerator{ public float heating = 0.01f; /** max heat this block can output */ public float heatOutput = 15f; + /** whether to scale heat output (not base heat!) with timescale */ + public boolean scaleHeat = true; /** rate at which heat progress increases */ public float heatWarmupRate = 1f; /** time taken to cool down if no fuel is inputted even if coolant is not present*/ @@ -89,6 +91,7 @@ public void setBars(){ public class NuclearReactorBuild extends GeneratorBuild implements HeatBlock{ public float heat; public float heatProgress; + public float heatOutScaled = heatOutput; public float flash; public float smoothLight; @@ -124,6 +127,7 @@ public void updateTile(){ } heat = Mathf.clamp(heat); + if(scaleHeat) heatOutScaled = Mathf.approachDelta(heatOutScaled, heatOutput * timeScale, heatWarmupRate * delta()); heatProgress = heatOutput > 0f ? Mathf.approachDelta(heatProgress, heat * heatOutput * (enabled ? 1f : 0f), heatWarmupRate * delta()) : 0f; if(heat >= 0.999f){ @@ -134,7 +138,7 @@ public void updateTile(){ @Override public float heatFrac(){ - return heatProgress / heatOutput; + return heatProgress / heatOutScaled; } @Override @@ -181,16 +185,23 @@ public void draw(){ Draw.reset(); } + @Override + public byte version(){ + return 2; + } + @Override public void write(Writes write){ super.write(write); write.f(heat); + write.f(heatOutScaled); } @Override public void read(Reads read, byte revision){ super.read(read, revision); heat = read.f(); + if(revision >= 2) heatOutScaled = read.f(); } } }