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