WIP animated gas
This commit is contained in:
@@ -60,7 +60,9 @@ public class Blocks implements ContentList{
|
||||
//crafting
|
||||
siliconSmelter, siliconCrucible, siliconArcFurnace, kiln, graphitePress, plastaniumCompressor, multiPress, phaseWeaver, surgeSmelter, pyratiteMixer, blastMixer, cryofluidMixer,
|
||||
melter, separator, disassembler, sporePress, pulverizer, incinerator, coalCentrifuge,
|
||||
electrolyzer, oxidationChamber, slagHeater, slagIncinerator, heatReactor, carbideCrucible, slagCentrifuge, surgeCrucible, cyanogenSynthesizer, phaseSynthesizer,
|
||||
|
||||
//erekir
|
||||
electrolyzer, oxidationChamber, atmosphericConcentrator, slagHeater, slagIncinerator, heatReactor, carbideCrucible, slagCentrifuge, surgeCrucible, cyanogenSynthesizer, phaseSynthesizer,
|
||||
cellSynthesisChamber,
|
||||
|
||||
//sandbox
|
||||
@@ -987,6 +989,20 @@ public class Blocks implements ContentList{
|
||||
liquidOutputDirections = new int[]{1, 3};
|
||||
}};
|
||||
|
||||
if(false)
|
||||
atmosphericConcentrator = new HeatCrafter("atmospheric-concentrator"){{
|
||||
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
||||
size = 3;
|
||||
craftTime = 60f;
|
||||
|
||||
liquidCapacity = 50f;
|
||||
consumes.power(2f);
|
||||
|
||||
heatRequirement = 5f;
|
||||
|
||||
outputLiquid = new LiquidStack(Liquids.nitrogen, 4f / 60f);
|
||||
}};
|
||||
|
||||
oxidationChamber = new HeatProducer("oxidation-chamber"){{
|
||||
requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30));
|
||||
size = 3;
|
||||
@@ -1627,12 +1643,14 @@ public class Blocks implements ContentList{
|
||||
liquidRouter = new LiquidRouter("liquid-router"){{
|
||||
requirements(Category.liquid, with(Items.graphite, 4, Items.metaglass, 2));
|
||||
liquidCapacity = 20f;
|
||||
newDrawing = true;
|
||||
}};
|
||||
|
||||
liquidContainer = new LiquidRouter("liquid-container"){{
|
||||
requirements(Category.liquid, with(Items.titanium, 10, Items.metaglass, 15));
|
||||
liquidCapacity = 700f;
|
||||
size = 2;
|
||||
newDrawing = true;
|
||||
}};
|
||||
|
||||
liquidTank = new LiquidRouter("liquid-tank"){{
|
||||
@@ -1640,6 +1658,7 @@ public class Blocks implements ContentList{
|
||||
size = 3;
|
||||
liquidCapacity = 1800f;
|
||||
health = 500;
|
||||
newDrawing = true;
|
||||
}};
|
||||
|
||||
liquidJunction = new LiquidJunction("liquid-junction"){{
|
||||
@@ -1705,18 +1724,24 @@ public class Blocks implements ContentList{
|
||||
reinforcedLiquidRouter = new LiquidRouter("reinforced-liquid-router"){{
|
||||
requirements(Category.liquid, with(Items.graphite, 4, Items.beryllium, 2));
|
||||
liquidCapacity = 30f;
|
||||
newDrawing = true;
|
||||
liquidPadding = 3f/4f;
|
||||
}};
|
||||
|
||||
reinforcedLiquidContainer = new LiquidRouter("reinforced-liquid-container"){{
|
||||
requirements(Category.liquid, with(Items.graphite, 10, Items.beryllium, 15));
|
||||
liquidCapacity = 1000f;
|
||||
size = 2;
|
||||
newDrawing = true;
|
||||
liquidPadding = 6f/4f;
|
||||
}};
|
||||
|
||||
reinforcedLiquidTank = new LiquidRouter("reinforced-liquid-tank"){{
|
||||
requirements(Category.liquid, with(Items.tungsten, 30, Items.beryllium, 40));
|
||||
size = 3;
|
||||
liquidCapacity = 2700f;
|
||||
newDrawing = true;
|
||||
liquidPadding = 2f;
|
||||
}};
|
||||
|
||||
//endregion
|
||||
@@ -1958,6 +1983,8 @@ public class Blocks implements ContentList{
|
||||
consumes.liquid(Liquids.water, 0.2f);
|
||||
}};
|
||||
|
||||
//TODO higher tier impact drill, 5x5
|
||||
|
||||
waterExtractor = new SolidPump("water-extractor"){{
|
||||
requirements(Category.production, with(Items.metaglass, 30, Items.graphite, 30, Items.lead, 30, Items.copper, 30));
|
||||
result = Liquids.water;
|
||||
|
||||
@@ -7,7 +7,7 @@ import mindustry.type.*;
|
||||
public class Liquids implements ContentList{
|
||||
public static Liquid water, slag, oil, cryofluid, neoplasm,
|
||||
gallium,
|
||||
ozone, hydrogen, cyanogen;
|
||||
ozone, hydrogen, nitrogen, cyanogen;
|
||||
|
||||
@Override
|
||||
public void load(){
|
||||
@@ -64,7 +64,7 @@ public class Liquids implements ContentList{
|
||||
}};
|
||||
|
||||
//TODO reactivity, etc
|
||||
ozone = new Liquid("ozone", Color.valueOf("f099da")){{
|
||||
ozone = new Liquid("ozone", Color.valueOf("fc81dd")){{
|
||||
gas = true;
|
||||
barColor = Color.valueOf("d699f0");
|
||||
explosiveness = 1f;
|
||||
@@ -78,9 +78,12 @@ public class Liquids implements ContentList{
|
||||
flammability = 1f;
|
||||
}};
|
||||
|
||||
nitrogen = new Liquid("nitrogen", Color.valueOf("e2cffa")){{
|
||||
gas = true;
|
||||
}};
|
||||
|
||||
cyanogen = new Liquid("cyanogen", Color.valueOf("89e8b6")){{
|
||||
gas = true;
|
||||
barColor = color;
|
||||
flammability = 2f;
|
||||
}};
|
||||
|
||||
|
||||
@@ -16,6 +16,10 @@ import static mindustry.entities.Puddles.*;
|
||||
|
||||
/** A better name for this class would be "fluid", but it's too late for that. */
|
||||
public class Liquid extends UnlockableContent{
|
||||
//must be static and global so conduits don't conflict - DO NOT INTERACT WITH THESE IN MODS OR I WILL PERSONALLY YELL AT YOU
|
||||
public static final int animationFrames = 40;
|
||||
public static float animationScale = 190f;
|
||||
|
||||
protected static final Rand rand = new Rand();
|
||||
|
||||
/** TODO If true, this fluid is treated as a gas (and does not create puddles) */
|
||||
@@ -74,6 +78,9 @@ public class Liquid extends UnlockableContent{
|
||||
color.a = 0.6f;
|
||||
//for gases, gas color is implicitly their color
|
||||
gasColor = color;
|
||||
if(barColor == null){
|
||||
barColor = color.cpy().a(1f);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@ import mindustry.world.blocks.*;
|
||||
import mindustry.world.blocks.distribution.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
import static mindustry.type.Liquid.*;
|
||||
|
||||
public class Conduit extends LiquidBlock implements Autotiler{
|
||||
public final int timerFlow = timers++;
|
||||
@@ -28,8 +29,13 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
public @Load(value = "@-top-#", length = 5) TextureRegion[] topRegions;
|
||||
public @Load(value = "@-bottom-#", length = 5, fallback = "conduit-bottom-#") TextureRegion[] botRegions;
|
||||
public @Load(value = "@-liquid-r#", length = 4, fallback = "conduit-liquid-r#") TextureRegion[] liquidRotateRegions;
|
||||
public @Load(value = "@-liquid", fallback = "conduit-liquid") TextureRegion liquidBaseRegion;
|
||||
public @Load("@-cap") TextureRegion capRegion;
|
||||
|
||||
public @Load(value = "conduit-liquid-#", length = animationFrames) TextureRegion[] gasRegions;
|
||||
public @Load(value = "conduit-liquid-r#1-#2", lengths = {4, animationFrames}) TextureRegion[][] rotateGasRegions;
|
||||
|
||||
public boolean leaks = true;
|
||||
public @Nullable Block junctionReplacement, bridgeReplacement, rotBridgeReplacement;
|
||||
|
||||
@@ -106,7 +112,6 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
float rotation = rotdeg();
|
||||
int r = this.rotation;
|
||||
|
||||
//draw extra conduits facing this one for tiling purposes
|
||||
@@ -114,28 +119,40 @@ public class Conduit extends LiquidBlock implements Autotiler{
|
||||
for(int i = 0; i < 4; i++){
|
||||
if((blending & (1 << i)) != 0){
|
||||
int dir = r - i;
|
||||
float rot = i == 0 ? rotation : (dir)*90;
|
||||
drawAt(x + Geometry.d4x(dir) * tilesize*0.75f, y + Geometry.d4y(dir) * tilesize*0.75f, 0, rot, i != 0 ? SliceMode.bottom : SliceMode.top);
|
||||
drawAt(x + Geometry.d4x(dir) * tilesize*0.75f, y + Geometry.d4y(dir) * tilesize*0.75f, 0, i == 0 ? r : dir, i != 0 ? SliceMode.bottom : SliceMode.top);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.z(Layer.block);
|
||||
|
||||
Draw.scl(xscl, yscl);
|
||||
drawAt(x, y, blendbits, rotation, SliceMode.none);
|
||||
drawAt(x, y, blendbits, r, SliceMode.none);
|
||||
Draw.reset();
|
||||
|
||||
if(capped && capRegion.found()) Draw.rect(capRegion, x, y, rotdeg());
|
||||
if(backCapped && capRegion.found()) Draw.rect(capRegion, x, y, rotdeg() + 180);
|
||||
}
|
||||
|
||||
protected void drawAt(float x, float y, int bits, float rotation, SliceMode slice){
|
||||
protected void drawAt(float x, float y, int bits, int rotation, SliceMode slice){
|
||||
float angle = rotation * 90f;
|
||||
Draw.color(botColor);
|
||||
Draw.rect(sliced(botRegions[bits], slice), x, y, rotation);
|
||||
Draw.rect(sliced(botRegions[bits], slice), x, y, angle);
|
||||
|
||||
Drawf.liquid(sliced(botRegions[bits], slice), x, y, smoothLiquid, liquids.current().color, rotation);
|
||||
int offset = yscl == -1 ? 3 : 0;
|
||||
//TODO move out of conduit
|
||||
int frame = (int)(Time.time / animationScale * animationFrames) % animationFrames;
|
||||
TextureRegion liquidr =
|
||||
liquids.current().gas ?
|
||||
(bits == 1 ? rotateGasRegions[(rotation + offset) % 4][frame] : gasRegions[frame]) :
|
||||
(bits == 1 ? liquidRotateRegions[(rotation + offset) % 4] : liquidBaseRegion);
|
||||
|
||||
Draw.rect(sliced(topRegions[bits], slice), x, y, rotation);
|
||||
//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));
|
||||
Draw.scl(xscl, yscl);
|
||||
|
||||
Draw.rect(sliced(topRegions[bits], slice), x, y, angle);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.meta.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class LiquidBlock extends Block{
|
||||
public @Load("@-liquid") TextureRegion liquidRegion;
|
||||
public @Load("@-top") TextureRegion topRegion;
|
||||
@@ -27,6 +32,39 @@ public class LiquidBlock extends Block{
|
||||
return new TextureRegion[]{bottomRegion, topRegion};
|
||||
}
|
||||
|
||||
public static void drawTiledGas(TextureRegion[] gasRegions, int size, float x, float y, float padding, Color color, float alpha){
|
||||
TextureRegion region = gasRegions[(int)(Time.time / Liquid.animationScale * Liquid.animationFrames) % Liquid.animationFrames];
|
||||
TextureRegion toDraw = Tmp.tr1;
|
||||
|
||||
float bounds = size/2f * tilesize - padding;
|
||||
|
||||
for(int sx = 0; sx < size; sx++){
|
||||
for(int sy = 0; sy < size; sy++){
|
||||
float relx = sx - (size-1)/2f, rely = sy - (size-1)/2f;
|
||||
|
||||
toDraw.set(region);
|
||||
|
||||
//truncate region if at border
|
||||
float rightBorder = relx*tilesize + padding, topBorder = rely*tilesize + padding;
|
||||
float squishX = rightBorder + tilesize/2f - bounds, squishY = topBorder + tilesize/2f - bounds;
|
||||
float ox = 0f, oy = 0f;
|
||||
|
||||
//cut out the parts that don't fit inside the padding
|
||||
if(squishX > 0){
|
||||
toDraw.setWidth(toDraw.width - squishX * 4f);
|
||||
ox = -squishX/2f;
|
||||
}
|
||||
|
||||
if(squishY > 0){
|
||||
toDraw.setY(toDraw.getY() + squishY * 4f);
|
||||
oy = -squishY/2f;
|
||||
}
|
||||
|
||||
Drawf.liquid(toDraw, x + rightBorder + ox, y + topBorder + oy, alpha, Tmp.c1.set(color).a(1f));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class LiquidBuild extends Building{
|
||||
@Override
|
||||
public void draw(){
|
||||
|
||||
@@ -1,9 +1,18 @@
|
||||
package mindustry.world.blocks.liquid;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.annotations.Annotations.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.type.*;
|
||||
|
||||
import static mindustry.Vars.*;
|
||||
|
||||
public class LiquidRouter extends LiquidBlock{
|
||||
/** kept only for mod compatibility reasons; all vanilla blocks have this as true */
|
||||
public boolean newDrawing = false;
|
||||
public float liquidPadding = 0f;
|
||||
|
||||
public @Load(value = "conduit-liquid-#", length = Liquid.animationFrames) TextureRegion[] gasRegions;
|
||||
|
||||
public LiquidRouter(String name){
|
||||
super(name);
|
||||
@@ -12,6 +21,11 @@ public class LiquidRouter extends LiquidBlock{
|
||||
canOverdrive = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TextureRegion[] icons(){
|
||||
return newDrawing ? new TextureRegion[]{bottomRegion, region} : super.icons();
|
||||
}
|
||||
|
||||
public class LiquidRouterBuild extends LiquidBuild{
|
||||
@Override
|
||||
public void updateTile(){
|
||||
@@ -20,6 +34,28 @@ public class LiquidRouter extends LiquidBlock{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(){
|
||||
if(newDrawing){
|
||||
Draw.rect(bottomRegion, x, y);
|
||||
|
||||
if(liquids.currentAmount() > 0.001f){
|
||||
if(liquids.current().gas){
|
||||
drawTiledGas(gasRegions, size, x, y, liquidPadding, liquids.current().color, liquids.currentAmount() / liquidCapacity);
|
||||
}else{
|
||||
Draw.color(liquids.current().color, liquids.currentAmount() / liquidCapacity);
|
||||
Fill.square(x, y, size * tilesize/2f - liquidPadding);
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
|
||||
Draw.rect(region, x, y);
|
||||
}else{
|
||||
super.draw();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean acceptLiquid(Building source, Liquid liquid){
|
||||
return (liquids.current() == liquid || liquids.currentAmount() < 0.2f);
|
||||
|
||||
Reference in New Issue
Block a user