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=shared]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=shared]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the shared part of the GameBots2004 message VEH.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Holds vehicles we see. Id for vehicles doesn't work, so 
25  		this message is without Id. We can join vehicles by ENTER command if we are 
26  		close enough - ussually 100 ut units or less. Note: Vehicle support is 
27  		in aplha testing right now.
28  	
29           */
30   	public abstract class VehicleShared 
31    						extends InfoMessage
32    						implements ISharedWorldObject
33    						
34  	    		,ILocated
35  	    		,ILocomotive
36  	    		,IRotable
37  	    {
38   	
39      	
40      	
41      	/**
42      	 * Parameter-less contructor for the message.
43      	 */
44  		public VehicleShared()
45  		{
46  		}
47  		
48  				// abstract definition of the shared-part of the message, no more constructors is needed
49  			
50  	   		
51  			protected long SimTime;
52  				
53  			/**
54  			 * Simulation time in MILLI SECONDS !!!
55  			 */	
56  			@Override
57  			public long getSimTime() {
58  				return SimTime;
59  			}
60  						
61  			/**
62  			 * Used by Yylex to slip correct time of the object or programmatically.
63  			 */
64  			protected void setSimTime(long SimTime) {
65  				this.SimTime = SimTime;
66  			}
67  	   	
68  	    						public static final Token RotationPropertyToken = Tokens.get("Rotation");
69  	    					
70  	    						public static final Token LocationPropertyToken = Tokens.get("Location");
71  	    					
72  	    						public static final Token VelocityPropertyToken = Tokens.get("Velocity");
73  	    					
74  	    						public static final Token TeamPropertyToken = Tokens.get("Team");
75  	    					
76  	    						public static final Token HealthPropertyToken = Tokens.get("Health");
77  	    					
78  	    						public static final Token ArmorPropertyToken = Tokens.get("Armor");
79  	    					
80  	    						public static final Token DriverPropertyToken = Tokens.get("Driver");
81  	    					
82  	    						public static final Token TeamLockedPropertyToken = Tokens.get("TeamLocked");
83  	    						
84  							
85  							public static final Set<Token> SharedPropertyTokens;
86  	
87  							static {
88  								Set<Token> tokens = new HashSet<Token>();
89  								
90  									tokens.add(RotationPropertyToken);
91  								
92  									tokens.add(LocationPropertyToken);
93  								
94  									tokens.add(VelocityPropertyToken);
95  								
96  									tokens.add(TeamPropertyToken);
97  								
98  									tokens.add(HealthPropertyToken);
99  								
100 									tokens.add(ArmorPropertyToken);
101 								
102 									tokens.add(DriverPropertyToken);
103 								
104 									tokens.add(TeamLockedPropertyToken);
105 								
106 								SharedPropertyTokens = Collections.unmodifiableSet(tokens);
107 							}
108 	    				
109 	    			
110 	    				@Override
111 		    			public abstract 
112 		    			VehicleShared clone();
113 		    			
114 						@Override
115 						public Class getCompositeClass() {
116 							return Vehicle.class;
117 						}
118 	
119 						
120 		    			
121  		/**
122          * Unique Id of the vehicle or vehicle part. 
123          */
124         public abstract UnrealId getId()
125  	;
126 		    			
127  		/**
128          * 
129 			Which direction the vehicle is facing in absolute terms.
130 		 
131          */
132         public abstract Rotation getRotation()
133  	;
134 		    			
135  		/**
136          * 
137 			An absolute location of the vehicle within the map.
138 		 
139          */
140         public abstract Location getLocation()
141  	;
142 		    			
143  		/**
144          * 
145 			Absolute velocity of the vehicle as a vector of movement per one
146 			game second.
147 		 
148          */
149         public abstract Velocity getVelocity()
150  	;
151 		    			
152  		/**
153          * 
154 			What team the vehicle is on. 255 is no team. 0-3 are red,
155 			blue, green, gold in that order.
156 		 
157          */
158         public abstract Integer getTeam()
159  	;
160 		    			
161  		/**
162          * 
163 			How much health the vehicle has left. Ranges from 0 to x, depending on the vehicle type.
164 		 
165          */
166         public abstract Integer getHealth()
167  	;
168 		    			
169  		/**
170          * 
171 			How much the vehicle has left. Note: This may be 0 all the time. Maybe the vehicles are not supporting armor.
172 		 
173          */
174         public abstract Integer getArmor()
175  	;
176 		    			
177  		/**
178          * Unique Id of the driver - if any. 
179          */
180         public abstract UnrealId getDriver()
181  	;
182 		    			
183  		/**
184          * 
185             If the vehicle is locked just for its current team.
186          
187          */
188         public abstract boolean isTeamLocked()
189  	;
190 		    			
191  		
192  	    public String toString() {
193             return
194             	super.toString() + "[" +
195             	
196 		              			"Id = " + String.valueOf(getId()
197  	) + " | " + 
198 		              		
199 		              			"Rotation = " + String.valueOf(getRotation()
200  	) + " | " + 
201 		              		
202 		              			"Location = " + String.valueOf(getLocation()
203  	) + " | " + 
204 		              		
205 		              			"Velocity = " + String.valueOf(getVelocity()
206  	) + " | " + 
207 		              		
208 		              			"Team = " + String.valueOf(getTeam()
209  	) + " | " + 
210 		              		
211 		              			"Health = " + String.valueOf(getHealth()
212  	) + " | " + 
213 		              		
214 		              			"Armor = " + String.valueOf(getArmor()
215  	) + " | " + 
216 		              		
217 		              			"Driver = " + String.valueOf(getDriver()
218  	) + " | " + 
219 		              		
220 		              			"TeamLocked = " + String.valueOf(isTeamLocked()
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>Rotation</b> = " + String.valueOf(getRotation()
234  	) + " <br/> " + 
235 		              		
236 		              			"<b>Location</b> = " + String.valueOf(getLocation()
237  	) + " <br/> " + 
238 		              		
239 		              			"<b>Velocity</b> = " + String.valueOf(getVelocity()
240  	) + " <br/> " + 
241 		              		
242 		              			"<b>Team</b> = " + String.valueOf(getTeam()
243  	) + " <br/> " + 
244 		              		
245 		              			"<b>Health</b> = " + String.valueOf(getHealth()
246  	) + " <br/> " + 
247 		              		
248 		              			"<b>Armor</b> = " + String.valueOf(getArmor()
249  	) + " <br/> " + 
250 		              		
251 		              			"<b>Driver</b> = " + String.valueOf(getDriver()
252  	) + " <br/> " + 
253 		              		
254 		              			"<b>TeamLocked</b> = " + String.valueOf(isTeamLocked()
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=shared+classtype[@name=abstract]) ---
266 	        
267 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=abstract]) ---        	            	
268  	
269 		}
270