Physics, pathfinding improvements

This commit is contained in:
Anuken
2018-10-10 11:29:34 -04:00
parent 6b4983537e
commit 05201d7012
6 changed files with 20 additions and 12 deletions

View File

@@ -27,7 +27,7 @@ allprojects {
appName = 'Mindustry' appName = 'Mindustry'
gdxVersion = '1.9.8' gdxVersion = '1.9.8'
roboVMVersion = '2.3.0' roboVMVersion = '2.3.0'
uCoreVersion = '5b96fa9e60beb16d05ab19b2fc73bfb3c92da816' uCoreVersion = '628ced32dbceefe9096c6acc9639cd39b1a867f4'
getVersionString = { getVersionString = {
String buildVersion = getBuildVersion() String buildVersion = getBuildVersion()

View File

@@ -155,9 +155,7 @@ public class BlockIndexer{
return ores.get(item, emptySet); 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){ public Tile findClosestOre(float xp, float yp, Item item){
Tile tile = Geometry.findClosest(xp, yp, world.indexer.getOrePositions(item)); Tile tile = Geometry.findClosest(xp, yp, world.indexer.getOrePositions(item));

View File

@@ -82,16 +82,12 @@ public class Pathfinder{
return target; 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){ public float getValueforTeam(Team team, int x, int y){
return paths == null || team.ordinal() >= paths.length ? 0 : paths[team.ordinal()].weights[x][y]; return paths == null || team.ordinal() >= paths.length ? 0 : paths[team.ordinal()].weights[x][y];
} }
private boolean passable(Tile tile, Team team){ private boolean passable(Tile tile, Team team){
return (!tile.solid() && !(tile.floor().isLiquid)) return (!tile.solid())
|| (tile.breakable() && (tile.target().getTeam() != team)); || (tile.breakable() && (tile.target().getTeam() != team));
} }
@@ -160,10 +156,10 @@ public class Pathfinder{
int dx = tile.x + point.x, dy = tile.y + point.y; int dx = tile.x + point.x, dy = tile.y + point.y;
Tile other = world.tile(dx, dy); 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)){ && passable(other, team)){
path.frontier.addFirst(world.tile(dx, dy)); 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; path.searches[dx][dy] = path.search;
} }
} }

View File

@@ -121,6 +121,15 @@ public abstract class Unit extends DestructibleEntity implements SaveTrait, Targ
return velocity; return velocity;
} }
@Override
public void move(float x, float y){
if(!isFlying()){
super.move(x, y);
}else{
moveBy(x, y);
}
}
@Override @Override
public void writeSave(DataOutput stream) throws IOException{ public void writeSave(DataOutput stream) throws IOException{
writeSave(stream, false); writeSave(stream, false);

View File

@@ -23,7 +23,7 @@ public class BattleMission extends Mission{
@Override @Override
public void generate(Generation gen){ 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, coreX, coreY, Team.blue);
//generateCoreAt(gen, enemyX, enemyY, Team.red); //generateCoreAt(gen, enemyX, enemyY, Team.red);

View File

@@ -390,9 +390,14 @@ public class Tile implements PosTrait, TargetTrait{
cliffs |= (1 << (i * 2)); cliffs |= (1 << (i * 2));
} }
} }
if(occluded){ if(occluded){
cost += 1; cost += 1;
} }
if(floor.isLiquid){
cost += 100f;
}
} }
private void preChanged(){ private void preChanged(){