Cyanogen synthesis retexture
This commit is contained in:
@@ -23,6 +23,9 @@ import static mindustry.Vars.*;
|
||||
import static mindustry.type.Liquid.*;
|
||||
|
||||
public class Conduit extends LiquidBlock implements Autotiler{
|
||||
static final float rotatePad = 6, hpad = rotatePad / 2f / 4f;
|
||||
static final float[][] rotateOffsets = {{hpad, hpad}, {-hpad, hpad}, {-hpad, -hpad}, {hpad, -hpad}};
|
||||
|
||||
public final int timerFlow = timers++;
|
||||
|
||||
public Color botColor = Color.valueOf("565656");
|
||||
@@ -31,8 +34,8 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public @Load(value = "@-bottom-#", length = 5, fallback = "conduit-bottom-#") TextureRegion[] botRegions;
|
||||
public @Load("@-cap") TextureRegion capRegion;
|
||||
|
||||
public @Load(value = "conduit-liquid-r#1-gas-#2", lengths = {4, animationFrames}) TextureRegion[][] rotateGasRegions;
|
||||
public @Load(value = "conduit-liquid-r#1-liquid-#2", lengths = {4, animationFrames}) TextureRegion[][] rotateLiquidRegions;
|
||||
/** indices: [rotation] [fluid type] [frame] */
|
||||
public TextureRegion[][][] rotateRegions;
|
||||
|
||||
public boolean leaks = true;
|
||||
public @Nullable Block junctionReplacement, bridgeReplacement, rotBridgeReplacement;
|
||||
@@ -55,6 +58,44 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
if(bridgeReplacement == null || !(bridgeReplacement instanceof ItemBridge)) bridgeReplacement = Blocks.bridgeConduit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
super.load();
|
||||
|
||||
rotateRegions = new TextureRegion[4][2][animationFrames];
|
||||
|
||||
if(renderer != null){
|
||||
float pad = rotatePad;
|
||||
var frames = renderer.getFluidFrames();
|
||||
|
||||
for(int rot = 0; rot < 4; rot++){
|
||||
for(int fluid = 0; fluid < 2; fluid++){
|
||||
for(int frame = 0; frame < animationFrames; frame++){
|
||||
TextureRegion base = frames[fluid][frame];
|
||||
TextureRegion result = new TextureRegion();
|
||||
result.set(base);
|
||||
|
||||
if(rot == 0){
|
||||
result.setX(result.getX() + pad);
|
||||
result.setHeight(result.height - pad);
|
||||
}else if(rot == 1){
|
||||
result.setWidth(result.width - pad);
|
||||
result.setHeight(result.height - pad);
|
||||
}else if(rot == 2){
|
||||
result.setWidth(result.width - pad);
|
||||
result.setY(result.getY() + pad);
|
||||
}else{
|
||||
result.setX(result.getX() + pad);
|
||||
result.setY(result.getY() + pad);
|
||||
}
|
||||
|
||||
rotateRegions[rot][fluid][frame] = result;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawRequestRegion(BuildPlan plan, Eachable<BuildPlan> list){
|
||||
int[] bits = getTiling(plan, list);
|
||||
@@ -138,17 +179,21 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
int offset = yscl == -1 ? 3 : 0;
|
||||
|
||||
//TODO move out of conduit
|
||||
int frame = liquids.current().getAnimationFrame();
|
||||
TextureRegion liquidr =
|
||||
liquids.current().gas ?
|
||||
(bits == 1 ? rotateGasRegions[(rotation + offset) % 4][frame] : renderer.fluidFrames[1][frame]) :
|
||||
(bits == 1 ? rotateLiquidRegions[(rotation + offset) % 4][frame] : renderer.fluidFrames[0][frame]);
|
||||
int gas = liquids.current().gas ? 1 : 0;
|
||||
float ox = 0f, oy = 0f;
|
||||
int wrapRot = (rotation + offset) % 4;
|
||||
TextureRegion liquidr = bits == 1 ? rotateRegions[wrapRot][gas][frame] : renderer.fluidFrames[gas][frame];
|
||||
|
||||
if(bits == 1){
|
||||
ox = rotateOffsets[wrapRot][0];
|
||||
oy = rotateOffsets[wrapRot][1];
|
||||
}
|
||||
|
||||
//the drawing state machine sure was a great design choice with no downsides or hidden behavior!!!
|
||||
float xscl = Draw.xscl, yscl = Draw.yscl;
|
||||
Draw.scl(1f, 1f);
|
||||
Drawf.liquid(sliced(liquidr, slice), x, y, smoothLiquid, liquids.current().color.write(Tmp.c1).a(1f));
|
||||
Drawf.liquid(sliced(liquidr, slice), x + ox, y + oy, smoothLiquid, liquids.current().color.write(Tmp.c1).a(1f));
|
||||
Draw.scl(xscl, yscl);
|
||||
|
||||
Draw.rect(sliced(topRegions[bits], slice), x, y, angle);
|
||||
|
||||
@@ -50,6 +50,8 @@ public class LiquidBlock extends Block{
|
||||
float squishX = rightBorder + tilesize/2f - bounds, squishY = topBorder + tilesize/2f - bounds;
|
||||
float ox = 0f, oy = 0f;
|
||||
|
||||
if(squishX >= 8 || squishY >= 8) continue;
|
||||
|
||||
//cut out the parts that don't fit inside the padding
|
||||
if(squishX > 0){
|
||||
toDraw.setWidth(toDraw.width - squishX * 4f);
|
||||
|
||||
@@ -29,6 +29,8 @@ public class GenericCrafter extends Block{
|
||||
/** Liquid output directions, specified in the same order as outputLiquids. Use -1 to dump in every direction. Rotations are relative to block. */
|
||||
public int[] liquidOutputDirections = {-1};
|
||||
|
||||
/** 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 float craftTime = 80;
|
||||
public Effect craftEffect = Fx.none;
|
||||
public Effect updateEffect = Fx.none;
|
||||
@@ -109,6 +111,10 @@ public class GenericCrafter extends Block{
|
||||
outputLiquid = outputLiquids[0];
|
||||
}
|
||||
outputsLiquid = outputLiquids != null;
|
||||
|
||||
if(outputItems != null) hasItems = true;
|
||||
if(outputLiquids != null) hasLiquids = true;
|
||||
|
||||
super.init();
|
||||
}
|
||||
|
||||
@@ -169,11 +175,22 @@ public class GenericCrafter extends Block{
|
||||
}
|
||||
}
|
||||
if(outputLiquids != null){
|
||||
boolean allFull = true;
|
||||
for(var output : outputLiquids){
|
||||
if(liquids.get(output.liquid) >= liquidCapacity - 0.001f){
|
||||
return false;
|
||||
if(!dumpExtraLiquid){
|
||||
return false;
|
||||
}
|
||||
}else{
|
||||
//if there's still space left, it's not full for all liquids
|
||||
allFull = false;
|
||||
}
|
||||
}
|
||||
|
||||
//if there is no space left for any liquid, it can't reproduce
|
||||
if(allFull){
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return enabled;
|
||||
|
||||
@@ -29,16 +29,9 @@ public class HeatCrafter extends GenericCrafter{
|
||||
|
||||
bars.add("heat", (HeatCrafterBuild entity) ->
|
||||
new Bar(() ->
|
||||
Core.bundle.format("bar.heatpercent", (int)entity.heat),
|
||||
Core.bundle.format("bar.heatpercent", (int)entity.heat, (int)(entity.efficiencyScale() * 100)),
|
||||
() -> Pal.lightOrange,
|
||||
() -> entity.heat / heatRequirement));
|
||||
|
||||
//TODO unnecessary?
|
||||
bars.add("efficiency", (HeatCrafterBuild entity) ->
|
||||
new Bar(() ->
|
||||
Core.bundle.format("bar.efficiency", (int)(entity.efficiencyScale() * 100)),
|
||||
() -> Pal.ammo,
|
||||
entity::efficiencyScale));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -8,8 +8,9 @@ import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
//TODO make non-standalone?
|
||||
public class DrawArcSmelter extends DrawBlock{
|
||||
public TextureRegion top, bottom;
|
||||
public TextureRegion bottom;
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 3f, flameRadiusMag = 0.3f, circleStroke = 1.5f;
|
||||
|
||||
@@ -17,7 +18,7 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
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 boolean drawBottom = true, drawRegion = true;
|
||||
public Blending blending = Blending.additive;
|
||||
|
||||
@Override
|
||||
@@ -53,17 +54,15 @@ public class DrawArcSmelter extends DrawBlock{
|
||||
}
|
||||
|
||||
if(drawRegion) Draw.rect(build.block.region, build.x, build.y);
|
||||
if(drawTop && top.found()) Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, block.region, top};
|
||||
return new TextureRegion[]{bottom, block.region};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@ public class DrawBubbles extends DrawBlock{
|
||||
public int amount = 12, sides = 8;
|
||||
public float strokeMin = 0.2f, spread = 3f, timeScl = 30f;
|
||||
public float recurrence = 6f, radius = 3f;
|
||||
public boolean fill = false;
|
||||
|
||||
public DrawBubbles(Color color){
|
||||
this.color = color;
|
||||
@@ -37,8 +38,13 @@ public class DrawBubbles extends DrawBlock{
|
||||
float life = 1f - ((Time.time / timeScl + rand.random(recurrence)) % recurrence);
|
||||
|
||||
if(life > 0){
|
||||
Lines.stroke(build.warmup() * (life + strokeMin));
|
||||
Lines.poly(build.x + x, build.y + y, sides, (1f - life) * radius);
|
||||
float rad = (1f - life) * radius;
|
||||
if(fill){
|
||||
Fill.circle(build.x + x, build.y + y, rad);
|
||||
}else{
|
||||
Lines.stroke(build.warmup() * (life + strokeMin));
|
||||
Lines.poly(build.x + x, build.y + y, sides, rad);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.math.Interp.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.world.*;
|
||||
|
||||
public class DrawCrucible extends DrawBlock{
|
||||
public TextureRegion top, bottom;
|
||||
public Color flameColor = Color.valueOf("f58349"), midColor = Color.valueOf("f2d585");
|
||||
public float flameRad = 1f, circleSpace = 2f, flameRadiusScl = 10f, flameRadiusMag = 0.6f, circleStroke = 1.5f;
|
||||
|
||||
@@ -21,7 +20,6 @@ public class DrawCrucible extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
Draw.rect(bottom, build.x, build.y);
|
||||
|
||||
if(build.warmup() > 0f && flameColor.a > 0.001f){
|
||||
Lines.stroke(circleStroke * build.warmup());
|
||||
@@ -53,19 +51,8 @@ public class DrawCrucible extends DrawBlock{
|
||||
Draw.blend();
|
||||
Draw.reset();
|
||||
}
|
||||
|
||||
Draw.rect(build.block.region, build.x, build.y);
|
||||
if(top.found()) Draw.rect(top, build.x, build.y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
bottom = Core.atlas.find(block.name + "-bottom");
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return new TextureRegion[]{bottom, block.region, top};
|
||||
}
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
}
|
||||
|
||||
@@ -11,8 +11,8 @@ import mindustry.world.blocks.production.HeatCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawHeatRegion extends DrawBlock{
|
||||
public Color heatColor = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||
public float heatPulse = 0.3f, heatPulseScl = 10f;
|
||||
public Color color = new Color(1f, 0.22f, 0.22f, 0.8f);
|
||||
public float pulse = 0.3f, pulseScl = 10f;
|
||||
|
||||
public TextureRegion heat;
|
||||
public String suffix = "-glow";
|
||||
@@ -30,7 +30,7 @@ public class DrawHeatRegion extends DrawBlock{
|
||||
Draw.z(Layer.blockAdditive);
|
||||
if(build instanceof HeatCrafterBuild hc && hc.heat > 0){
|
||||
Draw.blend(Blending.additive);
|
||||
Draw.color(heatColor, Mathf.clamp(hc.heat / hc.heatRequirement()) * (heatColor.a * (1f - heatPulse + Mathf.absin(heatPulseScl, heatPulse))));
|
||||
Draw.color(color, Mathf.clamp(hc.heat / hc.heatRequirement()) * (color.a * (1f - pulse + Mathf.absin(pulseScl, pulse))));
|
||||
Draw.rect(heat, build.x, build.y);
|
||||
Draw.blend();
|
||||
Draw.color();
|
||||
|
||||
36
core/src/mindustry/world/draw/DrawLiquidTile.java
Normal file
36
core/src/mindustry/world/draw/DrawLiquidTile.java
Normal file
@@ -0,0 +1,36 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.liquid.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawLiquidTile extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public float padding;
|
||||
public float alpha = 1f;
|
||||
|
||||
public DrawLiquidTile(Liquid drawLiquid, float padding){
|
||||
this.drawLiquid = drawLiquid;
|
||||
this.padding = padding;
|
||||
}
|
||||
|
||||
public DrawLiquidTile(Liquid drawLiquid){
|
||||
this.drawLiquid = drawLiquid;
|
||||
}
|
||||
|
||||
public DrawLiquidTile(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(Block block, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
|
||||
@Override
|
||||
public void drawBase(Building build){
|
||||
Liquid drawn = drawLiquid != null ? drawLiquid : build.liquids.current();
|
||||
LiquidBlock.drawTiledFrames(build.block.size, build.x, build.y, padding, drawn, build.liquids.get(drawn) / build.block.liquidCapacity * alpha);
|
||||
}
|
||||
}
|
||||
@@ -8,12 +8,13 @@ import arc.util.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawParticlesIn extends DrawBlock{
|
||||
public class DrawParticles extends DrawBlock{
|
||||
public Color color = Color.valueOf("f2d585");
|
||||
|
||||
public float alpha = 0.5f;
|
||||
public int particles = 30;
|
||||
public float particleLife = 70f, particleRad = 7f, particleSize = 3f, fadeMargin = 0.4f, rotateScl = 3f;
|
||||
public boolean reverse = false;
|
||||
public Interp particleInterp = new PowIn(1.5f);
|
||||
public Interp particleSizeInterp = Interp.slope;
|
||||
public Blending blending = Blending.normal;
|
||||
@@ -30,7 +31,9 @@ public class DrawParticlesIn extends DrawBlock{
|
||||
float base = (Time.time / particleLife);
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < particles; i++){
|
||||
float fin = (rand.random(1f) + base) % 1f, fout = 1f - fin;
|
||||
float fin = (rand.random(2f) + base) % 1f;
|
||||
if(reverse) fin = 1f - fin;
|
||||
float fout = 1f - fin;
|
||||
float angle = rand.random(360f) + (Time.time / rotateScl) % 360f;
|
||||
float len = particleRad * particleInterp.apply(fout);
|
||||
Draw.alpha(a * (1f - Mathf.curve(fin, 1f - fadeMargin)));
|
||||
Reference in New Issue
Block a user