diff --git a/build.gradle b/build.gradle index be164223a8..3d396aa0a3 100644 --- a/build.gradle +++ b/build.gradle @@ -79,7 +79,7 @@ project(":core") { apply plugin: "java" dependencies { - compile 'com.github.anuken:ucore:91e4e11010' + compile 'com.github.anuken:ucore:c498e5920a' compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile "com.badlogicgames.gdx:gdx-ai:1.8.1" } diff --git a/core/assets/maps/test.png b/core/assets/maps/test.png index aec9f3a5db..070058cda4 100644 Binary files a/core/assets/maps/test.png and b/core/assets/maps/test.png differ diff --git a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java index 2e32bc8c3a..0f6533049e 100644 --- a/core/src/io/anuke/mindustry/entities/enemies/Enemy.java +++ b/core/src/io/anuke/mindustry/entities/enemies/Enemy.java @@ -2,6 +2,7 @@ package io.anuke.mindustry.entities.enemies; import com.badlogic.gdx.graphics.Color; import com.badlogic.gdx.math.Vector2; +import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.reflect.ClassReflection; import io.anuke.mindustry.Shaders; @@ -15,6 +16,7 @@ import io.anuke.mindustry.world.World; import io.anuke.ucore.core.*; import io.anuke.ucore.entities.*; import io.anuke.ucore.util.Mathf; +import io.anuke.ucore.util.Tmp; public class Enemy extends DestructibleEntity{ public final static Color[] tierColors = {Color.YELLOW, Color.ORANGE, Color.RED, Color.MAGENTA}; @@ -59,6 +61,22 @@ public class Enemy extends DestructibleEntity{ Vector2 vec = Pathfind.find(this); vec.sub(x, y).setLength(speed); + Array entities = Entities.getNearby(x, y, range); + + Vector2 shift = Tmp.v3.setZero(); + float shiftRange = hitbox.width + 3f; + + for(SolidEntity other : entities){ + float dst = other.distanceTo(this); + if(other != this && other instanceof Enemy && dst < shiftRange){ + float scl = Mathf.clamp(1.4f - dst/shiftRange); + shift.add((x - other.x) * scl, (y - other.y) * scl); + } + } + + shift.nor(); + vec.add(shift.scl(0.5f)); + move(vec.x*Timers.delta(), vec.y*Timers.delta()); if(Timers.get(this, "target", 15)){ @@ -66,9 +84,7 @@ public class Enemy extends DestructibleEntity{ //no tile found if(target == null){ - target = Entities.getClosest(x, y, range, e->{ - return e instanceof Player; - }); + target = Entities.getClosest(entities, x, y, range, e -> e instanceof Player); } } diff --git a/core/src/io/anuke/mindustry/ui/LevelDialog.java b/core/src/io/anuke/mindustry/ui/LevelDialog.java index 5d9c0b8725..b14daa2e84 100644 --- a/core/src/io/anuke/mindustry/ui/LevelDialog.java +++ b/core/src/io/anuke/mindustry/ui/LevelDialog.java @@ -35,7 +35,7 @@ public class LevelDialog extends FloatingDialog{ for(int i = 0; i < Map.values().length; i ++){ Map map = Map.values()[i]; - if(!map.visible) continue; + if(!map.visible && !Vars.debug) continue; if(i % maxwidth == 0){ maps.row(); @@ -48,18 +48,18 @@ public class LevelDialog extends FloatingDialog{ .pad(3f).units(Unit.dp); inset.pack(); - float images = Unit.dp.inPixels(154); + float images = 154f; ImageButton image = new ImageButton(new TextureRegion(World.getTexture(map)), "togglemap"); image.row(); - image.add(inset).width(images+6); + image.add(inset).width(images+6).units(Unit.dp); image.clicked(()->{ selectedMap = map; hide(); Vars.control.playMap(selectedMap); }); image.getImageCell().size(images); - maps.add(image).width(Unit.dp.inPixels(170)).pad(4f).units(Unit.dp); + maps.add(image).width(170).pad(4f).units(Unit.dp); } content().add(pane); diff --git a/core/src/io/anuke/mindustry/world/Block.java b/core/src/io/anuke/mindustry/world/Block.java index f68e834dd1..d3326d2730 100644 --- a/core/src/io/anuke/mindustry/world/Block.java +++ b/core/src/io/anuke/mindustry/world/Block.java @@ -203,9 +203,8 @@ public class Block{ } //update the tile entity through the draw method, only if it's an entity without updating - //TODO enable if(destructible && !update && !GameState.is(State.paused)){ - // tile.entity.update(); + tile.entity.update(); } } diff --git a/core/src/io/anuke/mindustry/world/Generator.java b/core/src/io/anuke/mindustry/world/Generator.java index ffacd1996b..c4c5e537af 100644 --- a/core/src/io/anuke/mindustry/world/Generator.java +++ b/core/src/io/anuke/mindustry/world/Generator.java @@ -2,6 +2,7 @@ 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; @@ -94,9 +95,9 @@ public class Generator{ } //preformance debugging - //if(Vector2.dst(pixmap.getWidth()/2, pixmap.getHeight()/2, x, y) < 40){ - // block = DefenseBlocks.stonewall; - //} + 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/blocks/types/production/Drill.java b/core/src/io/anuke/mindustry/world/blocks/types/production/Drill.java index 54231cf0d4..5821145308 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 @@ -12,18 +12,20 @@ public class Drill extends Block{ protected Block resource; protected Item result; protected int time = 5; + protected int capacity = 5; public Drill(String name) { super(name); update = true; + //update = false; + //destructible = true; solid = true; } @Override public void update(Tile tile){ - //drills can only hold up to 10 items at a time - if(tile.floor() == resource && Timers.get(tile, "drill", 60 * time) && tile.entity.totalItems() < 10){ + if(tile.floor() == resource && Timers.get(tile, "drill", 60 * time) && tile.entity.totalItems() < capacity){ offloadNear(tile, result); Effects.effect("spark", tile.worldx(), tile.worldy()); }