diff --git a/android/src/io/anuke/mindustry/AndroidLauncher.java b/android/src/io/anuke/mindustry/AndroidLauncher.java index 89c3fffcdf..2f07c3e724 100644 --- a/android/src/io/anuke/mindustry/AndroidLauncher.java +++ b/android/src/io/anuke/mindustry/AndroidLauncher.java @@ -6,6 +6,8 @@ import java.util.Date; import com.badlogic.gdx.backends.android.AndroidApplication; import com.badlogic.gdx.backends.android.AndroidApplicationConfiguration; +import com.badlogic.gdx.utils.Array; + import android.annotation.SuppressLint; import android.os.Bundle; import io.anuke.mindustry.io.Formatter; @@ -33,6 +35,9 @@ public class AndroidLauncher extends AndroidApplication { } }; + //TODO + Mindustry.args = Array.with("-debug"); + initialize(new Mindustry(), config); } } diff --git a/build.gradle b/build.gradle index 3d396aa0a3..652715624f 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:c498e5920a' + compile 'com.github.anuken:ucore:deacbf0568' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets-raw/sprites/blocks/liquiditemjunction.png b/core/assets-raw/sprites/blocks/liquiditemjunction.png new file mode 100644 index 0000000000..9df1857781 Binary files /dev/null and b/core/assets-raw/sprites/blocks/liquiditemjunction.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 59336f0935..e5969a0be7 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -361,20 +361,27 @@ blocks/lavaedge orig: 12, 12 offset: 0, 0 index: -1 -blocks/liquidjunction +blocks/liquiditemjunction rotate: false xy: 411, 340 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/liquidrouter +blocks/liquidjunction rotate: false xy: 411, 330 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 +blocks/liquidrouter + rotate: false + xy: 411, 320 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 blocks/machineturret rotate: false xy: 486, 485 @@ -398,14 +405,14 @@ blocks/mortarturret index: -1 blocks/mossblock rotate: false - xy: 411, 310 + xy: 411, 300 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 411, 310 + xy: 411, 300 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -419,7 +426,7 @@ blocks/nuclearreactor index: -1 blocks/nuclearreactor-icon rotate: false - xy: 411, 290 + xy: 411, 280 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -433,7 +440,7 @@ blocks/nuclearreactor-small index: -1 blocks/oil rotate: false - xy: 411, 280 + xy: 411, 270 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -447,14 +454,14 @@ blocks/oiledge index: -1 blocks/oilrefinery rotate: false - xy: 411, 270 + xy: 411, 260 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 411, 260 + xy: 230, 119 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -468,42 +475,42 @@ blocks/plasmaturret index: -1 blocks/powerbooster rotate: false - xy: 230, 119 + xy: 230, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyor rotate: false - xy: 230, 109 + xy: 240, 119 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/poweredconveyormove rotate: false - xy: 240, 119 + xy: 230, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaser rotate: false - xy: 230, 99 + xy: 240, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/powerlaserrouter rotate: false - xy: 240, 109 + xy: 230, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/pump rotate: false - xy: 230, 89 + xy: 240, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -517,35 +524,35 @@ blocks/repairturret index: -1 blocks/rock rotate: false - xy: 230, 79 + xy: 240, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 240, 89 + xy: 230, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2shadow rotate: false - xy: 230, 69 + xy: 240, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow rotate: false - xy: 240, 79 + xy: 230, 59 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 230, 59 + xy: 240, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -559,7 +566,7 @@ blocks/shadow index: -1 blocks/shieldgenerator rotate: false - xy: 240, 69 + xy: 230, 49 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -573,21 +580,21 @@ blocks/shotgunturret index: -1 blocks/shrub rotate: false - xy: 230, 39 + xy: 240, 49 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 240, 49 + xy: 240, 39 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 240, 39 + xy: 250, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -601,28 +608,28 @@ blocks/sniperturret index: -1 blocks/sorter rotate: false - xy: 250, 115 + xy: 260, 115 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyor rotate: false - xy: 260, 115 + xy: 250, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 250, 105 + xy: 250, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 250, 95 + xy: 260, 105 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -636,49 +643,49 @@ blocks/stone index: -1 blocks/stone1 rotate: false - xy: 260, 105 + xy: 250, 85 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 250, 85 + xy: 260, 95 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 260, 95 + xy: 250, 75 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock rotate: false - xy: 250, 75 + xy: 260, 85 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 260, 85 + xy: 250, 65 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 250, 65 + xy: 260, 75 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 260, 75 + xy: 250, 55 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -692,28 +699,28 @@ blocks/stoneedge index: -1 blocks/stonewall rotate: false - xy: 250, 55 + xy: 260, 65 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter rotate: false - xy: 260, 65 + xy: 250, 45 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/teleporter-top rotate: false - xy: 250, 45 + xy: 260, 55 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/thermalgenerator rotate: false - xy: 260, 55 + xy: 260, 45 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -734,49 +741,49 @@ blocks/titancannon-icon index: -1 blocks/titanium1 rotate: false - xy: 260, 45 + xy: 250, 35 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 250, 35 + xy: 260, 35 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 260, 35 + xy: 270, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 270, 109 + xy: 270, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumpurifier rotate: false - xy: 270, 99 + xy: 280, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumshieldwall rotate: false - xy: 280, 109 + xy: 270, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 270, 89 + xy: 280, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -790,7 +797,7 @@ blocks/titaniumwall-large index: -1 blocks/titaniumwall-large-icon rotate: false - xy: 280, 99 + xy: 290, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -804,35 +811,35 @@ blocks/turret index: -1 blocks/uranium1 rotate: false - xy: 270, 79 + xy: 280, 89 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium2 rotate: false - xy: 280, 89 + xy: 290, 99 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uranium3 rotate: false - xy: 290, 99 + xy: 300, 109 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/uraniumdrill rotate: false - xy: 300, 109 + xy: 270, 69 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/water rotate: false - xy: 270, 69 + xy: 280, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1168,14 +1175,14 @@ mechs/player index: -1 shot rotate: false - xy: 230, 49 + xy: 240, 59 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 shot-long rotate: false - xy: 240, 59 + xy: 230, 39 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -1629,28 +1636,28 @@ weapons/flamer index: -1 weapons/mortar rotate: false - xy: 411, 320 + xy: 411, 310 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/multigun rotate: false - xy: 411, 300 + xy: 411, 290 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/railgun rotate: false - xy: 240, 99 + xy: 230, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 weapons/triblaster rotate: false - xy: 290, 109 + xy: 270, 79 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index 7ffdcf0001..8e09d1348e 100644 Binary files a/core/assets/sprites/sprites.png and b/core/assets/sprites/sprites.png differ diff --git a/core/src/io/anuke/mindustry/Control.java b/core/src/io/anuke/mindustry/Control.java index 22a1997b34..7937eafecc 100644 --- a/core/src/io/anuke/mindustry/Control.java +++ b/core/src/io/anuke/mindustry/Control.java @@ -8,6 +8,7 @@ import com.badlogic.gdx.Input.Keys; import com.badlogic.gdx.input.GestureDetector; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.ObjectMap; +import com.badlogic.gdx.utils.TimeUtils; import com.badlogic.gdx.utils.reflect.ClassReflection; import com.badlogic.gdx.utils.reflect.Constructor; @@ -466,7 +467,9 @@ public class Control extends Module{ runWave(); } + long time = TimeUtils.nanoTime(); Entities.update(); + if(Timers.get("profileeu", profileTime)) Profiler.entityUpdate = TimeUtils.timeSinceNanos(time); } if(!android){ diff --git a/core/src/io/anuke/mindustry/Mindustry.java b/core/src/io/anuke/mindustry/Mindustry.java index e068013c67..54a4e58308 100644 --- a/core/src/io/anuke/mindustry/Mindustry.java +++ b/core/src/io/anuke/mindustry/Mindustry.java @@ -1,9 +1,12 @@ package io.anuke.mindustry; +import static io.anuke.mindustry.Vars.profileTime; + import java.util.Date; import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.utils.Array; +import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.io.Formatter; @@ -53,6 +56,7 @@ public class Mindustry extends ModuleCore { @Override public void render(){ + long time = TimeUtils.nanoTime(); try{ super.render(); @@ -67,5 +71,7 @@ public class Mindustry extends ModuleCore { } Inputs.update(); + + if(Timers.get("profilet", profileTime)) Profiler.total = TimeUtils.timeSinceNanos(time); } } diff --git a/core/src/io/anuke/mindustry/Profiler.java b/core/src/io/anuke/mindustry/Profiler.java new file mode 100644 index 0000000000..8a35cd7279 --- /dev/null +++ b/core/src/io/anuke/mindustry/Profiler.java @@ -0,0 +1,9 @@ +package io.anuke.mindustry; + +public class Profiler{ + public static long total; + public static long draw; + public static long blockDraw; + public static long entityDraw; + public static long entityUpdate; +} diff --git a/core/src/io/anuke/mindustry/Renderer.java b/core/src/io/anuke/mindustry/Renderer.java index c25012e20e..599d3cfb84 100644 --- a/core/src/io/anuke/mindustry/Renderer.java +++ b/core/src/io/anuke/mindustry/Renderer.java @@ -11,6 +11,7 @@ import com.badlogic.gdx.graphics.Texture; import com.badlogic.gdx.graphics.profiling.GLProfiler; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.TimeUtils; import io.anuke.mindustry.GameState.State; import io.anuke.mindustry.entities.Player; @@ -112,8 +113,10 @@ public class Renderer extends RendererModule{ if(Gdx.graphics.getWidth() / Core.cameraScale % 2 == 1){ camera.position.add(-0.5f, 0, 0); } - + + long time = TimeUtils.nanoTime(); drawDefault(); + if(Timers.get("profiled", profileTime)) Profiler.draw = TimeUtils.timeSinceNanos(time); if(Vars.debug && Vars.debugGL && Timers.get("profile", 60)){ UCore.log("shaders: " + GLProfiler.shaderSwitches, @@ -135,8 +138,13 @@ public class Renderer extends RendererModule{ Graphics.surface("shield"); Graphics.surface(); + long time = TimeUtils.nanoTime(); renderTiles(); + if(Timers.get("profilebd", profileTime)) Profiler.blockDraw = TimeUtils.timeSinceNanos(time); + + time = TimeUtils.nanoTime(); Entities.draw(); + if(Timers.get("profileed", profileTime)) Profiler.entityDraw = TimeUtils.timeSinceNanos(time); drawShield(); @@ -237,11 +245,13 @@ public class Renderer extends RendererModule{ int rangey = (int) (camera.viewportHeight * camera.zoom / tilesize / 2) + 2; boolean noshadows = Settings.getBool("noshadows"); - + + boolean drawTiles = true; + //0 = shadows //1 = normal blocks //2 = over blocks - for(int l = (noshadows ? 1 : 0); l < 3; l++){ + for(int l = (noshadows ? 1 : 0); l < (drawTiles ? 3 : 0); l++){ if(l == 0){ Graphics.surface("shadow"); } diff --git a/core/src/io/anuke/mindustry/UI.java b/core/src/io/anuke/mindustry/UI.java index b714ef867c..5b8ce52e0a 100644 --- a/core/src/io/anuke/mindustry/UI.java +++ b/core/src/io/anuke/mindustry/UI.java @@ -107,7 +107,7 @@ public class UI extends SceneModule{ Draw.color(); TextureRegion back = Draw.region("background"); - float backscl = 5; + float backscl = 5.5f; Core.batch.draw(back, w/2 - back.getRegionWidth()*backscl/2, h/2 - back.getRegionHeight()*backscl/2, back.getRegionWidth()*backscl, back.getRegionHeight()*backscl); @@ -505,6 +505,30 @@ public class UI extends SceneModule{ row(); new label("[red]DEBUG MODE").scale(0.5f).left(); }}.end(); + + new table(){{ + atop(); + new table("button"){{ + defaults().left().growX(); + atop(); + aleft(); + new label((StringSupplier)()->"[red]total: " + + String.format("%.1f", (float)Profiler.total/Profiler.total*100f)+ "% - " + Profiler.total).left(); + row(); + new label((StringSupplier)()->"[yellow]draw: " + + String.format("%.1f", (float)Profiler.draw/Profiler.total*100f)+ "% - " + Profiler.draw).left(); + row(); + new label((StringSupplier)()->"[green]blockDraw: " + + String.format("%.1f", (float)Profiler.blockDraw/Profiler.total*100f)+ "% - " + Profiler.blockDraw).left(); + row(); + new label((StringSupplier)()->"[blue]entityDraw: " + + String.format("%.1f", (float)Profiler.entityDraw/Profiler.total*100f)+ "% - " + Profiler.entityDraw).left(); + row(); + new label((StringSupplier)()->"[purple]entityUpdate: " + + String.format("%.1f", (float)Profiler.entityUpdate/Profiler.total*100f)+ "% - " + Profiler.entityUpdate).left(); + row(); + }}.width(400f).end(); + }}.end(); } //respawn background table diff --git a/core/src/io/anuke/mindustry/Vars.java b/core/src/io/anuke/mindustry/Vars.java index b8b68667c0..9571b03b0b 100644 --- a/core/src/io/anuke/mindustry/Vars.java +++ b/core/src/io/anuke/mindustry/Vars.java @@ -33,6 +33,8 @@ public class Vars{ //TODO named save slots, possibly with a scroll dialog public static final int saveSlots = 4; + public static final int profileTime = 30; + //only if smoothCamera public static boolean snapCamera = true; diff --git a/core/src/io/anuke/mindustry/resource/Recipe.java b/core/src/io/anuke/mindustry/resource/Recipe.java index 31318986c7..1ff5390365 100644 --- a/core/src/io/anuke/mindustry/resource/Recipe.java +++ b/core/src/io/anuke/mindustry/resource/Recipe.java @@ -29,6 +29,7 @@ public enum Recipe{ conduit(distribution, DistributionBlocks.conduit, stack(Item.steel, 1)), liquidrouter(distribution, DistributionBlocks.liquidrouter, stack(Item.steel, 2)), liquidjunction(distribution, DistributionBlocks.liquidjunction, stack(Item.steel, 2)), + liquiditemjunction(distribution, DistributionBlocks.liquiditemjunction, stack(Item.steel, 1), stack(Item.iron, 1)), sorter(distribution, DistributionBlocks.sorter, stack(Item.steel, 2)), turret(weapon, WeaponBlocks.turret, stack(Item.stone, 4)), diff --git a/core/src/io/anuke/mindustry/ui/LevelDialog.java b/core/src/io/anuke/mindustry/ui/LevelDialog.java index b14daa2e84..65a22ac19e 100644 --- a/core/src/io/anuke/mindustry/ui/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/LevelDialog.java @@ -58,7 +58,7 @@ public class LevelDialog extends FloatingDialog{ hide(); Vars.control.playMap(selectedMap); }); - image.getImageCell().size(images); + image.getImageCell().size(images).units(Unit.dp); maps.add(image).width(170).pad(4f).units(Unit.dp); } diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index 27fbde4fd5..ec5838c4ff 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -113,8 +113,7 @@ public class Block{ /** * Tries to put this item into a nearby container, if there are no available - * containers, it gets added to the block's inventory. - */ + * containers, it gets added to the block's inventory.*/ protected void offloadNear(Tile tile, Item item){ int i = tile.dump; int pdump = tile.dump; @@ -194,7 +193,7 @@ public class Block{ public void draw(Tile tile){ //note: multiblocks do not support rotation - if(width == 1 && height == 1){ + if(!isMultiblock()){ Draw.rect(name(), tile.worldx(), tile.worldy(), rotate ? tile.rotation * 90 : 0); }else{ //if multiblock, make sure to draw even block sizes offset, since the core block is at the BOTTOM LEFT diff --git a/core/src/io/anuke/mindustry/world/Generator.java b/core/src/io/anuke/mindustry/world/Generator.java index c4c5e537af..fe671abef5 100644 --- a/core/src/io/anuke/mindustry/world/Generator.java +++ b/core/src/io/anuke/mindustry/world/Generator.java @@ -2,7 +2,6 @@ package io.anuke.mindustry.world; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.graphics.Pixmap; -import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.ObjectMap; import io.anuke.mindustry.Vars; @@ -95,9 +94,9 @@ public class Generator{ } //preformance debugging - if(Vector2.dst(pixmap.getWidth()/2, pixmap.getHeight()/2, x, y) < 30){ + //if(Vector2.dst(pixmap.getWidth()/2, pixmap.getHeight()/2, x, y) < 30){ // block = Mathf.choose(ProductionBlocks.stonedrill, DistributionBlocks.conveyor); - } + //} World.tile(x, y).setBlock(block); World.tile(x, y).setFloor(floor); diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index ed6352d53b..f84df0edf0 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -114,7 +114,7 @@ public class Tile{ public boolean breakable(){ if(link == 0){ - return (block.destructible || block.breakable); + return (block.destructible || block.breakable || block.update); }else{ return getLinked().breakable(); } diff --git a/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java index 53e9b09d6e..c2bf80382f 100644 --- a/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/DistributionBlocks.java @@ -41,6 +41,11 @@ public class DistributionBlocks{ }, liquidjunction = new LiquidJunction("liquidjunction"){ + }, + liquiditemjunction = new LiquidItemJunction("liquiditemjunction"){ + { + formalName = "liquid-item junction"; + } }, powerbooster = new PowerBooster("powerbooster"){ { diff --git a/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java new file mode 100644 index 0000000000..22314a1adb --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/types/distribution/LiquidItemJunction.java @@ -0,0 +1,69 @@ +package io.anuke.mindustry.world.blocks.types.distribution; + +import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.resource.Liquid; +import io.anuke.mindustry.world.Tile; +import io.anuke.mindustry.world.blocks.types.LiquidBlock; +import io.anuke.ucore.core.Draw; +import io.anuke.ucore.core.Timers; + +public class LiquidItemJunction extends LiquidBlock{ + + public LiquidItemJunction(String name) { + super(name); + rotate = true; + } + + @Override + public void draw(Tile tile){ + Draw.rect(name(), tile.worldx(), tile.worldy(), tile.rotation * 90); + } + + @Override + public void handleLiquid(Tile tile, Tile source, Liquid liquid, float amount){ + int dir = source.relativeTo(tile.x, tile.y); + dir = (dir+4)%4; + Tile to = tile.getNearby()[dir]; + + ((LiquidBlock)to.block()).handleLiquid(to, tile, liquid, amount); + } + + @Override + public boolean acceptLiquid(Tile dest, Tile source, Liquid liquid, float amount){ + int dir = source.relativeTo(dest.x, dest.y); + dir = (dir+4)%4; + + if(dir % 2 == 0) return false; + + Tile to = dest.getNearby()[dir]; + return to != null && to.block() != this && to.block() instanceof LiquidBlock && + ((LiquidBlock)to.block()).acceptLiquid(to, dest, liquid, amount); + } + + @Override + public void handleItem(Item item, Tile tile, Tile source){ + int dir = source.relativeTo(tile.x, tile.y); + Tile to = tile.getNearby()[dir]; + + Timers.run(15, ()->{ + if(to == null || to.entity == null) return; + to.block().handleItem(item, to, tile); + }); + + } + + @Override + public boolean acceptItem(Item item, Tile dest, Tile source){ + int dir = source.relativeTo(dest.x, dest.y); + + if(dir % 2 == 1) return false; + + Tile to = dest.getNearby()[dir]; + return to != null && to.block().acceptItem(item, to, dest); + } + + @Override + public String description(){ + return "Serves as a junction for items and liquids."; + } +} diff --git a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java index 5821145308..ece8d267a4 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java @@ -17,8 +17,6 @@ public class Drill extends Block{ public Drill(String name) { super(name); update = true; - //update = false; - //destructible = true; solid = true; } diff --git a/desktop/mindustry-saves/3.mins b/desktop/mindustry-saves/3.mins index 2f98e3aa43..25d9316473 100644 Binary files a/desktop/mindustry-saves/3.mins and b/desktop/mindustry-saves/3.mins differ