View Javadoc

1   
2               /**
3               IMPORTANT !!!
4   
5               DO NOT EDIT THIS FILE. IT IS GENERATED FROM approriate xml file in xmlresources/gbinfomessages BY
6               THE JavaClassesGenerator.xslt. MODIFY THESE FILES INSTEAD OF THIS ONE.
7   
8               IMPORTANT END !!!
9               */
10              package
11              cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12  	    		import java.util.*;
13      import javax.vecmath.*;
14      import cz.cuni.amis.pogamut.base.communication.messages.*;
15      import cz.cuni.amis.pogamut.base.communication.worldview.*;
16      import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17      import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18      import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19      import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20      import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21      import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22      import cz.cuni.amis.pogamut.udk.communication.messages.*;
23      import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24      import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25      import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26      import cz.cuni.amis.utils.exception.*;
27      import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28      import cz.cuni.amis.utils.SafeEquals;
29      import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30      
31              
32              /**
33                
34  		Synchronous message. Alive message are for confirmation, that
35  		the connection is still working. They are sent periodically with
36  		usual period of one second (this can change depending on the
37  		configuration of ControlServer)
38  	
39                            Corresponding GameBots message is
40                            ALIVE.
41                        
42               */
43              
44              public class
45              AliveMessage
46                      extends GBObjectUpdate
47                  
48  	            	implements IGBWorldObjectEvent, IWorldObject
49  
50              {
51              
52              /**
53                Creates new instance of command AliveMessage.
54                
55  		Synchronous message. Alive message are for confirmation, that
56  		the connection is still working. They are sent periodically with
57  		usual period of one second (this can change depending on the
58  		configuration of ControlServer)
59  	Corresponding GameBots message for this command is
60                .
61                    @param Time 
62  			Game time when this message was send.
63  		
64                */
65               public AliveMessage(
66                  double Time) {
67                      
68                      this.Time = Time;
69                  
70                  }
71  
72              
73      	/** Example how the message looks like - used during parser tests. */
74      	public static final String PROTOTYPE =
75      		"ALIVE {Time 0}";
76      
77  
78              /////// Properties BEGIN
79              
80          /**
81          
82  			Game time when this message was send.
83  		 */
84          protected
85           double Time =
86          	0;
87  
88          
89          /**
90          
91  			Game time when this message was send.
92  		 */
93          public
94          double getTime() {
95              return
96           Time;
97          }
98          
99  
100         
101             /////// Properties END
102 
103             /////// Extra Java code BEGIN
104 
105             	/////// Additional code from xslt BEGIN
106             		
107             					public static final UnrealId AliveMessageId = UnrealId.get("AliveMessageId");
108 
109             					public UnrealId getId() {
110             						return AliveMessageId;
111             					}
112             				
113        							protected void setTime(double time) {
114        								this.Time = time;
115        							}
116 
117        							public double getLastSeenTime() {
118        								return Time;
119        							}
120        						
121        					
122        					public ILocalWorldObject getLocal() {
123        						return null;
124        					}
125        					
126        					public ISharedWorldObject getShared() {
127        						return null;
128        					}
129        					
130        					public IStaticWorldObject getStatic() {
131        						return null;
132        					}
133        					
134        					@Override
135        					public long getSimTime() {
136        						return (long)getLastSeenTime();
137        					}
138 
139        					public boolean equals(Object obj) {
140 	                      if (!(obj instanceof AliveMessage)) return false;
141 	                      AliveMessage cast = (AliveMessage)obj;
142 	                      if (this.getId() != null) return this.getId().equals(cast.getId());
143 	                      else return cast.getId() == null;
144 	                    }
145 
146 	                    public int hashCode() {
147 	                      if (getId() != null) return getId().hashCode();
148 	                      return 0;
149 	                    }
150 
151             		
152 
153 
154             	/////// Additional code from xslt END
155 
156 	            /////// Extra Java from XML BEGIN
157             		
158             	/////// Extra Java from XML END
159 
160             /////// Extra Java code END
161 
162             
163 
164             /**
165               * Cloning constructor.
166               */
167              public AliveMessage(AliveMessage original) {
168                 
169                      this.Time=original.Time;
170                 
171              }
172 
173              
174                  /**
175                   * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
176                   */
177 	             public AliveMessage() {
178 	             }
179              
180 
181 	    		/**
182 	    		 * Here we save the original object for which this object is an update.
183 	    		 */
184 	    		private IWorldObject orig = null;
185 
186 	            public IWorldObjectUpdateResult update(IWorldObject obj) {
187 		            if(obj == null) {
188 		               orig = this;
189 		               return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
190 		            }
191 		            orig = obj;
192 		            // typecast
193 		            AliveMessage  o = (AliveMessage)obj;
194 
195 		            boolean updated = false;
196 
197 		            
198 		    					if (o.Time != Time) {
199 		    					    o.Time=Time;
200 		    						updated = true;
201 		    					}
202 		    				
203 
204 		            if (updated) {
205 		                return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
206 		            } else {
207 		            	return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
208 		            }
209 		        }
210 
211 	            /**
212 	             * Returns original object (if method update() has already been called, for bot-programmer that is always true
213 	             * as the original object is updated and then the event is propagated).
214 	             */
215 		        public IWorldObject getObject() {
216 		            if (orig == null) return this;
217 		            return orig;
218 		        }
219 	        
220 
221                  
222             public String toString() {
223                 return
224                 
225                 		super.toString() + " | " +
226                 		
227 				               "Time = " +
228 				               String.valueOf(Time) + " | " +
229 				             "";
230                 	
231              }
232 
233              public String toHtmlString() {
234                 return super.toString() +
235             
236             "<b>Time</b> : " +
237             String.valueOf(Time) +
238             " <br/> " +
239              "";
240              }
241 
242              
243              
244              }
245 
246