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 PRJ.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Both asynchronous and synchronous message. Incoming projectile that we can see.
25  	
26           */
27   	public abstract class IncomingProjectile   
28    				extends 
29    				InfoMessage
30    						implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31    						
32  	    {
33   	
34      	/** Example how the message looks like - used during parser tests. */
35      	public static final String PROTOTYPE =
36      		"PRJ {Id unreal_id}  {ImpactTime 0}  {Direction 0,0,0}  {Location 0,0,0}  {Velocity 0,0,0}  {Speed 0}  {Origin 0,0,0}  {DamageRadius 0}  {Type text} ";
37      
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public IncomingProjectile()
44  		{
45  		}
46  	
47  				// abstract message, it does not have any more constructors				
48  			
49  	   		
50  			protected long SimTime;
51  				
52  			/**
53  			 * Simulation time in MILLI SECONDS !!!
54  			 */	
55  			@Override
56  			public long getSimTime() {
57  				return SimTime;
58  			}
59  						
60  			/**
61  			 * Used by Yylex to slip correct time of the object or programmatically.
62  			 */
63  			protected void setSimTime(long SimTime) {
64  				this.SimTime = SimTime;
65  			}
66  	   	
67   		/**
68           * Unique Id of the projectile. 
69           */
70          public abstract UnrealId getId()
71   	;
72  		    			
73   		/**
74           * Estimated time till impact. 
75           */
76          public abstract double getImpactTime()
77   	;
78  		    			
79   		/**
80           * 
81  			Which direction projectile is heading to -> orientation
82  			vector.
83  		 
84           */
85          public abstract Vector3d getDirection()
86   	;
87  		    			
88   		/**
89           * 
90  			Current location of the projectile.
91  		 
92           */
93          public abstract Location getLocation()
94   	;
95  		    			
96   		/**
97           * 
98  			Current velocity vector of the projectile.
99  		 
100          */
101         public abstract Velocity getVelocity()
102  	;
103 		    			
104  		/**
105          * 
106 			Current speed of the projectile.
107 		 
108          */
109         public abstract double getSpeed()
110  	;
111 		    			
112  		/**
113          * 
114 			Possition of the origin, when combined with direction can
115 			define the line of fire.
116 		 
117          */
118         public abstract Location getOrigin()
119  	;
120 		    			
121  		/**
122          * 
123 			If the projectile has splash damage, how big it is – in ut
124 			units.
125 		 
126          */
127         public abstract double getDamageRadius()
128  	;
129 		    			
130  		/**
131          * 
132 			The class of the projectile (so you know what is flying
133 			against you).
134 		 
135          */
136         public abstract String getType()
137  	;
138 		    			
139     	
140     	public static class IncomingProjectileUpdate
141      extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {	
142 			private IncomingProjectile object;
143 			private long time;
144 			private ITeamId teamId;
145 			
146 			public IncomingProjectileUpdate
147     (IncomingProjectile source, long eventTime, ITeamId teamId) {
148 				this.object = source;
149 				this.time = eventTime;
150 				this.teamId = teamId;
151 			}
152 			
153 			/**
154 			 * Simulation time in MILLI SECONDS !!!
155 			 */ 
156 			@Override
157 			public long getSimTime() {
158 				return time;
159 			}
160 	
161 			@Override
162 			public IWorldObject getObject() {
163 				return object;
164 			}
165 	
166 			@Override
167 			public WorldObjectId getId() {
168 				return object.getId();
169 			}
170 	
171 			@Override
172 			public ILocalWorldObjectUpdatedEvent getLocalEvent() {
173 				return new IncomingProjectileLocalImpl.IncomingProjectileLocalUpdate
174     ((IncomingProjectileLocal)object.getLocal(), time);
175 			}
176 	
177 			@Override
178 			public ISharedWorldObjectUpdatedEvent getSharedEvent() {
179 				return new IncomingProjectileSharedImpl.IncomingProjectileSharedUpdate
180     ((IncomingProjectileShared)object.getShared(), time, teamId);
181 			}
182 	
183 			@Override
184 			public IStaticWorldObjectUpdatedEvent getStaticEvent() {
185 				return new IncomingProjectileStaticImpl.IncomingProjectileStaticUpdate
186     ((IncomingProjectileStatic)object.getStatic(), time);
187 			}
188 			
189 		}
190     
191  		
192  	    public String toString() {
193             return
194             	super.toString() + "[" +
195             	
196 		              			"Id = " + String.valueOf(getId()
197  	) + " | " + 
198 		              		
199 		              			"ImpactTime = " + String.valueOf(getImpactTime()
200  	) + " | " + 
201 		              		
202 		              			"Direction = " + String.valueOf(getDirection()
203  	) + " | " + 
204 		              		
205 		              			"Location = " + String.valueOf(getLocation()
206  	) + " | " + 
207 		              		
208 		              			"Velocity = " + String.valueOf(getVelocity()
209  	) + " | " + 
210 		              		
211 		              			"Speed = " + String.valueOf(getSpeed()
212  	) + " | " + 
213 		              		
214 		              			"Origin = " + String.valueOf(getOrigin()
215  	) + " | " + 
216 		              		
217 		              			"DamageRadius = " + String.valueOf(getDamageRadius()
218  	) + " | " + 
219 		              		
220 		              			"Type = " + String.valueOf(getType()
221  	) + " | " + 
222 		              		
223 				"]";           		
224         }
225  	
226  		
227  		public String toHtmlString() {
228  			return super.toString() + "[<br/>" +
229             	
230 		              			"<b>Id</b> = " + String.valueOf(getId()
231  	) + " <br/> " + 
232 		              		
233 		              			"<b>ImpactTime</b> = " + String.valueOf(getImpactTime()
234  	) + " <br/> " + 
235 		              		
236 		              			"<b>Direction</b> = " + String.valueOf(getDirection()
237  	) + " <br/> " + 
238 		              		
239 		              			"<b>Location</b> = " + String.valueOf(getLocation()
240  	) + " <br/> " + 
241 		              		
242 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
243  	) + " <br/> " + 
244 		              		
245 		              			"<b>Speed</b> = " + String.valueOf(getSpeed()
246  	) + " <br/> " + 
247 		              		
248 		              			"<b>Origin</b> = " + String.valueOf(getOrigin()
249  	) + " <br/> " + 
250 		              		
251 		              			"<b>DamageRadius</b> = " + String.valueOf(getDamageRadius()
252  	) + " <br/> " + 
253 		              		
254 		              			"<b>Type</b> = " + String.valueOf(getType()
255  	) + " <br/> " + 
256 		              		
257 				"<br/>]";     
258 		}
259  	
260  		
261  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
262         	
263 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
264 		
265 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---
266 	        
267 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=abstract]) ---        	            	
268  	
269 		}
270