View Javadoc

1   
2               /**
3               IMPORTANT !!!
4   
5               DO NOT EDIT THIS FILE. IT IS GENERATED FROM approriate xml file in xmlresources/gbinfomessages BY
6               THE JavaClassesGenerator.xslt. MODIFY THESE FILES INSTEAD OF THIS ONE.
7   
8               IMPORTANT END !!!
9               */
10              package
11              cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12  	    		import java.util.*;
13      import javax.vecmath.*;
14      import cz.cuni.amis.pogamut.base.communication.messages.*;
15      import cz.cuni.amis.pogamut.base.communication.worldview.*;
16      import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17      import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18      import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19      import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20      import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21      import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22      import cz.cuni.amis.pogamut.udk.communication.messages.*;
23      import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24      import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25      import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26      import cz.cuni.amis.utils.exception.*;
27      import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28      import cz.cuni.amis.utils.SafeEquals;
29      import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30      
31              
32              /**
33                
34  		Both asynchronous and synchronous message. Incoming projectile that we can see.
35  	
36                            Corresponding GameBots message is
37                            PRJ.
38                        
39               */
40              
41              public class
42              IncomingProjectile
43                      extends GBObjectUpdate
44                  
45  	            	implements IGBWorldObjectEvent, IWorldObject
46  
47              {
48              
49              /**
50                Creates new instance of command IncomingProjectile.
51                
52  		Both asynchronous and synchronous message. Incoming projectile that we can see.
53  	Corresponding GameBots message for this command is
54                .
55                    @param Id Unique Id of the projectile.
56                    @param Time Estimated time till impact.
57                    @param Direction 
58  			Which direction projectile is heading to -> orientation
59  			vector.
60  		
61                    @param Location 
62  			Current location of the projectile.
63  		
64                    @param Velocity 
65  			Current velocity vector of the projectile.
66  		
67                    @param Speed 
68  			Current speed of the projectile.
69  		
70                    @param Origin 
71  			Possition of the origin, when combined with direction can
72  			define the line of fire.
73  		
74                    @param DamageRadius 
75  			If the projectile has splash damage, how big it is – in ut
76  			units.
77  		
78                    @param Type 
79  			The class of the projectile (so you know what is flying
80  			against you).
81  		
82                */
83               public IncomingProjectile(
84                  UnrealId Id,  double Time,  Vector3d Direction,  Location Location,  Velocity Velocity,  double Speed,  Location Origin,  double DamageRadius,  String Type) {
85                      
86                      this.Id = Id;
87                  
88                      this.Time = Time;
89                  
90                      this.Direction = Direction;
91                  
92                      this.Location = Location;
93                  
94                      this.Velocity = Velocity;
95                  
96                      this.Speed = Speed;
97                  
98                      this.Origin = Origin;
99                  
100                     this.DamageRadius = DamageRadius;
101                 
102                     this.Type = Type;
103                 
104                 }
105 
106             
107     	/** Example how the message looks like - used during parser tests. */
108     	public static final String PROTOTYPE =
109     		"PRJ {Id unreal_id} {Time 0} {Direction 0,0,0} {Location 0,0,0} {Velocity 0,0,0} {Speed 0} {Origin 0,0,0} {DamageRadius 0} {Type text}";
110     
111 
112             /////// Properties BEGIN
113             
114         /**
115         Unique Id of the projectile. */
116         protected
117          UnrealId Id =
118         	null;
119 
120         
121         /**
122         Unique Id of the projectile. */
123         public
124         UnrealId getId() {
125             return
126          Id;
127         }
128         
129 
130         
131         /**
132         Estimated time till impact. */
133         protected
134          double Time =
135         	0;
136 
137         
138         /**
139         Estimated time till impact. */
140         public
141         double getTime() {
142             return
143          Time;
144         }
145         
146 
147         
148         /**
149         
150 			Which direction projectile is heading to -> orientation
151 			vector.
152 		 */
153         protected
154          Vector3d Direction =
155         	null;
156 
157         
158         /**
159         
160 			Which direction projectile is heading to -> orientation
161 			vector.
162 		 */
163         public
164         Vector3d getDirection() {
165             return
166          Direction;
167         }
168         
169 
170         
171         /**
172         
173 			Current location of the projectile.
174 		 */
175         protected
176          Location Location =
177         	null;
178 
179         
180         /**
181         
182 			Current location of the projectile.
183 		 */
184         public
185         Location getLocation() {
186             return
187          Location;
188         }
189         
190 
191         
192         /**
193         
194 			Current velocity vector of the projectile.
195 		 */
196         protected
197          Velocity Velocity =
198         	null;
199 
200         
201         /**
202         
203 			Current velocity vector of the projectile.
204 		 */
205         public
206         Velocity getVelocity() {
207             return
208          Velocity;
209         }
210         
211 
212         
213         /**
214         
215 			Current speed of the projectile.
216 		 */
217         protected
218          double Speed =
219         	0;
220 
221         
222         /**
223         
224 			Current speed of the projectile.
225 		 */
226         public
227         double getSpeed() {
228             return
229          Speed;
230         }
231         
232 
233         
234         /**
235         
236 			Possition of the origin, when combined with direction can
237 			define the line of fire.
238 		 */
239         protected
240          Location Origin =
241         	null;
242 
243         
244         /**
245         
246 			Possition of the origin, when combined with direction can
247 			define the line of fire.
248 		 */
249         public
250         Location getOrigin() {
251             return
252          Origin;
253         }
254         
255 
256         
257         /**
258         
259 			If the projectile has splash damage, how big it is – in ut
260 			units.
261 		 */
262         protected
263          double DamageRadius =
264         	0;
265 
266         
267         /**
268         
269 			If the projectile has splash damage, how big it is – in ut
270 			units.
271 		 */
272         public
273         double getDamageRadius() {
274             return
275          DamageRadius;
276         }
277         
278 
279         
280         /**
281         
282 			The class of the projectile (so you know what is flying
283 			against you).
284 		 */
285         protected
286          String Type =
287         	null;
288 
289         
290         /**
291         
292 			The class of the projectile (so you know what is flying
293 			against you).
294 		 */
295         public
296         String getType() {
297             return
298          Type;
299         }
300         
301 
302         
303             /////// Properties END
304 
305             /////// Extra Java code BEGIN
306 
307             	/////// Additional code from xslt BEGIN
308             		
309        							protected void setTime(double time) {
310        								this.Time = time;
311        							}
312 
313        							public double getLastSeenTime() {
314        								return Time;
315        							}
316        						
317        					
318        					public ILocalWorldObject getLocal() {
319        						return null;
320        					}
321        					
322        					public ISharedWorldObject getShared() {
323        						return null;
324        					}
325        					
326        					public IStaticWorldObject getStatic() {
327        						return null;
328        					}
329        					
330        					@Override
331        					public long getSimTime() {
332        						return (long)getLastSeenTime();
333        					}
334 
335        					public boolean equals(Object obj) {
336 	                      if (!(obj instanceof IncomingProjectile)) return false;
337 	                      IncomingProjectile cast = (IncomingProjectile)obj;
338 	                      if (this.getId() != null) return this.getId().equals(cast.getId());
339 	                      else return cast.getId() == null;
340 	                    }
341 
342 	                    public int hashCode() {
343 	                      if (getId() != null) return getId().hashCode();
344 	                      return 0;
345 	                    }
346 
347             		
348 
349 
350             	/////// Additional code from xslt END
351 
352 	            /////// Extra Java from XML BEGIN
353             		
354             	/////// Extra Java from XML END
355 
356             /////// Extra Java code END
357 
358             
359 
360             /**
361               * Cloning constructor.
362               */
363              public IncomingProjectile(IncomingProjectile original) {
364                 
365                      this.Id=original.Id;
366                 
367                      this.Time=original.Time;
368                 
369                      this.Direction=original.Direction;
370                 
371                      this.Location=original.Location;
372                 
373                      this.Velocity=original.Velocity;
374                 
375                      this.Speed=original.Speed;
376                 
377                      this.Origin=original.Origin;
378                 
379                      this.DamageRadius=original.DamageRadius;
380                 
381                      this.Type=original.Type;
382                 
383              }
384 
385              
386                  /**
387                   * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
388                   */
389 	             public IncomingProjectile() {
390 	             }
391              
392 
393 	    		/**
394 	    		 * Here we save the original object for which this object is an update.
395 	    		 */
396 	    		private IWorldObject orig = null;
397 
398 	            public IWorldObjectUpdateResult update(IWorldObject obj) {
399 		            if(obj == null) {
400 		               orig = this;
401 		               return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
402 		            }
403 		            orig = obj;
404 		            // typecast
405 		            IncomingProjectile  o = (IncomingProjectile)obj;
406 
407 		            boolean updated = false;
408 
409 		            
410 
411 		            if (updated) {
412 		                return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
413 		            } else {
414 		            	return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
415 		            }
416 		        }
417 
418 	            /**
419 	             * Returns original object (if method update() has already been called, for bot-programmer that is always true
420 	             * as the original object is updated and then the event is propagated).
421 	             */
422 		        public IWorldObject getObject() {
423 		            if (orig == null) return this;
424 		            return orig;
425 		        }
426 	        
427 
428                  
429             public String toString() {
430                 return
431                 
432                 		super.toString() + " | " +
433                 		
434 				               "Id = " +
435 				               String.valueOf(Id) + " | " +
436 				            
437 				               "Time = " +
438 				               String.valueOf(Time) + " | " +
439 				            
440 				               "Direction = " +
441 				               String.valueOf(Direction) + " | " +
442 				            
443 				               "Location = " +
444 				               String.valueOf(Location) + " | " +
445 				            
446 				               "Velocity = " +
447 				               String.valueOf(Velocity) + " | " +
448 				            
449 				               "Speed = " +
450 				               String.valueOf(Speed) + " | " +
451 				            
452 				               "Origin = " +
453 				               String.valueOf(Origin) + " | " +
454 				            
455 				               "DamageRadius = " +
456 				               String.valueOf(DamageRadius) + " | " +
457 				            
458 				               "Type = " +
459 				               String.valueOf(Type) + " | " +
460 				             "";
461                 	
462              }
463 
464              public String toHtmlString() {
465                 return super.toString() +
466             
467             "<b>Id</b> : " +
468             String.valueOf(Id) +
469             " <br/> " +
470             
471             "<b>Time</b> : " +
472             String.valueOf(Time) +
473             " <br/> " +
474             
475             "<b>Direction</b> : " +
476             String.valueOf(Direction) +
477             " <br/> " +
478             
479             "<b>Location</b> : " +
480             String.valueOf(Location) +
481             " <br/> " +
482             
483             "<b>Velocity</b> : " +
484             String.valueOf(Velocity) +
485             " <br/> " +
486             
487             "<b>Speed</b> : " +
488             String.valueOf(Speed) +
489             " <br/> " +
490             
491             "<b>Origin</b> : " +
492             String.valueOf(Origin) +
493             " <br/> " +
494             
495             "<b>DamageRadius</b> : " +
496             String.valueOf(DamageRadius) +
497             " <br/> " +
498             
499             "<b>Type</b> : " +
500             String.valueOf(Type) +
501             " <br/> " +
502              "";
503              }
504 
505              
506              
507              }
508 
509