mirror of
https://github.com/Anuken/Mindustry.git
synced 2025-02-22 12:38:05 +07:00
HeatCrafter
This commit is contained in:
parent
a1107eae13
commit
51301a50cc
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.liquid = Liquid
|
||||
bar.heat = Heat
|
||||
bar.heatpercent = Heat: {0}
|
||||
bar.power = Power
|
||||
bar.progress = Build Progress
|
||||
bar.input = Input
|
||||
|
@ -950,17 +950,19 @@ public class Blocks implements ContentList{
|
||||
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));
|
||||
craftEffect = Fx.smeltsmoke;
|
||||
outputItem = new ItemStack(Items.carbide, 1);
|
||||
craftTime = 30f;
|
||||
size = 2;
|
||||
size = 3;
|
||||
hasPower = hasItems = true;
|
||||
drawer = new DrawSmelter(Color.valueOf("ffc099"));
|
||||
ambientSound = Sounds.smelter;
|
||||
ambientSoundVolume = 0.07f;
|
||||
|
||||
heatRequirement = 10f;
|
||||
|
||||
//TODO use heat!
|
||||
consumes.items(with(Items.tungsten, 1, Items.graphite, 2));
|
||||
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. */
|
||||
public void iterateTaken(int x, int y, Intc2 placer){
|
||||
if(isMultiblock()){
|
||||
|
@ -221,12 +221,12 @@ public class Build{
|
||||
|
||||
public static boolean contactsShallows(int x, int y, Block block){
|
||||
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);
|
||||
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);
|
||||
if(tile != null && !tile.floor().isDeep()) return true;
|
||||
}
|
||||
|
@ -1,14 +1,6 @@
|
||||
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{
|
||||
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.io.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
@ -26,6 +28,7 @@ public class HeatProducer extends Block{
|
||||
public @Load("@-top2") TextureRegion topRegion2;
|
||||
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||
public float heatPulse = 0.3f, heatPulseScl = 10f, glowMult = 1.2f;
|
||||
public Effect consumeEffect = Fx.none;
|
||||
|
||||
public HeatProducer(String 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);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
return new TextureRegion[]{region, topRegion1};
|
||||
@ -72,6 +74,7 @@ public class HeatProducer extends Block{
|
||||
|
||||
if(progress >= 1f){
|
||||
consume();
|
||||
consumeEffect.at(this);
|
||||
progress -= 1f;
|
||||
}
|
||||
}
|
||||
|
74
core/src/mindustry/world/blocks/production/HeatCrafter.java
Normal file
74
core/src/mindustry/world/blocks/production/HeatCrafter.java
Normal file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user