From 398019b3f2756a67cebe3d8f8c880d797d9152cf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Zurcher?= Date: Mon, 11 Jan 2016 01:37:24 +0100 Subject: Board: tilesToDraw is an ArrayListIt --- core/src/ch/asynk/rustanddust/engine/Board.java | 27 ++++++++++--------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index d1eecc9..740d71b 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -2,7 +2,6 @@ package ch.asynk.rustanddust.engine; import java.util.Iterator; import java.util.Collection; -import java.util.LinkedHashSet; import com.badlogic.gdx.Gdx; @@ -62,7 +61,7 @@ public abstract class Board implements Disposable, Animation private int animationCount = 0; private final ArrayListIt animations = new ArrayListIt(10); private final ArrayListIt nextAnimations = new ArrayListIt(10); - private final LinkedHashSet tilesToDraw = new LinkedHashSet(); + private final ArrayListIt tilesToDraw = new ArrayListIt(); protected SelectedTile selectedTile; @@ -283,9 +282,8 @@ public abstract class Board implements Disposable, Animation batch.setTransformMatrix(nextTransform); } - Iterator tileIter = tilesToDraw.iterator(); - while (tileIter.hasNext()) - tileIter.next().draw(batch); + for (Tile tile : tilesToDraw) + tile.draw(batch); for (Animation a : animations) a.draw(batch); @@ -304,9 +302,8 @@ public abstract class Board implements Disposable, Animation debugShapes.setTransformMatrix(nextTransform); } - Iterator iter = tilesToDraw.iterator(); - while (iter.hasNext()) - iter.next().drawDebug(debugShapes); + for (Tile tile : tilesToDraw) + tile.drawDebug(debugShapes); for (Animation a : animations) a.drawDebug(debugShapes); @@ -343,9 +340,7 @@ public abstract class Board implements Disposable, Animation for (int i = 0; i < 6; i++) { Tile tile = neighbours[i]; if (tile != null) { - Iterator pawns = tile.iterator(); - while (pawns.hasNext()) { - Pawn p = pawns.next(); + for (Pawn p : tile) { if (!pawn.isEnemy(p) && p.canMove()) assists.add(p); } @@ -409,7 +404,7 @@ public abstract class Board implements Disposable, Animation if (tile.isObjective()) { tile.enableOverlay(o, false); tile.enableOverlay(moveable.getFaction().overlay(), true); - tilesToDraw.add(tile); + tilesToDraw.addUnique(tile); } } } @@ -420,7 +415,7 @@ public abstract class Board implements Disposable, Animation if (tile.isObjective()) { tile.enableOverlay(moveable.getFaction().overlay(), false); tile.enableOverlay(tile.belongsTo().overlay(), true); - tilesToDraw.add(tile); + tilesToDraw.addUnique(tile); } } } @@ -435,7 +430,7 @@ public abstract class Board implements Disposable, Animation public void enableOverlayOn(Tile tile, int i, boolean enable) { if (tile.enableOverlay(i, enable)) - tilesToDraw.add(tile); + tilesToDraw.addUnique(tile); else tilesToDraw.remove(tile); } @@ -443,7 +438,7 @@ public abstract class Board implements Disposable, Animation public void enableOverlayOn(Tile tile, int i, Orientation o, boolean enable) { if (tile.enableOverlay(i, enable, o.r())) - tilesToDraw.add(tile); + tilesToDraw.addUnique(tile); else tilesToDraw.remove(tile); } @@ -451,7 +446,7 @@ public abstract class Board implements Disposable, Animation private int pushPawnOnto(Pawn pawn, Tile tile) { if (!tile.isOffMap()) - tilesToDraw.add(tile); + tilesToDraw.addUnique(tile); return tile.push(pawn); } -- cgit v1.1-2-g2b99