diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-bottom.png b/core/assets-raw/sprites/blocks/production/electrolyzer-bottom.png new file mode 100644 index 0000000000..4f4b6a2b8f Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-bottom.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-glow.png b/core/assets-raw/sprites/blocks/production/electrolyzer-glow.png new file mode 100644 index 0000000000..7d88560571 Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-glow.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output1.png b/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output1.png new file mode 100644 index 0000000000..bae0b40146 Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output1.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output2.png b/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output2.png new file mode 100644 index 0000000000..11551ea704 Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-hydrogen-output2.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-liquid.png b/core/assets-raw/sprites/blocks/production/electrolyzer-liquid.png new file mode 100644 index 0000000000..0ecd1df73e Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-liquid.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output1.png b/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output1.png new file mode 100644 index 0000000000..0728839ede Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output1.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output2.png b/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output2.png new file mode 100644 index 0000000000..2f1bdd0bdc Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-ozone-output2.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer-top.png b/core/assets-raw/sprites/blocks/production/electrolyzer-top.png new file mode 100644 index 0000000000..ccc870c30e Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer-top.png differ diff --git a/core/assets-raw/sprites/blocks/production/electrolyzer.png b/core/assets-raw/sprites/blocks/production/electrolyzer.png new file mode 100644 index 0000000000..cdd5653682 Binary files /dev/null and b/core/assets-raw/sprites/blocks/production/electrolyzer.png differ diff --git a/core/assets-raw/sprites/items/item-dormant-cyst.png b/core/assets-raw/sprites/items/item-dormant-cyst.png index 5693bd3059..263f7ea57f 100644 Binary files a/core/assets-raw/sprites/items/item-dormant-cyst.png and b/core/assets-raw/sprites/items/item-dormant-cyst.png differ diff --git a/core/assets-raw/sprites/items/liquid-hydrogen.png b/core/assets-raw/sprites/items/liquid-hydrogen.png index 1cdc08913b..cf55930c42 100644 Binary files a/core/assets-raw/sprites/items/liquid-hydrogen.png and b/core/assets-raw/sprites/items/liquid-hydrogen.png differ diff --git a/core/assets-raw/sprites/items/liquid-ozone.png b/core/assets-raw/sprites/items/liquid-ozone.png index f28f3bf493..295d350621 100644 Binary files a/core/assets-raw/sprites/items/liquid-ozone.png and b/core/assets-raw/sprites/items/liquid-ozone.png differ diff --git a/core/assets/icons/icons.properties b/core/assets/icons/icons.properties index 650210e171..efd68836ba 100755 --- a/core/assets/icons/icons.properties +++ b/core/assets/icons/icons.properties @@ -441,3 +441,5 @@ 63265=oxide|item-oxide-ui 63264=oxygen|liquid-oxygen-ui 63263=hydrogen|liquid-hydrogen-ui +63262=electrolyzer|block-electrolyzer-ui +63261=ozone|liquid-ozone-ui diff --git a/core/assets/logicids.dat b/core/assets/logicids.dat index f345a790b6..2be980b92e 100644 Binary files a/core/assets/logicids.dat and b/core/assets/logicids.dat differ diff --git a/core/src/mindustry/content/Blocks.java b/core/src/mindustry/content/Blocks.java index 6c0fc1209e..6d43933bef 100644 --- a/core/src/mindustry/content/Blocks.java +++ b/core/src/mindustry/content/Blocks.java @@ -60,7 +60,7 @@ 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, - oxidizer, heatReactor, carbideCrucible, + electrolyzer, oxidizer, heatReactor, carbideCrucible, cellSynthesisChamber, //sandbox @@ -935,6 +935,7 @@ public class Blocks implements ContentList{ craftTime = 30f; size = 2; hasPower = hasItems = hasLiquids = true; + rotatePlan = false; consumes.liquid(Liquids.oil, 0.1f); consumes.power(0.7f); @@ -946,10 +947,46 @@ public class Blocks implements ContentList{ consumes.power(0.50f); }}; + //TODO better name + electrolyzer = new GenericCrafter("electrolyzer"){{ + requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30)); + size = 3; + + craftTime = 10f; + rotate = true; + + liquidCapacity = 100f; + + consumes.liquid(Liquids.water, 1f); + consumes.power(2f); + + drawer = new DrawMulti( + new DrawRegion("-bottom"), + new DrawLiquidRegion(Liquids.water), + new DrawBubbles(Color.valueOf("7693e3")){{ + sides = 10; + recurrence = 3f; + spread = 6; + radius = 1.5f; + amount = 20; + }}, + new DrawRegion(), + new DrawLiquidOutputs(), + new DrawRegion("-top"), + new DrawGlowRegion(){{ + alpha = 0.5f; + color = new Color(1f, 0.22f, 0.22f); + }} + ); + iconOverride = new String[]{"-bottom", "", "-top"}; + + outputLiquids = LiquidStack.with(Liquids.ozone, 0.5f, Liquids.hydrogen, 0.5f); + liquidOutputDirections = new int[]{1, 3}; + }}; + oxidizer = new HeatProducer("oxidizer"){{ requirements(Category.crafting, with(Items.tungsten, 60, Items.graphite, 30)); - //TODO bigger? - size = 2; + size = 3; //TODO multi liquid output //converts oxygen (?) + beryllium into heat + oxide diff --git a/core/src/mindustry/content/Liquids.java b/core/src/mindustry/content/Liquids.java index 5f40b987cc..94db84a5e2 100644 --- a/core/src/mindustry/content/Liquids.java +++ b/core/src/mindustry/content/Liquids.java @@ -58,17 +58,18 @@ public class Liquids implements ContentList{ }}; //TODO reactivity, etc - ozone = new Liquid("ozone", Color.valueOf("bdd7ff")){{ + ozone = new Liquid("ozone", Color.valueOf("f099da")){{ gas = true; - barColor = Color.valueOf("97bdf7"); + barColor = Color.valueOf("d699f0"); explosiveness = 1f; flammability = 1f; }}; //TODO combustion - hydrogen = new Liquid("hydrogen", Color.valueOf("e8d1ff")){{ + hydrogen = new Liquid("hydrogen", Color.valueOf("97a5f7")){{ gas = true; - barColor = Color.valueOf("c599f0"); + barColor = Color.valueOf("7d8be0"); + flammability = 1f; }}; //TODO dicyanoacetylene diff --git a/core/src/mindustry/entities/comp/BuildingComp.java b/core/src/mindustry/entities/comp/BuildingComp.java index 75fb1fe866..5332a455d8 100644 --- a/core/src/mindustry/entities/comp/BuildingComp.java +++ b/core/src/mindustry/entities/comp/BuildingComp.java @@ -567,6 +567,7 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, liquids.add(liquid, amount); } + //TODO entire liquid system is awful public void dumpLiquid(Liquid liquid){ dumpLiquid(liquid, 2f); } @@ -585,9 +586,9 @@ abstract class BuildingComp implements Posc, Teamc, Healthc, Buildingc, Timerc, for(int i = 0; i < proximity.size; i++){ incrementDump(proximity.size); - Building other = proximity.get((i + dump) % proximity.size); - if(outputDir != -1 && (relativeTo(other) + rotation) % 4 != outputDir) return; + Building other = proximity.get((i + dump) % proximity.size); + if(outputDir != -1 && (outputDir + rotation) % 4 != relativeTo(other)) continue; other = other.getLiquidDestination(self(), liquid); diff --git a/core/src/mindustry/type/LiquidStack.java b/core/src/mindustry/type/LiquidStack.java index 9250d24c8e..d233697302 100644 --- a/core/src/mindustry/type/LiquidStack.java +++ b/core/src/mindustry/type/LiquidStack.java @@ -1,6 +1,5 @@ package mindustry.type; -import arc.math.*; import arc.struct.*; import mindustry.content.*; @@ -38,7 +37,7 @@ public class LiquidStack implements Comparable{ public static LiquidStack[] mult(LiquidStack[] stacks, float amount){ LiquidStack[] copy = new LiquidStack[stacks.length]; for(int i = 0; i < copy.length; i++){ - copy[i] = new LiquidStack(stacks[i].liquid, Mathf.round(stacks[i].amount * amount)); + copy[i] = new LiquidStack(stacks[i].liquid, stacks[i].amount * amount); } return copy; } @@ -46,7 +45,7 @@ public class LiquidStack implements Comparable{ public static LiquidStack[] with(Object... items){ LiquidStack[] stacks = new LiquidStack[items.length / 2]; for(int i = 0; i < items.length; i += 2){ - stacks[i / 2] = new LiquidStack((Liquid)items[i], ((Number)items[i + 1]).intValue()); + stacks[i / 2] = new LiquidStack((Liquid)items[i], ((Number)items[i + 1]).floatValue()); } return stacks; } @@ -54,7 +53,7 @@ public class LiquidStack implements Comparable{ public static Seq list(Object... items){ Seq stacks = new Seq<>(items.length / 2); for(int i = 0; i < items.length; i += 2){ - stacks.add(new LiquidStack((Liquid)items[i], ((Number)items[i + 1]).intValue())); + stacks.add(new LiquidStack((Liquid)items[i], ((Number)items[i + 1]).floatValue())); } return stacks; } diff --git a/core/src/mindustry/world/Block.java b/core/src/mindustry/world/Block.java index 76f20d8090..e05dff979f 100644 --- a/core/src/mindustry/world/Block.java +++ b/core/src/mindustry/world/Block.java @@ -90,6 +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; /** 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 */ @@ -544,7 +546,7 @@ public class Block extends UnlockableContent{ public void drawRequestRegion(BuildPlan plan, Eachable list){ TextureRegion reg = getRequestRegion(plan, list); - Draw.rect(reg, plan.drawx(), plan.drawy(), !rotate ? 0 : plan.rotation * 90); + Draw.rect(reg, plan.drawx(), plan.drawy(), !rotate || !rotatePlan ? 0 : plan.rotation * 90); if(plan.worldContext && player != null && teamRegion != null && teamRegion.found()){ if(teamRegions[player.team().id] == teamRegion) Draw.color(player.team().color); diff --git a/core/src/mindustry/world/blocks/Autotiler.java b/core/src/mindustry/world/blocks/Autotiler.java index 03e0b7e01a..d6b47c8f02 100644 --- a/core/src/mindustry/world/blocks/Autotiler.java +++ b/core/src/mindustry/world/blocks/Autotiler.java @@ -201,8 +201,13 @@ public interface Autotiler{ /** @return whether this tile is looking at the other tile, or the other tile is looking at this one. * If the other tile does not rotate, it is always considered to be facing this one. */ default boolean lookingAtEither(Tile tile, int rotation, int otherx, int othery, int otherrot, Block otherblock){ - return (Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) - || (!otherblock.rotatedOutput(otherx, othery) || Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y))); + return + //block is facing the other + Point2.equals(tile.x + Geometry.d4(rotation).x, tile.y + Geometry.d4(rotation).y, otherx, othery) || + //does not output to rotated direction + !otherblock.rotatedOutput(otherx, othery) || + //other block is facing this one + Point2.equals(otherx + Geometry.d4(otherrot).x, othery + Geometry.d4(otherrot).y, tile.x, tile.y); } /** diff --git a/core/src/mindustry/world/blocks/production/GenericCrafter.java b/core/src/mindustry/world/blocks/production/GenericCrafter.java index 17f66b7d61..86a535185e 100644 --- a/core/src/mindustry/world/blocks/production/GenericCrafter.java +++ b/core/src/mindustry/world/blocks/production/GenericCrafter.java @@ -1,5 +1,6 @@ package mindustry.world.blocks.production; +import arc.*; import arc.graphics.g2d.*; import arc.math.*; import arc.struct.*; @@ -13,6 +14,7 @@ import mindustry.logic.*; import mindustry.type.*; import mindustry.ui.*; import mindustry.world.*; +import mindustry.world.consumers.*; import mindustry.world.draw.*; import mindustry.world.meta.*; @@ -38,6 +40,8 @@ public class GenericCrafter extends Block{ public boolean legacyReadWarmup = false; public DrawBlock drawer = new DrawBlock(); + /** If set, the icon is overridden to be these strings, in order. Each string is a suffix. */ + public String[] iconOverride = null; public GenericCrafter(String name){ super(name); @@ -48,6 +52,7 @@ public class GenericCrafter extends Block{ sync = true; ambientSoundVolume = 0.03f; flags = EnumSet.of(BlockFlag.factory); + drawArrow = false; } @Override @@ -69,13 +74,37 @@ public class GenericCrafter extends Block{ public void setBars(){ super.setBars(); - //set up liquid bars for multiple liquid outputs; TODO multiple inputs not yet supported due to inherent complexity - //TODO this will currently screw up input display if input liquids are available - no good way to fix that yet - if(outputLiquids != null && outputLiquids.length > 1){ + //set up liquid bars for multiple liquid outputs + //TODO this will currently screw up input display if input liquids are filters - no good way to fix that yet + if(outputLiquids != null && outputLiquids.length > 0){ bars.remove("liquid"); + Seq consumed = new Seq<>(); + + //find list of liquids consumed + if(consumes.has(ConsumeType.liquid)){ + var consl = consumes.get(ConsumeType.liquid); + if(consl instanceof ConsumeLiquid liq){ + consumed.add(liq.liquid); + }else if(consl instanceof ConsumeLiquids multi){ + for(var stack : multi.liquids){ + consumed.add(stack.liquid); + } + } + } + + //display consumed first + for(var liq : consumed){ + bars.add("liquid-consume-" + liq.name, entity -> new Bar( + () -> liq.localizedName, + liq::barColor, + () -> entity.liquids.get(liq) / liquidCapacity) + ); + } + + //then display output buffer for(var stack : outputLiquids){ - bars.add("liquid-" + stack.liquid.name, entity -> new Bar( + bars.add("liquid-output-" + stack.liquid.name, entity -> new Bar( () -> stack.liquid.localizedName, () -> stack.liquid.barColor(), () -> entity.liquids.get(stack.liquid) / liquidCapacity) @@ -84,6 +113,11 @@ public class GenericCrafter extends Block{ } } + @Override + public boolean rotatedOutput(int x, int y){ + return false; + } + @Override public void load(){ super.load(); @@ -93,13 +127,13 @@ public class GenericCrafter extends Block{ @Override public void init(){ - outputsLiquid = outputLiquid != null; if(outputItems == null && outputItem != null){ outputItems = new ItemStack[]{outputItem}; } if(outputLiquids == null && outputLiquid != null){ outputLiquids = new LiquidStack[]{outputLiquid}; } + outputsLiquid = outputLiquids != null; super.init(); } @@ -114,6 +148,13 @@ public class GenericCrafter extends Block{ @Override public TextureRegion[] icons(){ + if(iconOverride != null){ + var out = new TextureRegion[iconOverride.length]; + for(int i = 0; i < out.length; i++){ + out[i] = Core.atlas.find(name + iconOverride[i]); + } + return out; + } return drawer.icons(this); } diff --git a/core/src/mindustry/world/consumers/ConsumeLiquid.java b/core/src/mindustry/world/consumers/ConsumeLiquid.java index 4d499bda1d..7dc1e557ec 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquid.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquid.java @@ -9,6 +9,7 @@ import mindustry.world.meta.*; import static mindustry.Vars.*; +//TODO replace with ConsumeLiquids public class ConsumeLiquid extends ConsumeLiquidBase{ public final Liquid liquid; diff --git a/core/src/mindustry/world/consumers/ConsumeLiquids.java b/core/src/mindustry/world/consumers/ConsumeLiquids.java index ddefd5d4ff..a38e4dc725 100644 --- a/core/src/mindustry/world/consumers/ConsumeLiquids.java +++ b/core/src/mindustry/world/consumers/ConsumeLiquids.java @@ -2,6 +2,7 @@ package mindustry.world.consumers; import arc.scene.ui.layout.*; import arc.struct.*; +import mindustry.*; import mindustry.gen.*; import mindustry.type.*; import mindustry.ui.*; @@ -38,7 +39,7 @@ public class ConsumeLiquids extends Consume{ int i = 0; for(var stack : liquids){ c.add(new ReqImage(stack.liquid.uiIcon, - () -> build.liquids != null && build.liquids.get(stack.liquid) >= stack.amount * build.delta())).padRight(8); + () -> build.liquids.get(stack.liquid) >= stack.amount * build.delta())).size(Vars.iconMed).padRight(8); if(++i % 4 == 0) c.row(); } }).left(); @@ -63,6 +64,7 @@ public class ConsumeLiquids extends Consume{ @Override public void display(Stats stats){ + //TODO display is wrong stats.add(booster ? Stat.booster : Stat.input, StatValues.liquids(stats.timePeriod, stats.timePeriod >= 0, liquids)); } diff --git a/core/src/mindustry/world/draw/DrawBubbles.java b/core/src/mindustry/world/draw/DrawBubbles.java new file mode 100644 index 0000000000..7665ff6d25 --- /dev/null +++ b/core/src/mindustry/world/draw/DrawBubbles.java @@ -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 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(); + } +} diff --git a/core/src/mindustry/world/draw/DrawGlow.java b/core/src/mindustry/world/draw/DrawGlow.java index 47748cad06..8db84eccb2 100644 --- a/core/src/mindustry/world/draw/DrawGlow.java +++ b/core/src/mindustry/world/draw/DrawGlow.java @@ -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); } } diff --git a/core/src/mindustry/world/draw/DrawGlowRegion.java b/core/src/mindustry/world/draw/DrawGlowRegion.java new file mode 100644 index 0000000000..b9dc5511e6 --- /dev/null +++ b/core/src/mindustry/world/draw/DrawGlowRegion.java @@ -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 list){} +} diff --git a/core/src/mindustry/world/draw/DrawLiquidOutputs.java b/core/src/mindustry/world/draw/DrawLiquidOutputs.java new file mode 100644 index 0000000000..c650f6b524 --- /dev/null +++ b/core/src/mindustry/world/draw/DrawLiquidOutputs.java @@ -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 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); + } +} diff --git a/core/src/mindustry/world/draw/DrawLiquidRegion.java b/core/src/mindustry/world/draw/DrawLiquidRegion.java new file mode 100644 index 0000000000..ac2e1ce14f --- /dev/null +++ b/core/src/mindustry/world/draw/DrawLiquidRegion.java @@ -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 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); + } +} diff --git a/core/src/mindustry/world/draw/DrawMulti.java b/core/src/mindustry/world/draw/DrawMulti.java index 78262a2dd1..eeb9614b98 100644 --- a/core/src/mindustry/world/draw/DrawMulti.java +++ b/core/src/mindustry/world/draw/DrawMulti.java @@ -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 list){ + for(var draw : drawers){ + draw.drawPlan(crafter, plan, list); + } + } + @Override public void drawLight(GenericCrafterBuild build){ for(var draw : drawers){ diff --git a/core/src/mindustry/world/draw/DrawRegion.java b/core/src/mindustry/world/draw/DrawRegion.java new file mode 100644 index 0000000000..50206d5d10 --- /dev/null +++ b/core/src/mindustry/world/draw/DrawRegion.java @@ -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 list){ + Draw.rect(region, plan.drawx(), plan.drawy()); + } + + @Override + public void load(Block block){ + region = Core.atlas.find(block.name + suffix); + } +}