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