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=static]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=static]+classtype[@name=impl] END
15      
16   		/**
17           *  
18              				Implementation of the static part of the GameBots2004 message ATR.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Contains the results of automatically
25  		casted rays. One ATR message is for one casted ray. New
26  		automatically casted rays can be defined by ADDRAY command and
27  		removed by REMOVERAY command.
28  	
29           */
30   	public class AutoTraceRayStaticImpl 
31    						extends
32    						AutoTraceRayStatic
33  	    {
34   	
35      	
36      	
37      	/**
38      	 * Parameter-less contructor for the message.
39      	 */
40  		public AutoTraceRayStaticImpl()
41  		{
42  		}
43  	
44      	
45      	
46      	
47      	/**
48  		 * Creates new instance of the message AutoTraceRay.
49  		 * 
50  		Synchronous message. Contains the results of automatically
51  		casted rays. One ATR message is for one casted ray. New
52  		automatically casted rays can be defined by ADDRAY command and
53  		removed by REMOVERAY command.
54  	
55  		 * Corresponding GameBots message
56  		 *   (static part)
57  		 *   is
58  		 *   ATR.
59  		 * 
60   	  	 * 
61  		 *   
62  		 *     @param Id 
63  			An Id for this ray (should be unique), assigned by the user
64  			when adding ray.
65  		
66  		 *   
67  		 * 
68  		 *   
69  		 * 
70  		 *   
71  		 * 
72  		 *   
73  		 * 
74  		 *   
75  		 * 
76  		 *   
77  		 * 
78  		 *   
79  		 * 
80  		 *   
81  		 * 
82  		 *   
83  		 * 
84  		 *   
85  		 * 
86  		 */
87  		public AutoTraceRayStaticImpl(
88  			UnrealId Id
89  		) {
90  			
91  					this.Id = Id;
92  				
93  		}
94      
95      	/**
96  		 * Cloning constructor from the full message.
97  		 *
98  		 * @param original
99  		 */
100 		public AutoTraceRayStaticImpl(AutoTraceRay original) {		
101 			
102 					this.Id = original.getId()
103  	;
104 				
105 			this.SimTime = original.getSimTime();			
106 		}
107 		
108 		/**
109 		 * Cloning constructor from the full message.
110 		 *
111 		 * @param original
112 		 */
113 		public AutoTraceRayStaticImpl(AutoTraceRayStaticImpl original) {		
114 			
115 					this.Id = original.getId()
116  	;
117 				
118 			this.SimTime = original.getSimTime();
119 		}
120 		
121 			/**
122 			 * Cloning constructor from the message part.
123 			 *
124 			 * @param original
125 			 */
126 			public AutoTraceRayStaticImpl(AutoTraceRayStatic original) {
127 				
128 						this.Id = original.getId()
129  	;
130 					
131 			}
132 		
133    				
134    				@Override
135    				public void setSimTime(long SimTime) {
136 					super.setSimTime(SimTime);
137 				}
138    			
139 	    				@Override
140 	    				public 
141 	    				AutoTraceRayStaticImpl clone() {
142 	    					return new 
143 	    					AutoTraceRayStaticImpl(this);
144 	    				}
145 	    				
146 	    				
147     	
148 	    /**
149          * 
150 			An Id for this ray (should be unique), assigned by the user
151 			when adding ray.
152 		 
153          */
154         protected
155          UnrealId Id =
156        	null;
157 	
158  		/**
159          * 
160 			An Id for this ray (should be unique), assigned by the user
161 			when adding ray.
162 		 
163          */
164         public  UnrealId getId()
165  	 {
166 				    					return Id;
167 				    				}
168 				    			
169     	
170     	
171     	public static class AutoTraceRayStaticUpdate
172      implements IStaticWorldObjectUpdatedEvent
173 		{
174 			
175 			private AutoTraceRayStatic data;
176 			private long time;
177 			
178 			public AutoTraceRayStaticUpdate
179     (AutoTraceRayStatic source, long time)
180 			{
181 				this.data = source;
182 				this.time = time;
183 			}
184 			
185 			/**
186 			 * Simulation time in MILLI SECONDS !!!
187 			 */
188 			@Override
189 			public long getSimTime() {
190 				return time;
191 			}
192 	
193 			@Override
194 			public WorldObjectId getId() {
195 				return data.getId();
196 			}
197 			
198 			@Override
199 			public IWorldObjectUpdateResult<IStaticWorldObject> update(
200 					IStaticWorldObject object) {
201 				if ( object == null)
202 				{
203 					data = new AutoTraceRayStaticImpl(data);
204 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
205 				}
206 				//since static objects can't be updated, we'll just check that the object stays the same
207 				if ( object instanceof AutoTraceRayStaticImpl)
208 				{
209 					AutoTraceRayStaticImpl orig = (AutoTraceRayStaticImpl)object;
210 					//since these errors usually mean error in gamebots, we will just print an error message
211 					if ( data.isDifferentFrom(orig) )
212 					{
213 						//data.isDifferentFrom(orig);
214 						//throw new PogamutException("Trying to modify static object " + this.data.getId().toString() , this);
215 						System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : AutoTraceRayStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
216 					}
217 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
218 				}				
219 				throw new PogamutException("Unexpected object type for update, AutoTraceRayStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
220 			}
221 		}
222 	
223     
224  		
225  		@Override
226  		public boolean isDifferentFrom(IStaticWorldObject other)
227  		{
228  			if (other == null) //early fail
229  			{
230  				return true;
231  			}
232  			else if (other == this) //early out
233  			{
234  				return false;
235  			}
236  			else
237  			{
238  				AutoTraceRayStatic obj = (AutoTraceRayStatic) other;
239 
240  				
241  						if ( !(
242  	 			AdvancedEquals.equalsOrNull(this.getId()
243  	, obj.getId()
244  	)
245  	 		) )
246 						{
247 							System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class AutoTraceRayStatic");
248 							return true;
249 						}
250  					
251  			}
252  			return false;
253  		}
254  	 
255  		
256  	    public String toString() {
257             return
258             	super.toString() + "[" +
259             	
260 		              			"Id = " + String.valueOf(getId()
261  	) + " | " + 
262 		              		
263 				"]";           		
264         }
265  	
266  		
267  		public String toHtmlString() {
268  			return super.toString() + "[<br/>" +
269             	
270 		              			"<b>Id</b> = " + String.valueOf(getId()
271  	) + " <br/> " + 
272 		              		
273 				"<br/>]";     
274 		}
275  	
276  		
277  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
278         	
279 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
280 		
281 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---
282 	        
283 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---        	            	
284  	
285 		}
286