diff --git a/build.gradle b/build.gradle index d38ab95196..bdec592689 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:779c75e1b2' + compile 'com.github.anuken:ucore:073aa61a1c' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets-raw/sprites/blocks/coalpurifier.png b/core/assets-raw/sprites/blocks/coalpurifier.png new file mode 100644 index 0000000000..a0ab6216b9 Binary files /dev/null and b/core/assets-raw/sprites/blocks/coalpurifier.png differ diff --git a/core/assets/sprites/sprites.atlas b/core/assets/sprites/sprites.atlas index 4128a264d5..b078686940 100644 --- a/core/assets/sprites/sprites.atlas +++ b/core/assets/sprites/sprites.atlas @@ -46,104 +46,111 @@ blocks/coaldrill orig: 8, 8 offset: 0, 0 index: -1 -blocks/conduit +blocks/coalpurifier rotate: false xy: 331, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/conduitbottom +blocks/conduit rotate: false xy: 341, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/conduitliquid +blocks/conduitbottom rotate: false xy: 351, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/conduittop +blocks/conduitliquid rotate: false xy: 361, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/conveyor +blocks/conduittop rotate: false xy: 371, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/conveyormove +blocks/conveyor rotate: false xy: 381, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/core +blocks/conveyormove rotate: false xy: 391, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/cross +blocks/core rotate: false xy: 401, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/crucible +blocks/cross rotate: false xy: 411, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/deepwater +blocks/crucible rotate: false xy: 421, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/dirt1 +blocks/deepwater rotate: false xy: 431, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/dirt2 +blocks/dirt1 rotate: false xy: 441, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/dirt3 +blocks/dirt2 rotate: false xy: 451, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 -blocks/dirtblock +blocks/dirt3 rotate: false xy: 461, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 +blocks/dirtblock + rotate: false + xy: 471, 23 + size: 8, 8 + orig: 8, 8 + offset: 0, 0 + index: -1 blocks/dirtedge rotate: false xy: 85, 19 @@ -160,7 +167,7 @@ blocks/doubleturret index: -1 blocks/drill rotate: false - xy: 471, 23 + xy: 481, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -174,35 +181,35 @@ blocks/flameturret index: -1 blocks/grass1 rotate: false - xy: 491, 23 + xy: 501, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass2 rotate: false - xy: 501, 23 + xy: 128, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grass3 rotate: false - xy: 128, 11 + xy: 128, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock rotate: false - xy: 128, 1 + xy: 138, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/grassblock2 rotate: false - xy: 138, 11 + xy: 138, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -216,42 +223,42 @@ blocks/grassedge index: -1 blocks/iron1 rotate: false - xy: 168, 1 + xy: 178, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron2 rotate: false - xy: 178, 11 + xy: 178, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/iron3 rotate: false - xy: 178, 1 + xy: 188, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/irondrill rotate: false - xy: 188, 11 + xy: 188, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/ironwall rotate: false - xy: 188, 1 + xy: 198, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/junction rotate: false - xy: 198, 11 + xy: 198, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -286,21 +293,21 @@ blocks/mortarturret index: -1 blocks/mossblock rotate: false - xy: 208, 11 + xy: 208, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/mossstone rotate: false - xy: 208, 11 + xy: 208, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/omnidrill rotate: false - xy: 208, 1 + xy: 218, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -314,7 +321,7 @@ blocks/plasmaturret index: -1 blocks/pump rotate: false - xy: 218, 1 + xy: 228, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -328,35 +335,35 @@ blocks/repairturret index: -1 blocks/rock rotate: false - xy: 228, 11 + xy: 228, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2 rotate: false - xy: 228, 1 + xy: 238, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rock2shadow rotate: false - xy: 238, 11 + xy: 238, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/rockshadow rotate: false - xy: 238, 1 + xy: 248, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/router rotate: false - xy: 248, 11 + xy: 248, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -377,21 +384,21 @@ blocks/shotgunturret index: -1 blocks/shrub rotate: false - xy: 248, 1 + xy: 258, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/shrubshadow rotate: false - xy: 258, 11 + xy: 258, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/smelter rotate: false - xy: 258, 1 + xy: 268, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -405,21 +412,21 @@ blocks/sniperturret index: -1 blocks/steelconveyor rotate: false - xy: 268, 11 + xy: 268, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelconveyormove rotate: false - xy: 268, 1 + xy: 278, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/steelwall rotate: false - xy: 278, 13 + xy: 278, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -433,49 +440,49 @@ blocks/stone index: -1 blocks/stone1 rotate: false - xy: 278, 3 + xy: 288, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone2 rotate: false - xy: 288, 13 + xy: 288, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stone3 rotate: false - xy: 288, 3 + xy: 298, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock rotate: false - xy: 298, 13 + xy: 298, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock2 rotate: false - xy: 298, 3 + xy: 308, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stoneblock3 rotate: false - xy: 308, 13 + xy: 308, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/stonedrill rotate: false - xy: 308, 3 + xy: 318, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -489,42 +496,42 @@ blocks/stoneedge index: -1 blocks/stonewall rotate: false - xy: 318, 13 + xy: 318, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium1 rotate: false - xy: 318, 3 + xy: 328, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium2 rotate: false - xy: 328, 13 + xy: 328, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titanium3 rotate: false - xy: 328, 3 + xy: 338, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumdrill rotate: false - xy: 338, 13 + xy: 338, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 blocks/titaniumwall rotate: false - xy: 338, 3 + xy: 348, 13 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -538,7 +545,7 @@ blocks/turret index: -1 blocks/water rotate: false - xy: 348, 13 + xy: 348, 3 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -580,7 +587,7 @@ enemies/bossmech index: -1 enemies/fastmech rotate: false - xy: 481, 23 + xy: 491, 23 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -594,49 +601,49 @@ enemies/firemech index: -1 enemies/mech1 rotate: false - xy: 198, 1 + xy: 208, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-coal rotate: false - xy: 138, 1 + xy: 148, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-dirium rotate: false - xy: 148, 11 + xy: 148, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-iron rotate: false - xy: 148, 1 + xy: 158, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-steel rotate: false - xy: 158, 11 + xy: 158, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-stone rotate: false - xy: 158, 1 + xy: 168, 11 size: 8, 8 orig: 8, 8 offset: 0, 0 index: -1 icon-titanium rotate: false - xy: 168, 11 + xy: 168, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 @@ -657,7 +664,7 @@ laserend index: -1 player rotate: false - xy: 218, 11 + xy: 218, 1 size: 8, 8 orig: 8, 8 offset: 0, 0 diff --git a/core/assets/sprites/sprites.png b/core/assets/sprites/sprites.png index b3b6082ca4..19dec1f644 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 8aeee09936..dd3e373bed 100644 --- a/core/src/io/anuke/mindustry/Control.java +++ b/core/src/io/anuke/mindustry/Control.java @@ -402,7 +402,7 @@ public class Control extends ControlModule{ if(!GameState.is(State.paused)){ Inputs.update(); - Timers.update(Gdx.graphics.getDeltaTime()*60f); + Timers.update(); } } diff --git a/core/src/io/anuke/mindustry/EffectLoader.java b/core/src/io/anuke/mindustry/EffectLoader.java index 4c981844f3..8c52bcd1fb 100644 --- a/core/src/io/anuke/mindustry/EffectLoader.java +++ b/core/src/io/anuke/mindustry/EffectLoader.java @@ -35,6 +35,13 @@ public class EffectLoader{ Draw.square(e.x, e.y, Vars.tilesize / 2f + e.ifract() * 3f); Draw.reset(); }); + + Effects.create("purify", 10, e -> { + Draw.color(Hue.mix(Color.ROYAL, Color.GRAY, e.ifract())); + Draw.thickness(2f); + Draw.spikes(e.x, e.y, e.ifract() * 4f, 2, 6); + Draw.reset(); + }); Effects.create("spark", 10, e -> { Draw.thickness(1f); diff --git a/core/src/io/anuke/mindustry/entities/BulletType.java b/core/src/io/anuke/mindustry/entities/BulletType.java index 18d63e2a0f..834c74d2ea 100644 --- a/core/src/io/anuke/mindustry/entities/BulletType.java +++ b/core/src/io/anuke/mindustry/entities/BulletType.java @@ -108,7 +108,7 @@ public abstract class BulletType extends BaseBulletType{ Draw.reset(); } }, - plasmaflame = new BulletType(0.8f, 15){ + plasmaflame = new BulletType(0.8f, 17){ { lifetime = 65f; } diff --git a/core/src/io/anuke/mindustry/entities/Player.java b/core/src/io/anuke/mindustry/entities/Player.java index d6a6d8dfbd..07ca131400 100644 --- a/core/src/io/anuke/mindustry/entities/Player.java +++ b/core/src/io/anuke/mindustry/entities/Player.java @@ -51,7 +51,7 @@ public class Player extends DestructibleEntity{ float speed = this.speed; if(Vars.debug) - speed = 2f; + speed *= 3f; if(health < maxhealth && Timers.get(this, 50)) health ++; @@ -76,10 +76,10 @@ public class Player extends DestructibleEntity{ vector.limit(speed); - move(vector.x*delta, vector.y*delta, 4); + move(vector.x*Timers.delta(), vector.y*Timers.delta(), 4); if(!shooting){ - direction.add(vector.scl(delta)); + direction.add(vector.scl(Timers.delta())); direction.limit(speed*6); }else{ float angle = Angles.mouseAngle(x, y); diff --git a/core/src/io/anuke/mindustry/entities/TileEntity.java b/core/src/io/anuke/mindustry/entities/TileEntity.java index 4d3e9bb13c..20b5b16356 100644 --- a/core/src/io/anuke/mindustry/entities/TileEntity.java +++ b/core/src/io/anuke/mindustry/entities/TileEntity.java @@ -13,6 +13,7 @@ import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.Blocks; import io.anuke.mindustry.world.blocks.ProductionBlocks; import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Timers; import io.anuke.ucore.entities.Entity; import io.anuke.ucore.util.Mathf; @@ -67,7 +68,7 @@ public class TileEntity extends Entity{ @Override public void update(){ if(health != 0 && !tile.block().name().contains("block") && - Mathf.chance(0.009f*delta*(1f-(float)health/maxhealth))){ + Mathf.chance(0.009f*Timers.delta()*(1f-(float)health/maxhealth))){ Effects.effect("smoke", x+Mathf.range(4), y+Mathf.range(4)); } @@ -87,6 +88,10 @@ public class TileEntity extends Entity{ return items.get(item, 0) > 0; } + public boolean hasItem(Item item, int amount){ + return items.get(item, 0) >= amount; + } + public void addItem(Item item, int amount){ items.put(item, items.get(item, 0) + amount); } diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 4833b63e1b..9fd12159b6 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -48,7 +48,7 @@ public class Enemy extends DestructibleEntity{ Vector2 vec = Pathfind.find(this); vec.sub(x, y).setLength(speed); - move(vec.x*delta, vec.y*delta, Vars.tilesize-4); + move(vec.x*Timers.delta(), vec.y*Timers.delta(), Vars.tilesize-4); if(Timers.get(this, 15)){ target = World.findTileTarget(x, y, null, range, false); diff --git a/core/src/io/anuke/mindustry/input/Input.java b/core/src/io/anuke/mindustry/input/Input.java index c9280139a8..ae3da19b12 100644 --- a/core/src/io/anuke/mindustry/input/Input.java +++ b/core/src/io/anuke/mindustry/input/Input.java @@ -76,7 +76,7 @@ public class Input{ Tile cursor = World.cursorTile(); //block breaking - if(Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.breakable() + if(cursor != null && Inputs.buttonDown(Buttons.RIGHT) && World.cursorNear() && cursor.breakable() && cursor.block() != ProductionBlocks.core){ Tile tile = cursor; player.breaktime += Timers.delta(); diff --git a/core/src/io/anuke/mindustry/resource/Recipe.java b/core/src/io/anuke/mindustry/resource/Recipe.java index 1426aa64d5..4268eb58a2 100644 --- a/core/src/io/anuke/mindustry/resource/Recipe.java +++ b/core/src/io/anuke/mindustry/resource/Recipe.java @@ -27,8 +27,8 @@ public enum Recipe{ sniperturret(defense, WeaponBlocks.sniperturret, stack(Item.iron, 30), stack(Item.steel, 20)), laserturret(defense, WeaponBlocks.laserturret, stack(Item.steel, 20), stack(Item.titanium, 20)), mortarturret(defense, WeaponBlocks.mortarturret, stack(Item.steel, 40), stack(Item.titanium, 30)), - waveturret(defense, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 20), stack(Item.dirium, 20)), - plasmaturret(defense, WeaponBlocks.plasmaturret, stack(Item.steel, 40), stack(Item.titanium, 30), stack(Item.dirium, 25)), + teslaturret(defense, WeaponBlocks.teslaturret, stack(Item.steel, 20), stack(Item.titanium, 30), stack(Item.dirium, 30)), + plasmaturret(defense, WeaponBlocks.plasmaturret, stack(Item.steel, 20), stack(Item.titanium, 20), stack(Item.dirium, 30)), healturret(defense, WeaponBlocks.repairturret, stack(Item.iron, 50)), megahealturret(defense, WeaponBlocks.megarepairturret, stack(Item.iron, 30), stack(Item.steel, 50)), @@ -40,6 +40,7 @@ public enum Recipe{ omnidrill(production, ProductionBlocks.omnidrill, stack(Item.steel, 50), stack(Item.titanium, 50)), smelter(production, ProductionBlocks.smelter, stack(Item.stone, 80), stack(Item.iron, 80)), crucible(production, ProductionBlocks.crucible, stack(Item.titanium, 80), stack(Item.steel, 80)), + coalpurifier(production, ProductionBlocks.coalpurifier, stack(Item.steel, 20), stack(Item.iron, 20)), conduit(distribution, ProductionBlocks.conduit, stack(Item.steel, 1)), pump(production, ProductionBlocks.pump, stack(Item.steel, 20)); diff --git a/core/src/io/anuke/mindustry/world/Generator.java b/core/src/io/anuke/mindustry/world/Generator.java index 6c6189141d..470b7f95df 100644 --- a/core/src/io/anuke/mindustry/world/Generator.java +++ b/core/src/io/anuke/mindustry/world/Generator.java @@ -62,7 +62,7 @@ public class Generator{ floor = Blocks.coal; } - if(Noise.nnoise(x, y, 5, 1) > 0.2){ + if(Noise.nnoise(x, y, 9, 1) > 0.254){ floor = Blocks.titanium; } } diff --git a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java index 1817119e3d..8dfdcfc8cb 100644 --- a/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/ProductionBlocks.java @@ -7,6 +7,7 @@ import io.anuke.mindustry.Inventory; import io.anuke.mindustry.Renderer; import io.anuke.mindustry.Vars; import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.resource.Liquid; import io.anuke.mindustry.world.Block; import io.anuke.mindustry.world.Tile; import io.anuke.mindustry.world.blocks.types.*; @@ -154,6 +155,20 @@ public class ProductionBlocks{ } }, + coalpurifier = new Purifier("coalpurifier"){ + { + formalName = "coal purifier"; + input = Item.stone; + inputLiquid = Liquid.water; + output = Item.coal; + } + + @Override + public String description(){ + return "Takes in stone + water, outputs coal."; + } + }, + stonedrill = new Drill("stonedrill"){{ resource = Blocks.stone; result = Item.stone; diff --git a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java index 40603f45ce..b94fea9a15 100644 --- a/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java +++ b/core/src/io/anuke/mindustry/world/blocks/WeaponBlocks.java @@ -141,7 +141,7 @@ public class WeaponBlocks{ reload = 20f; bullet = BulletType.shell; ammo = Item.stone; - health = 1100; + health = 140; } @Override @@ -150,7 +150,7 @@ public class WeaponBlocks{ Angles.translation(entity.rotation, 4); new TeslaOrb(tile.worldx() + Angles.x(), tile.worldy() + Angles.y(), - 70, (int)(10*Vars.multiplier)).add(); + 70, (int)(8*Vars.multiplier)).add(); } }, diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java b/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java index b2bee49557..7f830c65ca 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Conduit.java @@ -12,7 +12,7 @@ import io.anuke.ucore.core.Draw; import io.anuke.ucore.core.Timers; public class Conduit extends Block{ - protected float capacity = 10f; + protected float liquidCapacity = 10f; protected float flowfactor = 4f; public Conduit(String name) { @@ -26,9 +26,9 @@ public class Conduit extends Block{ ConduitEntity entity = tile.entity(); Draw.rect(name() + "bottom", tile.worldx(), tile.worldy(), tile.rotation * 90); - if(entity.liquid != null && entity.amount > 0.01f){ + if(entity.liquid != null && entity.liquidAmount > 0.01f){ Draw.color(entity.liquid.color); - Draw.alpha(entity.amount / capacity); + Draw.alpha(entity.liquidAmount / liquidCapacity); Draw.rect("conduitliquid", tile.worldx(), tile.worldy(), tile.rotation * 90); Draw.color(); } @@ -45,7 +45,7 @@ public class Conduit extends Block{ public void update(Tile tile){ ConduitEntity entity = tile.entity(); - if(entity.amount > 0.01f && Timers.get(entity, "flow", 3)){ + if(entity.liquidAmount > 0.01f && Timers.get(entity, "flow", 3)){ tryMoveLiquid(tile, tile.getNearby()[tile.rotation]); } @@ -54,7 +54,7 @@ public class Conduit extends Block{ public void tryDumpLiquid(Tile tile){ ConduitEntity entity = tile.entity(); - if(entity.amount > 0.01f){ + if(entity.liquidAmount > 0.01f){ tryMoveLiquid(tile, tile.getNearby()[tile.dump]); tile.dump ++; tile.dump %= 4; @@ -66,47 +66,47 @@ public class Conduit extends Block{ Liquid liquid = entity.liquid; - if(next != null && next.block() instanceof Conduit && entity.amount > 0.01f){ + if(next != null && next.block() instanceof Conduit && entity.liquidAmount > 0.01f){ Conduit other = (Conduit)next.block(); ConduitEntity otherentity = next.entity(); - float flow = Math.min(other.capacity - otherentity.amount - 0.001f, Math.min(entity.amount/flowfactor, entity.amount)); + float flow = Math.min(other.liquidCapacity - otherentity.liquidAmount - 0.001f, Math.min(entity.liquidAmount/flowfactor, entity.liquidAmount)); - if(flow <= 0f || entity.amount < flow) return; + if(flow <= 0f || entity.liquidAmount < flow) return; - if(other.accept(next, tile, liquid, flow)){ + if(other.acceptLiquid(next, tile, liquid, flow)){ other.addLiquid(next, tile, liquid, flow); - entity.amount -= flow; + entity.liquidAmount -= flow; } } } - public boolean accept(Tile tile, Tile source, Liquid liquid, float amount){ + public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ ConduitEntity entity = tile.entity(); - return entity.amount + amount < capacity && (entity.liquid == liquid || entity.amount <= 0.01f); + return entity.liquidAmount + amount < liquidCapacity && (entity.liquid == liquid || entity.liquidAmount <= 0.01f); } public void addLiquid(Tile tile, Tile source, Liquid liquid, float amount){ ConduitEntity entity = tile.entity(); entity.liquid = liquid; - entity.amount += amount; + entity.liquidAmount += amount; } static class ConduitEntity extends TileEntity{ Liquid liquid; - float amount; + float liquidAmount; @Override public void write(DataOutputStream stream) throws IOException{ stream.writeByte(liquid.ordinal()); - stream.writeByte((byte)(amount)); + stream.writeByte((byte)(liquidAmount)); } @Override public void read(DataInputStream stream) throws IOException{ liquid = Liquid.values()[stream.readByte()]; - amount = stream.readByte(); + liquidAmount = stream.readByte(); } } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/Drill.java index 11b26a2113..beab1b726c 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Drill.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Drill.java @@ -27,7 +27,7 @@ public class Drill extends Block{ Effects.effect("spark", tile.worldx(), tile.worldy()); } - if(Timers.get(tile.hashCode() + "dump", 30)){ + if(Timers.get(tile.hashCode(), "dump", 30)){ tryDump(tile); } } diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java index e3ee6047c8..1d4577a251 100644 --- a/core/src/io/anuke/mindustry/world/blocks/types/Pump.java +++ b/core/src/io/anuke/mindustry/world/blocks/types/Pump.java @@ -14,7 +14,7 @@ public class Pump extends Conduit{ } @Override - public boolean accept(Tile tile, Tile source, Liquid liquid, float amount){ + public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ return false; } @@ -27,9 +27,9 @@ public class Pump extends Conduit{ public void update(Tile tile){ ConduitEntity entity = tile.entity(); - if(Timers.get(tile, "pump", 8) && entity.amount < capacity){ + if(Timers.get(tile, "pump", 8) && entity.liquidAmount < liquidCapacity){ entity.liquid = Liquid.water; - entity.amount += pumpspeed; + entity.liquidAmount += pumpspeed; } if(Timers.get(tile, "dump", 1)){ diff --git a/core/src/io/anuke/mindustry/world/blocks/types/Purifier.java b/core/src/io/anuke/mindustry/world/blocks/types/Purifier.java new file mode 100644 index 0000000000..c201e5f76a --- /dev/null +++ b/core/src/io/anuke/mindustry/world/blocks/types/Purifier.java @@ -0,0 +1,77 @@ +package io.anuke.mindustry.world.blocks.types; + +import com.badlogic.gdx.graphics.Color; + +import io.anuke.mindustry.Renderer; +import io.anuke.mindustry.entities.TileEntity; +import io.anuke.mindustry.resource.Item; +import io.anuke.mindustry.resource.Liquid; +import io.anuke.mindustry.world.Tile; +import io.anuke.ucore.core.Draw; +import io.anuke.ucore.core.Effects; +import io.anuke.ucore.core.Timers; + +public class Purifier extends Conduit{ + public Item input = null; + public int inputAmount = 5; + public Liquid inputLiquid = null; + public float liquidAmount = 19.99f; + public Item output = null; + public int itemCapacity = 100; + public int purifyTime = 90; + + public Purifier(String name) { + super(name); + update = true; + rotate = false; + liquidCapacity = 20f; + } + + @Override + public void draw(Tile tile){ + ConduitEntity entity = tile.entity(); + Draw.rect(name(), tile.worldx(), tile.worldy()); + + Draw.color(Color.ROYAL); + Draw.alpha(entity.liquidAmount / liquidCapacity); + Draw.rect("blank", tile.worldx(), tile.worldy(), 2, 2); + Draw.color(); + } + + @Override + public void update(Tile tile){ + ConduitEntity entity = tile.entity(); + + if(Timers.get(tile, "purify", purifyTime) && entity.liquidAmount >= liquidAmount && + entity.hasItem(input, inputAmount)){ + + entity.removeItem(input, inputAmount); + entity.liquidAmount -= liquidAmount; + offloadNear(tile, output); + Effects.effect("purify", tile.worldx(), tile.worldy()); + } + + if(Timers.get(tile.hashCode(), "dump", 30)){ + tryDump(tile, -1, output); + } + } + + @Override + public void drawPixelOverlay(Tile tile){ + float fract = (float)tile.entity.items.get(input, 0) / itemCapacity; + + Renderer.drawBar(Color.GREEN, tile.worldx(), tile.worldy() + 13, fract); + } + + @Override + public boolean acceptLiquid(Tile tile, Tile source, Liquid liquid, float amount){ + return super.acceptLiquid(tile, source, liquid, amount) && liquid == inputLiquid; + } + + @Override + public boolean accept(Item item, Tile tile, Tile source){ + TileEntity entity = tile.entity(); + return item == input && entity.items.get(item, 0) < itemCapacity; + } + +} diff --git a/desktop/gifexport/recording1506017475.gif b/desktop/gifexport/recording1506017475.gif new file mode 100644 index 0000000000..276b5c6f3f Binary files /dev/null and b/desktop/gifexport/recording1506017475.gif differ diff --git a/desktop/gifexport/recording1506017731.gif b/desktop/gifexport/recording1506017731.gif new file mode 100644 index 0000000000..990c303f6e Binary files /dev/null and b/desktop/gifexport/recording1506017731.gif differ diff --git a/desktop/gifexport/recording1506017778.gif b/desktop/gifexport/recording1506017778.gif new file mode 100644 index 0000000000..70c3e8dbf2 Binary files /dev/null and b/desktop/gifexport/recording1506017778.gif differ diff --git a/desktop/gifexport/recording1506017832.gif b/desktop/gifexport/recording1506017832.gif new file mode 100644 index 0000000000..a93f869aca Binary files /dev/null and b/desktop/gifexport/recording1506017832.gif differ diff --git a/desktop/gifexport/recording1506018606.gif b/desktop/gifexport/recording1506018606.gif new file mode 100644 index 0000000000..20cda0073b Binary files /dev/null and b/desktop/gifexport/recording1506018606.gif differ diff --git a/desktop/gifexport/recording1506023873.gif b/desktop/gifexport/recording1506023873.gif new file mode 100644 index 0000000000..630b7d6dad Binary files /dev/null and b/desktop/gifexport/recording1506023873.gif differ diff --git a/desktop/gifexport/recording1506023906.gif b/desktop/gifexport/recording1506023906.gif new file mode 100644 index 0000000000..af70c8bcba Binary files /dev/null and b/desktop/gifexport/recording1506023906.gif differ diff --git a/desktop/gifexport/recording1506024063.gif b/desktop/gifexport/recording1506024063.gif new file mode 100644 index 0000000000..17bb04c14b Binary files /dev/null and b/desktop/gifexport/recording1506024063.gif differ diff --git a/desktop/gifexport/recording1506024075.gif b/desktop/gifexport/recording1506024075.gif new file mode 100644 index 0000000000..ffd44447f9 Binary files /dev/null and b/desktop/gifexport/recording1506024075.gif differ diff --git a/desktop/gifexport/recording1506024118.gif b/desktop/gifexport/recording1506024118.gif new file mode 100644 index 0000000000..20fe8d18ce Binary files /dev/null and b/desktop/gifexport/recording1506024118.gif differ diff --git a/desktop/gifexport/recording1506024266.gif b/desktop/gifexport/recording1506024266.gif new file mode 100644 index 0000000000..922a8e0a1b Binary files /dev/null and b/desktop/gifexport/recording1506024266.gif differ diff --git a/desktop/gifexport/recording1506024543.gif b/desktop/gifexport/recording1506024543.gif new file mode 100644 index 0000000000..2740d0344d Binary files /dev/null and b/desktop/gifexport/recording1506024543.gif differ diff --git a/desktop/gifexport/recording1506024651.gif b/desktop/gifexport/recording1506024651.gif new file mode 100644 index 0000000000..7e77587e9b Binary files /dev/null and b/desktop/gifexport/recording1506024651.gif differ