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 IPK.
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Asynchronous message. Comes when we have picked up an item. This does not mean the item will be added to
25 our inventory (for example Adrenaline or Health pickup just raise our stats).
26
27 */
28 public class ItemPickedUp
29 extends InfoMessage
30 implements IWorldEvent, IWorldChangeEvent
31
32 ,ILocated
33 {
34
35 /** Example how the message looks like - used during parser tests. */
36 public static final String PROTOTYPE =
37 "IPK {Id unreal_id} {InventoryId unreal_id} {Location 0,0,0} {Amount 0} {AmountSec 0} {Type xWeapons.FlakCannonPickup} {Dropped False} ";
38
39
40
41 /**
42 * Parameter-less contructor for the message.
43 */
44 public ItemPickedUp()
45 {
46 }
47
48
49
50
51 /**
52 * Creates new instance of the message ItemPickedUp.
53 *
54 Asynchronous message. Comes when we have picked up an item. This does not mean the item will be added to
55 our inventory (for example Adrenaline or Health pickup just raise our stats).
56
57 * Corresponding GameBots message
58 *
59 * is
60 * IPK.
61 *
62 *
63 *
64 * @param Id
65 Unique Id of the item. This Id represents just item on the
66 map, not in our inventory.
67
68 *
69 *
70 *
71 * @param InventoryId
72 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
73 Unreal has different Ids for items in map and actual item in bot's inventory.
74 If the item does not go into our inventory nothing will be here (null).
75
76 *
77 *
78 *
79 * @param Location Location of the item.
80 *
81 *
82 *
83 * @param Amount
84 If this item is some ammo or health pack, here we can find
85 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
86
87 *
88 *
89 *
90 * @param AmountSec
91 Only sent if this item is a weapon. Holds secondary ammo amount.
92
93 *
94 *
95 *
96 * @param Type
97 Class of the item (e.g. xWeapons.FlakCannonPickup).
98
99 *
100 *
101 *
102 * @param Descriptor
103 Descriptor of the item - according the ItemType you may cast this to various XYZDescriptor.
104
105 *
106 *
107 *
108 * @param Dropped
109 Whether it is a regular item or dropped by player or bot.
110
111 *
112 *
113 */
114 public ItemPickedUp(
115 UnrealId Id, UnrealId InventoryId, Location Location, int Amount, int AmountSec, ItemType Type, ItemDescriptor Descriptor, Boolean Dropped
116 ) {
117
118 this.Id = Id;
119
120 this.InventoryId = InventoryId;
121
122 this.Location = Location;
123
124 this.Amount = Amount;
125
126 this.AmountSec = AmountSec;
127
128 this.Type = Type;
129
130 this.Descriptor = Descriptor;
131
132 this.Dropped = Dropped;
133
134 }
135
136 /**
137 * Cloning constructor from the full message.
138 *
139 * @param original
140 */
141 public ItemPickedUp(ItemPickedUp original) {
142
143 this.Id = original.getId()
144 ;
145
146 this.InventoryId = original.getInventoryId()
147 ;
148
149 this.Location = original.getLocation()
150 ;
151
152 this.Amount = original.getAmount()
153 ;
154
155 this.AmountSec = original.getAmountSec()
156 ;
157
158 this.Type = original.getType()
159 ;
160
161 this.Descriptor = original.getDescriptor()
162 ;
163
164 this.Dropped = original.isDropped()
165 ;
166
167 this.SimTime = original.getSimTime();
168 }
169
170
171 protected long SimTime;
172
173 /**
174 * Simulation time in MILLI SECONDS !!!
175 */
176 @Override
177 public long getSimTime() {
178 return SimTime;
179 }
180
181 /**
182 * Used by Yylex to slip correct time of the object or programmatically.
183 */
184 protected void setSimTime(long SimTime) {
185 this.SimTime = SimTime;
186 }
187
188
189 /**
190 *
191 Unique Id of the item. This Id represents just item on the
192 map, not in our inventory.
193
194 */
195 protected
196 UnrealId Id =
197 null;
198
199 /**
200 *
201 Unique Id of the item. This Id represents just item on the
202 map, not in our inventory.
203
204 */
205 public UnrealId getId()
206 {
207 return Id;
208 }
209
210
211 /**
212 *
213 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
214 Unreal has different Ids for items in map and actual item in bot's inventory.
215 If the item does not go into our inventory nothing will be here (null).
216
217 */
218 protected
219 UnrealId InventoryId =
220 null;
221
222 /**
223 *
224 Unique Id of the item in our inventory - use this Id to do changeweapons etc.
225 Unreal has different Ids for items in map and actual item in bot's inventory.
226 If the item does not go into our inventory nothing will be here (null).
227
228 */
229 public UnrealId getInventoryId()
230 {
231 return InventoryId;
232 }
233
234
235 /**
236 * Location of the item.
237 */
238 protected
239 Location Location =
240 null;
241
242 /**
243 * Location of the item.
244 */
245 public Location getLocation()
246 {
247 return Location;
248 }
249
250
251 /**
252 *
253 If this item is some ammo or health pack, here we can find
254 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
255
256 */
257 protected
258 int Amount =
259 0;
260
261 /**
262 *
263 If this item is some ammo or health pack, here we can find
264 out how much of the attribute this item will add. Works also for weapons - will hold primary ammo amount.
265
266 */
267 public int getAmount()
268 {
269 return Amount;
270 }
271
272
273 /**
274 *
275 Only sent if this item is a weapon. Holds secondary ammo amount.
276
277 */
278 protected
279 int AmountSec =
280 0;
281
282 /**
283 *
284 Only sent if this item is a weapon. Holds secondary ammo amount.
285
286 */
287 public int getAmountSec()
288 {
289 return AmountSec;
290 }
291
292
293 /**
294 *
295 Class of the item (e.g. xWeapons.FlakCannonPickup).
296
297 */
298 protected
299 ItemType Type =
300 null;
301
302 /**
303 *
304 Class of the item (e.g. xWeapons.FlakCannonPickup).
305
306 */
307 public ItemType getType()
308 {
309 return Type;
310 }
311
312
313 /**
314 *
315 Descriptor of the item - according the ItemType you may cast this to various XYZDescriptor.
316
317 */
318 protected
319 ItemDescriptor Descriptor =
320 null;
321
322 /**
323 *
324 Descriptor of the item - according the ItemType you may cast this to various XYZDescriptor.
325
326 */
327 public ItemDescriptor getDescriptor()
328 {
329 return Descriptor;
330 }
331
332
333 /**
334 *
335 Whether it is a regular item or dropped by player or bot.
336
337 */
338 protected
339 Boolean Dropped =
340 null;
341
342 /**
343 *
344 Whether it is a regular item or dropped by player or bot.
345
346 */
347 public Boolean isDropped()
348 {
349 return Dropped;
350 }
351
352
353 public String toString() {
354 return
355 super.toString() + "[" +
356
357 "Id = " + String.valueOf(getId()
358 ) + " | " +
359
360 "InventoryId = " + String.valueOf(getInventoryId()
361 ) + " | " +
362
363 "Location = " + String.valueOf(getLocation()
364 ) + " | " +
365
366 "Amount = " + String.valueOf(getAmount()
367 ) + " | " +
368
369 "AmountSec = " + String.valueOf(getAmountSec()
370 ) + " | " +
371
372 "Type = " + String.valueOf(getType()
373 ) + " | " +
374
375 "Dropped = " + String.valueOf(isDropped()
376 ) + " | " +
377
378 "]";
379 }
380
381
382 public String toHtmlString() {
383 return super.toString() + "[<br/>" +
384
385 "<b>Id</b> = " + String.valueOf(getId()
386 ) + " <br/> " +
387
388 "<b>InventoryId</b> = " + String.valueOf(getInventoryId()
389 ) + " <br/> " +
390
391 "<b>Location</b> = " + String.valueOf(getLocation()
392 ) + " <br/> " +
393
394 "<b>Amount</b> = " + String.valueOf(getAmount()
395 ) + " <br/> " +
396
397 "<b>AmountSec</b> = " + String.valueOf(getAmountSec()
398 ) + " <br/> " +
399
400 "<b>Type</b> = " + String.valueOf(getType()
401 ) + " <br/> " +
402
403 "<b>Dropped</b> = " + String.valueOf(isDropped()
404 ) + " <br/> " +
405
406 "<br/>]";
407 }
408
409 public String toJsonLiteral() {
410 return "ItemPickedUp(null, "
411
412 + ")";
413 }
414
415
416 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
417
418 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
419
420 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
421
422 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
423
424 }
425