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 CONFCH.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Asynchronous message. Message sent when the bot configuration
25  		changed - each agent has a lot of parameters affecting his state
26  		in the environment. See each property for the details.
27  	
28           */
29   	public abstract class ConfigChange   
30    				extends 
31    				InfoMessage
32    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
33    						
34  	    {
35   	
36      	/** Example how the message looks like - used during parser tests. */
37      	public static final String PROTOTYPE =
38      		"CONFCH {Id unreal_id}  {BotId unreal_id}  {ManualSpawn False}  {AutoTrace False}  {Name text}  {SpeedMultiplier 0}  {RotationRate 0,0,0}  {Invulnerable False}  {SelfUpdateTime 0}  {VisionTime 0}  {LocUpdateMultiplier 0}  {ShowDebug False}  {ShowFocalPoint False}  {DrawTraceLines False}  {SynchronousOff False}  {AutoPickupOff False}  {Action text} ";
39      
40      	
41      	
42      	/**
43      	 * Parameter-less contructor for the message.
44      	 */
45  		public ConfigChange()
46  		{
47  		}
48  	
49  				// abstract message, it does not have any more constructors				
50  			
51  	   		
52  			protected long SimTime;
53  				
54  			/**
55  			 * Simulation time in MILLI SECONDS !!!
56  			 */	
57  			@Override
58  			public long getSimTime() {
59  				return SimTime;
60  			}
61  						
62  			/**
63  			 * Used by Yylex to slip correct time of the object or programmatically.
64  			 */
65  			protected void setSimTime(long SimTime) {
66  				this.SimTime = SimTime;
67  			}
68  	   	
69   		/**
70           * Id of this config message. This Id is generated from BotId, string "_CONFCH" is added at the end. 
71           */
72          public abstract UnrealId getId()
73   	;
74  		    			
75   		/**
76           * Unique Id of the bot. 
77           */
78          public abstract UnrealId getBotId()
79   	;
80  		    			
81   		/**
82           * 
83  			True if we have to spawn the bot manually after each death
84  		 
85           */
86          public abstract boolean isManualSpawn()
87   	;
88  		    			
89   		/**
90           * 
91  			True if the bot is using auto ray tracing (is provided with
92  			synchronous ATR messages). See ATR messages for more
93  			details.
94  		 
95           */
96          public abstract boolean isAutoTrace()
97   	;
98  		    			
99   		/**
100          * The bot's name. 
101          */
102         public abstract String getName()
103  	;
104 		    			
105  		/**
106          * 
107 			Bots default speed will be multiplied by this number. Ranges from 0.1 to 2 (default, can be set in ini in [GameBots2004.RemoteBot] MaxSpeed).
108 		 
109          */
110         public abstract double getSpeedMultiplier()
111  	;
112 		    			
113  		/**
114          * 
115 			Bot rotation rate. Default rotation rate is: (Pitch=3072,Yaw=60000,Roll=2048) and may be configured in ini file in [GameBots2004.RemoteBot] DefaultRotationRate. (pitch - up/down, yaw - left/right, roll - equivalent of doing a cartwheel)
116 		 
117          */
118         public abstract Rotation getRotationRate()
119  	;
120 		    			
121  		/**
122          * 
123 			If bot is invulnerable (cannot die) or not.
124 		 
125          */
126         public abstract boolean isInvulnerable()
127  	;
128 		    			
129  		/**
130          * 
131 			The delay between two self message synchronous batches 
132 			(can range from 0.01 to 2 seconds). Will be used only if NewSelfBatchProtocol
133 			attribute is set to true in INIT message.
134 		 
135          */
136         public abstract double getSelfUpdateTime()
137  	;
138 		    			
139  		/**
140          * 
141 			The delay between two synchronous batches containing vision updates
142 			(can range from 0.1 to 2 seconds). If NewSelfBatchProtocol
143 			attribute is set to true in INIT message, more batch messages containing only
144 			SELF message will arrive between two vision update batches (containing PLR,PRJ,INV.. messages).
145 		 
146          */
147         public abstract double getVisionTime()
148  	;
149 		    			
150  		/**
151          * 
152 			Holds information how many times faster is exported location update message (UPD) compared to sync. batch, e.g. when this multiplier is set to 5 and vision time is 250 ms, UPD message will arrive every 50 ms.
153 		 
154          */
155         public abstract int getLocUpdateMultiplier()
156  	;
157 		    			
158  		/**
159          * 
160 			If some additional debug information will be shown in the
161 			UT2004 server console window.
162 		 
163          */
164         public abstract boolean isShowDebug()
165  	;
166 		    			
167  		/**
168          * 
169 			If true an actor visualizing the location the bot is
170 			actually looking at will appear in the game.
171 		 
172          */
173         public abstract boolean isShowFocalPoint()
174  	;
175 		    			
176  		/**
177          * 
178 			if the GB should draw lines representing the auto ray traces
179 			of the bot (for more information see ATR message).
180 		 
181          */
182         public abstract boolean isDrawTraceLines()
183  	;
184 		    			
185  		/**
186          * 
187 			It informs if sending of all GB synchronous messages is
188 			enabled or disabled.
189 		 
190          */
191         public abstract boolean isSynchronousOff()
192  	;
193 		    			
194  		/**
195          * 
196 			It enables/disables automatic pickup of the bot. If true the items can be picked up through PICK command.
197 		 
198          */
199         public abstract boolean isAutoPickupOff()
200  	;
201 		    			
202  		/**
203          * 
204 			Name of current BDI action.
205 		 
206          */
207         public abstract String getAction()
208  	;
209 		    			
210     	
211     	public static class ConfigChangeUpdate
212      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
213 			private ConfigChange object;
214 			private long time;
215 			private ITeamId teamId;
216 			
217 			public ConfigChangeUpdate
218     (ConfigChange source, long eventTime, ITeamId teamId) {
219 				this.object = source;
220 				this.time = eventTime;
221 				this.teamId = teamId;
222 			}
223 			
224 			/**
225 			 * Simulation time in MILLI SECONDS !!!
226 			 */ 
227 			@Override
228 			public long getSimTime() {
229 				return time;
230 			}
231 	
232 			@Override
233 			public IWorldObject getObject() {
234 				return object;
235 			}
236 	
237 			@Override
238 			public WorldObjectId getId() {
239 				return object.getId();
240 			}
241 	
242 			@Override
243 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
244 				return new ConfigChangeLocalImpl.ConfigChangeLocalUpdate
245     ((ConfigChangeLocal)object.getLocal(), time);
246 			}
247 	
248 			@Override
249 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
250 				return new ConfigChangeSharedImpl.ConfigChangeSharedUpdate
251     ((ConfigChangeShared)object.getShared(), time, teamId);
252 			}
253 	
254 			@Override
255 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
256 				return new ConfigChangeStaticImpl.ConfigChangeStaticUpdate
257     ((ConfigChangeStatic)object.getStatic(), time);
258 			}
259 			
260 		}
261     
262  		
263  	    public String toString() {
264             return
265             	super.toString() + "[" +
266             	
267 		              			"Id = " + String.valueOf(getId()
268  	) + " | " + 
269 		              		
270 		              			"BotId = " + String.valueOf(getBotId()
271  	) + " | " + 
272 		              		
273 		              			"ManualSpawn = " + String.valueOf(isManualSpawn()
274  	) + " | " + 
275 		              		
276 		              			"AutoTrace = " + String.valueOf(isAutoTrace()
277  	) + " | " + 
278 		              		
279 		              			"Name = " + String.valueOf(getName()
280  	) + " | " + 
281 		              		
282 		              			"SpeedMultiplier = " + String.valueOf(getSpeedMultiplier()
283  	) + " | " + 
284 		              		
285 		              			"RotationRate = " + String.valueOf(getRotationRate()
286  	) + " | " + 
287 		              		
288 		              			"Invulnerable = " + String.valueOf(isInvulnerable()
289  	) + " | " + 
290 		              		
291 		              			"SelfUpdateTime = " + String.valueOf(getSelfUpdateTime()
292  	) + " | " + 
293 		              		
294 		              			"VisionTime = " + String.valueOf(getVisionTime()
295  	) + " | " + 
296 		              		
297 		              			"LocUpdateMultiplier = " + String.valueOf(getLocUpdateMultiplier()
298  	) + " | " + 
299 		              		
300 		              			"ShowDebug = " + String.valueOf(isShowDebug()
301  	) + " | " + 
302 		              		
303 		              			"ShowFocalPoint = " + String.valueOf(isShowFocalPoint()
304  	) + " | " + 
305 		              		
306 		              			"DrawTraceLines = " + String.valueOf(isDrawTraceLines()
307  	) + " | " + 
308 		              		
309 		              			"SynchronousOff = " + String.valueOf(isSynchronousOff()
310  	) + " | " + 
311 		              		
312 		              			"AutoPickupOff = " + String.valueOf(isAutoPickupOff()
313  	) + " | " + 
314 		              		
315 		              			"Action = " + String.valueOf(getAction()
316  	) + " | " + 
317 		              		
318 				"]";           		
319         }
320  	
321  		
322  		public String toHtmlString() {
323  			return super.toString() + "[<br/>" +
324             	
325 		              			"<b>Id</b> = " + String.valueOf(getId()
326  	) + " <br/> " + 
327 		              		
328 		              			"<b>BotId</b> = " + String.valueOf(getBotId()
329  	) + " <br/> " + 
330 		              		
331 		              			"<b>ManualSpawn</b> = " + String.valueOf(isManualSpawn()
332  	) + " <br/> " + 
333 		              		
334 		              			"<b>AutoTrace</b> = " + String.valueOf(isAutoTrace()
335  	) + " <br/> " + 
336 		              		
337 		              			"<b>Name</b> = " + String.valueOf(getName()
338  	) + " <br/> " + 
339 		              		
340 		              			"<b>SpeedMultiplier</b> = " + String.valueOf(getSpeedMultiplier()
341  	) + " <br/> " + 
342 		              		
343 		              			"<b>RotationRate</b> = " + String.valueOf(getRotationRate()
344  	) + " <br/> " + 
345 		              		
346 		              			"<b>Invulnerable</b> = " + String.valueOf(isInvulnerable()
347  	) + " <br/> " + 
348 		              		
349 		              			"<b>SelfUpdateTime</b> = " + String.valueOf(getSelfUpdateTime()
350  	) + " <br/> " + 
351 		              		
352 		              			"<b>VisionTime</b> = " + String.valueOf(getVisionTime()
353  	) + " <br/> " + 
354 		              		
355 		              			"<b>LocUpdateMultiplier</b> = " + String.valueOf(getLocUpdateMultiplier()
356  	) + " <br/> " + 
357 		              		
358 		              			"<b>ShowDebug</b> = " + String.valueOf(isShowDebug()
359  	) + " <br/> " + 
360 		              		
361 		              			"<b>ShowFocalPoint</b> = " + String.valueOf(isShowFocalPoint()
362  	) + " <br/> " + 
363 		              		
364 		              			"<b>DrawTraceLines</b> = " + String.valueOf(isDrawTraceLines()
365  	) + " <br/> " + 
366 		              		
367 		              			"<b>SynchronousOff</b> = " + String.valueOf(isSynchronousOff()
368  	) + " <br/> " + 
369 		              		
370 		              			"<b>AutoPickupOff</b> = " + String.valueOf(isAutoPickupOff()
371  	) + " <br/> " + 
372 		              		
373 		              			"<b>Action</b> = " + String.valueOf(getAction()
374  	) + " <br/> " + 
375 		              		
376 				"<br/>]";     
377 		}
378  	
379  	    public String toJsonLiteral() {
380             return "configchange( "
381             		+
382 									(getId()
383  	 == null ? "null" :
384 										"\"" + getId()
385  	.getStringId() + "\"" 
386 									)
387 								+ ", " + 
388 									(getBotId()
389  	 == null ? "null" :
390 										"\"" + getBotId()
391  	.getStringId() + "\"" 
392 									)
393 								+ ", " + 
394 								    String.valueOf(isManualSpawn()
395  	)									
396 								+ ", " + 
397 								    String.valueOf(isAutoTrace()
398  	)									
399 								+ ", " + 
400 									(getName()
401  	 == null ? "null" :
402 										"\"" + getName()
403  	 + "\"" 
404 									)
405 								+ ", " + 
406 								    String.valueOf(getSpeedMultiplier()
407  	)									
408 								+ ", " + 
409 									(getRotationRate()
410  	 == null ? "null" :
411 										"[" + getRotationRate()
412  	.getPitch() + ", " + getRotationRate()
413  	.getYaw() + ", " + getRotationRate()
414  	.getRoll() + "]" 
415 									)								    
416 								+ ", " + 
417 								    String.valueOf(isInvulnerable()
418  	)									
419 								+ ", " + 
420 								    String.valueOf(getSelfUpdateTime()
421  	)									
422 								+ ", " + 
423 								    String.valueOf(getVisionTime()
424  	)									
425 								+ ", " + 
426 								    String.valueOf(getLocUpdateMultiplier()
427  	)									
428 								+ ", " + 
429 								    String.valueOf(isShowDebug()
430  	)									
431 								+ ", " + 
432 								    String.valueOf(isShowFocalPoint()
433  	)									
434 								+ ", " + 
435 								    String.valueOf(isDrawTraceLines()
436  	)									
437 								+ ", " + 
438 								    String.valueOf(isSynchronousOff()
439  	)									
440 								+ ", " + 
441 								    String.valueOf(isAutoPickupOff()
442  	)									
443 								+ ", " + 
444 									(getAction()
445  	 == null ? "null" :
446 										"\"" + getAction()
447  	 + "\"" 
448 									)
449 								
450                    + ")";
451         }
452  	
453  		
454  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
455         	
456 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
457 		
458 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
459 	        
460 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
461  	
462 		}
463