v0.5.0: performance & functionality improvements to wall blocking & fog
This commit is contained in:
parent
f035945b09
commit
91a920a14c
|
@ -102,6 +102,7 @@ import com.watabou.noosa.audio.Music;
|
|||
import com.watabou.noosa.audio.Sample;
|
||||
import com.watabou.noosa.particles.Emitter;
|
||||
import com.watabou.utils.GameMath;
|
||||
import com.watabou.utils.PathFinder;
|
||||
import com.watabou.utils.Random;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -706,6 +707,7 @@ public class GameScene extends PixelScene {
|
|||
scene.visualGrid.updateMap();
|
||||
scene.terrainFeatures.updateMap();
|
||||
scene.walls.updateMap();
|
||||
updateFog();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -715,8 +717,7 @@ public class GameScene extends PixelScene {
|
|||
scene.visualGrid.updateMapCell( cell );
|
||||
scene.terrainFeatures.updateMapCell( cell );
|
||||
scene.walls.updateMapCell( cell );
|
||||
scene.fog.updateFogCell( cell );
|
||||
scene.wallBlocking.updateMapCell( cell );
|
||||
updateFog( cell );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -750,6 +751,23 @@ public class GameScene extends PixelScene {
|
|||
scene.wallBlocking.updateArea(x, y, w, h);
|
||||
}
|
||||
}
|
||||
|
||||
public static void updateFog( int cell ){
|
||||
if (scene != null) {
|
||||
//update in a 3x3 grid to account for neighbours which might also be affected
|
||||
if (Dungeon.level.insideMap(cell)) {
|
||||
for (int i : PathFinder.NEIGHBOURS9) {
|
||||
scene.fog.updateFogCell( cell + i );
|
||||
scene.wallBlocking.updateMapCell( cell + i );
|
||||
}
|
||||
|
||||
//unless we're at the level's edge, then just do the one tile.
|
||||
} else {
|
||||
scene.fog.updateFogCell( cell );
|
||||
scene.wallBlocking.updateMapCell( cell );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void afterObserve() {
|
||||
if (scene != null) {
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.shatteredpixel.shatteredpixeldungeon.levels.Terrain;
|
|||
import com.watabou.utils.Random;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.HashSet;
|
||||
|
||||
public class DungeonTileSheet {
|
||||
|
||||
|
@ -83,14 +83,14 @@ public class DungeonTileSheet {
|
|||
//next 15 slots are all water stitching with ground.
|
||||
|
||||
//These tiles can stitch with water
|
||||
public static List waterStitcheable = Arrays.asList(
|
||||
public static HashSet<Integer> waterStitcheable = new HashSet<>(Arrays.asList(
|
||||
Terrain.EMPTY, Terrain.GRASS, Terrain.EMPTY_WELL,
|
||||
Terrain.ENTRANCE, Terrain.EXIT, Terrain.EMBERS,
|
||||
Terrain.BARRICADE, Terrain.HIGH_GRASS, Terrain.SECRET_TRAP,
|
||||
Terrain.TRAP, Terrain.INACTIVE_TRAP, Terrain.EMPTY_DECO,
|
||||
Terrain.SIGN, Terrain.WELL, Terrain.STATUE, Terrain.ALCHEMY,
|
||||
Terrain.DOOR, Terrain.OPEN_DOOR, Terrain.LOCKED_DOOR
|
||||
);
|
||||
));
|
||||
|
||||
//+1 for ground above, +2 for ground right, +4 for ground below, +8 for ground left.
|
||||
public static int stitchWaterTile(int top, int right, int bottom, int left){
|
||||
|
@ -191,10 +191,10 @@ public class DungeonTileSheet {
|
|||
public static final int RAISED_WALL_BOOKSHELF_ALT = RAISED_WALLS+28;
|
||||
|
||||
//These tiles count as wall for the purposes of wall stitching
|
||||
public static List wallStitcheable = Arrays.asList(
|
||||
public static HashSet<Integer> wallStitcheable = new HashSet<>(Arrays.asList(
|
||||
Terrain.WALL, Terrain.WALL_DECO, Terrain.SECRET_DOOR,
|
||||
Terrain.LOCKED_EXIT, Terrain.UNLOCKED_EXIT, Terrain.BOOKSHELF, NULL_TILE
|
||||
);
|
||||
));
|
||||
|
||||
public static int getRaisedWallTile(int tile, int pos, int right, int below, int left){
|
||||
int result;
|
||||
|
@ -227,9 +227,9 @@ public class DungeonTileSheet {
|
|||
else return -1;
|
||||
}
|
||||
|
||||
public static List doorTiles = Arrays.asList(
|
||||
public static HashSet<Integer> doorTiles = new HashSet<>(Arrays.asList(
|
||||
Terrain.DOOR, Terrain.LOCKED_DOOR, Terrain.OPEN_DOOR
|
||||
);
|
||||
));
|
||||
|
||||
public static final int RAISED_BARRICADE = xy(1, 11);
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ public class WallBlockingTilemap extends Tilemap {
|
|||
int curr;
|
||||
|
||||
//no point in blocking tiles that are already obscured by fog
|
||||
if (fogHidden(cell) && fogHidden(cell - mapWidth)){
|
||||
if (fogHidden(cell) && fogHidden(cell - mapWidth) && fogHidden(cell + mapWidth)){
|
||||
curr = BLOCK_NONE;
|
||||
|
||||
} else if (wall(cell)) {
|
||||
|
@ -115,7 +115,14 @@ public class WallBlockingTilemap extends Tilemap {
|
|||
}
|
||||
|
||||
} else {
|
||||
curr = BLOCK_NONE;
|
||||
if (fogHidden(cell - 1) && fogHidden(cell) && fogHidden(cell + 1)
|
||||
&& cell + mapWidth < Dungeon.level.map.length
|
||||
&& wall(cell + mapWidth -1 ) && wall(cell + mapWidth) && wall(cell + mapWidth + 1)
|
||||
&& !fogHidden(cell + mapWidth)){
|
||||
curr = BLOCK_ALL;
|
||||
} else {
|
||||
curr = BLOCK_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
if (prev != curr){
|
||||
|
@ -126,12 +133,11 @@ public class WallBlockingTilemap extends Tilemap {
|
|||
|
||||
private boolean fogHidden(int cell){
|
||||
if (cell < 0 || cell >= Dungeon.level.length()) return false;
|
||||
if (wall(cell) && cell + mapWidth < Dungeon.level.length() && !wall(cell + mapWidth)){
|
||||
return (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell])
|
||||
|| (!Dungeon.level.visited[cell + mapWidth] && !Dungeon.level.mapped[cell + mapWidth]);
|
||||
} else {
|
||||
return (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell]);
|
||||
}
|
||||
if (!Dungeon.level.visited[cell] && !Dungeon.level.mapped[cell]) return true;
|
||||
if (wall(cell) && cell + mapWidth < Dungeon.level.length() && !wall(cell + mapWidth) &&
|
||||
!Dungeon.level.visited[cell + mapWidth] && !Dungeon.level.mapped[cell + mapWidth])
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private boolean wall(int cell){
|
||||
|
|
Loading…
Reference in New Issue
Block a user