diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 17:11:22 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2016-01-04 17:11:22 +0100 |
commit | 0b6b4bc5e3d7ebb6cc276f4d558aa1b7b8413a44 (patch) | |
tree | 0350e21872424e0cf5095f20ff091ed6a8b5a44a /core/src | |
parent | 86bc45471088d8faf95dbd2300386e18c6a80f6e (diff) | |
download | RustAndDust-0b6b4bc5e3d7ebb6cc276f4d558aa1b7b8413a44.zip RustAndDust-0b6b4bc5e3d7ebb6cc276f4d558aa1b7b8413a44.tar.gz |
PathIterator: do not compute size all the time
Diffstat (limited to 'core/src')
-rw-r--r-- | core/src/ch/asynk/rustanddust/engine/PathIterator.java | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/PathIterator.java b/core/src/ch/asynk/rustanddust/engine/PathIterator.java index 39b3db4..099c65e 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathIterator.java +++ b/core/src/ch/asynk/rustanddust/engine/PathIterator.java @@ -17,6 +17,7 @@ public class PathIterator implements Iterator<Vector3> private Vector2 pos = new Vector2(); private Vector3 v = new Vector3(); private int i; + private int s; private List<Tile> path; public PathIterator(Pawn pawn, Tile from, Tile to, Orientation orientation, List<Tile> path) @@ -30,12 +31,12 @@ public class PathIterator implements Iterator<Vector3> this.o = pawn.getOrientation(); this.v.set(pawn.getPosition().x, pawn.getPosition().y, o.r()); this.i = 0; + this.s = path.size(); } @Override public boolean hasNext() { - int s = path.size(); if ((rotation || (i > s)) && (o == orientation)) return false; return true; @@ -47,8 +48,6 @@ public class PathIterator implements Iterator<Vector3> if (!hasNext()) throw new java.util.NoSuchElementException(); - int s = path.size(); - if (rotation || (i > s)) { v.z = orientation.r(); o = orientation; |