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