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 ActionPropertyToken = Tokens.get("Action");
68  	    					
69  	    						public static final Token RotationPropertyToken = Tokens.get("Rotation");
70  	    					
71  	    						public static final Token LocationPropertyToken = Tokens.get("Location");
72  	    					
73  	    						public static final Token VelocityPropertyToken = Tokens.get("Velocity");
74  	    					
75  	    						public static final Token TeamPropertyToken = Tokens.get("Team");
76  	    					
77  	    						public static final Token WeaponPropertyToken = Tokens.get("Weapon");
78  	    					
79  	    						public static final Token CrouchedPropertyToken = Tokens.get("Crouched");
80  	    					
81  	    						public static final Token FiringPropertyToken = Tokens.get("Firing");
82  	    					
83  	    						public static final Token EmotLeftPropertyToken = Tokens.get("EmotLeft");
84  	    					
85  	    						public static final Token EmotCenterPropertyToken = Tokens.get("EmotCenter");
86  	    					
87  	    						public static final Token EmotRightPropertyToken = Tokens.get("EmotRight");
88  	    					
89  	    						public static final Token BubblePropertyToken = Tokens.get("Bubble");
90  	    					
91  	    						public static final Token AnimPropertyToken = Tokens.get("Anim");
92  	    						
93  							
94  							public static final Set<Token> SharedPropertyTokens;
95  	
96  							static {
97  								Set<Token> tokens = new HashSet<Token>();
98  								
99  									tokens.add(NamePropertyToken);
100 								
101 									tokens.add(ActionPropertyToken);
102 								
103 									tokens.add(RotationPropertyToken);
104 								
105 									tokens.add(LocationPropertyToken);
106 								
107 									tokens.add(VelocityPropertyToken);
108 								
109 									tokens.add(TeamPropertyToken);
110 								
111 									tokens.add(WeaponPropertyToken);
112 								
113 									tokens.add(CrouchedPropertyToken);
114 								
115 									tokens.add(FiringPropertyToken);
116 								
117 									tokens.add(EmotLeftPropertyToken);
118 								
119 									tokens.add(EmotCenterPropertyToken);
120 								
121 									tokens.add(EmotRightPropertyToken);
122 								
123 									tokens.add(BubblePropertyToken);
124 								
125 									tokens.add(AnimPropertyToken);
126 								
127 								SharedPropertyTokens = Collections.unmodifiableSet(tokens);
128 							}
129 	    				
130 	    			
131 	    				@Override
132 		    			public abstract 
133 		    			PlayerShared clone();
134 		    			
135 						@Override
136 						public Class getCompositeClass() {
137 							return Player.class;
138 						}
139 	
140 						
141 		    			
142  		/**
143          * Unique Id of the player. 
144          */
145         public abstract UnrealId getId()
146  	;
147 		    			
148  		/**
149          * 
150 			Human readable name of the player.
151 		 
152          */
153         public abstract String getName()
154  	;
155 		    			
156  		/**
157          * 
158 			Atomic action this bot is doing (BDI).
159 		 
160          */
161         public abstract String getAction()
162  	;
163 		    			
164  		/**
165          * 
166 			Which direction the player is facing in absolute terms.
167 		 
168          */
169         public abstract Rotation getRotation()
170  	;
171 		    			
172  		/**
173          * 
174 			An absolute location of the player within the map.
175 		 
176          */
177         public abstract Location getLocation()
178  	;
179 		    			
180  		/**
181          * 
182 			Absolute velocity of the player as a vector of movement per one
183 			game second.
184 		 
185          */
186         public abstract Velocity getVelocity()
187  	;
188 		    			
189  		/**
190          * 
191 			What team the player is on. 255 is no team. 0-3 are red,
192 			blue, green, gold in that order.
193 		 
194          */
195         public abstract int getTeam()
196  	;
197 		    			
198  		/**
199          * 
200 			Class of the weapon the player is holding. Weapon strings to
201 			look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
202 			"BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
203 			"RocketLauncher", "Minigun", "LightingGun", "Translocator".
204 			TODO: Look if this is all.
205 		 
206          */
207         public abstract String getWeapon()
208  	;
209 		    			
210  		/**
211          * 
212 			True if the bot is crouched.
213 		 
214          */
215         public abstract boolean isCrouched()
216  	;
217 		    			
218  		/**
219          * 
220 			0 means is not firing, 1 - firing in primary mode, 2 -
221 			firing in secondary mode (alt firing).
222 		 
223          */
224         public abstract int getFiring()
225  	;
226 		    			
227  		/**
228          * 
229 			For UE2. Holds left emoticon of the bot, "None" means none set.
230 		 
231          */
232         public abstract String getEmotLeft()
233  	;
234 		    			
235  		/**
236          * 
237 			For UE2. Holds center emoticon of the bot, "None" means none set.
238 		 
239          */
240         public abstract String getEmotCenter()
241  	;
242 		    			
243  		/**
244          * 
245 			For UE2. Holds right emoticon of the bot, "None" means none set.
246 		 
247          */
248         public abstract String getEmotRight()
249  	;
250 		    			
251  		/**
252          * 
253 			For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
254 		 
255          */
256         public abstract String getBubble()
257  	;
258 		    			
259  		/**
260          * 
261 			For UE2. Current played animation of the bot.
262 		 
263          */
264         public abstract String getAnim()
265  	;
266 		    			
267  		
268  	    public String toString() {
269             return
270             	super.toString() + "[" +
271             	
272 		              			"Id = " + String.valueOf(getId()
273  	) + " | " + 
274 		              		
275 		              			"Name = " + String.valueOf(getName()
276  	) + " | " + 
277 		              		
278 		              			"Action = " + String.valueOf(getAction()
279  	) + " | " + 
280 		              		
281 		              			"Rotation = " + String.valueOf(getRotation()
282  	) + " | " + 
283 		              		
284 		              			"Location = " + String.valueOf(getLocation()
285  	) + " | " + 
286 		              		
287 		              			"Velocity = " + String.valueOf(getVelocity()
288  	) + " | " + 
289 		              		
290 		              			"Team = " + String.valueOf(getTeam()
291  	) + " | " + 
292 		              		
293 		              			"Weapon = " + String.valueOf(getWeapon()
294  	) + " | " + 
295 		              		
296 		              			"Crouched = " + String.valueOf(isCrouched()
297  	) + " | " + 
298 		              		
299 		              			"Firing = " + String.valueOf(getFiring()
300  	) + " | " + 
301 		              		
302 		              			"EmotLeft = " + String.valueOf(getEmotLeft()
303  	) + " | " + 
304 		              		
305 		              			"EmotCenter = " + String.valueOf(getEmotCenter()
306  	) + " | " + 
307 		              		
308 		              			"EmotRight = " + String.valueOf(getEmotRight()
309  	) + " | " + 
310 		              		
311 		              			"Bubble = " + String.valueOf(getBubble()
312  	) + " | " + 
313 		              		
314 		              			"Anim = " + String.valueOf(getAnim()
315  	) + " | " + 
316 		              		
317 				"]";           		
318         }
319  	
320  		
321  		public String toHtmlString() {
322  			return super.toString() + "[<br/>" +
323             	
324 		              			"<b>Id</b> = " + String.valueOf(getId()
325  	) + " <br/> " + 
326 		              		
327 		              			"<b>Name</b> = " + String.valueOf(getName()
328  	) + " <br/> " + 
329 		              		
330 		              			"<b>Action</b> = " + String.valueOf(getAction()
331  	) + " <br/> " + 
332 		              		
333 		              			"<b>Rotation</b> = " + String.valueOf(getRotation()
334  	) + " <br/> " + 
335 		              		
336 		              			"<b>Location</b> = " + String.valueOf(getLocation()
337  	) + " <br/> " + 
338 		              		
339 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
340  	) + " <br/> " + 
341 		              		
342 		              			"<b>Team</b> = " + String.valueOf(getTeam()
343  	) + " <br/> " + 
344 		              		
345 		              			"<b>Weapon</b> = " + String.valueOf(getWeapon()
346  	) + " <br/> " + 
347 		              		
348 		              			"<b>Crouched</b> = " + String.valueOf(isCrouched()
349  	) + " <br/> " + 
350 		              		
351 		              			"<b>Firing</b> = " + String.valueOf(getFiring()
352  	) + " <br/> " + 
353 		              		
354 		              			"<b>EmotLeft</b> = " + String.valueOf(getEmotLeft()
355  	) + " <br/> " + 
356 		              		
357 		              			"<b>EmotCenter</b> = " + String.valueOf(getEmotCenter()
358  	) + " <br/> " + 
359 		              		
360 		              			"<b>EmotRight</b> = " + String.valueOf(getEmotRight()
361  	) + " <br/> " + 
362 		              		
363 		              			"<b>Bubble</b> = " + String.valueOf(getBubble()
364  	) + " <br/> " + 
365 		              		
366 		              			"<b>Anim</b> = " + String.valueOf(getAnim()
367  	) + " <br/> " + 
368 		              		
369 				"<br/>]";     
370 		}
371  	
372  		
373  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
374         	
375 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
376 		
377 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=abstract]) ---
378 	        
379 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=abstract]) ---        	            	
380  	
381 		}
382