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}  {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 			If some additional debug information will be shown in the
153 			UT2004 server console window.
154 		 
155          */
156         public abstract boolean isShowDebug()
157  	;
158 		    			
159  		/**
160          * 
161 			If true an actor visualizing the location the bot is
162 			actually looking at will appear in the game.
163 		 
164          */
165         public abstract boolean isShowFocalPoint()
166  	;
167 		    			
168  		/**
169          * 
170 			if the GB should draw lines representing the auto ray traces
171 			of the bot (for more information see ATR message).
172 		 
173          */
174         public abstract boolean isDrawTraceLines()
175  	;
176 		    			
177  		/**
178          * 
179 			It informs if sending of all GB synchronous messages is
180 			enabled or disabled.
181 		 
182          */
183         public abstract boolean isSynchronousOff()
184  	;
185 		    			
186  		/**
187          * 
188 			It enables/disables automatic pickup of the bot. If true the items can be picked up through PICK command.
189 		 
190          */
191         public abstract boolean isAutoPickupOff()
192  	;
193 		    			
194  		/**
195          * 
196 			Name of current BDI action.
197 		 
198          */
199         public abstract String getAction()
200  	;
201 		    			
202     	
203     	public static class ConfigChangeUpdate
204      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
205 			private ConfigChange object;
206 			private long time;
207 			private ITeamId teamId;
208 			
209 			public ConfigChangeUpdate
210     (ConfigChange source, long eventTime, ITeamId teamId) {
211 				this.object = source;
212 				this.time = eventTime;
213 				this.teamId = teamId;
214 			}
215 			
216 			/**
217 			 * Simulation time in MILLI SECONDS !!!
218 			 */ 
219 			@Override
220 			public long getSimTime() {
221 				return time;
222 			}
223 	
224 			@Override
225 			public IWorldObject getObject() {
226 				return object;
227 			}
228 	
229 			@Override
230 			public WorldObjectId getId() {
231 				return object.getId();
232 			}
233 	
234 			@Override
235 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
236 				return new ConfigChangeLocalImpl.ConfigChangeLocalUpdate
237     ((ConfigChangeLocal)object.getLocal(), time);
238 			}
239 	
240 			@Override
241 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
242 				return new ConfigChangeSharedImpl.ConfigChangeSharedUpdate
243     ((ConfigChangeShared)object.getShared(), time, teamId);
244 			}
245 	
246 			@Override
247 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
248 				return new ConfigChangeStaticImpl.ConfigChangeStaticUpdate
249     ((ConfigChangeStatic)object.getStatic(), time);
250 			}
251 			
252 		}
253     
254  		
255  	    public String toString() {
256             return
257             	super.toString() + "[" +
258             	
259 		              			"Id = " + String.valueOf(getId()
260  	) + " | " + 
261 		              		
262 		              			"BotId = " + String.valueOf(getBotId()
263  	) + " | " + 
264 		              		
265 		              			"ManualSpawn = " + String.valueOf(isManualSpawn()
266  	) + " | " + 
267 		              		
268 		              			"AutoTrace = " + String.valueOf(isAutoTrace()
269  	) + " | " + 
270 		              		
271 		              			"Name = " + String.valueOf(getName()
272  	) + " | " + 
273 		              		
274 		              			"SpeedMultiplier = " + String.valueOf(getSpeedMultiplier()
275  	) + " | " + 
276 		              		
277 		              			"RotationRate = " + String.valueOf(getRotationRate()
278  	) + " | " + 
279 		              		
280 		              			"Invulnerable = " + String.valueOf(isInvulnerable()
281  	) + " | " + 
282 		              		
283 		              			"SelfUpdateTime = " + String.valueOf(getSelfUpdateTime()
284  	) + " | " + 
285 		              		
286 		              			"VisionTime = " + String.valueOf(getVisionTime()
287  	) + " | " + 
288 		              		
289 		              			"ShowDebug = " + String.valueOf(isShowDebug()
290  	) + " | " + 
291 		              		
292 		              			"ShowFocalPoint = " + String.valueOf(isShowFocalPoint()
293  	) + " | " + 
294 		              		
295 		              			"DrawTraceLines = " + String.valueOf(isDrawTraceLines()
296  	) + " | " + 
297 		              		
298 		              			"SynchronousOff = " + String.valueOf(isSynchronousOff()
299  	) + " | " + 
300 		              		
301 		              			"AutoPickupOff = " + String.valueOf(isAutoPickupOff()
302  	) + " | " + 
303 		              		
304 		              			"Action = " + String.valueOf(getAction()
305  	) + " | " + 
306 		              		
307 				"]";           		
308         }
309  	
310  		
311  		public String toHtmlString() {
312  			return super.toString() + "[<br/>" +
313             	
314 		              			"<b>Id</b> = " + String.valueOf(getId()
315  	) + " <br/> " + 
316 		              		
317 		              			"<b>BotId</b> = " + String.valueOf(getBotId()
318  	) + " <br/> " + 
319 		              		
320 		              			"<b>ManualSpawn</b> = " + String.valueOf(isManualSpawn()
321  	) + " <br/> " + 
322 		              		
323 		              			"<b>AutoTrace</b> = " + String.valueOf(isAutoTrace()
324  	) + " <br/> " + 
325 		              		
326 		              			"<b>Name</b> = " + String.valueOf(getName()
327  	) + " <br/> " + 
328 		              		
329 		              			"<b>SpeedMultiplier</b> = " + String.valueOf(getSpeedMultiplier()
330  	) + " <br/> " + 
331 		              		
332 		              			"<b>RotationRate</b> = " + String.valueOf(getRotationRate()
333  	) + " <br/> " + 
334 		              		
335 		              			"<b>Invulnerable</b> = " + String.valueOf(isInvulnerable()
336  	) + " <br/> " + 
337 		              		
338 		              			"<b>SelfUpdateTime</b> = " + String.valueOf(getSelfUpdateTime()
339  	) + " <br/> " + 
340 		              		
341 		              			"<b>VisionTime</b> = " + String.valueOf(getVisionTime()
342  	) + " <br/> " + 
343 		              		
344 		              			"<b>ShowDebug</b> = " + String.valueOf(isShowDebug()
345  	) + " <br/> " + 
346 		              		
347 		              			"<b>ShowFocalPoint</b> = " + String.valueOf(isShowFocalPoint()
348  	) + " <br/> " + 
349 		              		
350 		              			"<b>DrawTraceLines</b> = " + String.valueOf(isDrawTraceLines()
351  	) + " <br/> " + 
352 		              		
353 		              			"<b>SynchronousOff</b> = " + String.valueOf(isSynchronousOff()
354  	) + " <br/> " + 
355 		              		
356 		              			"<b>AutoPickupOff</b> = " + String.valueOf(isAutoPickupOff()
357  	) + " <br/> " + 
358 		              		
359 		              			"<b>Action</b> = " + String.valueOf(getAction()
360  	) + " <br/> " + 
361 		              		
362 				"<br/>]";     
363 		}
364  	
365  	    public String toJsonLiteral() {
366             return "configchange( "
367             		+
368 									(getId()
369  	 == null ? "null" :
370 										"\"" + getId()
371  	.getStringId() + "\"" 
372 									)
373 								+ ", " + 
374 									(getBotId()
375  	 == null ? "null" :
376 										"\"" + getBotId()
377  	.getStringId() + "\"" 
378 									)
379 								+ ", " + 
380 								    String.valueOf(isManualSpawn()
381  	)									
382 								+ ", " + 
383 								    String.valueOf(isAutoTrace()
384  	)									
385 								+ ", " + 
386 									(getName()
387  	 == null ? "null" :
388 										"\"" + getName()
389  	 + "\"" 
390 									)
391 								+ ", " + 
392 								    String.valueOf(getSpeedMultiplier()
393  	)									
394 								+ ", " + 
395 									(getRotationRate()
396  	 == null ? "null" :
397 										"[" + getRotationRate()
398  	.getPitch() + ", " + getRotationRate()
399  	.getYaw() + ", " + getRotationRate()
400  	.getRoll() + "]" 
401 									)								    
402 								+ ", " + 
403 								    String.valueOf(isInvulnerable()
404  	)									
405 								+ ", " + 
406 								    String.valueOf(getSelfUpdateTime()
407  	)									
408 								+ ", " + 
409 								    String.valueOf(getVisionTime()
410  	)									
411 								+ ", " + 
412 								    String.valueOf(isShowDebug()
413  	)									
414 								+ ", " + 
415 								    String.valueOf(isShowFocalPoint()
416  	)									
417 								+ ", " + 
418 								    String.valueOf(isDrawTraceLines()
419  	)									
420 								+ ", " + 
421 								    String.valueOf(isSynchronousOff()
422  	)									
423 								+ ", " + 
424 								    String.valueOf(isAutoPickupOff()
425  	)									
426 								+ ", " + 
427 									(getAction()
428  	 == null ? "null" :
429 										"\"" + getAction()
430  	 + "\"" 
431 									)
432 								
433                    + ")";
434         }
435  	
436  		
437  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
438         	
439 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
440 		
441 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
442 	        
443 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
444  	
445 		}
446