DEADSOFTWARE

0e4c6592abe3badac802872be953ab84c68b2324
[cavedroid.git] / core / src / ru / deadsoftware / cavedroid / game / objects / DropController.java
1 package ru.deadsoftware.cavedroid.game.objects;
3 import ru.deadsoftware.cavedroid.game.GameScope;
5 import javax.inject.Inject;
6 import java.io.Serializable;
7 import java.util.Iterator;
8 import java.util.LinkedList;
10 @GameScope
11 public class DropController implements Serializable {
13 public interface Callback {
14 void run(Drop drop);
15 }
17 private final LinkedList<Drop> mDrops = new LinkedList<>();
19 @Inject
20 public DropController() {
21 }
23 public void addDrop(float x, float y, int id) {
24 mDrops.add(new Drop(x, y, id));
25 }
27 public int getSize() {
28 return mDrops.size();
29 }
31 public void forEach(Callback callback) {
32 mDrops.forEach(callback::run);
33 }
35 public Iterator<Drop> getIterator() {
36 return mDrops.iterator();
37 }
39 }