diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-24 20:02:21 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2015-12-24 20:02:21 +0100 |
commit | 4fdf26458bc803ec6f818ee4e96356b565ff25b1 (patch) | |
tree | 530993a6581133bf299e27b4aaba6704b12d80d5 /core/src/ch/asynk/rustanddust/engine | |
parent | cf17d0465c15cf5770138f79176f3892df50104d (diff) | |
download | RustAndDust-4fdf26458bc803ec6f818ee4e96356b565ff25b1.zip RustAndDust-4fdf26458bc803ec6f818ee4e96356b565ff25b1.tar.gz |
Hex: blockLineOfSightFrom(Tile) -> blockLineOfSight(Tile, Tile)
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/SearchBoard.java | 13 | ||||
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/Tile.java | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java index e8c07f9..f4bfd4c 100644 --- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java +++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java @@ -401,6 +401,7 @@ public class SearchBoard los.clear(); losBlocked = false; Tile from = board.getTile(x0, y0); + Tile to = board.getTile(x1, y1); // orthogonal axis int ox0 = x0 - ((y0 +1) / 2); @@ -465,7 +466,7 @@ public class SearchBoard } } los.add(getNode(x, y)); - if (!losBlocked) losBlocked = board.getTile(x, y).blockLineOfSightFrom(from); + if (!losBlocked) losBlocked = board.getTile(x, y).blockLineOfSight(from, to); if(losBlocked && clearVisibility) return fixLineOfSight(false, x1, y1); } @@ -475,6 +476,7 @@ public class SearchBoard private boolean verticalLineOfSight(int x0, int y0, int x1, int y1, boolean clearVisibility) { Tile from = board.getTile(x0, y0); + Tile to = board.getTile(x1, y1); int d = ( (y1 > y0) ? 1 : -1); int x = x0; @@ -488,12 +490,12 @@ public class SearchBoard y += d; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!losBlocked) blocked = t.blockLineOfSightFrom(from); + if (!losBlocked) blocked = t.blockLineOfSight(from, to); x += d; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (blocked && !t.blockLineOfSightFrom(from)) + if (blocked && !t.blockLineOfSight(from, to)) blocked = false; if (blocked) losBlocked = true; @@ -510,6 +512,7 @@ public class SearchBoard private boolean diagonalLineOfSight(int x0, int y0, int x1, int y1, boolean clearVisibility) { Tile from = board.getTile(x0, y0); + Tile to = board.getTile(x1, y1); int dy = ( (y1 > y0) ? 1 : -1); int dx = ( (x1 > x0) ? 1 : -1); @@ -526,14 +529,14 @@ public class SearchBoard x += dx; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (!losBlocked) blocked = t.blockLineOfSightFrom(from); + if (!losBlocked) blocked = t.blockLineOfSight(from, to); y += dy; if (!sig) x -= dx; t = board.getTile(x, y); if (!t.isOffMap()) los.add(getNode(x, y)); - if (blocked && !t.blockLineOfSightFrom(from)) + if (blocked && !t.blockLineOfSight(from, to)) blocked = false; if (blocked) losBlocked = true; diff --git a/core/src/ch/asynk/rustanddust/engine/Tile.java b/core/src/ch/asynk/rustanddust/engine/Tile.java index c3ccf37..63ff193 100644 --- a/core/src/ch/asynk/rustanddust/engine/Tile.java +++ b/core/src/ch/asynk/rustanddust/engine/Tile.java @@ -33,7 +33,7 @@ public abstract class Tile implements Drawable, Disposable, Iterable<Pawn> public abstract boolean isA(TileTerrain terrain); public abstract boolean road(Orientation side); public abstract boolean atLeastOneMove(Pawn pawn); - public abstract boolean blockLineOfSightFrom(Tile tile); + public abstract boolean blockLineOfSight(Tile from, Tile to); protected Tile(int col, int row) { |