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