Heat conductor + phase heater
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
package mindustry.world.blocks.heat;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.struct.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
@@ -10,12 +12,13 @@ import mindustry.world.*;
|
||||
import mindustry.world.draw.*;
|
||||
|
||||
public class HeatConductor extends Block{
|
||||
public float visualMaxHeat = 10f;
|
||||
public float visualMaxHeat = 15f;
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
|
||||
public HeatConductor(String name){
|
||||
super(name);
|
||||
update = solid = rotate = true;
|
||||
rotateDraw = false;
|
||||
size = 3;
|
||||
}
|
||||
|
||||
@@ -23,7 +26,8 @@ public class HeatConductor extends Block{
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("heat", (HeatConductorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat / visualMaxHeat));
|
||||
//TODO show number
|
||||
bars.add("heat", (HeatConductorBuild entity) -> new Bar(() -> Core.bundle.format("bar.heatamount", (int)entity.heat), () -> Pal.lightOrange, () -> entity.heat / visualMaxHeat));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -43,8 +47,10 @@ public class HeatConductor extends Block{
|
||||
return drawer.finalIcons(this);
|
||||
}
|
||||
|
||||
public class HeatConductorBuild extends Building implements HeatBlock{
|
||||
public class HeatConductorBuild extends Building implements HeatBlock, HeatConsumer{
|
||||
public float heat = 0f;
|
||||
public float[] sideHeat = new float[4];
|
||||
public IntSet cameFrom = new IntSet();
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
@@ -57,9 +63,19 @@ public class HeatConductor extends Block{
|
||||
drawer.drawLights(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] sideHeat(){
|
||||
return sideHeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heatRequirement(){
|
||||
return visualMaxHeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
heat = calculateHeat(null);
|
||||
heat = calculateHeat(sideHeat, cameFrom);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
6
core/src/mindustry/world/blocks/heat/HeatConsumer.java
Normal file
6
core/src/mindustry/world/blocks/heat/HeatConsumer.java
Normal file
@@ -0,0 +1,6 @@
|
||||
package mindustry.world.blocks.heat;
|
||||
|
||||
public interface HeatConsumer{
|
||||
float[] sideHeat();
|
||||
float heatRequirement();
|
||||
}
|
||||
@@ -4,6 +4,7 @@ import arc.*;
|
||||
import arc.math.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
/** A crafter that requires contact from heater blocks to craft. */
|
||||
@@ -35,9 +36,10 @@ public class HeatCrafter extends GenericCrafter{
|
||||
super.setStats();
|
||||
|
||||
stats.add(Stat.input, heatRequirement, StatUnit.heatUnits);
|
||||
stats.add(Stat.maxEfficiency, (int)(maxEfficiency * 100f), StatUnit.percent);
|
||||
}
|
||||
|
||||
public class HeatCrafterBuild extends GenericCrafterBuild{
|
||||
public class HeatCrafterBuild extends GenericCrafterBuild implements HeatConsumer{
|
||||
//TODO sideHeat could be smooth
|
||||
public float[] sideHeat = new float[4];
|
||||
public float heat = 0f;
|
||||
@@ -49,10 +51,16 @@ public class HeatCrafter extends GenericCrafter{
|
||||
super.updateTile();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heatRequirement(){
|
||||
return heatRequirement;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float[] sideHeat(){
|
||||
return sideHeat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float warmupTarget(){
|
||||
return Mathf.clamp(heat / heatRequirement);
|
||||
|
||||
@@ -4,27 +4,42 @@ import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.HeatCrafter.*;
|
||||
import mindustry.world.blocks.heat.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawHeatInput extends DrawBlock{
|
||||
public String suffix = "-heat";
|
||||
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||
public float heatPulse = 0.3f, heatPulseScl = 10f;
|
||||
|
||||
public TextureRegion heat;
|
||||
|
||||
public DrawHeatInput(String suffix){
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public DrawHeatInput(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
|
||||
Draw.z(Layer.blockAdditive);
|
||||
if(build instanceof HeatCrafterBuild hc){
|
||||
if(build instanceof HeatConsumer hc){
|
||||
float[] side = hc.sideHeat();
|
||||
for(int i = 0; i < 4; i++){
|
||||
if(hc.sideHeat[i] > 0){
|
||||
if(side[i] > 0){
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.color(heatColor, hc.sideHeat[i] / hc.heatRequirement() * (heatColor.a * (1f - heatPulse + Mathf.absin(heatPulseScl, heatPulse))));
|
||||
Draw.color(heatColor, side[i] / hc.heatRequirement() * (heatColor.a * (1f - heatPulse + Mathf.absin(heatPulseScl, heatPulse))));
|
||||
Draw.rect(heat, build.x, build.y, i * 90f);
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
@@ -37,6 +52,6 @@ public class DrawHeatInput extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
heat = Core.atlas.find(block.name + "-heat");
|
||||
heat = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -61,6 +61,7 @@ public enum Stat{
|
||||
input(StatCat.crafting),
|
||||
output(StatCat.crafting),
|
||||
productionTime(StatCat.crafting),
|
||||
maxEfficiency(StatCat.crafting),
|
||||
drillTier(StatCat.crafting),
|
||||
drillSpeed(StatCat.crafting),
|
||||
linkRange(StatCat.crafting),
|
||||
|
||||
Reference in New Issue
Block a user