HeatCrafter
This commit is contained in:
Binary file not shown.
|
Before Width: | Height: | Size: 896 B After Width: | Height: | Size: 850 B |
@@ -810,6 +810,7 @@ bar.capacity = Capacity: {0}
|
|||||||
bar.unitcap = {0} {1}/{2}
|
bar.unitcap = {0} {1}/{2}
|
||||||
bar.liquid = Liquid
|
bar.liquid = Liquid
|
||||||
bar.heat = Heat
|
bar.heat = Heat
|
||||||
|
bar.heatpercent = Heat: {0}
|
||||||
bar.power = Power
|
bar.power = Power
|
||||||
bar.progress = Build Progress
|
bar.progress = Build Progress
|
||||||
bar.input = Input
|
bar.input = Input
|
||||||
|
|||||||
@@ -950,17 +950,19 @@ public class Blocks implements ContentList{
|
|||||||
consumes.item(Items.fissileMatter, 1);
|
consumes.item(Items.fissileMatter, 1);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
carbideCrucible = new GenericCrafter("carbide-crucible"){{
|
carbideCrucible = new HeatCrafter("carbide-crucible"){{
|
||||||
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
||||||
craftEffect = Fx.smeltsmoke;
|
craftEffect = Fx.smeltsmoke;
|
||||||
outputItem = new ItemStack(Items.carbide, 1);
|
outputItem = new ItemStack(Items.carbide, 1);
|
||||||
craftTime = 30f;
|
craftTime = 30f;
|
||||||
size = 2;
|
size = 3;
|
||||||
hasPower = hasItems = true;
|
hasPower = hasItems = true;
|
||||||
drawer = new DrawSmelter(Color.valueOf("ffc099"));
|
drawer = new DrawSmelter(Color.valueOf("ffc099"));
|
||||||
ambientSound = Sounds.smelter;
|
ambientSound = Sounds.smelter;
|
||||||
ambientSoundVolume = 0.07f;
|
ambientSoundVolume = 0.07f;
|
||||||
|
|
||||||
|
heatRequirement = 10f;
|
||||||
|
|
||||||
//TODO use heat!
|
//TODO use heat!
|
||||||
consumes.items(with(Items.tungsten, 1, Items.graphite, 2));
|
consumes.items(with(Items.tungsten, 1, Items.graphite, 2));
|
||||||
consumes.power(2f);
|
consumes.power(2f);
|
||||||
|
|||||||
@@ -604,6 +604,14 @@ public class Block extends UnlockableContent{
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Point2[] getEdges(){
|
||||||
|
return Edges.getEdges(size);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Point2[] getInsideEdges(){
|
||||||
|
return Edges.getInsideEdges(size);
|
||||||
|
}
|
||||||
|
|
||||||
/** Iterate through ever grid position taken up by this block. */
|
/** Iterate through ever grid position taken up by this block. */
|
||||||
public void iterateTaken(int x, int y, Intc2 placer){
|
public void iterateTaken(int x, int y, Intc2 placer){
|
||||||
if(isMultiblock()){
|
if(isMultiblock()){
|
||||||
|
|||||||
@@ -221,12 +221,12 @@ public class Build{
|
|||||||
|
|
||||||
public static boolean contactsShallows(int x, int y, Block block){
|
public static boolean contactsShallows(int x, int y, Block block){
|
||||||
if(block.isMultiblock()){
|
if(block.isMultiblock()){
|
||||||
for(Point2 point : Edges.getInsideEdges(block.size)){
|
for(Point2 point : block.getInsideEdges()){
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && !tile.floor().isDeep()) return true;
|
if(tile != null && !tile.floor().isDeep()) return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Point2 point : Edges.getEdges(block.size)){
|
for(Point2 point : block.getEdges()){
|
||||||
Tile tile = world.tile(x + point.x, y + point.y);
|
Tile tile = world.tile(x + point.x, y + point.y);
|
||||||
if(tile != null && !tile.floor().isDeep()) return true;
|
if(tile != null && !tile.floor().isDeep()) return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,6 @@
|
|||||||
package mindustry.world.blocks.heat;
|
package mindustry.world.blocks.heat;
|
||||||
|
|
||||||
/** Basic interface for any block that produces or requires heat.*/
|
/** Basic interface for any block that produces heat.*/
|
||||||
public interface HeatBlock{
|
public interface HeatBlock{
|
||||||
float heat();
|
float heat();
|
||||||
|
|
||||||
//potentially unnecessary
|
|
||||||
/*
|
|
||||||
void heat(float value);
|
|
||||||
|
|
||||||
default void addHeat(float amount){
|
|
||||||
heat(heat() + amount);
|
|
||||||
}*/
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ import arc.math.*;
|
|||||||
import arc.util.*;
|
import arc.util.*;
|
||||||
import arc.util.io.*;
|
import arc.util.io.*;
|
||||||
import mindustry.annotations.Annotations.*;
|
import mindustry.annotations.Annotations.*;
|
||||||
|
import mindustry.content.*;
|
||||||
|
import mindustry.entities.*;
|
||||||
import mindustry.entities.units.*;
|
import mindustry.entities.units.*;
|
||||||
import mindustry.gen.*;
|
import mindustry.gen.*;
|
||||||
import mindustry.graphics.*;
|
import mindustry.graphics.*;
|
||||||
@@ -26,6 +28,7 @@ public class HeatProducer extends Block{
|
|||||||
public @Load("@-top2") TextureRegion topRegion2;
|
public @Load("@-top2") TextureRegion topRegion2;
|
||||||
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||||
public float heatPulse = 0.3f, heatPulseScl = 10f, glowMult = 1.2f;
|
public float heatPulse = 0.3f, heatPulseScl = 10f, glowMult = 1.2f;
|
||||||
|
public Effect consumeEffect = Fx.none;
|
||||||
|
|
||||||
public HeatProducer(String name){
|
public HeatProducer(String name){
|
||||||
super(name);
|
super(name);
|
||||||
@@ -55,7 +58,6 @@ public class HeatProducer extends Block{
|
|||||||
Draw.rect(req.rotation > 1 ? topRegion2 : topRegion1, req.drawx(), req.drawy(), req.rotation * 90);
|
Draw.rect(req.rotation > 1 ? topRegion2 : topRegion1, req.drawx(), req.drawy(), req.rotation * 90);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TextureRegion[] icons(){
|
public TextureRegion[] icons(){
|
||||||
return new TextureRegion[]{region, topRegion1};
|
return new TextureRegion[]{region, topRegion1};
|
||||||
@@ -72,6 +74,7 @@ public class HeatProducer extends Block{
|
|||||||
|
|
||||||
if(progress >= 1f){
|
if(progress >= 1f){
|
||||||
consume();
|
consume();
|
||||||
|
consumeEffect.at(this);
|
||||||
progress -= 1f;
|
progress -= 1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,74 @@
|
|||||||
|
package mindustry.world.blocks.production;
|
||||||
|
|
||||||
|
import arc.*;
|
||||||
|
import arc.math.*;
|
||||||
|
import mindustry.gen.*;
|
||||||
|
import mindustry.graphics.*;
|
||||||
|
import mindustry.ui.*;
|
||||||
|
import mindustry.world.blocks.heat.*;
|
||||||
|
|
||||||
|
/** A crafter that requires contact from heater blocks to craft. */
|
||||||
|
public class HeatCrafter extends GenericCrafter{
|
||||||
|
/** Base heat requirement for 100% efficiency. */
|
||||||
|
public float heatRequirement = 10f;
|
||||||
|
/** After heat meets this requirement, excess heat will be scaled by this number. */
|
||||||
|
public float overheatScale = 0.25f;
|
||||||
|
/** Maximum possible efficiency after overheat. */
|
||||||
|
public float maxEfficiency = 2f;
|
||||||
|
|
||||||
|
public HeatCrafter(String name){
|
||||||
|
super(name);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBars(){
|
||||||
|
super.setBars();
|
||||||
|
|
||||||
|
bars.add("heat", (AttributeCrafterBuild entity) ->
|
||||||
|
new Bar(() ->
|
||||||
|
Core.bundle.format("bar.heatpercent", (int)entity.lastHeat),
|
||||||
|
() -> Pal.lightOrange,
|
||||||
|
() -> entity.lastHeat / heatRequirement));
|
||||||
|
|
||||||
|
//TODO unnecessary?
|
||||||
|
bars.add("efficiency", (AttributeCrafterBuild entity) ->
|
||||||
|
new Bar(() ->
|
||||||
|
Core.bundle.format("bar.efficiency", (int)(entity.efficiencyScale() * 100)),
|
||||||
|
() -> Pal.ammo,
|
||||||
|
entity::efficiencyScale));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStats(){
|
||||||
|
super.setStats();
|
||||||
|
|
||||||
|
//TODO heat stats
|
||||||
|
}
|
||||||
|
|
||||||
|
public class AttributeCrafterBuild extends GenericCrafterBuild{
|
||||||
|
public float lastHeat = 0f;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateTile(){
|
||||||
|
lastHeat = 0f;
|
||||||
|
for(var edge : getEdges()){
|
||||||
|
Building build = nearby(edge.x, edge.y);
|
||||||
|
if(build != null && build.team == team && build instanceof HeatBlock heater && (!build.block.rotate || (relativeTo(build) + 2) % 4 == build.rotation)){
|
||||||
|
//heat is distributed across building size
|
||||||
|
lastHeat += heater.heat() / build.block.size;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.updateTile();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public float getProgressIncrease(float base){
|
||||||
|
return super.getProgressIncrease(base) * efficiencyScale();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float efficiencyScale(){
|
||||||
|
float over = Math.max(lastHeat - heatRequirement, 0f);
|
||||||
|
return Math.min(Mathf.clamp(lastHeat / heatRequirement) + over / heatRequirement * overheatScale, maxEfficiency);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user