blob: 7a8e3f39a37d2a76dbe73efdfa32d2458ec5162d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
|
package ch.asynk.rustanddust.game;
import java.util.Iterator;
import ch.asynk.rustanddust.engine.util.IterableArray;
public class OrderList extends IterableArray<Order>
{
private Player player;
public OrderList(int capacity)
{
super(capacity);
}
public Order get(Unit unit, Order.OrderType type)
{
for (Order o : this) {
if ((o.compareTo(unit) == 0) && (o.isA(type)))
return o;
}
return null;
}
public Order getId(int id)
{
for (Order o : this) {
if (o.id == id)
return o;
}
return null;
}
public void dispose(Unit unit)
{
Iterator<Order> it = iterator();
while (it.hasNext()) {
Order order = it.next();
if (order.compareTo(unit) == 0) {
it.remove();
order.dispose();
}
}
}
public void dispose(Unit unit, Order.OrderType type)
{
Iterator<Order> it = iterator();
while (it.hasNext()) {
Order order = it.next();
if ((order.compareTo(unit) == 0) && (order.isA(type))) {
it.remove();
order.dispose();
}
}
}
public void dispose()
{
for (Order o : this)
o.dispose();
clear();
}
}
|