Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions core/src/mindustry/content/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
23 changes: 18 additions & 5 deletions core/src/mindustry/world/blocks/heat/HeatProducer.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,16 @@
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);

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();
Expand All @@ -36,40 +38,51 @@ 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
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();
}
}
}
23 changes: 18 additions & 5 deletions core/src/mindustry/world/blocks/power/HeaterGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,16 @@
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);

drawer = new DrawMulti(new DrawDefault(), new DrawHeatOutput());
rotateDraw = false;
rotate = true;
canOverdrive = false;
canOverdrive = true;
drawArrow = true;
}

Expand All @@ -38,40 +40,51 @@ 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
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();
}
}
}
13 changes: 12 additions & 1 deletion core/src/mindustry/world/blocks/power/NuclearReactor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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*/
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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){
Expand All @@ -134,7 +138,7 @@ public void updateTile(){

@Override
public float heatFrac(){
return heatProgress / heatOutput;
return heatProgress / heatOutScaled;
}

@Override
Expand Down Expand Up @@ -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();
}
}
}
Loading