DEADSOFTWARE

084180d10b9cb4ae4a4c5b895b95c2a44fdb00f8
[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;
4 import ru.deadsoftware.cavedroid.game.model.item.Item;
6 import javax.inject.Inject;
7 import java.io.Serializable;
8 import java.util.Iterator;
9 import java.util.LinkedList;
11 @GameScope
12 public class DropController implements Serializable {
14 public interface Callback {
15 void run(Drop drop);
16 }
18 private final LinkedList<Drop> mDrops = new LinkedList<>();
20 @Inject
21 public DropController() {
22 }
24 public void addDrop(float x, float y, Item item) {
25 mDrops.add(new Drop(x, y, item));
26 }
28 public int getSize() {
29 return mDrops.size();
30 }
32 public void forEach(Callback callback) {
33 mDrops.forEach(callback::run);
34 }
36 public Iterator<Drop> getIterator() {
37 return mDrops.iterator();
38 }
40 }