diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 16:09:33 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 16:09:33 +0100 |
commit | 5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2 (patch) | |
tree | 9c10976b0f4850f8aa3142d9f5c16f595d223e79 | |
parent | 98dd87bc85fd0962efbfc861e762e9c3549b2ee5 (diff) | |
download | RustAndDust-5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2.zip RustAndDust-5f401d5b5cdf8f540b3fb3301ab33878f1d3a2e2.tar.gz |
PathIterator: support simple rotation
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathIterator.java | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathIterator.java b/core/src/ch/asynk/rustanddust/engine/PathIterator.java index 7feb550..a3667b4 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathIterator.java +++ b/core/src/ch/asynk/rustanddust/engine/PathIterator.java @@ -33,7 +33,8 @@ public class PathIterator implements Iterator<Vector3> @Override public boolean hasNext() { - if ((i > path.size()) && (o == orientation)) + int s = path.size(); + if (((s == 0) || (i > s)) && (o == orientation)) return false; return true; } @@ -44,13 +45,15 @@ public class PathIterator implements Iterator<Vector3> if (!hasNext()) throw new java.util.NoSuchElementException(); - if (i > path.size()) { + int s = path.size(); + + if ((s == 0) || (i >s)) { v.z = orientation.r(); o = orientation; return v; } Tile nextTile; - if (i < path.size()) + if (i < s) nextTile = path.get(i); else nextTile = to; |