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 INITED.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Asynchronous message. Sent after succesfull init command (so usually just once). 
25  		Holds many attributes of the bots like speed, id starting and max health, etc.
26  		Some attributes are not used due to GameBots mechanics.
27  	
28           */
29   	public class InitedMessageStaticImpl 
30    						extends
31    						InitedMessageStatic
32  	    {
33   	
34      	
35      	
36      	/**
37      	 * Parameter-less contructor for the message.
38      	 */
39  		public InitedMessageStaticImpl()
40  		{
41  		}
42  	
43      	/**
44  		 * Cloning constructor from the full message.
45  		 *
46  		 * @param original
47  		 */
48  		public InitedMessageStaticImpl(InitedMessage original) {		
49  			
50  			this.SimTime = original.getSimTime();			
51  		}
52  		
53  		/**
54  		 * Cloning constructor from the full message.
55  		 *
56  		 * @param original
57  		 */
58  		public InitedMessageStaticImpl(InitedMessageStaticImpl original) {		
59  			
60  			this.SimTime = original.getSimTime();
61  		}
62  		
63  			/**
64  			 * Cloning constructor from the message part.
65  			 *
66  			 * @param original
67  			 */
68  			public InitedMessageStaticImpl(InitedMessageStatic original) {
69  				
70  			}
71  		
72  						
73  						public UnrealId getId() {						
74  							return cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.InitedMessage.InitedMessageId;
75  						}
76  					
77     				
78     				@Override
79     				public void setSimTime(long SimTime) {
80  					super.setSimTime(SimTime);
81  				}
82     			
83  	    				@Override
84  	    				public 
85  	    				InitedMessageStaticImpl clone() {
86  	    					return new 
87  	    					InitedMessageStaticImpl(this);
88  	    				}
89  	    				
90  	    				
91      	
92      	
93      	public static class InitedMessageStaticUpdate
94       implements IStaticWorldObjectUpdatedEvent
95  		{
96  			
97  			private InitedMessageStatic data;
98  			private long time;
99  			
100 			public InitedMessageStaticUpdate
101     (InitedMessageStatic source, long time)
102 			{
103 				this.data = source;
104 				this.time = time;
105 			}
106 			
107 			/**
108 			 * Simulation time in MILLI SECONDS !!!
109 			 */
110 			@Override
111 			public long getSimTime() {
112 				return time;
113 			}
114 	
115 			@Override
116 			public WorldObjectId getId() {
117 				return data.getId();
118 			}
119 			
120 			@Override
121 			public IWorldObjectUpdateResult<IStaticWorldObject> update(
122 					IStaticWorldObject object) {
123 				if ( object == null)
124 				{
125 					data = new InitedMessageStaticImpl(data);
126 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
127 				}
128 				//since static objects can't be updated, we'll just check that the object stays the same
129 				if ( object instanceof InitedMessageStaticImpl)
130 				{
131 					InitedMessageStaticImpl orig = (InitedMessageStaticImpl)object;
132 					//since these errors usually mean error in gamebots, we will just print an error message
133 					if ( data.isDifferentFrom(orig) )
134 					{
135 						//data.isDifferentFrom(orig);
136 						//throw new PogamutException("Trying to modify static object " + this.data.getId().toString() , this);
137 						System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : InitedMessageStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
138 					}
139 					return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
140 				}				
141 				throw new PogamutException("Unexpected object type for update, InitedMessageStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
142 			}
143 		}
144 	
145     
146  		
147  		@Override
148  		public boolean isDifferentFrom(IStaticWorldObject other)
149  		{
150  			if (other == null) //early fail
151  			{
152  				return true;
153  			}
154  			else if (other == this) //early out
155  			{
156  				return false;
157  			}
158  			else
159  			{
160  				InitedMessageStatic obj = (InitedMessageStatic) other;
161 
162  				
163  			}
164  			return false;
165  		}
166  	 
167  		
168  	    public String toString() {
169             return
170             	super.toString() + "[" +
171             	
172 				"]";           		
173         }
174  	
175  		
176  		public String toHtmlString() {
177  			return super.toString() + "[<br/>" +
178             	
179 				"<br/>]";     
180 		}
181  	
182  		
183  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
184         	
185 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
186 		
187 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---
188 	        
189 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=impl]) ---        	            	
190  	
191 		}
192