WIP electrolyzer + liquid fixes
This commit is contained in:
47
core/src/mindustry/world/draw/DrawBubbles.java
Normal file
47
core/src/mindustry/world/draw/DrawBubbles.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawBubbles extends DrawBlock{
|
||||
public Color color = Color.valueOf("7457ce");
|
||||
|
||||
public int amount = 12, sides = 8;
|
||||
public float strokeMin = 0.2f, spread = 3f, timeScl = 30f;
|
||||
public float recurrence = 6f, radius = 3f;
|
||||
|
||||
public DrawBubbles(Color color){
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
public DrawBubbles(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
if(build.warmup <= 0.001f) return;
|
||||
|
||||
Draw.color(color);
|
||||
Draw.alpha(build.warmup);
|
||||
|
||||
rand.setSeed(build.id);
|
||||
for(int i = 0; i < amount; i++){
|
||||
float x = rand.range(spread), y = rand.range(spread);
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
Draw.color();
|
||||
}
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
public class DrawGlow extends DrawBlock{
|
||||
public String suffix = "-top";
|
||||
public float glowAmount = 0.9f, glowScale = 3f;
|
||||
public TextureRegion top;
|
||||
|
||||
@@ -20,6 +21,6 @@ public class DrawGlow extends DrawBlock{
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + "-top");
|
||||
top = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
||||
|
||||
45
core/src/mindustry/world/draw/DrawGlowRegion.java
Normal file
45
core/src/mindustry/world/draw/DrawGlowRegion.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.math.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawGlowRegion extends DrawBlock{
|
||||
public Blending blending = Blending.additive;
|
||||
public String suffix = "-glow";
|
||||
public float alpha = 0.9f, glowScale = 3f;
|
||||
public float layer = Layer.blockAdditive;
|
||||
public Color color = Color.red.cpy();
|
||||
public TextureRegion top;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
if(build.warmup <= 0.001f) return;
|
||||
|
||||
float z = Draw.z();
|
||||
Draw.z(layer);
|
||||
Draw.blend(blending);
|
||||
Draw.color(color);
|
||||
Draw.alpha(Mathf.absin(build.totalProgress, glowScale, alpha) * build.warmup);
|
||||
Draw.rect(top, build.x, build.y);
|
||||
Draw.reset();
|
||||
Draw.blend();
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
top = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
}
|
||||
61
core/src/mindustry/world/draw/DrawLiquidOutputs.java
Normal file
61
core/src/mindustry/world/draw/DrawLiquidOutputs.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** This must be used in conjunction with another DrawBlock; it only draws outputs. */
|
||||
public class DrawLiquidOutputs extends DrawBlock{
|
||||
public TextureRegion[][] liquidOutputRegions;
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
GenericCrafter crafter = (GenericCrafter)build.block;
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
for(int i = 0; i < crafter.outputLiquids.length; i++){
|
||||
int side = i < crafter.liquidOutputDirections.length ? crafter.liquidOutputDirections[i] : -1;
|
||||
if(side != -1){
|
||||
int realRot = (side + build.rotation) % 4;
|
||||
Draw.rect(liquidOutputRegions[realRot > 1 ? 1 : 0][i], build.x, build.y, realRot * 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
for(int i = 0; i < crafter.outputLiquids.length; i++){
|
||||
int side = i < crafter.liquidOutputDirections.length ? crafter.liquidOutputDirections[i] : -1;
|
||||
if(side != -1){
|
||||
int realRot = (side + plan.rotation) % 4;
|
||||
Draw.rect(liquidOutputRegions[realRot > 1 ? 1 : 0][i], plan.drawx(), plan.drawy(), realRot * 90);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
GenericCrafter crafter = (GenericCrafter)block;
|
||||
|
||||
if(crafter.outputLiquids == null) return;
|
||||
|
||||
liquidOutputRegions = new TextureRegion[2][crafter.outputLiquids.length];
|
||||
for(int i = 0; i < crafter.outputLiquids.length; i++){
|
||||
for(int j = 1; j <= 2; j++){
|
||||
liquidOutputRegions[j - 1][i] = Core.atlas.find(block.name + "-" + crafter.outputLiquids[i].liquid.name + "-output" + j);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//TODO
|
||||
@Override
|
||||
public TextureRegion[] icons(Block block){
|
||||
return super.icons(block);
|
||||
}
|
||||
}
|
||||
44
core/src/mindustry/world/draw/DrawLiquidRegion.java
Normal file
44
core/src/mindustry/world/draw/DrawLiquidRegion.java
Normal file
@@ -0,0 +1,44 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.graphics.*;
|
||||
import mindustry.type.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawLiquidRegion extends DrawBlock{
|
||||
public Liquid drawLiquid;
|
||||
public TextureRegion liquid;
|
||||
public String suffix = "-liquid";
|
||||
|
||||
public DrawLiquidRegion(Liquid drawLiquid){
|
||||
this.drawLiquid = drawLiquid;
|
||||
}
|
||||
|
||||
public DrawLiquidRegion(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){}
|
||||
|
||||
@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
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
liquid = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** combined several DrawBlocks into one */
|
||||
@@ -24,6 +27,13 @@ public class DrawMulti extends DrawBlock{
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
for(var draw : drawers){
|
||||
draw.drawPlan(crafter, plan, list);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawLight(GenericCrafterBuild build){
|
||||
for(var draw : drawers){
|
||||
|
||||
42
core/src/mindustry/world/draw/DrawRegion.java
Normal file
42
core/src/mindustry/world/draw/DrawRegion.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package mindustry.world.draw;
|
||||
|
||||
import arc.*;
|
||||
import arc.graphics.g2d.*;
|
||||
import arc.util.*;
|
||||
import mindustry.entities.units.*;
|
||||
import mindustry.world.*;
|
||||
import mindustry.world.blocks.production.*;
|
||||
import mindustry.world.blocks.production.GenericCrafter.*;
|
||||
|
||||
/** Not standalone. */
|
||||
public class DrawRegion extends DrawBlock{
|
||||
public TextureRegion region;
|
||||
public String suffix = "";
|
||||
/** Any number <=0 disables layer changes. */
|
||||
public float layer = -1;
|
||||
|
||||
public DrawRegion(String suffix){
|
||||
this.suffix = suffix;
|
||||
}
|
||||
|
||||
public DrawRegion(){
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(GenericCrafterBuild build){
|
||||
float z = Draw.z();
|
||||
if(layer > 0) Draw.z(layer);
|
||||
Draw.rect(region, build.x, build.y);
|
||||
Draw.z(z);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlan(GenericCrafter crafter, BuildPlan plan, Eachable<BuildPlan> list){
|
||||
Draw.rect(region, plan.drawx(), plan.drawy());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load(Block block){
|
||||
region = Core.atlas.find(block.name + suffix);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user