summaryrefslogtreecommitdiffstats
path: root/core/src/ch/asynk/rustanddust/engine
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2016-01-11 12:18:52 +0100
committerJérémy Zurcher <jeremy@asynk.ch>2016-01-11 12:18:52 +0100
commite119aa82c0a4a4d066fcd462a99dc93f9ee15296 (patch)
tree7bfa496d1cc05b83032c445545a7666b9f5c7284 /core/src/ch/asynk/rustanddust/engine
parent5196c30138f4d659fb5176363421e61ba66228ba (diff)
downloadRustAndDust-e119aa82c0a4a4d066fcd462a99dc93f9ee15296.zip
RustAndDust-e119aa82c0a4a4d066fcd462a99dc93f9ee15296.tar.gz
add engine.util.Collection and use it
Diffstat (limited to 'core/src/ch/asynk/rustanddust/engine')
-rw-r--r--core/src/ch/asynk/rustanddust/engine/Board.java2
-rw-r--r--core/src/ch/asynk/rustanddust/engine/SearchBoard.java10
-rw-r--r--core/src/ch/asynk/rustanddust/engine/util/Collection.java18
-rw-r--r--core/src/ch/asynk/rustanddust/engine/util/IterableArray.java2
4 files changed, 24 insertions, 8 deletions
diff --git a/core/src/ch/asynk/rustanddust/engine/Board.java b/core/src/ch/asynk/rustanddust/engine/Board.java
index 9441dac..2da88be 100644
--- a/core/src/ch/asynk/rustanddust/engine/Board.java
+++ b/core/src/ch/asynk/rustanddust/engine/Board.java
@@ -1,7 +1,6 @@
package ch.asynk.rustanddust.engine;
import java.util.Iterator;
-import java.util.Collection;
import com.badlogic.gdx.Gdx;
@@ -16,6 +15,7 @@ import com.badlogic.gdx.math.Matrix4;
import ch.asynk.rustanddust.engine.util.IterableArray;
import ch.asynk.rustanddust.engine.util.IterableSet;
+import ch.asynk.rustanddust.engine.util.Collection;
import ch.asynk.rustanddust.engine.gfx.Moveable;
import ch.asynk.rustanddust.engine.gfx.Animation;
import ch.asynk.rustanddust.engine.gfx.animations.AnimationSequence;
diff --git a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
index 583cee6..141f5cc 100644
--- a/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
+++ b/core/src/ch/asynk/rustanddust/engine/SearchBoard.java
@@ -1,8 +1,6 @@
package ch.asynk.rustanddust.engine;
-import java.util.List;
-import java.util.Collection;
-
+import ch.asynk.rustanddust.engine.util.Collection;
import ch.asynk.rustanddust.engine.util.IterableArray;
import ch.asynk.rustanddust.engine.util.IterableStack;
import ch.asynk.rustanddust.engine.util.IterableQueue;
@@ -258,7 +256,7 @@ public class SearchBoard
a[5] = null;
}
- public List<Node> buildLineOfSight(int x0, int y0, int x1, int y1, boolean clearVisibility)
+ public Collection<Node> buildLineOfSight(int x0, int y0, int x1, int y1, boolean clearVisibility)
{
lineOfSight(x0, y0, x1, y1, clearVisibility);
return los;
@@ -347,7 +345,7 @@ public class SearchBoard
return validateFireAngle(angleOfAttack, los);
}
- private boolean isFlankAttack(int angle, List<Node> los)
+ private boolean isFlankAttack(int angle, Collection<Node> los)
{
Node from = los.get(los.size() - 2);
Node to = los.get(los.size() - 1);
@@ -364,7 +362,7 @@ public class SearchBoard
return (o.isInSides(angle) && o2.isInSides(angle));
}
- private boolean validateFireAngle(int angle, List<Node> los)
+ private boolean validateFireAngle(int angle, Collection<Node> los)
{
Node from = los.get(0);
Node p0 = los.get(1);
diff --git a/core/src/ch/asynk/rustanddust/engine/util/Collection.java b/core/src/ch/asynk/rustanddust/engine/util/Collection.java
new file mode 100644
index 0000000..c768d45
--- /dev/null
+++ b/core/src/ch/asynk/rustanddust/engine/util/Collection.java
@@ -0,0 +1,18 @@
+package ch.asynk.rustanddust.engine.util;
+
+import java.util.Iterator;
+
+public interface Collection<E> extends Iterator, Iterable<E>
+{
+ public void clear();
+
+ public int size();
+
+ public boolean isEmpty();
+
+ public E get(int idx);
+
+ public boolean add(E e);
+
+ // public boolean contains(E e);
+}
diff --git a/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java b/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java
index f310a60..baa58d9 100644
--- a/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java
+++ b/core/src/ch/asynk/rustanddust/engine/util/IterableArray.java
@@ -3,7 +3,7 @@ package ch.asynk.rustanddust.engine.util;
import java.util.ArrayList;
import java.util.Iterator;
-public class IterableArray<E> extends ArrayList<E> implements Iterator, Iterable<E>
+public class IterableArray<E> extends ArrayList<E> implements Collection<E>
{
private int i;
private int s;