1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3 // --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
4 import java.util.*;import javax.vecmath.*;import cz.cuni.amis.pogamut.base.communication.messages.*;import cz.cuni.amis.pogamut.base.communication.worldview.*;import cz.cuni.amis.pogamut.base.communication.worldview.event.*;import cz.cuni.amis.pogamut.base.communication.worldview.object.*;import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;import cz.cuni.amis.pogamut.base.communication.translator.event.*;import cz.cuni.amis.pogamut.multi.communication.translator.event.*;import cz.cuni.amis.pogamut.base3d.worldview.object.*;import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.*;import cz.cuni.amis.pogamut.ut2004.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.objects.*;import cz.cuni.amis.pogamut.ut2004.communication.translator.itemdescriptor.*;import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType.Category;import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;import cz.cuni.amis.utils.exception.*;import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;import cz.cuni.amis.utils.SafeEquals;import cz.cuni.amis.pogamut.base.agent.*;import cz.cuni.amis.pogamut.multi.agent.*;import cz.cuni.amis.pogamut.multi.communication.worldview.property.*;import cz.cuni.amis.pogamut.ut2004multi.communication.worldview.property.*;import cz.cuni.amis.utils.token.*;import cz.cuni.amis.utils.*;
5 // --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6
7
8 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9
10 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11
12 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] BEGIN
13
14 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15
16 /**
17 *
18 Definition of the event IRC.
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Asynchronous message. Other bot gave us an item. We receive normal IPK message and this message with
25 information about the giver and the item.
26
27 */
28 public class ItemReceived
29 extends InfoMessage
30 implements IWorldEvent, IWorldChangeEvent
31
32 {
33
34 /** Example how the message looks like - used during parser tests. */
35 public static final String PROTOTYPE =
36 "IRC {Id unreal_id} {InventoryId unreal_id} {GiverId unreal_id} {Location 0,0,0} {Amount 0} {Type text} {Dropped False} ";
37
38
39
40 /**
41 * Parameter-less contructor for the message.
42 */
43 public ItemReceived()
44 {
45 }
46
47
48
49
50 /**
51 * Creates new instance of the message ItemReceived.
52 *
53 Asynchronous message. Other bot gave us an item. We receive normal IPK message and this message with
54 information about the giver and the item.
55
56 * Corresponding GameBots message
57 *
58 * is
59 * IRC.
60 *
61 *
62 *
63 * @param Id
64 Unique Id of the item. This Id represents just item on the
65 map, not in our inventory.
66
67 *
68 *
69 *
70 * @param InventoryId
71 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
72 Unreal has different Ids for items in map and actual item in bot's inventory.
73 If the item does not go into our inventory nothing will be here (null).
74
75 *
76 *
77 *
78 * @param GiverId
79 Unique Id of the bot that gave us this item.
80
81 *
82 *
83 *
84 * @param Location Location of the item.
85 *
86 *
87 *
88 * @param Amount
89 If this item is some ammo or health pack, here we can find
90 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
91
92 *
93 *
94 *
95 * @param Type
96 Class of the item.
97
98 *
99 *
100 *
101 * @param Dropped
102 Whether it is a regular item or dropped by player or bot.
103
104 *
105 *
106 */
107 public ItemReceived(
108 UnrealId Id, UnrealId InventoryId, UnrealId GiverId, Location Location, int Amount, String Type, Boolean Dropped
109 ) {
110
111 this.Id = Id;
112
113 this.InventoryId = InventoryId;
114
115 this.GiverId = GiverId;
116
117 this.Location = Location;
118
119 this.Amount = Amount;
120
121 this.Type = Type;
122
123 this.Dropped = Dropped;
124
125 }
126
127 /**
128 * Cloning constructor from the full message.
129 *
130 * @param original
131 */
132 public ItemReceived(ItemReceived original) {
133
134 this.Id = original.getId()
135 ;
136
137 this.InventoryId = original.getInventoryId()
138 ;
139
140 this.GiverId = original.getGiverId()
141 ;
142
143 this.Location = original.getLocation()
144 ;
145
146 this.Amount = original.getAmount()
147 ;
148
149 this.Type = original.getType()
150 ;
151
152 this.Dropped = original.isDropped()
153 ;
154
155 this.SimTime = original.getSimTime();
156 }
157
158
159 protected long SimTime;
160
161 /**
162 * Simulation time in MILLI SECONDS !!!
163 */
164 @Override
165 public long getSimTime() {
166 return SimTime;
167 }
168
169 /**
170 * Used by Yylex to slip correct time of the object or programmatically.
171 */
172 protected void setSimTime(long SimTime) {
173 this.SimTime = SimTime;
174 }
175
176
177 /**
178 *
179 Unique Id of the item. This Id represents just item on the
180 map, not in our inventory.
181
182 */
183 protected
184 UnrealId Id =
185 null;
186
187 /**
188 *
189 Unique Id of the item. This Id represents just item on the
190 map, not in our inventory.
191
192 */
193 public UnrealId getId()
194 {
195 return Id;
196 }
197
198
199 /**
200 *
201 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
202 Unreal has different Ids for items in map and actual item in bot's inventory.
203 If the item does not go into our inventory nothing will be here (null).
204
205 */
206 protected
207 UnrealId InventoryId =
208 null;
209
210 /**
211 *
212 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
213 Unreal has different Ids for items in map and actual item in bot's inventory.
214 If the item does not go into our inventory nothing will be here (null).
215
216 */
217 public UnrealId getInventoryId()
218 {
219 return InventoryId;
220 }
221
222
223 /**
224 *
225 Unique Id of the bot that gave us this item.
226
227 */
228 protected
229 UnrealId GiverId =
230 null;
231
232 /**
233 *
234 Unique Id of the bot that gave us this item.
235
236 */
237 public UnrealId getGiverId()
238 {
239 return GiverId;
240 }
241
242
243 /**
244 * Location of the item.
245 */
246 protected
247 Location Location =
248 null;
249
250 /**
251 * Location of the item.
252 */
253 public Location getLocation()
254 {
255 return Location;
256 }
257
258
259 /**
260 *
261 If this item is some ammo or health pack, here we can find
262 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
263
264 */
265 protected
266 int Amount =
267 0;
268
269 /**
270 *
271 If this item is some ammo or health pack, here we can find
272 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
273
274 */
275 public int getAmount()
276 {
277 return Amount;
278 }
279
280
281 /**
282 *
283 Class of the item.
284
285 */
286 protected
287 String Type =
288 null;
289
290 /**
291 *
292 Class of the item.
293
294 */
295 public String getType()
296 {
297 return Type;
298 }
299
300
301 /**
302 *
303 Whether it is a regular item or dropped by player or bot.
304
305 */
306 protected
307 Boolean Dropped =
308 null;
309
310 /**
311 *
312 Whether it is a regular item or dropped by player or bot.
313
314 */
315 public Boolean isDropped()
316 {
317 return Dropped;
318 }
319
320
321 public String toString() {
322 return
323 super.toString() + "[" +
324
325 "Id = " + String.valueOf(getId()
326 ) + " | " +
327
328 "InventoryId = " + String.valueOf(getInventoryId()
329 ) + " | " +
330
331 "GiverId = " + String.valueOf(getGiverId()
332 ) + " | " +
333
334 "Location = " + String.valueOf(getLocation()
335 ) + " | " +
336
337 "Amount = " + String.valueOf(getAmount()
338 ) + " | " +
339
340 "Type = " + String.valueOf(getType()
341 ) + " | " +
342
343 "Dropped = " + String.valueOf(isDropped()
344 ) + " | " +
345
346 "]";
347 }
348
349
350 public String toHtmlString() {
351 return super.toString() + "[<br/>" +
352
353 "<b>Id</b> = " + String.valueOf(getId()
354 ) + " <br/> " +
355
356 "<b>InventoryId</b> = " + String.valueOf(getInventoryId()
357 ) + " <br/> " +
358
359 "<b>GiverId</b> = " + String.valueOf(getGiverId()
360 ) + " <br/> " +
361
362 "<b>Location</b> = " + String.valueOf(getLocation()
363 ) + " <br/> " +
364
365 "<b>Amount</b> = " + String.valueOf(getAmount()
366 ) + " <br/> " +
367
368 "<b>Type</b> = " + String.valueOf(getType()
369 ) + " <br/> " +
370
371 "<b>Dropped</b> = " + String.valueOf(isDropped()
372 ) + " <br/> " +
373
374 "<br/>]";
375 }
376
377
378 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
379
380 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
381
382 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
383
384 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
385
386 }
387