oxidation chamber implementation

This commit is contained in:
Anuken
2021-11-16 14:54:23 -05:00
parent 67f8cffca0
commit 8d05b878d7
21 changed files with 50 additions and 29 deletions

View File

@@ -935,7 +935,7 @@ public class Blocks implements ContentList{
craftTime = 30f;
size = 2;
hasPower = hasItems = hasLiquids = true;
rotatePlan = false;
rotateDraw = false;
consumes.liquid(Liquids.oil, 0.1f);
consumes.power(0.7f);
@@ -987,8 +987,6 @@ public class Blocks implements ContentList{
}};
//TODO sprite
//TODO 'oxidation chamber'
if(false)
oxidationChamber = new HeatProducer("oxidation-chamber"){{
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
size = 3;
@@ -999,11 +997,19 @@ public class Blocks implements ContentList{
consumes.item(Items.beryllium);
consumes.power(1f);
rotateDraw = false;
//TODO rotor?
//TODO vent
iconOverride = new String[]{"-bottom", "", "-top1", "-glass"};
drawer = new DrawMulti(new DrawRegion("-bottom"), new DrawLiquidRegion(), new DrawBlock(), new DrawHeatOutput(), new DrawRegion("-glass"));
craftTime = 60f * 3f;
liquidCapacity = 30f;
heatOutput = 8f;
}};
//TODO check sprite correctness
heatReactor = new HeatProducer("heat-reactor"){{
//TODO quadvent
//TODO coolant?
@@ -1021,7 +1027,7 @@ public class Blocks implements ContentList{
size = 3;
itemCapacity = 20;
hasPower = hasItems = true;
drawer = new DrawMulti(new DrawCrucible(), new DrawHeat());
drawer = new DrawMulti(new DrawCrucible(), new DrawHeatInput());
ambientSound = Sounds.smelter;
ambientSoundVolume = 0.07f;

View File

@@ -337,6 +337,11 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
return rotation * 90;
}
/** @return preferred rotation of main texture region to be drawn */
public float drawrot(){
return block.rotate && block.rotateDraw ? rotation * 90 : 0f;
}
public Floor floor(){
return tile.floor();
}
@@ -930,9 +935,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc,
public void draw(){
if(block.variants == 0){
Draw.rect(block.region, x, y, block.rotate ? rotdeg() : 0);
Draw.rect(block.region, x, y, drawrot());
}else{
Draw.rect(block.variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, block.variantRegions.length - 1))], x, y, block.rotate ? rotdeg() : 0);
Draw.rect(block.variantRegions[Mathf.randomSeed(tile.pos(), 0, Math.max(0, block.variantRegions.length - 1))], x, y, drawrot());
}
drawTeamTop();

View File

@@ -64,6 +64,7 @@ public class ContentParser{
});
put(Sortf.class, (type, data) -> field(UnitSorts.class, data));
put(Interp.class, (type, data) -> field(Interp.class, data));
put(Blending.class, (type, data) -> field(Blending.class, data));
put(CacheLayer.class, (type, data) -> field(CacheLayer.class, data));
put(Attribute.class, (type, data) -> Attribute.get(data.asString()));
put(Schematic.class, (type, data) -> {

View File

@@ -90,8 +90,8 @@ public class Block extends UnlockableContent{
public boolean solidifes;
/** whether this is rotatable */
public boolean rotate;
/** if set to plan, the plan region won't rotate when drawing */
public boolean rotatePlan = true;
/** if rotate is true and this is false, the region won't rotate when drawing */
public boolean rotateDraw = true;
/** number of different variant regions to use */
public int variants = 0;
/** whether to draw a rotation arrow - this does not apply to lines of blocks */
@@ -579,7 +579,7 @@ public class Block extends UnlockableContent{
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
TextureRegion reg = getRequestRegion(plan, list);
Draw.rect(reg, plan.drawx(), plan.drawy(), !rotate || !rotatePlan ? 0 : plan.rotation * 90);
Draw.rect(reg, plan.drawx(), plan.drawy(), !rotate || !rotateDraw ? 0 : plan.rotation * 90);
if(plan.worldContext && player != null && teamRegion != null && teamRegion.found()){
if(teamRegions[player.team().id] == teamRegion) Draw.color(player.team().color);

View File

@@ -14,9 +14,13 @@ public class HeatProducer extends GenericCrafter{
public HeatProducer(String name){
super(name);
drawer = new DrawHeatOutput();
update = solid = rotate = true;
drawer = new DrawMulti(new DrawHeatOutput(){{
drawRegion = true;
}});
rotateDraw = false;
rotate = true;
canOverdrive = false;
drawArrow = true;
}
@Override

View File

@@ -16,23 +16,26 @@ public class DrawArcSmelter extends DrawBlock{
public float alpha = 0.68f;
public int particles = 25;
public float particleLife = 40f, particleRad = 7f, particleStroke = 1.1f, particleLen = 3f;
public boolean drawCenter = true;
public boolean drawBottom = true, drawTop = true, drawRegion = true;
public Blending blending = Blending.additive;
@Override
public void draw(GenericCrafterBuild build){
Draw.rect(bottom, build.x, build.y);
if(drawBottom) Draw.rect(bottom, build.x, build.y);
if(build.warmup > 0f && flameColor.a > 0.001f){
Lines.stroke(circleStroke * build.warmup);
float si = Mathf.absin(flameRadiusScl, flameRadiusMag);
float a = alpha * build.warmup;
Draw.blend(Blending.additive);
Draw.blend(blending);
Draw.color(midColor, a);
Fill.circle(build.x, build.y, flameRad + si);
if(drawCenter) Fill.circle(build.x, build.y, flameRad + si);
Draw.color(flameColor, a);
Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup);
if(drawCenter) Lines.circle(build.x, build.y, (flameRad + circleSpace + si) * build.warmup);
Lines.stroke(particleStroke * build.warmup);
@@ -49,8 +52,8 @@ public class DrawArcSmelter extends DrawBlock{
Draw.reset();
}
Draw.rect(build.block.region, build.x, build.y);
if(top.found()) Draw.rect(top, build.x, build.y);
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
if(drawTop && top.found()) Draw.rect(top, build.x, build.y);
}
@Override

View File

@@ -15,7 +15,7 @@ public class DrawBlock{
/** Draws the block. */
public void draw(GenericCrafterBuild build){
Draw.rect(build.block.region, build.x, build.y, build.block.rotate ? build.rotdeg() : 0);
Draw.rect(build.block.region, build.x, build.y, build.drawrot());
}
/** Draws any extra light for the block. */

View File

@@ -9,7 +9,8 @@ import mindustry.world.*;
import mindustry.world.blocks.production.GenericCrafter.*;
import mindustry.world.blocks.production.HeatCrafter.*;
public class DrawHeat extends DrawBlock{
/** Not standalone. */
public class DrawHeatInput extends DrawBlock{
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
public float heatPulse = 0.3f, heatPulseScl = 10f;

View File

@@ -17,10 +17,11 @@ public class DrawHeatOutput extends DrawBlock{
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
public float heatPulse = 0.3f, heatPulseScl = 10f, glowMult = 1.2f;
public boolean drawRegion = false;
@Override
public void draw(GenericCrafterBuild build){
Draw.rect(build.block.region, build.x, build.y);
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
Draw.rect(build.rotation > 1 ? top2 : top1, build.x, build.y, build.rotdeg());
@@ -28,9 +29,9 @@ public class DrawHeatOutput extends DrawBlock{
Draw.z(Layer.blockAdditive);
Draw.blend(Blending.additive);
Draw.color(heatColor, heater.heatFrac() * (heatColor.a * (1f - heatPulse + Mathf.absin(heatPulseScl, heatPulse))));
Draw.rect(heat, build.x, build.y, build.rotdeg());
if(heat.found()) Draw.rect(heat, build.x, build.y, build.rotdeg());
Draw.color(Draw.getColor().mul(glowMult));
Draw.rect(glow, build.x, build.y);
if(glow.found()) Draw.rect(glow, build.x, build.y);
Draw.blend();
Draw.color();
}
@@ -38,7 +39,7 @@ public class DrawHeatOutput extends DrawBlock{
@Override
public void drawPlan(GenericCrafter block, BuildPlan plan, Eachable<BuildPlan> list){
Draw.rect(block.region, plan.drawx(), plan.drawy());
if(drawRegion) Draw.rect(block.region, plan.drawx(), plan.drawy());
Draw.rect(plan.rotation > 1 ? top2 : top1, plan.drawx(), plan.drawy(), plan.rotation * 90);
}

View File

@@ -29,12 +29,11 @@ public class DrawLiquidRegion extends DrawBlock{
@Override
public void draw(GenericCrafterBuild build){
if(drawLiquid != null){
Drawf.liquid(liquid, build.x, build.y,
build.liquids.get(drawLiquid) / build.block.liquidCapacity,
drawLiquid.color
);
}
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
Drawf.liquid(liquid, build.x, build.y,
build.liquids.get(drawn) / build.block.liquidCapacity,
drawn.color
);
}
@Override