diff options
Diffstat (limited to 'core')
7 files changed, 27 insertions, 25 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java index 6664d47..2e5a0b1 100644 --- a/core/src/ch/asynk/rustanddust/engine/Board.java +++ b/core/src/ch/asynk/rustanddust/engine/Board.java @@ -16,6 +16,7 @@ import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import com.badlogic.gdx.math.Matrix4; +import ch.asynk.rustanddust.engine.util.ArrayListIt; import ch.asynk.rustanddust.engine.gfx.Moveable; import ch.asynk.rustanddust.engine.gfx.Animation; import ch.asynk.rustanddust.engine.gfx.animations.AnimationSequence; @@ -61,7 +62,7 @@ public abstract class Board implements Disposable, Animation private int pawnCount = 0; private int animationCount = 0; private final ArrayList<Animation> animations = new ArrayList<Animation>(2); - private final ArrayList<Animation> nextAnimations = new ArrayList<Animation>(2); + private final ArrayListIt<Animation> nextAnimations = new ArrayListIt<Animation>(10); private final LinkedHashSet<Tile> tilesToDraw = new LinkedHashSet<Tile>(); protected SelectedTile selectedTile; @@ -128,8 +129,8 @@ public abstract class Board implements Disposable, Animation for (int i = 0; i < (this.cols * this.rows); i++) tiles[i].dispose(); tilesToDraw.clear(); - for (int i = 0, n = nextAnimations.size(); i < n; i++) - nextAnimations.get(i).dispose(); + for (Animation a : nextAnimations) + a.dispose(); animations.clear(); for (int i = 0, n = animations.size(); i < n; i++) animations.get(i).dispose(); @@ -263,8 +264,8 @@ public abstract class Board implements Disposable, Animation if (over && (animations.size() == 0)) animationsOver(); - for (int i = 0, n = nextAnimations.size(); i < n; i++) - animations.add(nextAnimations.get(i)); + for (Animation a : nextAnimations) + animations.add(a); nextAnimations.clear(); selectedTile.animate(delta); diff --git a/core/src/ch/asynk/rustanddust/engine/Path.java b/core/src/ch/asynk/rustanddust/engine/Path.java index 44b0a1f..6fd3c47 100644 --- a/core/src/ch/asynk/rustanddust/engine/Path.java +++ b/core/src/ch/asynk/rustanddust/engine/Path.java @@ -1,10 +1,10 @@ package ch.asynk.rustanddust.engine; -import java.util.ArrayList; - import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.utils.Disposable; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class Path implements Disposable, Pool.Poolable { private static final Pool<Path> pathPool = new Pool<Path>() { @@ -29,7 +29,7 @@ public class Path implements Disposable, Pool.Poolable public int cost; public int fitness; public boolean roadMarch; - public ArrayList<Tile> tiles; + public ArrayListIt<Tile> tiles; public Path() { @@ -42,7 +42,7 @@ public class Path implements Disposable, Pool.Poolable protected void init(int size) { if (tiles == null) - tiles = new ArrayList<Tile>(size); + tiles = new ArrayListIt<Tile>(size); else tiles. ensureCapacity(size); cost = -1; diff --git a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java index 453583f..6a2b1a2 100644 --- a/core/src/ch/asynk/rustanddust/engine/PathBuilder.java +++ b/core/src/ch/asynk/rustanddust/engine/PathBuilder.java @@ -1,6 +1,5 @@ package ch.asynk.rustanddust.engine; -import java.util.ArrayList; import java.util.List; import java.util.LinkedList; import java.util.HashSet; @@ -8,6 +7,8 @@ import java.util.LinkedHashSet; import com.badlogic.gdx.utils.Disposable; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class PathBuilder implements Disposable { private final Board board; @@ -27,8 +28,8 @@ public class PathBuilder implements Disposable { this.board = board; this.tiles = new LinkedHashSet<Tile>(tSize); - this.stack = new ArrayList<Tile>(stSize); - this.ctrlTiles = new ArrayList<Tile>(ftSize); + this.stack = new ArrayListIt<Tile>(stSize); + this.ctrlTiles = new ArrayListIt<Tile>(ftSize); this.paths = new LinkedList<Path>(); this.filteredPaths = new LinkedList<Path>(); this.to = null; diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java index f4bfd4c..19fa7a8 100644 --- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java +++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java @@ -1,12 +1,13 @@ package ch.asynk.rustanddust.engine; import java.util.List; -import java.util.ArrayList; import java.util.LinkedList; import java.util.ArrayDeque; import java.util.Iterator; import java.util.Collection; +import ch.asynk.rustanddust.engine.util.ArrayListIt; + public class SearchBoard { public class Node @@ -60,7 +61,7 @@ public class SearchBoard this.queue = new LinkedList<Node>(); this.stack = new ArrayDeque<Node>(20); this.roadMarch = new ArrayDeque<Node>(5); - this.los = new ArrayList<Node>(10); + this.los = new ArrayListIt<Node>(10); } private boolean inMap(int col, int row) diff --git a/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java b/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java index fdd1e80..d440adc 100644 --- a/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java +++ b/core/src/ch/asynk/rustanddust/engine/gfx/animations/AnimationSequence.java @@ -1,16 +1,15 @@ package ch.asynk.rustanddust.engine.gfx.animations; -import java.util.ArrayList; - import com.badlogic.gdx.utils.Pool; import com.badlogic.gdx.graphics.g2d.Batch; import com.badlogic.gdx.graphics.glutils.ShapeRenderer; import ch.asynk.rustanddust.engine.gfx.Animation; +import ch.asynk.rustanddust.engine.util.ArrayListIt; public class AnimationSequence implements Animation, Pool.Poolable { - private ArrayList<Animation> animations; + private ArrayListIt<Animation> animations; private static final Pool<AnimationSequence> animationSequencePool = new Pool<AnimationSequence>() { @Override @@ -23,7 +22,7 @@ public class AnimationSequence implements Animation, Pool.Poolable { AnimationSequence seq = animationSequencePool.obtain(); if (seq.animations == null) - seq.animations = new ArrayList<Animation>(capacity); + seq.animations = new ArrayListIt<Animation>(capacity); else seq.animations.ensureCapacity(capacity); @@ -33,8 +32,8 @@ public class AnimationSequence implements Animation, Pool.Poolable @Override public void reset() { - for (int i = 0, n = animations.size(); i < n; i++) - animations.get(i).dispose(); + for (Animation a : animations) + a.dispose(); animations.clear(); } diff --git a/core/src/ch/asynk/rustanddust/game/UnitList.java b/core/src/ch/asynk/rustanddust/game/UnitList.java index 9637036..834dd98 100644 --- a/core/src/ch/asynk/rustanddust/game/UnitList.java +++ b/core/src/ch/asynk/rustanddust/game/UnitList.java @@ -1,11 +1,11 @@ package ch.asynk.rustanddust.game; import java.util.Collection; -import java.util.ArrayList; +import ch.asynk.rustanddust.engine.util.ArrayListIt; import ch.asynk.rustanddust.engine.Pawn; -public class UnitList extends ArrayList<Unit> +public class UnitList extends ArrayListIt<Unit> { public UnitList(int n) { diff --git a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java index a5c9b3d..7b7904d 100644 --- a/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java +++ b/core/src/ch/asynk/rustanddust/game/battles/BattleCommon.java @@ -2,7 +2,6 @@ package ch.asynk.rustanddust.game.battles; import java.util.Random; import java.util.HashMap; -import java.util.ArrayList; import ch.asynk.rustanddust.game.Army; import ch.asynk.rustanddust.game.Battle; @@ -15,6 +14,7 @@ import ch.asynk.rustanddust.game.Unit.UnitId; import ch.asynk.rustanddust.game.Factory; import ch.asynk.rustanddust.game.State.StateType; import ch.asynk.rustanddust.engine.Orientation; +import ch.asynk.rustanddust.engine.util.ArrayListIt; public abstract class BattleCommon implements Battle { @@ -28,8 +28,8 @@ public abstract class BattleCommon implements Battle protected Player currentPlayer; protected Player usPlayer; protected Player gePlayer; - protected ArrayList<Zone> entryZone = new ArrayList<Zone>(); - protected ArrayList<Zone> exitZone = new ArrayList<Zone>(); + protected ArrayListIt<Zone> entryZone = new ArrayListIt<Zone>(); + protected ArrayListIt<Zone> exitZone = new ArrayListIt<Zone>(); protected HashMap<Unit, Zone> unitEntry = new HashMap<Unit, Zone>(); protected HashMap<Unit, Zone> unitExit = new HashMap<Unit, Zone>(); |