Many various internal changes

This commit is contained in:
Anuken
2019-12-26 17:46:01 -05:00
parent 36ec88e2e2
commit de5979f4ee
53 changed files with 435 additions and 575 deletions

View File

@@ -103,7 +103,7 @@ public class BlockIndexer{
}
private ObjectSet<Tile>[] getFlagged(Team team){
return flagMap[(int) team.id];
return flagMap[(int)team.id];
}
/** @return whether this item is present on this map.*/
@@ -115,11 +115,11 @@ public class BlockIndexer{
public ObjectSet<Tile> getDamaged(Team team){
returnArray.clear();
if(damagedTiles[(int) team.id] == null){
damagedTiles[(int) team.id] = new ObjectSet<>();
if(damagedTiles[(int)team.id] == null){
damagedTiles[(int)team.id] = new ObjectSet<>();
}
ObjectSet<Tile> set = damagedTiles[(int) team.id];
ObjectSet<Tile> set = damagedTiles[(int)team.id];
for(Tile tile : set){
if((tile.entity == null || tile.entity.getTeam() != team || !tile.entity.damaged()) || tile.block() instanceof BuildBlock){
returnArray.add(tile);
@@ -135,7 +135,7 @@ public class BlockIndexer{
/** Get all allied blocks with a flag. */
public ObjectSet<Tile> getAllied(Team team, BlockFlag type){
return flagMap[(int) team.id][type.ordinal()];
return flagMap[(int)team.id][type.ordinal()];
}
/** Get all enemy blocks with a flag. */
@@ -155,11 +155,11 @@ public class BlockIndexer{
}
public void notifyTileDamaged(TileEntity entity){
if(damagedTiles[(int) entity.getTeam().id] == null){
damagedTiles[(int) entity.getTeam().id] = new ObjectSet<>();
if(damagedTiles[(int)entity.getTeam().id] == null){
damagedTiles[(int)entity.getTeam().id] = new ObjectSet<>();
}
ObjectSet<Tile> set = damagedTiles[(int) entity.getTeam().id];
ObjectSet<Tile> set = damagedTiles[(int)entity.getTeam().id];
set.add(entity.tile);
}
@@ -287,11 +287,11 @@ public class BlockIndexer{
//fast-set this quadrant to 'occupied' if the tile just placed is already of this team
if(tile.getTeam() == data.team && tile.entity != null && tile.block().targetable){
structQuadrants[(int) data.team.id].set(quadrantX, quadrantY);
structQuadrants[(int)data.team.id].set(quadrantX, quadrantY);
continue; //no need to process futher
}
structQuadrants[(int) data.team.id].set(quadrantX, quadrantY, false);
structQuadrants[(int)data.team.id].set(quadrantX, quadrantY, false);
outer:
for(int x = quadrantX * quadrantSize; x < world.width() && x < (quadrantX + 1) * quadrantSize; x++){
@@ -299,7 +299,7 @@ public class BlockIndexer{
Tile result = world.ltile(x, y);
//when a targetable block is found, mark this quadrant as occupied and stop searching
if(result.entity != null && result.getTeam() == data.team){
structQuadrants[(int) data.team.id].set(quadrantX, quadrantY);
structQuadrants[(int)data.team.id].set(quadrantX, quadrantY);
break outer;
}
}
@@ -308,7 +308,7 @@ public class BlockIndexer{
}
private boolean getQuad(Team team, int quadrantX, int quadrantY){
return structQuadrants[(int) team.id].get(quadrantX, quadrantY);
return structQuadrants[(int)team.id].get(quadrantX, quadrantY);
}
private int quadWidth(){

View File

@@ -53,7 +53,7 @@ public class Pathfinder implements Runnable{
}
//special preset which may help speed things up; this is optional
preloadPath(waveTeam, PathTarget.enemyCores);
preloadPath(state.rules.waveTeam, PathTarget.enemyCores);
start();
});
@@ -84,8 +84,8 @@ public class Pathfinder implements Runnable{
}
public int debugValue(Team team, int x, int y){
if(pathMap[(int) team.id][PathTarget.enemyCores.ordinal()] == null) return 0;
return pathMap[(int) team.id][PathTarget.enemyCores.ordinal()].weights[x][y];
if(pathMap[(int)team.id][PathTarget.enemyCores.ordinal()] == null) return 0;
return pathMap[(int)team.id][PathTarget.enemyCores.ordinal()].weights[x][y];
}
/** Update a tile in the internal pathfinding grid. Causes a complete pathfinding reclaculation. */
@@ -149,12 +149,12 @@ public class Pathfinder implements Runnable{
public Tile getTargetTile(Tile tile, Team team, PathTarget target){
if(tile == null) return null;
PathData data = pathMap[(int) team.id][target.ordinal()];
PathData data = pathMap[(int)team.id][target.ordinal()];
if(data == null){
//if this combination is not found, create it on request
if(!created.get((int) team.id, target.ordinal())){
created.set((int) team.id, target.ordinal());
if(!created.get((int)team.id, target.ordinal())){
created.set((int)team.id, target.ordinal());
//grab targets since this is run on main thread
IntArray targets = target.getTargets(team, new IntArray());
queue.post(() -> createPath(team, target, targets));
@@ -188,7 +188,7 @@ public class Pathfinder implements Runnable{
/** @return whether a tile can be passed through by this team. Pathfinding thread only.*/
private boolean passable(int x, int y, Team team){
int tile = tiles[x][y];
return PathTile.passable(tile) || (PathTile.team(tile) != (int) team.id && PathTile.team(tile) != (int) Team.derelict.id);
return PathTile.passable(tile) || (PathTile.team(tile) != (int)team.id && PathTile.team(tile) != (int)Team.derelict.id);
}
/**
@@ -238,7 +238,7 @@ public class Pathfinder implements Runnable{
PathData path = new PathData(team, target, world.width(), world.height());
list.add(path);
pathMap[(int) team.id][target.ordinal()] = path;
pathMap[(int)team.id][target.ordinal()] = path;
//grab targets from passed array
synchronized(path.targets){
@@ -303,7 +303,7 @@ public class Pathfinder implements Runnable{
}
//spawn points are also enemies.
if(state.rules.waves && team == defaultTeam){
if(state.rules.waves && team == state.rules.defaultTeam){
for(Tile other : spawner.getGroundSpawns()){
out.add(other.pos());
}

View File

@@ -53,7 +53,7 @@ public class WaveSpawner{
eachFlyerSpawn((spawnX, spawnY) -> {
for(int i = 0; i < spawned; i++){
BaseUnit unit = group.createUnit(waveTeam);
BaseUnit unit = group.createUnit(state.rules.waveTeam);
unit.set(spawnX + Mathf.range(spread), spawnY + Mathf.range(spread));
unit.add();
}
@@ -66,7 +66,7 @@ public class WaveSpawner{
for(int i = 0; i < spawned; i++){
Tmp.v1.rnd(spread);
BaseUnit unit = group.createUnit(waveTeam);
BaseUnit unit = group.createUnit(state.rules.waveTeam);
unit.set(spawnX + Tmp.v1.x, spawnY + Tmp.v1.y);
Time.run(Math.min(i * 5, 60 * 2), () -> spawnEffect(unit));
@@ -78,7 +78,7 @@ public class WaveSpawner{
eachGroundSpawn((spawnX, spawnY, doShockwave) -> {
if(doShockwave){
Time.run(20f, () -> Effects.effect(Fx.spawnShockwave, spawnX, spawnY, state.rules.dropZoneRadius));
Time.run(40f, () -> Damage.damage(waveTeam, spawnX, spawnY, state.rules.dropZoneRadius, 99999999f, true));
Time.run(40f, () -> Damage.damage(state.rules.waveTeam, spawnX, spawnY, state.rules.dropZoneRadius, 99999999f, true));
}
});
@@ -90,9 +90,9 @@ public class WaveSpawner{
cons.accept(spawn.worldx(), spawn.worldy(), true);
}
if(state.rules.attackMode && state.teams.isActive(waveTeam) && !state.teams.get(defaultTeam).cores.isEmpty()){
Tile firstCore = state.teams.get(defaultTeam).cores.first();
for(Tile core : state.teams.get(waveTeam).cores){
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam) && !state.teams.playerCores().isEmpty()){
Tile firstCore = state.teams.playerCores().first();
for(Tile core : state.teams.get(state.rules.waveTeam).cores){
Tmp.v1.set(firstCore).sub(core.worldx(), core.worldy()).limit(coreMargin + core.block().size*tilesize);
cons.accept(core.worldx() + Tmp.v1.x, core.worldy() + Tmp.v1.y, false);
}
@@ -107,8 +107,8 @@ public class WaveSpawner{
cons.get(spawnX, spawnY);
}
if(state.rules.attackMode && state.teams.isActive(waveTeam)){
for(Tile core : state.teams.get(waveTeam).cores){
if(state.rules.attackMode && state.teams.isActive(state.rules.waveTeam)){
for(Tile core : state.teams.get(state.rules.waveTeam).cores){
cons.get(core.worldx(), core.worldy());
}
}