View Javadoc

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=base]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the GameBots2004 message SLF.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Information about your bot's state.
25  	
26           */
27   	public abstract class Self   
28    				extends 
29    				InfoMessage
30    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31    						
32  	    		,IPerson
33  	    {
34   	
35      	/** Example how the message looks like - used during parser tests. */
36      	public static final String PROTOTYPE =
37      		"SLF {Id unreal_id}  {BotId unreal_id}  {Name text}  {Vehicle False}  {Location 0,0,0}  {Velocity 0,0,0}  {Rotation 0,0,0}  {Team 0}  {Weapon text}  {Shooting False}  {Health 0}  {PrimaryAmmo 0}  {SecondaryAmmo 0}  {Adrenaline 0}  {Armor 0}  {SmallArmor 0}  {AltFiring False}  {Crouched False}  {Walking False}  {FloorLocation 0,0,0}  {FloorNormal 0,0,0}  {Combo text}  {UDamageTime 0}  {Action text}  {EmotLeft text}  {EmotCenter text}  {EmotRight text}  {Bubble text}  {Anim text} ";
38      
39      	
40      	
41      	/**
42      	 * Parameter-less contructor for the message.
43      	 */
44  		public Self()
45  		{
46  		}
47  	
48  				// abstract message, it does not have any more constructors				
49  			
50  	   		
51  			protected long SimTime;
52  				
53  			/**
54  			 * Simulation time in MILLI SECONDS !!!
55  			 */	
56  			@Override
57  			public long getSimTime() {
58  				return SimTime;
59  			}
60  						
61  			/**
62  			 * Used by Yylex to slip correct time of the object or programmatically.
63  			 */
64  			protected void setSimTime(long SimTime) {
65  				this.SimTime = SimTime;
66  			}
67  	   	
68   		/**
69           * Unique Id of this self message instance. 
70           */
71          public abstract UnrealId getId()
72   	;
73  		    			
74   		/**
75           * Unique Id of this bot. 
76           */
77          public abstract UnrealId getBotId()
78   	;
79  		    			
80   		/**
81           * Human readable bot name. 
82           */
83          public abstract String getName()
84   	;
85  		    			
86   		/**
87           * If we are vehicle just these attr. are sent in SLF: "Id","Vehicle""Rotation", "Location","Velocity ","Name ","Team" ,"Health" 
88  	"Armor","Adrenaline", "FloorLocation", "FloorNormal". 
89           */
90          public abstract boolean isVehicle()
91   	;
92  		    			
93   		/**
94           * 
95  			An absolute location of the bot.
96  		 
97           */
98          public abstract Location getLocation()
99   	;
100 		    			
101  		/**
102          * 
103 			Absolute velocity of the bot as a vector of movement per one
104 			game second.
105 		 
106          */
107         public abstract Velocity getVelocity()
108  	;
109 		    			
110  		/**
111          * 
112 			Which direction the bot is facing in absolute terms.
113 		 
114          */
115         public abstract Rotation getRotation()
116  	;
117 		    			
118  		/**
119          * 
120 			What team the bot is on. 255 is no team. 0-3 are red,
121 			blue, green, gold in that order.
122 		 
123          */
124         public abstract int getTeam()
125  	;
126 		    			
127  		/**
128          * 
129 			Id of the weapon we are holding. This is unique Id of an
130 			item in our inventory and is different from the Id of the
131 			item we pick up from the ground! We can parse this string to
132 			look which weapon we hold. Weapon strings to look for
133 			include: "AssaultRifle", "ShieldGun", "FlakCannon",
134 			"BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
135 			"RocketLauncher", "Minigun", "LightingGun", "Translocator".
136 			TODO: Look if this is all.
137 		 
138          */
139         public abstract String getWeapon()
140  	;
141 		    			
142  		/**
143          * If the bot is shooting or not. 
144          */
145         public abstract boolean isShooting()
146  	;
147 		    			
148  		/**
149          * 
150 			How much health the bot has left. Starts at 100, ranges from
151 			0 to 200.
152 		 
153          */
154         public abstract int getHealth()
155  	;
156 		    			
157  		/**
158          * 
159 			How much ammo the bot has left for current weapon primary
160 			mode.
161 		 
162          */
163         public abstract int getPrimaryAmmo()
164  	;
165 		    			
166  		/**
167          * 
168 			How much ammo the bot has left for current weapon secondary
169 			mode. Weapon does not have to support sec. fire mode.
170 		 
171          */
172         public abstract int getSecondaryAmmo()
173  	;
174 		    			
175  		/**
176          * How much adrenaline the bot has. 
177          */
178         public abstract int getAdrenaline()
179  	;
180 		    			
181  		/**
182          * 
183 			Combined size of high armor and low armor (or small armor). The high and low armor are tracked
184                         separately. Low armor is limited to 50 points, while the
185                         high armor can have up to 150 points. Both stacks can have a combined size of 150 points as well,
186                         so if low armor is already at 50 points, high armor can have
187                         100 points at max.
188 		 
189          */
190         public abstract int getArmor()
191  	;
192 		    			
193  		/**
194          * 
195 			Also refered to as a "low armor". Ranges from 0 to 50 points.
196 		 
197          */
198         public abstract int getSmallArmor()
199  	;
200 		    			
201  		/**
202          * 
203 			If we are firing in secondary firing mode. 
204 		 
205          */
206         public abstract boolean isAltFiring()
207  	;
208 		    			
209  		/**
210          * 
211 			If we are currently crouched.
212 		 
213          */
214         public abstract boolean isCrouched()
215  	;
216 		    			
217  		/**
218          * 
219 			If we are currently in walking mode.
220 		 
221          */
222         public abstract boolean isWalking()
223  	;
224 		    			
225  		/**
226          * 
227 			Holds current floor location under the bot.
228 		 
229          */
230         public abstract Location getFloorLocation()
231  	;
232 		    			
233  		/**
234          * 
235 			Holds current floor normal under the bot.
236 		 
237          */
238         public abstract Location getFloorNormal()
239  	;
240 		    			
241  		/**
242          * 
243 			Name of the current combo (None if no combo active).
244 			Can be xGame.ComboBerserk, xGame.ComboDefensive, xGame.ComboInvis or xGame.ComboSpeed.
245 			To trigger combo adrenaline needs to be at 100 (maximum) and no other combo can be active.
246 		 
247          */
248         public abstract String getCombo()
249  	;
250 		    			
251  		/**
252          * 
253 			Time when the UDamage effect expires. If the number is higher then the current
254 			time, it means the bot has UDamage effect active right now.
255 		 
256          */
257         public abstract double getUDamageTime()
258  	;
259 		    			
260  		/**
261          * 
262 			Name of the current BDI action.
263 		 
264          */
265         public abstract String getAction()
266  	;
267 		    			
268  		/**
269          * 
270 			For UE2. Holds left emoticon of the bot, "None" means none set.
271 		 
272          */
273         public abstract String getEmotLeft()
274  	;
275 		    			
276  		/**
277          * 
278 			For UE2. Holds center emoticon of the bot, "None" means none set.
279 		 
280          */
281         public abstract String getEmotCenter()
282  	;
283 		    			
284  		/**
285          * 
286 			For UE2. Holds right emoticon of the bot, "None" means none set.
287 		 
288          */
289         public abstract String getEmotRight()
290  	;
291 		    			
292  		/**
293          * 
294 			For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
295 		 
296          */
297         public abstract String getBubble()
298  	;
299 		    			
300  		/**
301          * 
302 			For UE2. Current played animation of the bot.
303 		 
304          */
305         public abstract String getAnim()
306  	;
307 		    			
308     	
309     	public static class SelfUpdate
310      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
311 			private Self object;
312 			private long time;
313 			private ITeamId teamId;
314 			
315 			public SelfUpdate
316     (Self source, long eventTime, ITeamId teamId) {
317 				this.object = source;
318 				this.time = eventTime;
319 				this.teamId = teamId;
320 			}
321 			
322 			/**
323 			 * Simulation time in MILLI SECONDS !!!
324 			 */ 
325 			@Override
326 			public long getSimTime() {
327 				return time;
328 			}
329 	
330 			@Override
331 			public IWorldObject getObject() {
332 				return object;
333 			}
334 	
335 			@Override
336 			public WorldObjectId getId() {
337 				return object.getId();
338 			}
339 	
340 			@Override
341 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
342 				return new SelfLocalImpl.SelfLocalUpdate
343     ((SelfLocal)object.getLocal(), time);
344 			}
345 	
346 			@Override
347 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
348 				return new SelfSharedImpl.SelfSharedUpdate
349     ((SelfShared)object.getShared(), time, teamId);
350 			}
351 	
352 			@Override
353 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
354 				return new SelfStaticImpl.SelfStaticUpdate
355     ((SelfStatic)object.getStatic(), time);
356 			}
357 			
358 		}
359     
360  		
361  	    public String toString() {
362             return
363             	super.toString() + "[" +
364             	
365 		              			"Id = " + String.valueOf(getId()
366  	) + " | " + 
367 		              		
368 		              			"BotId = " + String.valueOf(getBotId()
369  	) + " | " + 
370 		              		
371 		              			"Name = " + String.valueOf(getName()
372  	) + " | " + 
373 		              		
374 		              			"Vehicle = " + String.valueOf(isVehicle()
375  	) + " | " + 
376 		              		
377 		              			"Location = " + String.valueOf(getLocation()
378  	) + " | " + 
379 		              		
380 		              			"Velocity = " + String.valueOf(getVelocity()
381  	) + " | " + 
382 		              		
383 		              			"Rotation = " + String.valueOf(getRotation()
384  	) + " | " + 
385 		              		
386 		              			"Team = " + String.valueOf(getTeam()
387  	) + " | " + 
388 		              		
389 		              			"Weapon = " + String.valueOf(getWeapon()
390  	) + " | " + 
391 		              		
392 		              			"Shooting = " + String.valueOf(isShooting()
393  	) + " | " + 
394 		              		
395 		              			"Health = " + String.valueOf(getHealth()
396  	) + " | " + 
397 		              		
398 		              			"PrimaryAmmo = " + String.valueOf(getPrimaryAmmo()
399  	) + " | " + 
400 		              		
401 		              			"SecondaryAmmo = " + String.valueOf(getSecondaryAmmo()
402  	) + " | " + 
403 		              		
404 		              			"Adrenaline = " + String.valueOf(getAdrenaline()
405  	) + " | " + 
406 		              		
407 		              			"Armor = " + String.valueOf(getArmor()
408  	) + " | " + 
409 		              		
410 		              			"SmallArmor = " + String.valueOf(getSmallArmor()
411  	) + " | " + 
412 		              		
413 		              			"AltFiring = " + String.valueOf(isAltFiring()
414  	) + " | " + 
415 		              		
416 		              			"Crouched = " + String.valueOf(isCrouched()
417  	) + " | " + 
418 		              		
419 		              			"Walking = " + String.valueOf(isWalking()
420  	) + " | " + 
421 		              		
422 		              			"FloorLocation = " + String.valueOf(getFloorLocation()
423  	) + " | " + 
424 		              		
425 		              			"FloorNormal = " + String.valueOf(getFloorNormal()
426  	) + " | " + 
427 		              		
428 		              			"Combo = " + String.valueOf(getCombo()
429  	) + " | " + 
430 		              		
431 		              			"UDamageTime = " + String.valueOf(getUDamageTime()
432  	) + " | " + 
433 		              		
434 		              			"Action = " + String.valueOf(getAction()
435  	) + " | " + 
436 		              		
437 		              			"EmotLeft = " + String.valueOf(getEmotLeft()
438  	) + " | " + 
439 		              		
440 		              			"EmotCenter = " + String.valueOf(getEmotCenter()
441  	) + " | " + 
442 		              		
443 		              			"EmotRight = " + String.valueOf(getEmotRight()
444  	) + " | " + 
445 		              		
446 		              			"Bubble = " + String.valueOf(getBubble()
447  	) + " | " + 
448 		              		
449 		              			"Anim = " + String.valueOf(getAnim()
450  	) + " | " + 
451 		              		
452 				"]";           		
453         }
454  	
455  		
456  		public String toHtmlString() {
457  			return super.toString() + "[<br/>" +
458             	
459 		              			"<b>Id</b> = " + String.valueOf(getId()
460  	) + " <br/> " + 
461 		              		
462 		              			"<b>BotId</b> = " + String.valueOf(getBotId()
463  	) + " <br/> " + 
464 		              		
465 		              			"<b>Name</b> = " + String.valueOf(getName()
466  	) + " <br/> " + 
467 		              		
468 		              			"<b>Vehicle</b> = " + String.valueOf(isVehicle()
469  	) + " <br/> " + 
470 		              		
471 		              			"<b>Location</b> = " + String.valueOf(getLocation()
472  	) + " <br/> " + 
473 		              		
474 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
475  	) + " <br/> " + 
476 		              		
477 		              			"<b>Rotation</b> = " + String.valueOf(getRotation()
478  	) + " <br/> " + 
479 		              		
480 		              			"<b>Team</b> = " + String.valueOf(getTeam()
481  	) + " <br/> " + 
482 		              		
483 		              			"<b>Weapon</b> = " + String.valueOf(getWeapon()
484  	) + " <br/> " + 
485 		              		
486 		              			"<b>Shooting</b> = " + String.valueOf(isShooting()
487  	) + " <br/> " + 
488 		              		
489 		              			"<b>Health</b> = " + String.valueOf(getHealth()
490  	) + " <br/> " + 
491 		              		
492 		              			"<b>PrimaryAmmo</b> = " + String.valueOf(getPrimaryAmmo()
493  	) + " <br/> " + 
494 		              		
495 		              			"<b>SecondaryAmmo</b> = " + String.valueOf(getSecondaryAmmo()
496  	) + " <br/> " + 
497 		              		
498 		              			"<b>Adrenaline</b> = " + String.valueOf(getAdrenaline()
499  	) + " <br/> " + 
500 		              		
501 		              			"<b>Armor</b> = " + String.valueOf(getArmor()
502  	) + " <br/> " + 
503 		              		
504 		              			"<b>SmallArmor</b> = " + String.valueOf(getSmallArmor()
505  	) + " <br/> " + 
506 		              		
507 		              			"<b>AltFiring</b> = " + String.valueOf(isAltFiring()
508  	) + " <br/> " + 
509 		              		
510 		              			"<b>Crouched</b> = " + String.valueOf(isCrouched()
511  	) + " <br/> " + 
512 		              		
513 		              			"<b>Walking</b> = " + String.valueOf(isWalking()
514  	) + " <br/> " + 
515 		              		
516 		              			"<b>FloorLocation</b> = " + String.valueOf(getFloorLocation()
517  	) + " <br/> " + 
518 		              		
519 		              			"<b>FloorNormal</b> = " + String.valueOf(getFloorNormal()
520  	) + " <br/> " + 
521 		              		
522 		              			"<b>Combo</b> = " + String.valueOf(getCombo()
523  	) + " <br/> " + 
524 		              		
525 		              			"<b>UDamageTime</b> = " + String.valueOf(getUDamageTime()
526  	) + " <br/> " + 
527 		              		
528 		              			"<b>Action</b> = " + String.valueOf(getAction()
529  	) + " <br/> " + 
530 		              		
531 		              			"<b>EmotLeft</b> = " + String.valueOf(getEmotLeft()
532  	) + " <br/> " + 
533 		              		
534 		              			"<b>EmotCenter</b> = " + String.valueOf(getEmotCenter()
535  	) + " <br/> " + 
536 		              		
537 		              			"<b>EmotRight</b> = " + String.valueOf(getEmotRight()
538  	) + " <br/> " + 
539 		              		
540 		              			"<b>Bubble</b> = " + String.valueOf(getBubble()
541  	) + " <br/> " + 
542 		              		
543 		              			"<b>Anim</b> = " + String.valueOf(getAnim()
544  	) + " <br/> " + 
545 		              		
546 				"<br/>]";     
547 		}
548  	 
549  	    public String toJsonLiteral() {
550             return "Self(null, "
551             		
552                    + ")";
553         }
554  	
555  		
556  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
557         	
558 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
559 		
560 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
561 	        
562 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
563  	
564 		}
565