From d0227aebc8ce50658f9375c5f81e798323bf0613 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Thu, 2 Oct 2014 00:29:59 -0400 Subject: [PATCH] V0.2.1 : Added new level neighbour arrays --- .../shatteredpixeldungeon/levels/Level.java | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java index 68e92dc2b..cf8d74b53 100644 --- a/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java +++ b/src/com/shatteredpixel/shatteredpixeldungeon/levels/Level.java @@ -85,6 +85,20 @@ public abstract class Level implements Bundlable { public static final int[] NEIGHBOURS4 = {-WIDTH, +1, +WIDTH, -1}; public static final int[] NEIGHBOURS8 = {+1, -1, +WIDTH, -WIDTH, +1+WIDTH, +1-WIDTH, -1+WIDTH, -1-WIDTH}; public static final int[] NEIGHBOURS9 = {0, +1, -1, +WIDTH, -WIDTH, +1+WIDTH, +1-WIDTH, -1+WIDTH, -1-WIDTH}; + + //Note that use of these without checking values is unsafe, mobs can be within 2 tiles of the + //edge of the map, unsafe use in that cause will cause an array out of bounds exception. + public static final int[] NEIGHBOURS8DIST2 = {+2+2*WIDTH, +1+2*WIDTH, 2*WIDTH, -1+2*WIDTH, -2+2*WIDTH, + +2+WIDTH, +1+WIDTH, +WIDTH, -1+WIDTH, -2+WIDTH, + +2, +1, -1, -2, + +2-WIDTH, +1-WIDTH, -WIDTH, -1-WIDTH, -2-WIDTH, + +2-2*WIDTH, +1-2*WIDTH, -2*WIDTH, -1-2*WIDTH, -2-2*WIDTH}; + public static final int[] NEIGHBOURS9DIST2 = {+2+2*WIDTH, +1+2*WIDTH, 2*WIDTH, -1+2*WIDTH, -2+2*WIDTH, + +2+WIDTH, +1+WIDTH, +WIDTH, -1+WIDTH, -2+WIDTH, + +2, +1, 0, -1, -2, + +2-WIDTH, +1-WIDTH, -WIDTH, -1-WIDTH, -2-WIDTH, + +2-2*WIDTH, +1-2*WIDTH, -2*WIDTH, -1-2*WIDTH, -2-2*WIDTH}; + protected static final float TIME_TO_RESPAWN = 50;