From 05201d7012639c9047b0749220bb66c42132e481 Mon Sep 17 00:00:00 2001 From: Anuken Date: Wed, 10 Oct 2018 11:29:34 -0400 Subject: [PATCH] Physics, pathfinding improvements --- build.gradle | 2 +- core/src/io/anuke/mindustry/ai/BlockIndexer.java | 4 +--- core/src/io/anuke/mindustry/ai/Pathfinder.java | 10 +++------- core/src/io/anuke/mindustry/entities/Unit.java | 9 +++++++++ .../anuke/mindustry/maps/missions/BattleMission.java | 2 +- core/src/io/anuke/mindustry/world/Tile.java | 5 +++++ 6 files changed, 20 insertions(+), 12 deletions(-) diff --git a/build.gradle b/build.gradle index f29ed5fe6f..e90d91b5cc 100644 --- a/build.gradle +++ b/build.gradle @@ -27,7 +27,7 @@ allprojects { appName = 'Mindustry' gdxVersion = '1.9.8' roboVMVersion = '2.3.0' - uCoreVersion = '5b96fa9e60beb16d05ab19b2fc73bfb3c92da816' + uCoreVersion = '628ced32dbceefe9096c6acc9639cd39b1a867f4' getVersionString = { String buildVersion = getBuildVersion() diff --git a/core/src/io/anuke/mindustry/ai/BlockIndexer.java b/core/src/io/anuke/mindustry/ai/BlockIndexer.java index 9070ccb2dc..07ec34b2e9 100644 --- a/core/src/io/anuke/mindustry/ai/BlockIndexer.java +++ b/core/src/io/anuke/mindustry/ai/BlockIndexer.java @@ -155,9 +155,7 @@ public class BlockIndexer{ return ores.get(item, emptySet); } - /** - * Find the closest ore block relative to a position. - */ + /**Find the closest ore block relative to a position.*/ public Tile findClosestOre(float xp, float yp, Item item){ Tile tile = Geometry.findClosest(xp, yp, world.indexer.getOrePositions(item)); diff --git a/core/src/io/anuke/mindustry/ai/Pathfinder.java b/core/src/io/anuke/mindustry/ai/Pathfinder.java index 9f35128c4f..3f52497a92 100644 --- a/core/src/io/anuke/mindustry/ai/Pathfinder.java +++ b/core/src/io/anuke/mindustry/ai/Pathfinder.java @@ -82,16 +82,12 @@ public class Pathfinder{ return target; } - public float getDebugValue(int x, int y){ - return paths[Team.blue.ordinal()].weights[x][y]; - } - public float getValueforTeam(Team team, int x, int y){ return paths == null || team.ordinal() >= paths.length ? 0 : paths[team.ordinal()].weights[x][y]; } private boolean passable(Tile tile, Team team){ - return (!tile.solid() && !(tile.floor().isLiquid)) + return (!tile.solid()) || (tile.breakable() && (tile.target().getTeam() != team)); } @@ -160,10 +156,10 @@ public class Pathfinder{ int dx = tile.x + point.x, dy = tile.y + point.y; Tile other = world.tile(dx, dy); - if(other != null && (path.weights[dx][dy] > cost + 1 || path.searches[dx][dy] < path.search) + if(other != null && (path.weights[dx][dy] == Float.MAX_VALUE || path.searches[dx][dy] < path.search) && passable(other, team)){ path.frontier.addFirst(world.tile(dx, dy)); - path.weights[dx][dy] = cost + other.cost / 2f; + path.weights[dx][dy] = cost + other.cost; path.searches[dx][dy] = path.search; } } diff --git a/core/src/io/anuke/mindustry/entities/Unit.java b/core/src/io/anuke/mindustry/entities/Unit.java index c70ccb3d34..9a1809b19a 100644 --- a/core/src/io/anuke/mindustry/entities/Unit.java +++ b/core/src/io/anuke/mindustry/entities/Unit.java @@ -121,6 +121,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ return velocity; } + @Override + public void move(float x, float y){ + if(!isFlying()){ + super.move(x, y); + }else{ + moveBy(x, y); + } + } + @Override public void writeSave(DataOutput stream) throws IOException{ writeSave(stream, false); diff --git a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java index e09a8a07d8..fe48bf521f 100644 --- a/core/src/io/anuke/mindustry/maps/missions/BattleMission.java +++ b/core/src/io/anuke/mindustry/maps/missions/BattleMission.java @@ -23,7 +23,7 @@ public class BattleMission extends Mission{ @Override public void generate(Generation gen){ - int enemyX = gen.width-1-coreX, enemyY = gen.height-1-coreX; + //int enemyX = gen.width-1-coreX, enemyY = gen.height-1-coreX; //generateCoreAt(gen, coreX, coreY, Team.blue); //generateCoreAt(gen, enemyX, enemyY, Team.red); diff --git a/core/src/io/anuke/mindustry/world/Tile.java b/core/src/io/anuke/mindustry/world/Tile.java index 42e984e58c..868b919c52 100644 --- a/core/src/io/anuke/mindustry/world/Tile.java +++ b/core/src/io/anuke/mindustry/world/Tile.java @@ -390,9 +390,14 @@ public class Tile implements PosTrait, TargetTrait{ cliffs |= (1 << (i * 2)); } } + if(occluded){ cost += 1; } + + if(floor.isLiquid){ + cost += 100f; + } } private void preChanged(){