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  		Synchronous message. Contains the results of automatically
35  		casted rays. One ATR message is for one casted ray. New
36  		automatically casted rays can be defined by ADDRAY command and
37  		removed by REMOVERAY command.
38  	
39                            Corresponding GameBots message is
40                            ATR.
41                        
42               */
43              
44              public class
45              AutoTraceRay
46                      extends GBObjectUpdate
47                  
48  	            	implements IGBWorldObjectEvent, IWorldObject
49  
50              {
51              
52              /**
53                Creates new instance of command AutoTraceRay.
54                
55  		Synchronous message. Contains the results of automatically
56  		casted rays. One ATR message is for one casted ray. New
57  		automatically casted rays can be defined by ADDRAY command and
58  		removed by REMOVERAY command.
59  	Corresponding GameBots message for this command is
60                .
61                    @param Id 
62  			An Id for this ray (should be unique), assigned by the user
63  			when adding ray.
64  		
65                    @param From 
66  			Location from which the ray is emitted.
67  		
68                    @param To 
69  			Location to which the ray is sent.
70  		
71                    @param FastTrace 
72  			True if it is a fast trace, false if not (fast trace is a
73  			bit faster version of UDK ray trace - but provides us
74  			with less information - just true/false if we hit something
75  			on the way or not).
76  		
77                    @param FloorCorrection 
78        If we should correct ray directions accoring floor normal. Note: Has issue - we can't set set rays up or down when correction is active.
79  		
80                    @param Result 
81  			True if it hit something, false if not.
82  		
83                    @param HitNormal 
84  			Vector with normal of the plane we have hit (not sent if
85  			FastTrace is True).
86  		
87                    @param HitLocation 
88  			Vector with location of the collision (not sent if FastTrace
89  			is True).
90  		
91                    @param TraceActors 
92  			If we traced also actors with this ray (actors – moving
93  			things in a game – bots, players, monsters, pickup …) (only
94  			if NOT using FastTrace)
95  		
96                    @param HitId 
97  			Id of the actor we have hit. (Sent if FastTrace is False and
98  			TraceActors is True).
99  		
100               */
101              public AutoTraceRay(
102                 UnrealId Id,  Location From,  Location To,  boolean FastTrace,  boolean FloorCorrection,  boolean Result,  Vector3d HitNormal,  Location HitLocation,  boolean TraceActors,  UnrealId HitId) {
103                     
104                     this.Id = Id;
105                 
106                     this.From = From;
107                 
108                     this.To = To;
109                 
110                     this.FastTrace = FastTrace;
111                 
112                     this.FloorCorrection = FloorCorrection;
113                 
114                     this.Result = Result;
115                 
116                     this.HitNormal = HitNormal;
117                 
118                     this.HitLocation = HitLocation;
119                 
120                     this.TraceActors = TraceActors;
121                 
122                     this.HitId = HitId;
123                 
124                 }
125 
126             
127     	/** Example how the message looks like - used during parser tests. */
128     	public static final String PROTOTYPE =
129     		"ATR {Id unreal_id} {From 0,0,0} {To 0,0,0} {FastTrace False} {FloorCorrection False} {Result False} {HitNormal 0,0,0} {HitLocation 0,0,0} {TraceActors False} {HitId unreal_id}";
130     
131 
132             /////// Properties BEGIN
133             
134         /**
135         
136 			An Id for this ray (should be unique), assigned by the user
137 			when adding ray.
138 		 */
139         protected
140          UnrealId Id =
141         	null;
142 
143         
144         /**
145         
146 			An Id for this ray (should be unique), assigned by the user
147 			when adding ray.
148 		 */
149         public
150         UnrealId getId() {
151             return
152          Id;
153         }
154         
155 
156         
157         /**
158         
159 			Location from which the ray is emitted.
160 		 */
161         protected
162          Location From =
163         	null;
164 
165         
166         /**
167         
168 			Location from which the ray is emitted.
169 		 */
170         public
171         Location getFrom() {
172             return
173          From;
174         }
175         
176 
177         
178         /**
179         
180 			Location to which the ray is sent.
181 		 */
182         protected
183          Location To =
184         	null;
185 
186         
187         /**
188         
189 			Location to which the ray is sent.
190 		 */
191         public
192         Location getTo() {
193             return
194          To;
195         }
196         
197 
198         
199         /**
200         
201 			True if it is a fast trace, false if not (fast trace is a
202 			bit faster version of UDK ray trace - but provides us
203 			with less information - just true/false if we hit something
204 			on the way or not).
205 		 */
206         protected
207          boolean FastTrace =
208         	false;
209 
210         
211         /**
212         
213 			True if it is a fast trace, false if not (fast trace is a
214 			bit faster version of UDK ray trace - but provides us
215 			with less information - just true/false if we hit something
216 			on the way or not).
217 		 */
218         public
219         boolean isFastTrace() {
220             return
221          FastTrace;
222         }
223         
224 
225         
226         /**
227         
228       If we should correct ray directions accoring floor normal. Note: Has issue - we can't set set rays up or down when correction is active.
229 		 */
230         protected
231          boolean FloorCorrection =
232         	false;
233 
234         
235         /**
236         
237       If we should correct ray directions accoring floor normal. Note: Has issue - we can't set set rays up or down when correction is active.
238 		 */
239         public
240         boolean isFloorCorrection() {
241             return
242          FloorCorrection;
243         }
244         
245 
246         
247         /**
248         
249 			True if it hit something, false if not.
250 		 */
251         protected
252          boolean Result =
253         	false;
254 
255         
256         /**
257         
258 			True if it hit something, false if not.
259 		 */
260         public
261         boolean isResult() {
262             return
263          Result;
264         }
265         
266 
267         
268         /**
269         
270 			Vector with normal of the plane we have hit (not sent if
271 			FastTrace is True).
272 		 */
273         protected
274          Vector3d HitNormal =
275         	null;
276 
277         
278         /**
279         
280 			Vector with normal of the plane we have hit (not sent if
281 			FastTrace is True).
282 		 */
283         public
284         Vector3d getHitNormal() {
285             return
286          HitNormal;
287         }
288         
289 
290         
291         /**
292         
293 			Vector with location of the collision (not sent if FastTrace
294 			is True).
295 		 */
296         protected
297          Location HitLocation =
298         	null;
299 
300         
301         /**
302         
303 			Vector with location of the collision (not sent if FastTrace
304 			is True).
305 		 */
306         public
307         Location getHitLocation() {
308             return
309          HitLocation;
310         }
311         
312 
313         
314         /**
315         
316 			If we traced also actors with this ray (actors – moving
317 			things in a game – bots, players, monsters, pickup …) (only
318 			if NOT using FastTrace)
319 		 */
320         protected
321          boolean TraceActors =
322         	false;
323 
324         
325         /**
326         
327 			If we traced also actors with this ray (actors – moving
328 			things in a game – bots, players, monsters, pickup …) (only
329 			if NOT using FastTrace)
330 		 */
331         public
332         boolean isTraceActors() {
333             return
334          TraceActors;
335         }
336         
337 
338         
339         /**
340         
341 			Id of the actor we have hit. (Sent if FastTrace is False and
342 			TraceActors is True).
343 		 */
344         protected
345          UnrealId HitId =
346         	null;
347 
348         
349         /**
350         
351 			Id of the actor we have hit. (Sent if FastTrace is False and
352 			TraceActors is True).
353 		 */
354         public
355         UnrealId getHitId() {
356             return
357          HitId;
358         }
359         
360 
361         
362             /////// Properties END
363 
364             /////// Extra Java code BEGIN
365 
366             	/////// Additional code from xslt BEGIN
367             		
368        							protected double Time = 0;
369 
370        							protected double getTime() {
371        								return Time;
372        							}
373 
374        							protected void setTime(double time) {
375        								this.Time = time;
376        							}
377 
378        							public double getLastSeenTime() {
379        								return Time;
380        							}
381        						
382        					
383        					public ILocalWorldObject getLocal() {
384        						return null;
385        					}
386        					
387        					public ISharedWorldObject getShared() {
388        						return null;
389        					}
390        					
391        					public IStaticWorldObject getStatic() {
392        						return null;
393        					}
394        					
395        					@Override
396        					public long getSimTime() {
397        						return (long)getLastSeenTime();
398        					}
399 
400        					public boolean equals(Object obj) {
401 	                      if (!(obj instanceof AutoTraceRay)) return false;
402 	                      AutoTraceRay cast = (AutoTraceRay)obj;
403 	                      if (this.getId() != null) return this.getId().equals(cast.getId());
404 	                      else return cast.getId() == null;
405 	                    }
406 
407 	                    public int hashCode() {
408 	                      if (getId() != null) return getId().hashCode();
409 	                      return 0;
410 	                    }
411 
412             		
413 
414 
415             	/////// Additional code from xslt END
416 
417 	            /////// Extra Java from XML BEGIN
418             		
419             	/////// Extra Java from XML END
420 
421             /////// Extra Java code END
422 
423             
424 
425             /**
426               * Cloning constructor.
427               */
428              public AutoTraceRay(AutoTraceRay original) {
429                 
430                      this.Id=original.Id;
431                 
432                      this.From=original.From;
433                 
434                      this.To=original.To;
435                 
436                      this.FastTrace=original.FastTrace;
437                 
438                      this.FloorCorrection=original.FloorCorrection;
439                 
440                      this.Result=original.Result;
441                 
442                      this.HitNormal=original.HitNormal;
443                 
444                      this.HitLocation=original.HitLocation;
445                 
446                      this.TraceActors=original.TraceActors;
447                 
448                      this.HitId=original.HitId;
449                 
450              }
451 
452              
453                  /**
454                   * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
455                   */
456 	             public AutoTraceRay() {
457 	             }
458              
459 
460 	    		/**
461 	    		 * Here we save the original object for which this object is an update.
462 	    		 */
463 	    		private IWorldObject orig = null;
464 
465 	            public IWorldObjectUpdateResult update(IWorldObject obj) {
466 		            if(obj == null) {
467 		               orig = this;
468 		               return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
469 		            }
470 		            orig = obj;
471 		            // typecast
472 		            AutoTraceRay  o = (AutoTraceRay)obj;
473 
474 		            boolean updated = false;
475 
476 		            
477                                 if (!SafeEquals.equals(o.From, From)) {
478 		    						o.From=From;
479 		    						updated = true;
480 		    					}
481                             
482                                 if (!SafeEquals.equals(o.To, To)) {
483 		    						o.To=To;
484 		    						updated = true;
485 		    					}
486                             
487 		    					if (o.FastTrace != FastTrace) {
488 		    					    o.FastTrace=FastTrace;
489 		    						updated = true;
490 		    					}
491 		    				
492 		    					if (o.FloorCorrection != FloorCorrection) {
493 		    					    o.FloorCorrection=FloorCorrection;
494 		    						updated = true;
495 		    					}
496 		    				
497 		    					if (o.Result != Result) {
498 		    					    o.Result=Result;
499 		    						updated = true;
500 		    					}
501 		    				
502 		    					if (!SafeEquals.equals(o.HitNormal, HitNormal)) {
503 		    						o.HitNormal=HitNormal;
504 		    						updated = true;
505 		    					}
506 		    				
507                                 if (!SafeEquals.equals(o.HitLocation, HitLocation)) {
508 		    						o.HitLocation=HitLocation;
509 		    						updated = true;
510 		    					}
511                             
512 		    					if (o.TraceActors != TraceActors) {
513 		    					    o.TraceActors=TraceActors;
514 		    						updated = true;
515 		    					}
516 		    				
517 		    					if (!SafeEquals.equals(o.HitId, HitId)) {
518 		    						o.HitId=HitId;
519 		    						updated = true;
520 		    					}
521 		    				
522 								o.Time = Time;
523 							
524 
525 		            if (updated) {
526 		                return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
527 		            } else {
528 		            	return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
529 		            }
530 		        }
531 
532 	            /**
533 	             * Returns original object (if method update() has already been called, for bot-programmer that is always true
534 	             * as the original object is updated and then the event is propagated).
535 	             */
536 		        public IWorldObject getObject() {
537 		            if (orig == null) return this;
538 		            return orig;
539 		        }
540 	        
541 
542                  
543             public String toString() {
544                 return
545                 
546                 		super.toString() + " | " +
547                 		
548 				               "Id = " +
549 				               String.valueOf(Id) + " | " +
550 				            
551 				               "From = " +
552 				               String.valueOf(From) + " | " +
553 				            
554 				               "To = " +
555 				               String.valueOf(To) + " | " +
556 				            
557 				               "FastTrace = " +
558 				               String.valueOf(FastTrace) + " | " +
559 				            
560 				               "FloorCorrection = " +
561 				               String.valueOf(FloorCorrection) + " | " +
562 				            
563 				               "Result = " +
564 				               String.valueOf(Result) + " | " +
565 				            
566 				               "HitNormal = " +
567 				               String.valueOf(HitNormal) + " | " +
568 				            
569 				               "HitLocation = " +
570 				               String.valueOf(HitLocation) + " | " +
571 				            
572 				               "TraceActors = " +
573 				               String.valueOf(TraceActors) + " | " +
574 				            
575 				               "HitId = " +
576 				               String.valueOf(HitId) + " | " +
577 				             "";
578                 	
579              }
580 
581              public String toHtmlString() {
582                 return super.toString() +
583             
584             "<b>Id</b> : " +
585             String.valueOf(Id) +
586             " <br/> " +
587             
588             "<b>From</b> : " +
589             String.valueOf(From) +
590             " <br/> " +
591             
592             "<b>To</b> : " +
593             String.valueOf(To) +
594             " <br/> " +
595             
596             "<b>FastTrace</b> : " +
597             String.valueOf(FastTrace) +
598             " <br/> " +
599             
600             "<b>FloorCorrection</b> : " +
601             String.valueOf(FloorCorrection) +
602             " <br/> " +
603             
604             "<b>Result</b> : " +
605             String.valueOf(Result) +
606             " <br/> " +
607             
608             "<b>HitNormal</b> : " +
609             String.valueOf(HitNormal) +
610             " <br/> " +
611             
612             "<b>HitLocation</b> : " +
613             String.valueOf(HitLocation) +
614             " <br/> " +
615             
616             "<b>TraceActors</b> : " +
617             String.valueOf(TraceActors) +
618             " <br/> " +
619             
620             "<b>HitId</b> : " +
621             String.valueOf(HitId) +
622             " <br/> " +
623              "";
624              }
625 
626              
627              
628              }
629 
630