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