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=event]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15      
16   		/**
17           *  
18           			Definition of the event HRN.
19           		
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message - sent in synchronous batch (events are cached and then exported in the batch due
25  		to performance issues). 
26  		Maybe another player walking or shooting, maybe a bullet hitting the floor or just a nearby lift going up
27  		or down. If the very same sound is exported repeatedly (same sound, same source), 
28  		it won't be exported more than once per second.
29  	
30           */
31   	public class HearNoise 
32    				extends InfoMessage
33      			implements IWorldEvent, IWorldChangeEvent
34      			
35  	    {
36   	
37      	/** Example how the message looks like - used during parser tests. */
38      	public static final String PROTOTYPE =
39      		"HRN {Source unreal_id}  {Type text}  {Rotation 0,0,0}  {Distance 0} ";
40      
41      	
42      	
43      	/**
44      	 * Parameter-less contructor for the message.
45      	 */
46  		public HearNoise()
47  		{
48  		}
49  	
50      	
51      	
52      	
53      	/**
54  		 * Creates new instance of the message HearNoise.
55  		 * 
56  		Synchronous message - sent in synchronous batch (events are cached and then exported in the batch due
57  		to performance issues). 
58  		Maybe another player walking or shooting, maybe a bullet hitting the floor or just a nearby lift going up
59  		or down. If the very same sound is exported repeatedly (same sound, same source), 
60  		it won't be exported more than once per second.
61  	
62  		 * Corresponding GameBots message
63  		 *   
64  		 *   is
65  		 *   HRN.
66  		 * 
67   	  	 * 
68  		 *   
69  		 *     @param Source 
70  			Unique ID of actor making the noise - may be other player or
71  			some other object in the game.
72  		
73  		 *   
74  		 * 
75  		 *   
76  		 *     @param Type 
77  			What class this actor is - item, projectile, player...
78  		
79  		 *   
80  		 * 
81  		 *   
82  		 *     @param Rotation 
83  			How should bot rotate if it would like to be in the
84  			direction of the "noisy" actor.
85  		
86  		 *   
87  		 * 
88  		 *   
89  		 *     @param Distance 
90  			How far the noise source is. 
91  		
92  		 *   
93  		 * 
94  		 */
95  		public HearNoise(
96  			UnrealId Source,  String Type,  Rotation Rotation,  double Distance
97  		) {
98  			
99  					this.Source = Source;
100 				
101 					this.Type = Type;
102 				
103 					this.Rotation = Rotation;
104 				
105 					this.Distance = Distance;
106 				
107 		}
108     
109     	/**
110 		 * Cloning constructor from the full message.
111 		 *
112 		 * @param original
113 		 */
114 		public HearNoise(HearNoise original) {		
115 			
116 					this.Source = original.getSource()
117  	;
118 				
119 					this.Type = original.getType()
120  	;
121 				
122 					this.Rotation = original.getRotation()
123  	;
124 				
125 					this.Distance = original.getDistance()
126  	;
127 				
128 			this.SimTime = original.getSimTime();			
129 		}
130 		
131 	   		
132 			protected long SimTime;
133 				
134 			/**
135 			 * Simulation time in MILLI SECONDS !!!
136 			 */	
137 			@Override
138 			public long getSimTime() {
139 				return SimTime;
140 			}
141 						
142 			/**
143 			 * Used by Yylex to slip correct time of the object or programmatically.
144 			 */
145 			protected void setSimTime(long SimTime) {
146 				this.SimTime = SimTime;
147 			}
148 	   	
149     	
150 	    /**
151          * 
152 			Unique ID of actor making the noise - may be other player or
153 			some other object in the game.
154 		 
155          */
156         protected
157          UnrealId Source =
158        	null;
159 	
160  		/**
161          * 
162 			Unique ID of actor making the noise - may be other player or
163 			some other object in the game.
164 		 
165          */
166         public  UnrealId getSource()
167  	 {
168     					return Source;
169     				}
170     			
171     	
172 	    /**
173          * 
174 			What class this actor is - item, projectile, player...
175 		 
176          */
177         protected
178          String Type =
179        	null;
180 	
181  		/**
182          * 
183 			What class this actor is - item, projectile, player...
184 		 
185          */
186         public  String getType()
187  	 {
188     					return Type;
189     				}
190     			
191     	
192 	    /**
193          * 
194 			How should bot rotate if it would like to be in the
195 			direction of the "noisy" actor.
196 		 
197          */
198         protected
199          Rotation Rotation =
200        	null;
201 	
202  		/**
203          * 
204 			How should bot rotate if it would like to be in the
205 			direction of the "noisy" actor.
206 		 
207          */
208         public  Rotation getRotation()
209  	 {
210     					return Rotation;
211     				}
212     			
213     	
214 	    /**
215          * 
216 			How far the noise source is. 
217 		 
218          */
219         protected
220          double Distance =
221        	0;
222 	
223  		/**
224          * 
225 			How far the noise source is. 
226 		 
227          */
228         public  double getDistance()
229  	 {
230     					return Distance;
231     				}
232     			
233  		
234  	    public String toString() {
235             return
236             	super.toString() + "[" +
237             	
238 		              			"Source = " + String.valueOf(getSource()
239  	) + " | " + 
240 		              		
241 		              			"Type = " + String.valueOf(getType()
242  	) + " | " + 
243 		              		
244 		              			"Rotation = " + String.valueOf(getRotation()
245  	) + " | " + 
246 		              		
247 		              			"Distance = " + String.valueOf(getDistance()
248  	) + " | " + 
249 		              		
250 				"]";           		
251         }
252  	
253  		
254  		public String toHtmlString() {
255  			return super.toString() + "[<br/>" +
256             	
257 		              			"<b>Source</b> = " + String.valueOf(getSource()
258  	) + " <br/> " + 
259 		              		
260 		              			"<b>Type</b> = " + String.valueOf(getType()
261  	) + " <br/> " + 
262 		              		
263 		              			"<b>Rotation</b> = " + String.valueOf(getRotation()
264  	) + " <br/> " + 
265 		              		
266 		              			"<b>Distance</b> = " + String.valueOf(getDistance()
267  	) + " <br/> " + 
268 		              		
269 				"<br/>]";     
270 		}
271  	 
272  	    public String toJsonLiteral() {
273             return "HearNoise(null, "
274             		
275                    + ")";
276         }
277  	
278  		
279  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
280         	
281 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
282 		
283 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
284 	        
285 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
286  	
287 		}
288