Fixed units pathfinding to nonexistent cores
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package io.anuke.mindustry.ai;
|
||||
|
||||
import com.badlogic.gdx.math.GridPoint2;
|
||||
import com.badlogic.gdx.utils.Array;
|
||||
import com.badlogic.gdx.utils.IntArray;
|
||||
import com.badlogic.gdx.utils.Queue;
|
||||
import com.badlogic.gdx.utils.TimeUtils;
|
||||
@@ -31,7 +30,7 @@ public class Pathfinder{
|
||||
|
||||
for(Team team : Team.all){
|
||||
TeamData data = state.teams.get(team);
|
||||
if(state.teams.isActive(team) && data.team != event.tile.getTeam() && paths[data.team.ordinal()].weights[event.tile.x][event.tile.y] >= Float.MAX_VALUE){
|
||||
if(state.teams.isActive(team) && data.team != event.tile.getTeam()){
|
||||
update(event.tile, data.team);
|
||||
}
|
||||
}
|
||||
@@ -87,28 +86,28 @@ public class Pathfinder{
|
||||
}
|
||||
|
||||
private boolean passable(Tile tile, Team team){
|
||||
return (!tile.solid())
|
||||
|| (tile.breakable() && (tile.target().getTeam() != team));
|
||||
return (!tile.solid()) || (tile.breakable() && (tile.target().getTeam() != team));
|
||||
}
|
||||
|
||||
/**Clears the frontier, increments the search and sets up all flow sources.
|
||||
* This only occurs for active teams.*/
|
||||
private void update(Tile tile, Team team){
|
||||
//make sure team exists
|
||||
if(paths[team.ordinal()] != null){
|
||||
PathData path = paths[team.ordinal()];
|
||||
|
||||
//impassable tiles have a weight of float.max
|
||||
if(!passable(tile, team)){
|
||||
path.weights[tile.x][tile.y] = Float.MAX_VALUE;
|
||||
}
|
||||
|
||||
//increment search, clear frontier
|
||||
path.search++;
|
||||
|
||||
if(path.lastSearchTime + 1000 / 60 * 3 > TimeUtils.millis()){
|
||||
path.frontier.clear();
|
||||
}
|
||||
|
||||
path.frontier.clear();
|
||||
path.lastSearchTime = TimeUtils.millis();
|
||||
|
||||
Array<Tile> set = world.indexer.getEnemy(team, BlockFlag.target);
|
||||
for(Tile other : set){
|
||||
//add all targets to the frontier
|
||||
for(Tile other : world.indexer.getEnemy(team, BlockFlag.target)){
|
||||
path.weights[other.x][other.y] = 0;
|
||||
path.searches[other.x][other.y] = path.search;
|
||||
path.frontier.addFirst(other);
|
||||
|
||||
@@ -398,6 +398,11 @@ public class NetClient extends Module{
|
||||
Net.disconnect();
|
||||
}
|
||||
|
||||
/**When set, any disconnects will be ignored and no dialogs will be shown.*/
|
||||
public void setQuiet(){
|
||||
quiet = true;
|
||||
}
|
||||
|
||||
public synchronized void addRemovedEntity(int id){
|
||||
removed.add(id);
|
||||
}
|
||||
|
||||
@@ -418,6 +418,7 @@ public class NetServer extends Module{
|
||||
@Remote(called = Loc.both)
|
||||
public static void onGameOver(Team winner){
|
||||
threads.runGraphics(() -> ui.restart.show(winner));
|
||||
netClient.setQuiet();
|
||||
}
|
||||
|
||||
public boolean isWaitingForPlayers(){
|
||||
|
||||
@@ -76,6 +76,7 @@ public class EventType{
|
||||
}
|
||||
}
|
||||
|
||||
/**Called when block building begins. The tile's block will nearly always be a BuildBlock.*/
|
||||
public static class BlockBuildEvent implements Event{
|
||||
public final Tile tile;
|
||||
public final Team team;
|
||||
|
||||
@@ -51,7 +51,7 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
if(mode.hidden) continue;
|
||||
|
||||
modes.addButton("$mode." + mode.name() + ".name", "toggle", () -> state.mode = mode)
|
||||
.update(b -> b.setChecked(state.mode == mode)).group(group).size(125f, 54f).padBottom(-5);
|
||||
.update(b -> b.setChecked(state.mode == mode)).group(group).size(140f, 54f).padBottom(-5);
|
||||
if(i++ % 2 == 1) modes.row();
|
||||
}
|
||||
selmode.add(modes);
|
||||
@@ -73,9 +73,8 @@ public class CustomGameDialog extends FloatingDialog{
|
||||
state.difficulty = (ds[Mathf.mod(state.difficulty.ordinal() - 1, ds.length)]);
|
||||
}).width(s);
|
||||
|
||||
sdif.addButton("", () -> {
|
||||
|
||||
}).update(t -> {
|
||||
sdif.addButton("", () -> {})
|
||||
.update(t -> {
|
||||
t.setText(state.difficulty.toString());
|
||||
t.setTouchable(Touchable.disabled);
|
||||
}).width(180f);
|
||||
|
||||
Reference in New Issue
Block a user