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=local]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=local]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              				Implementation of the local part of the GameBots2004 message NAV.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message - however only NavPoints marking item pickup locations are exported synchronously. Other NavPoints are not exported synchronously at all, even if the bot can actually see them (but note that ALL NavPoints are exported in the handshake between bot and the server). Exporting NavPoints synchronously took a lot of UT server resources with limited information gain (in Pogamut there is now available visibility matrix holding static information which points can be seen from other points). NavPoint carries information about UT navigation point - location, paths and some additional information are stored there (if it is an ambush point, or sniper point, etc.).
25  	
26           */
27   	public class NavPointLocalImpl 
28    						extends
29    						NavPointLocal
30  	    {
31   	
32      	
33      	
34      	/**
35      	 * Parameter-less contructor for the message.
36      	 */
37  		public NavPointLocalImpl()
38  		{
39  		}
40  	
41      	
42      	
43      	
44      	/**
45  		 * Creates new instance of the message NavPoint.
46  		 * 
47  		Synchronous message - however only NavPoints marking item pickup locations are exported synchronously. Other NavPoints are not exported synchronously at all, even if the bot can actually see them (but note that ALL NavPoints are exported in the handshake between bot and the server). Exporting NavPoints synchronously took a lot of UT server resources with limited information gain (in Pogamut there is now available visibility matrix holding static information which points can be seen from other points). NavPoint carries information about UT navigation point - location, paths and some additional information are stored there (if it is an ambush point, or sniper point, etc.).
48  	
49  		 * Corresponding GameBots message
50  		 *   (local part)
51  		 *   is
52  		 *   NAV.
53  		 * 
54   	  	 * 
55  		 *   
56  		 *     @param Id 
57  			A unique Id of this navigation point assigned by the game.
58  		
59  		 *   
60  		 * 
61  		 *   
62  		 * 
63  		 *   
64  		 * 
65  		 *   
66  		 *     @param Visible 
67  			If the point is in the field of view of the bot.
68  		
69  		 *   
70  		 * 
71  		 *   
72  		 * 
73  		 *   
74  		 * 
75  		 *   
76  		 * 
77  		 *   
78  		 * 
79  		 *   
80  		 * 
81  		 *   
82  		 * 
83  		 *   
84  		 * 
85  		 *   
86  		 * 
87  		 *   
88  		 * 
89  		 *   
90  		 * 
91  		 *   
92  		 * 
93  		 *   
94  		 * 
95  		 *   
96  		 * 
97  		 *   
98  		 * 
99  		 *   
100 		 * 
101 		 *   
102 		 * 
103 		 *   
104 		 * 
105 		 *   
106 		 * 
107 		 *   
108 		 * 
109 		 *   
110 		 * 
111 		 *   
112 		 * 
113 		 *   
114 		 * 
115 		 *   
116 		 * 
117 		 *   
118 		 * 
119 		 *   
120 		 * 
121 		 *   
122 		 * 
123 		 *   
124 		 * 
125 		 *   
126 		 * 
127 		 */
128 		public NavPointLocalImpl(
129 			UnrealId Id,  boolean Visible
130 		) {
131 			
132 					this.Id = Id;
133 				
134 					this.Visible = Visible;
135 				
136 		}
137     
138     	/**
139 		 * Cloning constructor from the full message.
140 		 *
141 		 * @param original
142 		 */
143 		public NavPointLocalImpl(NavPoint original) {		
144 			
145 					this.Id = original.getId()
146  	;
147 				
148 					this.Visible = original.isVisible()
149  	;
150 				
151 			this.SimTime = original.getSimTime();			
152 		}
153 		
154 		/**
155 		 * Cloning constructor from the full message.
156 		 *
157 		 * @param original
158 		 */
159 		public NavPointLocalImpl(NavPointLocalImpl original) {		
160 			
161 					this.Id = original.getId()
162  	;
163 				
164 					this.Visible = original.isVisible()
165  	;
166 				
167 			this.SimTime = original.getSimTime();
168 		}
169 		
170 			/**
171 			 * Cloning constructor from the message part.
172 			 *
173 			 * @param original
174 			 */
175 			public NavPointLocalImpl(NavPointLocal original) {
176 				
177 						this.Id = original.getId()
178  	;
179 					
180 						this.Visible = original.isVisible()
181  	;
182 					
183 			}
184 		
185    				
186    				@Override
187    				public void setSimTime(long SimTime) {
188 					super.setSimTime(SimTime);
189 				}
190    			
191 	    				@Override
192 	    				public 
193 	    				NavPointLocalImpl clone() {
194 	    					return new 
195 	    					NavPointLocalImpl(this);
196 	    				}
197 	    				
198 	    				
199     	
200 	    /**
201          * 
202 			A unique Id of this navigation point assigned by the game.
203 		 
204          */
205         protected
206          UnrealId Id =
207        	null;
208 	
209  		/**
210          * 
211 			A unique Id of this navigation point assigned by the game.
212 		 
213          */
214         public  UnrealId getId()
215  	 {
216 				    					return Id;
217 				    				}
218 				    			
219     	
220 	    /**
221          * 
222 			If the point is in the field of view of the bot.
223 		 
224          */
225         protected
226          boolean Visible =
227        	false;
228 	
229  		/**
230          * 
231 			If the point is in the field of view of the bot.
232 		 
233          */
234         public  boolean isVisible()
235  	 {
236 				    					return Visible;
237 				    				}
238 				    			
239     	
240     	
241     	
242     	
243     	public NavPointLocalImpl getLocal() {
244 			return this;
245     	}
246 		public ISharedWorldObject getShared() {
247 		 	throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
248 		}
249 		public IStaticWorldObject getStatic() {
250 		    throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
251 		}
252  	
253 		public static class NavPointLocalUpdate
254      implements ILocalWorldObjectUpdatedEvent, IGBWorldObjectEvent
255 		{
256 			protected long time;
257 			
258 			protected NavPointLocal data = null; //contains object data for this update
259 			
260 			public NavPointLocalUpdate
261     (NavPointLocal moverLocal, long time)
262 			{
263 				this.data = moverLocal;
264 				this.time = time;
265 			}
266 			
267 			@Override
268 			public IWorldObjectUpdateResult<ILocalWorldObject> update(
269 					ILocalWorldObject object) 
270 			{
271 				if ( object == null)
272 				{
273 					data = new NavPointLocalImpl(data); //we always return Impl object
274 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
275 				}
276 				if ( object instanceof NavPointLocalImpl )
277 				{
278 					NavPointLocalImpl toUpdate = (NavPointLocalImpl)object;
279 					
280 					boolean updated = false;
281 					
282 					// UPDATING LOCAL PROPERTIES
283 					
284 				if (toUpdate.Visible != data.isVisible()
285  	) {
286 				    toUpdate.Visible=data.isVisible()
287  	;
288 					updated = true;
289 				}
290 			
291 					
292 					data = toUpdate; //the updating has finished
293 					
294 					if ( updated )
295 					{
296 						toUpdate.SimTime = this.time;
297 						return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, data);
298 					}
299 					
300 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
301 				}
302 				throw new PogamutException("Unsupported object type for update. Expected NavPointLocalImpl for object " + object.getId() +", not object of class " + object.getClass().getSimpleName() + ".", this);
303 			}
304 	
305 			/**
306 			 * Simulation time in MILLI SECONDS !!!
307 			 */
308 			@Override
309 			public long getSimTime() {
310 				return this.time;
311 			}
312 	
313 			@Override
314 			public IWorldObject getObject() {
315 				return data;
316 			}
317 	
318 			@Override
319 			public WorldObjectId getId() {
320 				return data.getId();
321 			}
322 			
323 		}	
324  	
325  		
326  	    public String toString() {
327             return
328             	super.toString() + "[" +
329             	
330 		              			"Id = " + String.valueOf(getId()
331  	) + " | " + 
332 		              		
333 		              			"Visible = " + String.valueOf(isVisible()
334  	) + " | " + 
335 		              		
336 				"]";           		
337         }
338  	
339  		
340  		public String toHtmlString() {
341  			return super.toString() + "[<br/>" +
342             	
343 		              			"<b>Id</b> = " + String.valueOf(getId()
344  	) + " <br/> " + 
345 		              		
346 		              			"<b>Visible</b> = " + String.valueOf(isVisible()
347  	) + " <br/> " + 
348 		              		
349 				"<br/>]";     
350 		}
351  	
352  		
353  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
354         	
355 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
356 		
357 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=local+classtype[@name=impl]) ---
358 	        
359 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=local+classtype[@name=impl]) ---        	            	
360  	
361 		}
362