1 package nl.tudelft.pogamut.unreal.agent.module.sensor;
2
3 import java.util.Collection;
4 import java.util.Map;
5
6 import cz.cuni.amis.pogamut.base.agent.module.SensorModule;
7 import cz.cuni.amis.pogamut.base.communication.worldview.object.WorldObjectId;
8 import cz.cuni.amis.pogamut.base.utils.math.DistanceUtils;
9 import cz.cuni.amis.pogamut.base3d.worldview.object.ILocated;
10 import cz.cuni.amis.pogamut.ut2004.agent.module.sensor.AgentInfo;
11 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
12 import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
13 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.IncomingProjectile;
14
15
16
17
18
19
20
21
22
23
24 @SuppressWarnings("rawtypes")
25 public abstract class Projectiles extends SensorModule<UT2004Bot> {
26
27 protected AgentInfo info;
28
29 public Projectiles(UT2004Bot<?, ?, ?> agent, AgentInfo info) {
30 super(agent);
31 this.info = info;
32
33 }
34
35
36 public IncomingProjectile getNearestProjectile() {
37 return DistanceUtils.getNearest(worldView.getAll(IncomingProjectile.class).values(), info.getLocation());
38 }
39
40
41 public Map<WorldObjectId, IncomingProjectile> getProjectiles() {
42 return worldView.getAll(IncomingProjectile.class);
43 }
44
45 public IncomingProjectile getNearestProjectile(ILocated location) {
46 return DistanceUtils.getNearest(worldView.getAll(IncomingProjectile.class).values(), location);
47 }
48
49 public IncomingProjectile getNearestProjectile(ILocated location, double maxDistance) {
50 return DistanceUtils.getNearest(worldView.getAll(IncomingProjectile.class).values(), location, maxDistance);
51 }
52
53
54 public IncomingProjectile getNearestProjectile(ILocated location, ItemType type) {
55 return DistanceUtils.getNearest(getProjectiles(type), location);
56 }
57
58 public abstract Collection<IncomingProjectile> getProjectiles(final ItemType type);
59
60
61 public IncomingProjectile getNearestProjectile(ILocated location, double maxDistance, ItemType type) {
62 return DistanceUtils.getNearest(getProjectiles(type), location, maxDistance);
63 }
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95 }