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=event]+classtype[@name=impl] BEGIN
13  		
14  		// --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=event]+classtype[@name=impl] END
15      
16   		/**
17           *  
18           			Definition of the event HIT.
19           		
20           *
21           *  <p></p><p></p>
22           *  Complete message documentation:               
23           *  
24  		Asynchronous message. Bot hurt another player. Hit them with a
25  		shot.
26  	
27           */
28   	public class PlayerDamaged 
29    				extends InfoMessage
30      			implements IWorldEvent, IWorldChangeEvent
31      			
32  	    {
33   	
34      	/** Example how the message looks like - used during parser tests. */
35      	public static final String PROTOTYPE =
36      		"HIT {Id unreal_id}  {Damage 0}  {DamageType text}  {WeaponName text}  {Flaming False}  {DirectDamage False}  {BulletHit False}  {VehicleHit False} ";
37      
38      	
39      	
40      	/**
41      	 * Parameter-less contructor for the message.
42      	 */
43  		public PlayerDamaged()
44  		{
45  		}
46  	
47      	
48      	
49      	
50      	/**
51  		 * Creates new instance of the message PlayerDamaged.
52  		 * 
53  		Asynchronous message. Bot hurt another player. Hit them with a
54  		shot.
55  	
56  		 * Corresponding GameBots message
57  		 *   
58  		 *   is
59  		 *   HIT.
60  		 * 
61   	  	 * 
62  		 *   
63  		 *     @param Id Unique Id of the player hit.
64  		 *   
65  		 * 
66  		 *   
67  		 *     @param Damage Amount of damage done.
68  		 *   
69  		 * 
70  		 *   
71  		 *     @param DamageType 
72  			A string describing what kind of damage.
73  		
74  		 *   
75  		 * 
76  		 *   
77  		 *     @param WeaponName 
78  			Name of the weapon that caused this damage.
79  		
80  		 *   
81  		 * 
82  		 *   
83  		 *     @param Flaming 
84  			If this damage is causing our bot to burn. TODO
85  		
86  		 *   
87  		 * 
88  		 *   
89  		 *     @param DirectDamage 
90  			If the damage is direct. TODO
91  		
92  		 *   
93  		 * 
94  		 *   
95  		 *     @param BulletHit 
96  			If this damage was caused by bullet.
97  		
98  		 *   
99  		 * 
100 		 *   
101 		 *     @param VehicleHit 
102 			If this damage was caused by vehicle running over.
103 		
104 		 *   
105 		 * 
106 		 */
107 		public PlayerDamaged(
108 			UnrealId Id,  int Damage,  String DamageType,  String WeaponName,  boolean Flaming,  boolean DirectDamage,  boolean BulletHit,  boolean VehicleHit
109 		) {
110 			
111 					this.Id = Id;
112 				
113 					this.Damage = Damage;
114 				
115 					this.DamageType = DamageType;
116 				
117 					this.WeaponName = WeaponName;
118 				
119 					this.Flaming = Flaming;
120 				
121 					this.DirectDamage = DirectDamage;
122 				
123 					this.BulletHit = BulletHit;
124 				
125 					this.VehicleHit = VehicleHit;
126 				
127 		}
128     
129     	/**
130 		 * Cloning constructor from the full message.
131 		 *
132 		 * @param original
133 		 */
134 		public PlayerDamaged(PlayerDamaged original) {		
135 			
136 					this.Id = original.getId()
137  	;
138 				
139 					this.Damage = original.getDamage()
140  	;
141 				
142 					this.DamageType = original.getDamageType()
143  	;
144 				
145 					this.WeaponName = original.getWeaponName()
146  	;
147 				
148 					this.Flaming = original.isFlaming()
149  	;
150 				
151 					this.DirectDamage = original.isDirectDamage()
152  	;
153 				
154 					this.BulletHit = original.isBulletHit()
155  	;
156 				
157 					this.VehicleHit = original.isVehicleHit()
158  	;
159 				
160 			this.SimTime = original.getSimTime();			
161 		}
162 		
163 	   		
164 			protected long SimTime;
165 				
166 			/**
167 			 * Simulation time in MILLI SECONDS !!!
168 			 */	
169 			@Override
170 			public long getSimTime() {
171 				return SimTime;
172 			}
173 						
174 			/**
175 			 * Used by Yylex to slip correct time of the object or programmatically.
176 			 */
177 			protected void setSimTime(long SimTime) {
178 				this.SimTime = SimTime;
179 			}
180 	   	
181     	
182 	    /**
183          * Unique Id of the player hit. 
184          */
185         protected
186          UnrealId Id =
187        	null;
188 	
189  		/**
190          * Unique Id of the player hit. 
191          */
192         public  UnrealId getId()
193  	 {
194     					return Id;
195     				}
196     			
197     	
198 	    /**
199          * Amount of damage done. 
200          */
201         protected
202          int Damage =
203        	0;
204 	
205  		/**
206          * Amount of damage done. 
207          */
208         public  int getDamage()
209  	 {
210     					return Damage;
211     				}
212     			
213     	
214 	    /**
215          * 
216 			A string describing what kind of damage.
217 		 
218          */
219         protected
220          String DamageType =
221        	null;
222 	
223  		/**
224          * 
225 			A string describing what kind of damage.
226 		 
227          */
228         public  String getDamageType()
229  	 {
230     					return DamageType;
231     				}
232     			
233     	
234 	    /**
235          * 
236 			Name of the weapon that caused this damage.
237 		 
238          */
239         protected
240          String WeaponName =
241        	null;
242 	
243  		/**
244          * 
245 			Name of the weapon that caused this damage.
246 		 
247          */
248         public  String getWeaponName()
249  	 {
250     					return WeaponName;
251     				}
252     			
253     	
254 	    /**
255          * 
256 			If this damage is causing our bot to burn. TODO
257 		 
258          */
259         protected
260          boolean Flaming =
261        	false;
262 	
263  		/**
264          * 
265 			If this damage is causing our bot to burn. TODO
266 		 
267          */
268         public  boolean isFlaming()
269  	 {
270     					return Flaming;
271     				}
272     			
273     	
274 	    /**
275          * 
276 			If the damage is direct. TODO
277 		 
278          */
279         protected
280          boolean DirectDamage =
281        	false;
282 	
283  		/**
284          * 
285 			If the damage is direct. TODO
286 		 
287          */
288         public  boolean isDirectDamage()
289  	 {
290     					return DirectDamage;
291     				}
292     			
293     	
294 	    /**
295          * 
296 			If this damage was caused by bullet.
297 		 
298          */
299         protected
300          boolean BulletHit =
301        	false;
302 	
303  		/**
304          * 
305 			If this damage was caused by bullet.
306 		 
307          */
308         public  boolean isBulletHit()
309  	 {
310     					return BulletHit;
311     				}
312     			
313     	
314 	    /**
315          * 
316 			If this damage was caused by vehicle running over.
317 		 
318          */
319         protected
320          boolean VehicleHit =
321        	false;
322 	
323  		/**
324          * 
325 			If this damage was caused by vehicle running over.
326 		 
327          */
328         public  boolean isVehicleHit()
329  	 {
330     					return VehicleHit;
331     				}
332     			
333  		
334  	    public String toString() {
335             return
336             	super.toString() + "[" +
337             	
338 		              			"Id = " + String.valueOf(getId()
339  	) + " | " + 
340 		              		
341 		              			"Damage = " + String.valueOf(getDamage()
342  	) + " | " + 
343 		              		
344 		              			"DamageType = " + String.valueOf(getDamageType()
345  	) + " | " + 
346 		              		
347 		              			"WeaponName = " + String.valueOf(getWeaponName()
348  	) + " | " + 
349 		              		
350 		              			"Flaming = " + String.valueOf(isFlaming()
351  	) + " | " + 
352 		              		
353 		              			"DirectDamage = " + String.valueOf(isDirectDamage()
354  	) + " | " + 
355 		              		
356 		              			"BulletHit = " + String.valueOf(isBulletHit()
357  	) + " | " + 
358 		              		
359 		              			"VehicleHit = " + String.valueOf(isVehicleHit()
360  	) + " | " + 
361 		              		
362 				"]";           		
363         }
364  	
365  		
366  		public String toHtmlString() {
367  			return super.toString() + "[<br/>" +
368             	
369 		              			"<b>Id</b> = " + String.valueOf(getId()
370  	) + " <br/> " + 
371 		              		
372 		              			"<b>Damage</b> = " + String.valueOf(getDamage()
373  	) + " <br/> " + 
374 		              		
375 		              			"<b>DamageType</b> = " + String.valueOf(getDamageType()
376  	) + " <br/> " + 
377 		              		
378 		              			"<b>WeaponName</b> = " + String.valueOf(getWeaponName()
379  	) + " <br/> " + 
380 		              		
381 		              			"<b>Flaming</b> = " + String.valueOf(isFlaming()
382  	) + " <br/> " + 
383 		              		
384 		              			"<b>DirectDamage</b> = " + String.valueOf(isDirectDamage()
385  	) + " <br/> " + 
386 		              		
387 		              			"<b>BulletHit</b> = " + String.valueOf(isBulletHit()
388  	) + " <br/> " + 
389 		              		
390 		              			"<b>VehicleHit</b> = " + String.valueOf(isVehicleHit()
391  	) + " <br/> " + 
392 		              		
393 				"<br/>]";     
394 		}
395  	 
396  	    public String toJsonLiteral() {
397             return "PlayerDamaged(null, "
398             		
399                    + ")";
400         }
401  	
402  		
403  		// --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
404         	
405 		// --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
406 		
407 	    // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---
408 	        
409 	    // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=event+classtype[@name=impl]) ---        	            	
410  	
411 		}
412