Vent condenser block
This commit is contained in:
80
core/src/mindustry/world/blocks/heat/HeatConductor.java
Normal file
80
core/src/mindustry/world/blocks/heat/HeatConductor.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package mindustry.world.blocks.heat;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.draw.*;
|
||||
|
||||
public class HeatConductor extends Block{
|
||||
public float visualMaxHeat = 10f;
|
||||
public DrawBlock drawer = new DrawBlock();
|
||||
|
||||
public HeatConductor(String name){
|
||||
super(name);
|
||||
update = solid = rotate = true;
|
||||
size = 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBars(){
|
||||
super.setBars();
|
||||
|
||||
bars.add("heat", (HeatConductorBuild entity) -> new Bar("bar.heat", Pal.lightOrange, () -> entity.heat / visualMaxHeat));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
drawer.load(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
return drawer.finalIcons(this);
|
||||
}
|
||||
|
||||
public class HeatConductorBuild extends Building implements HeatBlock{
|
||||
public float heat = 0f;
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
drawer.drawBase(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(){
|
||||
super.drawLight();
|
||||
drawer.drawLights(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
heat = calculateHeat(null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float warmup(){
|
||||
return heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heat(){
|
||||
return heat;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float heatFrac(){
|
||||
return heat / visualMaxHeat;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
public float displayEfficiencyScale = 1f;
|
||||
public boolean spinners = false;
|
||||
public boolean displayEfficiency = true;
|
||||
public @Nullable LiquidStack liquidOutput;
|
||||
public @Nullable LiquidStack outputLiquid;
|
||||
public Attribute attribute = Attribute.heat;
|
||||
|
||||
public @Load("@-rotator") TextureRegion rotatorRegion;
|
||||
@@ -34,7 +34,7 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
|
||||
@Override
|
||||
public void init(){
|
||||
if(liquidOutput != null){
|
||||
if(outputLiquid != null){
|
||||
outputsLiquid = true;
|
||||
hasLiquids = true;
|
||||
}
|
||||
@@ -49,8 +49,8 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
|
||||
stats.add(Stat.tiles, attribute, floating, size * size * displayEfficiencyScale, !displayEfficiency);
|
||||
|
||||
if(liquidOutput != null){
|
||||
stats.add(Stat.output, StatValues.liquid(liquidOutput.liquid, liquidOutput.amount * size * size * 60f, true));
|
||||
if(outputLiquid != null){
|
||||
stats.add(Stat.output, StatValues.liquid(outputLiquid.liquid, outputLiquid.amount * size * size * 60f, true));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,10 +88,10 @@ public class ThermalGenerator extends PowerGenerator{
|
||||
|
||||
spinRotation += productionEfficiency * spinSpeed;
|
||||
|
||||
if(liquidOutput != null){
|
||||
float added = Math.min(productionEfficiency * delta() * liquidOutput.amount, liquidCapacity - liquids.get(liquidOutput.liquid));
|
||||
liquids.add(liquidOutput.liquid, added);
|
||||
dumpLiquid(liquidOutput.liquid);
|
||||
if(outputLiquid != null){
|
||||
float added = Math.min(productionEfficiency * delta() * outputLiquid.amount, liquidCapacity - liquids.get(outputLiquid.liquid));
|
||||
liquids.add(outputLiquid.liquid, added);
|
||||
dumpLiquid(outputLiquid.liquid);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package mindustry.world.blocks.production;
|
||||
|
||||
import arc.*;
|
||||
import mindustry.game.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.ui.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
/** A crafter that gains efficiency from attribute tiles. */
|
||||
@@ -11,6 +13,9 @@ public class AttributeCrafter extends GenericCrafter{
|
||||
public float baseEfficiency = 1f;
|
||||
public float boostScale = 1f;
|
||||
public float maxBoost = 1f;
|
||||
public float minEfficiency = -1f;
|
||||
public float displayEfficiencyScale = 1f;
|
||||
public boolean displayEfficiency = true;
|
||||
|
||||
public AttributeCrafter(String name){
|
||||
super(name);
|
||||
@@ -18,6 +23,10 @@ public class AttributeCrafter extends GenericCrafter{
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
if(!displayEfficiency) return;
|
||||
|
||||
drawPlaceText(Core.bundle.format("bar.efficiency",
|
||||
(int)((baseEfficiency + Math.min(maxBoost, boostScale * sumAttribute(attribute, x, y))) * 100f)), x, y, valid);
|
||||
}
|
||||
@@ -28,11 +37,17 @@ public class AttributeCrafter extends GenericCrafter{
|
||||
|
||||
bars.add("efficiency", (AttributeCrafterBuild entity) ->
|
||||
new Bar(() ->
|
||||
Core.bundle.format("bar.efficiency", (int)(entity.efficiencyScale() * 100)),
|
||||
Core.bundle.format("bar.efficiency", (int)(entity.efficiencyScale() * 100 * displayEfficiencyScale)),
|
||||
() -> Pal.lightOrange,
|
||||
entity::efficiencyScale));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlaceOn(Tile tile, Team team, int rotation){
|
||||
//make sure there's enough efficiency at this location
|
||||
return tile.getLinkedTilesAs(this, tempTiles).sumf(other -> other.floor().attributes.get(attribute)) > minEfficiency;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setStats(){
|
||||
super.setStats();
|
||||
|
||||
@@ -30,6 +30,7 @@ public class GenericCrafter extends Block{
|
||||
|
||||
/** if true, crafters with multiple liquid outputs will dump excess when there's still space for at least one liquid type */
|
||||
public boolean dumpExtraLiquid = true;
|
||||
public boolean ignoreLiquidFullness = false;
|
||||
public float craftTime = 80;
|
||||
public Effect craftEffect = Fx.none;
|
||||
public Effect updateEffect = Fx.none;
|
||||
@@ -115,10 +116,6 @@ public class GenericCrafter extends Block{
|
||||
super.init();
|
||||
}
|
||||
|
||||
public void drawPlanBase(BuildPlan req, Eachable<BuildPlan> list){
|
||||
super.drawRequestRegion(req, list);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
drawer.drawPlan(this, plan, list);
|
||||
@@ -164,7 +161,7 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
}
|
||||
}
|
||||
if(outputLiquids != null){
|
||||
if(outputLiquids != null && !ignoreLiquidFullness){
|
||||
boolean allFull = true;
|
||||
for(var output : outputLiquids){
|
||||
if(liquids.get(output.liquid) >= liquidCapacity - 0.001f){
|
||||
|
||||
@@ -13,6 +13,7 @@ public class DrawRegion extends DrawBlock{
|
||||
public TextureRegion region;
|
||||
public String suffix = "";
|
||||
public boolean spinSprite = false;
|
||||
public boolean drawPlan = true;
|
||||
public float rotateSpeed, x, y;
|
||||
/** Any number <=0 disables layer changes. */
|
||||
public float layer = -1;
|
||||
@@ -38,6 +39,7 @@ public class DrawRegion extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(!drawPlan) return;
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
|
||||
@@ -168,6 +168,7 @@ public class DrawTurret extends DrawBlock{
|
||||
progress = interp.apply(progress);
|
||||
|
||||
for(int i = 0; i < regions.length; i++){
|
||||
//can be null if drawRegion == false
|
||||
var region = regions[i];
|
||||
float sign = i == 1 ? -1 : 1;
|
||||
Tmp.v1.set((x + moveX * progress) * sign, y + moveY * progress).rotate((build.rotation - 90));
|
||||
@@ -218,6 +219,8 @@ public class DrawTurret extends DrawBlock{
|
||||
regions = new TextureRegion[]{Core.atlas.find(block.name + suffix)};
|
||||
outlines = new TextureRegion[]{Core.atlas.find(block.name + suffix + "-outline")};
|
||||
}
|
||||
}else{
|
||||
regions = new TextureRegion[1];
|
||||
}
|
||||
|
||||
heat = Core.atlas.find(block.name + suffix + "-heat");
|
||||
|
||||
Reference in New Issue
Block a user