mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-10-01 18:50:27 +03:00
Sensing heat (#12191)
* Sensing heat * Returning null instead of 0 for turrets that do not use heat * Apply suggestions from code review Co-authored-by: Anuken <arnukren@gmail.com> --------- Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -107,8 +107,11 @@ public class ShockwaveTower extends Block{
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor) {
|
||||
if(sensor == LAccess.progress) return reloadCounter / reload;
|
||||
return super.sense(sensor);
|
||||
return switch(sensor){
|
||||
case progress -> reloadCounter / reload;
|
||||
case heat -> heat;
|
||||
default -> super.sense(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@ public class PowerTurret extends Turret{
|
||||
return switch(sensor){
|
||||
case ammo -> power == null ? 0f : power.status;
|
||||
case ammoCapacity -> 1;
|
||||
case heat -> heatRequirement > 0 ? heat : Float.NaN;
|
||||
default -> super.sense(sensor);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -8,6 +8,7 @@ import mindustry.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.draw.*;
|
||||
@@ -88,6 +89,12 @@ public class HeatConductor extends Block{
|
||||
heat = calculateHeat(sideHeat, cameFrom);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float warmup(){
|
||||
return heat;
|
||||
|
||||
@@ -4,6 +4,7 @@ import arc.math.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.draw.*;
|
||||
@@ -60,6 +61,12 @@ public class HeatProducer extends GenericCrafter{
|
||||
return heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
|
||||
@@ -3,6 +3,7 @@ package mindustry.world.blocks.power;
|
||||
import arc.math.*;
|
||||
import arc.util.io.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.draw.*;
|
||||
@@ -62,6 +63,12 @@ public class HeaterGenerator extends ConsumeGenerator{
|
||||
return heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
|
||||
@@ -12,6 +12,7 @@ import mindustry.entities.*;
|
||||
import mindustry.entities.effect.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -151,6 +152,12 @@ public class VariableReactor extends PowerGenerator{
|
||||
return maxHeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(Writes write){
|
||||
super.write(write);
|
||||
|
||||
@@ -3,6 +3,7 @@ package mindustry.world.blocks.production;
|
||||
import arc.*;
|
||||
import arc.math.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.logic.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.meta.*;
|
||||
@@ -71,6 +72,12 @@ public class HeatCrafter extends GenericCrafter{
|
||||
return Mathf.clamp(heat / heatRequirement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double sense(LAccess sensor){
|
||||
if(sensor == LAccess.heat) return heat;
|
||||
return super.sense(sensor);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float efficiencyScale(){
|
||||
float over = Math.max(heat - heatRequirement, 0f);
|
||||
|
||||
Reference in New Issue
Block a user