1 package cz.cuni.amis.pogamut.ut2004.agent.module.utils;
2
3 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdatedEvent;
4 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdatedEvent.DestroyWorldObject;
5 import cz.cuni.amis.pogamut.base.communication.worldview.react.ObjectEventReact;
6 import cz.cuni.amis.pogamut.base3d.worldview.object.event.WorldObjectDisappearedEvent;
7 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
8 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.IncomingProjectile;
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23 public class ProjectileCleanUp {
24
25 private UT2004Bot bot;
26
27 private ObjectEventReact<IncomingProjectile, WorldObjectDisappearedEvent<IncomingProjectile>> destroyProjectile;
28
29 public ProjectileCleanUp(UT2004Bot bot) {
30 this.bot = bot;
31 destroyProjectile = new ObjectEventReact<IncomingProjectile, WorldObjectDisappearedEvent<IncomingProjectile>>(IncomingProjectile.class, WorldObjectDisappearedEvent.class, bot.getWorldView()) {
32
33 @Override
34 protected void react(WorldObjectDisappearedEvent<IncomingProjectile> event) {
35 ProjectileCleanUp.this.bot.getWorldView().notifyAfterPropagation(
36 new IWorldObjectUpdatedEvent.DestroyWorldObject(event.getObject(), event.getSimTime())
37 );
38 }
39
40 };
41 destroyProjectile.enable();
42 }
43
44 public void enable() {
45 destroyProjectile.enable();
46 }
47
48 public void disable() {
49 destroyProjectile.disable();
50 }
51
52 }