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=composite]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=composite]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              		Composite implementation of the VEH abstract message. It wraps Local/Shared/Static parts in single object
19              		allowing to presenting a nice facade for users.
20              	
21           *
22           *  <p></p><p></p>
23           *  Complete message documentation:               
24           *  
25  		Synchronous message. Holds vehicles we see. Id for vehicles doesn't work, so 
26  		this message is without Id. We can join vehicles by ENTER command if we are 
27  		close enough - ussually 100 ut units or less. Note: Vehicle support is 
28  		in aplha testing right now.
29  	
30           */
31   	public class VehicleCompositeImpl 
32    				extends Vehicle
33  	    {
34   	
35      	
36      	
37      	/**
38      	 * Parameter-less contructor for the message.
39      	 */
40  		public VehicleCompositeImpl()
41  		{
42  		}
43  	
44  		
45  		/**
46  		 * Composite-impl constructor. It assembles the message from its three fragments - local/shared/static.
47  		 *
48  		 * @param partLocal local-part of the message
49  		 * @param partShared shared-part of the message
50  		 * @param partStatic static-part of the message
51  		 */
52  		public VehicleCompositeImpl(
53  			VehicleLocalImpl partLocal,
54  			VehicleSharedImpl partShared,
55  			VehicleStaticImpl partStatic
56  		) {
57  			this.partLocal  = partLocal;
58  			this.partShared = partShared;
59  			this.partStatic = partStatic;
60  		}
61  		
62  		/**
63  		 * Cloning constructor.
64  		 *
65  		 * @param original		 
66  		 */
67  		public VehicleCompositeImpl(VehicleCompositeImpl original) {
68  			this.partLocal = partLocal;
69  			this.partShared = partShared;
70  			this.partStatic = partStatic;
71  		}
72      
73     				
74     				@Override
75     				public void setSimTime(long SimTime) {
76  					super.setSimTime(SimTime);
77  				}
78     			
79      			
80      			protected 
81      			VehicleStaticImpl
82      			partStatic;
83      			
84      			@Override
85  				public VehicleStatic getStatic() {
86  					return partStatic;
87  				}
88      			
89      			protected
90      			VehicleLocalImpl
91      			partLocal;
92      	
93      			@Override
94  				public VehicleLocal getLocal() {
95  					return partLocal;
96  				}
97  			
98      			VehicleSharedImpl
99      			partShared;
100     			
101 				@Override
102 				public VehicleShared getShared() {
103 					return partShared;
104 				}
105 			
106 				
107   				
108   					@Override
109     				
110  		/**
111          * Unique Id of the vehicle or vehicle part. 
112          */
113         public  UnrealId getId()
114  	 {
115     					return 
116     						
117     								partStatic.
118     							getId()
119  	;
120     				}
121     			
122   					@Override
123     				
124  		/**
125          * 
126 			Which direction the vehicle is facing in absolute terms.
127 		 
128          */
129         public  Rotation getRotation()
130  	 {
131     					return 
132     						
133     								partShared.
134     							getRotation()
135  	;
136     				}
137     			
138   					@Override
139     				
140  		/**
141          * 
142 			An absolute location of the vehicle within the map.
143 		 
144          */
145         public  Location getLocation()
146  	 {
147     					return 
148     						
149     								partShared.
150     							getLocation()
151  	;
152     				}
153     			
154   					@Override
155     				
156  		/**
157          * 
158 			Absolute velocity of the vehicle as a vector of movement per one
159 			game second.
160 		 
161          */
162         public  Velocity getVelocity()
163  	 {
164     					return 
165     						
166     								partShared.
167     							getVelocity()
168  	;
169     				}
170     			
171   					@Override
172     				
173  		/**
174          * 
175             If the vehicle is in the field of view of the bot.
176          
177          */
178         public  boolean isVisible()
179  	 {
180     					return 
181     						
182     								partLocal.
183     							isVisible()
184  	;
185     				}
186     			
187   					@Override
188     				
189  		/**
190          * 
191 			What team the vehicle is on. 255 is no team. 0-3 are red,
192 			blue, green, gold in that order.
193 		 
194          */
195         public  Integer getTeam()
196  	 {
197     					return 
198     						
199     								partShared.
200     							getTeam()
201  	;
202     				}
203     			
204   					@Override
205     				
206  		/**
207          * 
208 			How much health the vehicle has left. Ranges from 0 to x, depending on the vehicle type.
209 		 
210          */
211         public  Integer getHealth()
212  	 {
213     					return 
214     						
215     								partShared.
216     							getHealth()
217  	;
218     				}
219     			
220   					@Override
221     				
222  		/**
223          * 
224 			How much the vehicle has left. Note: This may be 0 all the time. Maybe the vehicles are not supporting armor.
225 		 
226          */
227         public  Integer getArmor()
228  	 {
229     					return 
230     						
231     								partShared.
232     							getArmor()
233  	;
234     				}
235     			
236   					@Override
237     				
238  		/**
239          * Unique Id of the driver - if any. 
240          */
241         public  UnrealId getDriver()
242  	 {
243     					return 
244     						
245     								partShared.
246     							getDriver()
247  	;
248     				}
249     			
250   					@Override
251     				
252  		/**
253          * 
254             If the vehicle is locked just for its current team.
255          
256          */
257         public  boolean isTeamLocked()
258  	 {
259     					return 
260     						
261     								partShared.
262     							isTeamLocked()
263  	;
264     				}
265     			
266   					@Override
267     				
268  		/**
269          * 
270 			Class of the vehicle. If it is a car, turret etc.
271 		 
272          */
273         public  String getType()
274  	 {
275     					return 
276     						
277     								partStatic.
278     							getType()
279  	;
280     				}
281     			
282  		
283  	    public String toString() {
284             return
285             	super.toString() + "[" +
286             	
287             			"Static = " + String.valueOf(partStatic) + " | Local = " + String.valueOf(partLocal) + " | Shared = " + String.valueOf(partShared) + " ]" +
288             		
289 				"]";           		
290         }
291  	
292  		
293  		public String toHtmlString() {
294  			return super.toString() + "[<br/>" +
295             	
296             			"Static = " + String.valueOf(partStatic) + " <br/> Local = " + String.valueOf(partLocal) + " <br/> Shared = " + String.valueOf(partShared) + " ]" +
297             		
298 				"<br/>]";     
299 		}
300  	
301  		
302  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
303         	
304 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
305 		
306 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=composite+classtype[@name=impl]) ---
307 	        
308 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=composite+classtype[@name=impl]) ---        	            	
309  	
310 		}
311