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