1 package cz.cuni.amis.pogamut.emohawk.agent.module.sensomotoric;
2
3
4 import cz.cuni.amis.pogamut.base.agent.module.SensomotoricModule;
5 import cz.cuni.amis.pogamut.base.communication.worldview.event.IWorldEventListener;
6 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
7
8 import cz.cuni.amis.pogamut.ut2004.bot.impl.UT2004Bot;
9 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.GiveItem;
10 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.Pick;
11 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbcommands.PutDownItem;
12 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.GiveItemResult;
13 import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Player;
14
15
16
17
18
19
20 public class Inventory extends SensomotoricModule<UT2004Bot> {
21
22 GiveItemResult lastGiveItemResult = null;
23
24
25
26
27 IWorldEventListener<GiveItemResult> giveItemResultListener = new IWorldEventListener<GiveItemResult>() {
28 @Override
29 public void notify(GiveItemResult event) {
30 lastGiveItemResult = event;
31 }
32 };
33
34
35
36
37
38 public GiveItemResult getLastGiveItemResult() {
39 return lastGiveItemResult;
40 }
41
42
43
44
45
46
47 public void giveItem(Player pl, ItemTypeUE2 item) {
48 act.act(new GiveItem().setId(pl.getId()).setType(item.getUnrealName()));
49 }
50
51
52
53
54
55
56 public void giveItem(UnrealId id, ItemTypeUE2 item) {
57 act.act(new GiveItem().setId(id).setType(item.getUnrealName()));
58 }
59
60
61
62
63
64 public void putDownItem(ItemTypeUE2 item) {
65 act.act(new PutDownItem().setType(item.getUnrealName()));
66 }
67
68
69
70
71
72 public void pickItem(UnrealId id) {
73 act.act(new Pick().setId(id));
74 }
75
76
77
78
79
80 public Inventory(UT2004Bot agent) {
81 super(agent);
82 agent.getWorldView().addEventListener(GiveItemResult.class, giveItemResultListener);
83 }
84 }