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 NAV.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. NavPoint carries information about UT
25  		navigation point - location, reachability... Also some item can
26  		be respawned at this point. Or some additional information can
27  		be stored here (if it is an ambush point, or sniper point..).
28  	
29           */
30   	public abstract class NavPoint   
31    				extends 
32    				InfoMessage
33    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
34    						
35  	    		,ILocated
36  	    		,ILocomotive
37  	    		,IGBViewable
38  	    {
39   	
40      	/** Example how the message looks like - used during parser tests. */
41      	public static final String PROTOTYPE =
42      		"NAV {Id unreal_id}  {Location 0,0,0}  {Velocity 0,0,0}  {Visible False}  {Item unreal_id}  {ItemClass xWeapons.FlakCannonPickup}  {ItemSpawned False}  {DoorOpened False}  {Mover unreal_id}  {LiftOffset 0,0,0}  {LiftJumpExit False}  {NoDoubleJump False}  {InvSpot False}  {PlayerStart False}  {TeamNumber 0}  {DomPoint False}  {DomPointController 0}  {Door False}  {LiftCenter False}  {LiftExit False}  {AIMarker False}  {JumpSpot False}  {JumpPad False}  {JumpDest False}  {Teleporter False}  {Rotation 0,0,0}  {RoamingSpot False}  {SnipingSpot False}  {PreferedWeapon text} ";
43      
44      	
45      	
46      	/**
47      	 * Parameter-less contructor for the message.
48      	 */
49  		public NavPoint()
50  		{
51  		}
52  	
53  				// abstract message, it does not have any more constructors				
54  			
55  	   		
56  			protected long SimTime;
57  				
58  			/**
59  			 * Simulation time in MILLI SECONDS !!!
60  			 */	
61  			@Override
62  			public long getSimTime() {
63  				return SimTime;
64  			}
65  						
66  			/**
67  			 * Used by Yylex to slip correct time of the object or programmatically.
68  			 */
69  			protected void setSimTime(long SimTime) {
70  				this.SimTime = SimTime;
71  			}
72  	   	
73   		/**
74           * 
75  			A unique Id of this navigation point assigned by the game.
76  		 
77           */
78          public abstract UnrealId getId()
79   	;
80  		    			
81   		/**
82           * Location of navigation point. 
83           */
84          public abstract Location getLocation()
85   	;
86  		    			
87   		/**
88           * 
89  			Velocity of the navigation point (if the navigation point is
90  			currently moving). Not sent at the moment.
91  		 
92           */
93          public abstract Velocity getVelocity()
94   	;
95  		    			
96   		/**
97           * 
98  			If the point is in the field of view of the bot.
99  		 
100          */
101         public abstract boolean isVisible()
102  	;
103 		    			
104  		/**
105          * 
106 			Unique Id of the respawned item (the item respawns at this
107 			point). Not sent if point is not an inventory spot. Sent only in HandShake.
108 		 
109          */
110         public abstract UnrealId getItem()
111  	;
112 		    			
113  		/**
114          * 
115             Class of the item (e.g. xWeapons.FlakCannonPickup). Not sent if point is not an inventory spot. Sent only in HandShake.
116          
117          */
118         public abstract ItemType getItemClass()
119  	;
120 		    			
121  		/**
122          * 
123             True if the item is spawned at the point. Not sent if point is not an inventory spot. 
124          
125          */
126         public abstract boolean isItemSpawned()
127  	;
128 		    			
129  		/**
130          * 
131             True if this NavPoint is a Door and door is opened. Not sent if point is not a door.
132          
133          */
134         public abstract boolean isDoorOpened()
135  	;
136 		    			
137  		/**
138          * 
139             If this NavPoint is marking some mover, the mover id will be here. Not sent if point is not a Door, a LiftCenter or a LiftExit. Sent only in HandShake.
140          
141          */
142         public abstract UnrealId getMover()
143  	;
144 		    			
145  		/**
146          * 
147             Starting vector between MyLift location and LiftCenter location. Not sent if point is not a LiftCenter. Sent only in HandShake.
148          
149          */
150         public abstract Vector3d getLiftOffset()
151  	;
152 		    			
153  		/**
154          * 
155             Boolean. If we can/should exit the lift by a jump when near the destination place. Not sent if point is not a LiftExit. Sent only in HandShake.
156          
157          */
158         public abstract boolean isLiftJumpExit()
159  	;
160 		    			
161  		/**
162          * 
163             Boolean. If we should or not use double jump when exiting lift with a jump. Not sent if point is not a LiftExit. Sent only in HandShake.
164          
165          */
166         public abstract boolean isNoDoubleJump()
167  	;
168 		    			
169  		/**
170          * 
171 			If this is an inventory spot (item is respawned at this point).
172 		 
173          */
174         public abstract boolean isInvSpot()
175  	;
176 		    			
177  		/**
178          * 
179 			If this is a player start (players and/or bots are respawned at this point).
180 		 
181          */
182         public abstract boolean isPlayerStart()
183  	;
184 		    			
185  		/**
186          * 
187 			Will be sent if this is a player start. In Team games (team deathmatch, capture the flag, domination) holds information about which team respawns at this player start spot. In non-team games will return 0!
188 		 
189          */
190         public abstract int getTeamNumber()
191  	;
192 		    			
193  		/**
194          * If this point marks a DominationPoint (for BotDoubleDomination game). 
195          */
196         public abstract boolean isDomPoint()
197  	;
198 		    			
199  		/**
200          * Exported if this NavPoint is a DominationPoint (for BotDoubleDomination game) - which team controls this point. 
201          */
202         public abstract int getDomPointController()
203  	;
204 		    			
205  		/**
206          * 
207 			If this point marks a door mover.
208 		 
209          */
210         public abstract boolean isDoor()
211  	;
212 		    			
213  		/**
214          * 
215 			If this point marks a lift center (used to mark center of a lift mover, note that this point will be always moved with the lift).
216 		 
217          */
218         public abstract boolean isLiftCenter()
219  	;
220 		    			
221  		/**
222          * 
223 			If this point marks a lift exit (used to mark exit point of a lift mover).
224 		 
225          */
226         public abstract boolean isLiftExit()
227  	;
228 		    			
229  		/**
230          * 
231 			If this point is an AI marker - marks an interesting spot in the environment. May be ambush point or sniping spot, etc.
232 		 
233          */
234         public abstract boolean isAIMarker()
235  	;
236 		    			
237  		/**
238          * 
239 			If this point marks a jump spot (a special device that causes the bot to jump high or far).
240 		 
241          */
242         public abstract boolean isJumpSpot()
243  	;
244 		    			
245  		/**
246          * 
247 			If this point marks a jump pad (a special device that causes the bot to jump high or far).
248 		 
249          */
250         public abstract boolean isJumpPad()
251  	;
252 		    			
253  		/**
254          * 
255 			If this point marks a jump destination - some place that can be reached by some special jump.
256 		 
257          */
258         public abstract boolean isJumpDest()
259  	;
260 		    			
261  		/**
262          * 
263 			If this point marks a teleport. 
264 		 
265          */
266         public abstract boolean isTeleporter()
267  	;
268 		    			
269  		/**
270          * 
271 			If the type is AIMarker. The rotation the bot should be
272 			facing, when doing the action specified by AIMarker. Sent only in HandShake.
273 		 
274          */
275         public abstract Rotation getRotation()
276  	;
277 		    			
278  		/**
279          * 
280 			Some ambush point, where is good chance to intercept
281 			approaching opponents. Sent only in HandShake.
282 		 
283          */
284         public abstract boolean isRoamingSpot()
285  	;
286 		    			
287  		/**
288          * Point good for sniping. Sent only in HandShake. 
289          */
290         public abstract boolean isSnipingSpot()
291  	;
292 		    			
293  		/**
294          * If item should be present at this navpoint it's instance will be here. 
295          */
296         public abstract Item getItemInstance()
297  	;
298 		    			
299  		/**
300          * Maps edge-LEADING_TO-navpoint-UnrealId to neighbour link, those are outgoing edges (those edges that originates in this navpoint going to another one, those you may usually travel). 
301          */
302         public abstract Map<UnrealId, NavPointNeighbourLink> getOutgoingEdges()
303  	;
304 		    			
305  		/**
306          * Maps edge-ORIGINATES_FROM-navpoint-UnrealId to neighbour link, those are incoming edges (those edges that originates in different navpoint and ends here, do not use this to ask whether you can get to navpoint of specific unreal id, use OutgoingEdges instead). 
307          */
308         public abstract Map<UnrealId, NavPointNeighbourLink> getIncomingEdges()
309  	;
310 		    			
311  		/**
312          * 
313 			Class of the weapon that should be prefered when using this
314 			point for AIMarker specified action. Sent only in HandShake.
315 		 
316          */
317         public abstract String getPreferedWeapon()
318  	;
319 		    			
320 		 	@Override
321 			public IWorldObjectUpdatedEvent createDisappearEvent() {
322 				return new ObjectDisappeared(this, getSimTime());
323 			}
324 			
325 			public static class ObjectDisappeared implements IWorldObjectUpdatedEvent
326 			{
327 				
328 				public ObjectDisappeared(NavPoint obj, long time) {
329 					this.obj = obj;
330 					this.time = time;
331 				}
332 				
333 				private NavPoint obj;
334 				private long time;
335 		
336 				@Override
337 				public WorldObjectId getId() {
338 					return obj.getId();
339 				}
340 		
341 		        /**
342 		         * Simulation time in MILLI SECONDS !!!
343 		         */
344 				@Override
345 				public long getSimTime() {
346 					return time;
347 				}
348 		
349 				@Override
350 				public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject obj) {
351 					if (obj == null) {
352 						throw new PogamutException("Can't 'disappear' null!", this);
353 					}
354 					if (!(obj instanceof NavPointMessage)) {
355 						throw new PogamutException("Can't update different class than NavPointMessage, got class " + obj.getClass().getSimpleName() + "!", this);
356 					}
357 					NavPointMessage toUpdate = (NavPointMessage)obj;
358 					if (toUpdate.Visible) {
359 						toUpdate.Visible = false;
360 						return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.UPDATED, obj);
361 					} else {
362 						return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.SAME, obj);
363 					}
364 				}
365 		
366 			}
367 	
368 		
369     	
370     	public static class NavPointUpdate
371      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
372 			private NavPoint object;
373 			private long time;
374 			private ITeamId teamId;
375 			
376 			public NavPointUpdate
377     (NavPoint source, long eventTime, ITeamId teamId) {
378 				this.object = source;
379 				this.time = eventTime;
380 				this.teamId = teamId;
381 			}
382 			
383 			/**
384 			 * Simulation time in MILLI SECONDS !!!
385 			 */ 
386 			@Override
387 			public long getSimTime() {
388 				return time;
389 			}
390 	
391 			@Override
392 			public IWorldObject getObject() {
393 				return object;
394 			}
395 	
396 			@Override
397 			public WorldObjectId getId() {
398 				return object.getId();
399 			}
400 	
401 			@Override
402 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
403 				return new NavPointLocalImpl.NavPointLocalUpdate
404     ((NavPointLocal)object.getLocal(), time);
405 			}
406 	
407 			@Override
408 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
409 				return new NavPointSharedImpl.NavPointSharedUpdate
410     ((NavPointShared)object.getShared(), time, teamId);
411 			}
412 	
413 			@Override
414 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
415 				return new NavPointStaticImpl.NavPointStaticUpdate
416     ((NavPointStatic)object.getStatic(), time);
417 			}
418 			
419 		}
420     
421  		
422  	    public String toString() {
423             return
424             	super.toString() + "[" +
425             	
426 		              			"Id = " + String.valueOf(getId()
427  	) + " | " + 
428 		              		
429 		              			"Location = " + String.valueOf(getLocation()
430  	) + " | " + 
431 		              		
432 		              			"Velocity = " + String.valueOf(getVelocity()
433  	) + " | " + 
434 		              		
435 		              			"Visible = " + String.valueOf(isVisible()
436  	) + " | " + 
437 		              		
438 		              			"Item = " + String.valueOf(getItem()
439  	) + " | " + 
440 		              		
441 		              			"ItemClass = " + String.valueOf(getItemClass()
442  	) + " | " + 
443 		              		
444 		              			"ItemSpawned = " + String.valueOf(isItemSpawned()
445  	) + " | " + 
446 		              		
447 		              			"DoorOpened = " + String.valueOf(isDoorOpened()
448  	) + " | " + 
449 		              		
450 		              			"Mover = " + String.valueOf(getMover()
451  	) + " | " + 
452 		              		
453 		              			"LiftOffset = " + String.valueOf(getLiftOffset()
454  	) + " | " + 
455 		              		
456 		              			"LiftJumpExit = " + String.valueOf(isLiftJumpExit()
457  	) + " | " + 
458 		              		
459 		              			"NoDoubleJump = " + String.valueOf(isNoDoubleJump()
460  	) + " | " + 
461 		              		
462 		              			"InvSpot = " + String.valueOf(isInvSpot()
463  	) + " | " + 
464 		              		
465 		              			"PlayerStart = " + String.valueOf(isPlayerStart()
466  	) + " | " + 
467 		              		
468 		              			"TeamNumber = " + String.valueOf(getTeamNumber()
469  	) + " | " + 
470 		              		
471 		              			"DomPoint = " + String.valueOf(isDomPoint()
472  	) + " | " + 
473 		              		
474 		              			"DomPointController = " + String.valueOf(getDomPointController()
475  	) + " | " + 
476 		              		
477 		              			"Door = " + String.valueOf(isDoor()
478  	) + " | " + 
479 		              		
480 		              			"LiftCenter = " + String.valueOf(isLiftCenter()
481  	) + " | " + 
482 		              		
483 		              			"LiftExit = " + String.valueOf(isLiftExit()
484  	) + " | " + 
485 		              		
486 		              			"AIMarker = " + String.valueOf(isAIMarker()
487  	) + " | " + 
488 		              		
489 		              			"JumpSpot = " + String.valueOf(isJumpSpot()
490  	) + " | " + 
491 		              		
492 		              			"JumpPad = " + String.valueOf(isJumpPad()
493  	) + " | " + 
494 		              		
495 		              			"JumpDest = " + String.valueOf(isJumpDest()
496  	) + " | " + 
497 		              		
498 		              			"Teleporter = " + String.valueOf(isTeleporter()
499  	) + " | " + 
500 		              		
501 		              			"Rotation = " + String.valueOf(getRotation()
502  	) + " | " + 
503 		              		
504 		              			"RoamingSpot = " + String.valueOf(isRoamingSpot()
505  	) + " | " + 
506 		              		
507 		              			"SnipingSpot = " + String.valueOf(isSnipingSpot()
508  	) + " | " + 
509 		              		
510 		              			"PreferedWeapon = " + String.valueOf(getPreferedWeapon()
511  	) + " | " + 
512 		              		
513 				"]";           		
514         }
515  	
516  		
517  		public String toHtmlString() {
518  			return super.toString() + "[<br/>" +
519             	
520 		              			"<b>Id</b> = " + String.valueOf(getId()
521  	) + " <br/> " + 
522 		              		
523 		              			"<b>Location</b> = " + String.valueOf(getLocation()
524  	) + " <br/> " + 
525 		              		
526 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
527  	) + " <br/> " + 
528 		              		
529 		              			"<b>Visible</b> = " + String.valueOf(isVisible()
530  	) + " <br/> " + 
531 		              		
532 		              			"<b>Item</b> = " + String.valueOf(getItem()
533  	) + " <br/> " + 
534 		              		
535 		              			"<b>ItemClass</b> = " + String.valueOf(getItemClass()
536  	) + " <br/> " + 
537 		              		
538 		              			"<b>ItemSpawned</b> = " + String.valueOf(isItemSpawned()
539  	) + " <br/> " + 
540 		              		
541 		              			"<b>DoorOpened</b> = " + String.valueOf(isDoorOpened()
542  	) + " <br/> " + 
543 		              		
544 		              			"<b>Mover</b> = " + String.valueOf(getMover()
545  	) + " <br/> " + 
546 		              		
547 		              			"<b>LiftOffset</b> = " + String.valueOf(getLiftOffset()
548  	) + " <br/> " + 
549 		              		
550 		              			"<b>LiftJumpExit</b> = " + String.valueOf(isLiftJumpExit()
551  	) + " <br/> " + 
552 		              		
553 		              			"<b>NoDoubleJump</b> = " + String.valueOf(isNoDoubleJump()
554  	) + " <br/> " + 
555 		              		
556 		              			"<b>InvSpot</b> = " + String.valueOf(isInvSpot()
557  	) + " <br/> " + 
558 		              		
559 		              			"<b>PlayerStart</b> = " + String.valueOf(isPlayerStart()
560  	) + " <br/> " + 
561 		              		
562 		              			"<b>TeamNumber</b> = " + String.valueOf(getTeamNumber()
563  	) + " <br/> " + 
564 		              		
565 		              			"<b>DomPoint</b> = " + String.valueOf(isDomPoint()
566  	) + " <br/> " + 
567 		              		
568 		              			"<b>DomPointController</b> = " + String.valueOf(getDomPointController()
569  	) + " <br/> " + 
570 		              		
571 		              			"<b>Door</b> = " + String.valueOf(isDoor()
572  	) + " <br/> " + 
573 		              		
574 		              			"<b>LiftCenter</b> = " + String.valueOf(isLiftCenter()
575  	) + " <br/> " + 
576 		              		
577 		              			"<b>LiftExit</b> = " + String.valueOf(isLiftExit()
578  	) + " <br/> " + 
579 		              		
580 		              			"<b>AIMarker</b> = " + String.valueOf(isAIMarker()
581  	) + " <br/> " + 
582 		              		
583 		              			"<b>JumpSpot</b> = " + String.valueOf(isJumpSpot()
584  	) + " <br/> " + 
585 		              		
586 		              			"<b>JumpPad</b> = " + String.valueOf(isJumpPad()
587  	) + " <br/> " + 
588 		              		
589 		              			"<b>JumpDest</b> = " + String.valueOf(isJumpDest()
590  	) + " <br/> " + 
591 		              		
592 		              			"<b>Teleporter</b> = " + String.valueOf(isTeleporter()
593  	) + " <br/> " + 
594 		              		
595 		              			"<b>Rotation</b> = " + String.valueOf(getRotation()
596  	) + " <br/> " + 
597 		              		
598 		              			"<b>RoamingSpot</b> = " + String.valueOf(isRoamingSpot()
599  	) + " <br/> " + 
600 		              		
601 		              			"<b>SnipingSpot</b> = " + String.valueOf(isSnipingSpot()
602  	) + " <br/> " + 
603 		              		
604 		              			"<b>PreferedWeapon</b> = " + String.valueOf(getPreferedWeapon()
605  	) + " <br/> " + 
606 		              		
607 				"<br/>]";     
608 		}
609  	
610  		
611  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
612         	
613 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
614 		
615 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
616 	        
617 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
618  	
619 		}
620