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