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=local]+classtype[@name=abstract] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=local]+classtype[@name=abstract] END
15      
16   		/**
17           *  
18              				Abstract definition of the local part of the GameBots2004 message MOV.  
19              			
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Synchronous message. Movers can be doors, elevators, or any
25  		other chunk of architecture that can move. They generally need
26  		to be either run into, or activated by shooting or pressing a
27  		button. We are working on ways to provide bots with more of the
28  		information they need to deal with movers appropriately.
29  	
30           */
31   	public abstract class MoverLocal 
32    						extends InfoMessage
33    						implements ILocalWorldObject
34    						
35  	    		,ILocalGBViewable
36  	    {
37   	
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public MoverLocal()
44  		{
45  		}
46  		
47  				// abstract definition of the local-part of the message, no more constructors is needed
48  			
49  	   		
50  			protected long SimTime;
51  				
52  			/**
53  			 * Simulation time in MILLI SECONDS !!!
54  			 */	
55  			@Override
56  			public long getSimTime() {
57  				return SimTime;
58  			}
59  						
60  			/**
61  			 * Used by Yylex to slip correct time of the object or programmatically.
62  			 */
63  			protected void setSimTime(long SimTime) {
64  				this.SimTime = SimTime;
65  			}
66  	   	
67  	    			
68  	    				@Override
69  		    			public abstract 
70  		    			MoverLocal clone();
71  		    			
72  						@Override
73  						public Class getCompositeClass() {
74  							return Mover.class;
75  						}
76  	
77  						
78  		    			
79   		/**
80           * 
81  			A unique Id of this mover assigned by the game.
82  		 
83           */
84          public abstract UnrealId getId()
85   	;
86  		    			
87   		/**
88           * If the mover is in the field of view of the bot. 
89           */
90          public abstract boolean isVisible()
91   	;
92  		    			
93      	
94      	
95      	
96      	public MoverLocal getLocal() {
97  			return this;
98      	}
99  		public ISharedWorldObject getShared() {
100 		 	throw new UnsupportedOperationException("Could not return LOCAL");
101 		}
102 		public IStaticWorldObject getStatic() {
103 		    throw new UnsupportedOperationException("Could not return LOCAL");
104 		}
105  	
106  		
107 		 	@Override
108 			public ILocalWorldObjectUpdatedEvent createDisappearEvent() {
109 				return new ObjectDisappeared(this, getSimTime());
110 			}
111 			
112 			public static class ObjectDisappeared implements ILocalWorldObjectUpdatedEvent
113 			{
114 				
115 				public ObjectDisappeared(MoverLocal obj, long time) {
116 					this.obj = obj;
117 					this.time = time;
118 				}
119 				
120 				private MoverLocal obj;
121 				private long time;
122 		
123 				@Override
124 				public WorldObjectId getId() {
125 					return obj.getId();
126 				}
127 		
128 		        /**
129 		         * Simulation time in MILLI SECONDS !!!
130 		         */
131 				@Override
132 				public long getSimTime() {
133 					return time;
134 				}
135 		
136 				@Override
137 				public IWorldObjectUpdateResult<ILocalWorldObject> update(ILocalWorldObject obj) 
138 				{
139 					if (obj == null) {
140 						throw new PogamutException("Can't 'disappear' null!", this);
141 					}
142 					if (!(obj instanceof MoverLocalImpl)) {
143 						throw new PogamutException("Can't update different class than MoverLocalImpl, got class " + obj.getClass().getSimpleName() + "!", this);
144 					}
145 					MoverLocalImpl toUpdate = (MoverLocalImpl)obj;
146 					if (toUpdate.Visible) {
147 						toUpdate.Visible = false;
148 						return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.UPDATED, obj);
149 					} else {
150 						return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.SAME, obj);
151 					}	
152 				}
153 				
154 			}
155 	
156 		
157  		
158  	    public String toString() {
159             return
160             	super.toString() + "[" +
161             	
162 		              			"Id = " + String.valueOf(getId()
163  	) + " | " + 
164 		              		
165 		              			"Visible = " + String.valueOf(isVisible()
166  	) + " | " + 
167 		              		
168 				"]";           		
169         }
170  	
171  		
172  		public String toHtmlString() {
173  			return super.toString() + "[<br/>" +
174             	
175 		              			"<b>Id</b> = " + String.valueOf(getId()
176  	) + " <br/> " + 
177 		              		
178 		              			"<b>Visible</b> = " + String.valueOf(isVisible()
179  	) + " <br/> " + 
180 		              		
181 				"<br/>]";     
182 		}
183  	
184  		
185  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
186         	
187 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
188 		
189 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=local+classtype[@name=abstract]) ---
190 	        
191 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=local+classtype[@name=abstract]) ---        	            	
192  	
193 		}
194