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=shared]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=shared]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the shared part of the GameBots2004 message PLR.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Contains information about other players in
25  		the game, like their current velocity, position, weapon and
26  		reachability. Only reports those players that are visible.
27  		(within field of view and not occluded).
28  	
29           */
30   	public abstract class PlayerShared 
31    						extends InfoMessage
32    						implements ISharedWorldObject
33    						
34  	    {
35   	
36      	
37      	
38      	/**
39      	 * Parameter-less contructor for the message.
40      	 */
41  		public PlayerShared()
42  		{
43  		}
44  		
45  				// abstract definition of the shared-part of the message, no more constructors is needed
46  			
47  	   		
48  			protected long SimTime;
49  				
50  			/**
51  			 * Simulation time in MILLI SECONDS !!!
52  			 */	
53  			@Override
54  			public long getSimTime() {
55  				return SimTime;
56  			}
57  						
58  			/**
59  			 * Used by Yylex to slip correct time of the object or programmatically.
60  			 */
61  			protected void setSimTime(long SimTime) {
62  				this.SimTime = SimTime;
63  			}
64  	   	
65  	    						public static final Token NamePropertyToken = Tokens.get("Name");
66  	    					
67  	    						public static final Token SpectatorPropertyToken = Tokens.get("Spectator");
68  	    					
69  	    						public static final Token ActionPropertyToken = Tokens.get("Action");
70  	    					
71  	    						public static final Token RotationPropertyToken = Tokens.get("Rotation");
72  	    					
73  	    						public static final Token LocationPropertyToken = Tokens.get("Location");
74  	    					
75  	    						public static final Token VelocityPropertyToken = Tokens.get("Velocity");
76  	    					
77  	    						public static final Token TeamPropertyToken = Tokens.get("Team");
78  	    					
79  	    						public static final Token WeaponPropertyToken = Tokens.get("Weapon");
80  	    					
81  	    						public static final Token CrouchedPropertyToken = Tokens.get("Crouched");
82  	    					
83  	    						public static final Token FiringPropertyToken = Tokens.get("Firing");
84  	    					
85  	    						public static final Token EmotLeftPropertyToken = Tokens.get("EmotLeft");
86  	    					
87  	    						public static final Token EmotCenterPropertyToken = Tokens.get("EmotCenter");
88  	    					
89  	    						public static final Token EmotRightPropertyToken = Tokens.get("EmotRight");
90  	    					
91  	    						public static final Token BubblePropertyToken = Tokens.get("Bubble");
92  	    					
93  	    						public static final Token AnimPropertyToken = Tokens.get("Anim");
94  	    						
95  							
96  							public static final Set<Token> SharedPropertyTokens;
97  	
98  							static {
99  								Set<Token> tokens = new HashSet<Token>();
100 								
101 									tokens.add(NamePropertyToken);
102 								
103 									tokens.add(SpectatorPropertyToken);
104 								
105 									tokens.add(ActionPropertyToken);
106 								
107 									tokens.add(RotationPropertyToken);
108 								
109 									tokens.add(LocationPropertyToken);
110 								
111 									tokens.add(VelocityPropertyToken);
112 								
113 									tokens.add(TeamPropertyToken);
114 								
115 									tokens.add(WeaponPropertyToken);
116 								
117 									tokens.add(CrouchedPropertyToken);
118 								
119 									tokens.add(FiringPropertyToken);
120 								
121 									tokens.add(EmotLeftPropertyToken);
122 								
123 									tokens.add(EmotCenterPropertyToken);
124 								
125 									tokens.add(EmotRightPropertyToken);
126 								
127 									tokens.add(BubblePropertyToken);
128 								
129 									tokens.add(AnimPropertyToken);
130 								
131 								SharedPropertyTokens = Collections.unmodifiableSet(tokens);
132 							}
133 	    				
134 	    			
135 	    				@Override
136 		    			public abstract 
137 		    			PlayerShared clone();
138 		    			
139 						@Override
140 						public Class getCompositeClass() {
141 							return Player.class;
142 						}
143 	
144 						
145 		    			
146  		/**
147          * Unique Id of the player. 
148          */
149         public abstract UnrealId getId()
150  	;
151 		    			
152  		/**
153          * 
154 			Human readable name of the player.
155 		 
156          */
157         public abstract String getName()
158  	;
159 		    			
160  		/**
161          * 
162 			Whether this player is in SPECTATE mode. Humans can change the mode during runtime!
163 		 
164          */
165         public abstract Boolean isSpectator()
166  	;
167 		    			
168  		/**
169          * 
170 			Atomic action this bot is doing (BDI).
171 		 
172          */
173         public abstract String getAction()
174  	;
175 		    			
176  		/**
177          * 
178 			Which direction the player is facing in absolute terms.
179 		 
180          */
181         public abstract Rotation getRotation()
182  	;
183 		    			
184  		/**
185          * 
186 			An absolute location of the player within the map.
187 		 
188          */
189         public abstract Location getLocation()
190  	;
191 		    			
192  		/**
193          * 
194 			Absolute velocity of the player as a vector of movement per one
195 			game second.
196 		 
197          */
198         public abstract Velocity getVelocity()
199  	;
200 		    			
201  		/**
202          * 
203 			What team the player is on. 255 is no team. 0-3 are red,
204 			blue, green, gold in that order.
205 		 
206          */
207         public abstract int getTeam()
208  	;
209 		    			
210  		/**
211          * 
212 			Class of the weapon the player is holding. Weapon strings to
213 			look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
214 			"BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
215 			"RocketLauncher", "Minigun", "LightingGun", "Translocator".
216 			TODO: Look if this is all.
217 		 
218          */
219         public abstract String getWeapon()
220  	;
221 		    			
222  		/**
223          * 
224 			True if the bot is crouched.
225 		 
226          */
227         public abstract boolean isCrouched()
228  	;
229 		    			
230  		/**
231          * 
232 			0 means is not firing, 1 - firing in primary mode, 2 -
233 			firing in secondary mode (alt firing).
234 		 
235          */
236         public abstract int getFiring()
237  	;
238 		    			
239  		/**
240          * 
241 			For UE2. Holds left emoticon of the bot, "None" means none set.
242 		 
243          */
244         public abstract String getEmotLeft()
245  	;
246 		    			
247  		/**
248          * 
249 			For UE2. Holds center emoticon of the bot, "None" means none set.
250 		 
251          */
252         public abstract String getEmotCenter()
253  	;
254 		    			
255  		/**
256          * 
257 			For UE2. Holds right emoticon of the bot, "None" means none set.
258 		 
259          */
260         public abstract String getEmotRight()
261  	;
262 		    			
263  		/**
264          * 
265 			For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
266 		 
267          */
268         public abstract String getBubble()
269  	;
270 		    			
271  		/**
272          * 
273 			For UE2. Current played animation of the bot.
274 		 
275          */
276         public abstract String getAnim()
277  	;
278 		    			
279  		
280  	    public String toString() {
281             return
282             	super.toString() + "[" +
283             	
284 		              			"Id = " + String.valueOf(getId()
285  	) + " | " + 
286 		              		
287 		              			"Name = " + String.valueOf(getName()
288  	) + " | " + 
289 		              		
290 		              			"Spectator = " + String.valueOf(isSpectator()
291  	) + " | " + 
292 		              		
293 		              			"Action = " + String.valueOf(getAction()
294  	) + " | " + 
295 		              		
296 		              			"Rotation = " + String.valueOf(getRotation()
297  	) + " | " + 
298 		              		
299 		              			"Location = " + String.valueOf(getLocation()
300  	) + " | " + 
301 		              		
302 		              			"Velocity = " + String.valueOf(getVelocity()
303  	) + " | " + 
304 		              		
305 		              			"Team = " + String.valueOf(getTeam()
306  	) + " | " + 
307 		              		
308 		              			"Weapon = " + String.valueOf(getWeapon()
309  	) + " | " + 
310 		              		
311 		              			"Crouched = " + String.valueOf(isCrouched()
312  	) + " | " + 
313 		              		
314 		              			"Firing = " + String.valueOf(getFiring()
315  	) + " | " + 
316 		              		
317 		              			"EmotLeft = " + String.valueOf(getEmotLeft()
318  	) + " | " + 
319 		              		
320 		              			"EmotCenter = " + String.valueOf(getEmotCenter()
321  	) + " | " + 
322 		              		
323 		              			"EmotRight = " + String.valueOf(getEmotRight()
324  	) + " | " + 
325 		              		
326 		              			"Bubble = " + String.valueOf(getBubble()
327  	) + " | " + 
328 		              		
329 		              			"Anim = " + String.valueOf(getAnim()
330  	) + " | " + 
331 		              		
332 				"]";           		
333         }
334  	
335  		
336  		public String toHtmlString() {
337  			return super.toString() + "[<br/>" +
338             	
339 		              			"<b>Id</b> = " + String.valueOf(getId()
340  	) + " <br/> " + 
341 		              		
342 		              			"<b>Name</b> = " + String.valueOf(getName()
343  	) + " <br/> " + 
344 		              		
345 		              			"<b>Spectator</b> = " + String.valueOf(isSpectator()
346  	) + " <br/> " + 
347 		              		
348 		              			"<b>Action</b> = " + String.valueOf(getAction()
349  	) + " <br/> " + 
350 		              		
351 		              			"<b>Rotation</b> = " + String.valueOf(getRotation()
352  	) + " <br/> " + 
353 		              		
354 		              			"<b>Location</b> = " + String.valueOf(getLocation()
355  	) + " <br/> " + 
356 		              		
357 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
358  	) + " <br/> " + 
359 		              		
360 		              			"<b>Team</b> = " + String.valueOf(getTeam()
361  	) + " <br/> " + 
362 		              		
363 		              			"<b>Weapon</b> = " + String.valueOf(getWeapon()
364  	) + " <br/> " + 
365 		              		
366 		              			"<b>Crouched</b> = " + String.valueOf(isCrouched()
367  	) + " <br/> " + 
368 		              		
369 		              			"<b>Firing</b> = " + String.valueOf(getFiring()
370  	) + " <br/> " + 
371 		              		
372 		              			"<b>EmotLeft</b> = " + String.valueOf(getEmotLeft()
373  	) + " <br/> " + 
374 		              		
375 		              			"<b>EmotCenter</b> = " + String.valueOf(getEmotCenter()
376  	) + " <br/> " + 
377 		              		
378 		              			"<b>EmotRight</b> = " + String.valueOf(getEmotRight()
379  	) + " <br/> " + 
380 		              		
381 		              			"<b>Bubble</b> = " + String.valueOf(getBubble()
382  	) + " <br/> " + 
383 		              		
384 		              			"<b>Anim</b> = " + String.valueOf(getAnim()
385  	) + " <br/> " + 
386 		              		
387 				"<br/>]";     
388 		}
389  	
390  		
391  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
392         	
393 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
394 		
395 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=abstract]) ---
396 	        
397 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=abstract]) ---        	            	
398  	
399 		}
400