1
2
3
4
5
6
7
8
9
10 package
11 cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12 import java.util.*;
13 import javax.vecmath.*;
14 import cz.cuni.amis.pogamut.base.communication.messages.*;
15 import cz.cuni.amis.pogamut.base.communication.worldview.*;
16 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19 import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20 import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22 import cz.cuni.amis.pogamut.udk.communication.messages.*;
23 import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24 import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25 import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26 import cz.cuni.amis.utils.exception.*;
27 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28 import cz.cuni.amis.utils.SafeEquals;
29 import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30
31
32
33
34
35
36
37
38
39
40
41 public class
42 IncomingProjectile
43 extends GBObjectUpdate
44
45 implements IGBWorldObjectEvent, IWorldObject
46
47 {
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83 public IncomingProjectile(
84 UnrealId Id, double Time, Vector3d Direction, Location Location, Velocity Velocity, double Speed, Location Origin, double DamageRadius, String Type) {
85
86 this.Id = Id;
87
88 this.Time = Time;
89
90 this.Direction = Direction;
91
92 this.Location = Location;
93
94 this.Velocity = Velocity;
95
96 this.Speed = Speed;
97
98 this.Origin = Origin;
99
100 this.DamageRadius = DamageRadius;
101
102 this.Type = Type;
103
104 }
105
106
107
108 public static final String PROTOTYPE =
109 "PRJ {Id unreal_id} {Time 0} {Direction 0,0,0} {Location 0,0,0} {Velocity 0,0,0} {Speed 0} {Origin 0,0,0} {DamageRadius 0} {Type text}";
110
111
112
113
114
115
116 protected
117 UnrealId Id =
118 null;
119
120
121
122
123 public
124 UnrealId getId() {
125 return
126 Id;
127 }
128
129
130
131
132
133 protected
134 double Time =
135 0;
136
137
138
139
140 public
141 double getTime() {
142 return
143 Time;
144 }
145
146
147
148
149
150
151
152
153 protected
154 Vector3d Direction =
155 null;
156
157
158
159
160
161
162
163 public
164 Vector3d getDirection() {
165 return
166 Direction;
167 }
168
169
170
171
172
173
174
175 protected
176 Location Location =
177 null;
178
179
180
181
182
183
184 public
185 Location getLocation() {
186 return
187 Location;
188 }
189
190
191
192
193
194
195
196 protected
197 Velocity Velocity =
198 null;
199
200
201
202
203
204
205 public
206 Velocity getVelocity() {
207 return
208 Velocity;
209 }
210
211
212
213
214
215
216
217 protected
218 double Speed =
219 0;
220
221
222
223
224
225
226 public
227 double getSpeed() {
228 return
229 Speed;
230 }
231
232
233
234
235
236
237
238
239 protected
240 Location Origin =
241 null;
242
243
244
245
246
247
248
249 public
250 Location getOrigin() {
251 return
252 Origin;
253 }
254
255
256
257
258
259
260
261
262 protected
263 double DamageRadius =
264 0;
265
266
267
268
269
270
271
272 public
273 double getDamageRadius() {
274 return
275 DamageRadius;
276 }
277
278
279
280
281
282
283
284
285 protected
286 String Type =
287 null;
288
289
290
291
292
293
294
295 public
296 String getType() {
297 return
298 Type;
299 }
300
301
302
303
304
305
306
307
308
309 protected void setTime(double time) {
310 this.Time = time;
311 }
312
313 public double getLastSeenTime() {
314 return Time;
315 }
316
317
318 public ILocalWorldObject getLocal() {
319 return null;
320 }
321
322 public ISharedWorldObject getShared() {
323 return null;
324 }
325
326 public IStaticWorldObject getStatic() {
327 return null;
328 }
329
330 @Override
331 public long getSimTime() {
332 return (long)getLastSeenTime();
333 }
334
335 public boolean equals(Object obj) {
336 if (!(obj instanceof IncomingProjectile)) return false;
337 IncomingProjectile cast = (IncomingProjectile)obj;
338 if (this.getId() != null) return this.getId().equals(cast.getId());
339 else return cast.getId() == null;
340 }
341
342 public int hashCode() {
343 if (getId() != null) return getId().hashCode();
344 return 0;
345 }
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363 public IncomingProjectile(IncomingProjectile original) {
364
365 this.Id=original.Id;
366
367 this.Time=original.Time;
368
369 this.Direction=original.Direction;
370
371 this.Location=original.Location;
372
373 this.Velocity=original.Velocity;
374
375 this.Speed=original.Speed;
376
377 this.Origin=original.Origin;
378
379 this.DamageRadius=original.DamageRadius;
380
381 this.Type=original.Type;
382
383 }
384
385
386
387
388
389 public IncomingProjectile() {
390 }
391
392
393
394
395
396 private IWorldObject orig = null;
397
398 public IWorldObjectUpdateResult update(IWorldObject obj) {
399 if(obj == null) {
400 orig = this;
401 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
402 }
403 orig = obj;
404
405 IncomingProjectile o = (IncomingProjectile)obj;
406
407 boolean updated = false;
408
409
410
411 if (updated) {
412 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
413 } else {
414 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
415 }
416 }
417
418
419
420
421
422 public IWorldObject getObject() {
423 if (orig == null) return this;
424 return orig;
425 }
426
427
428
429 public String toString() {
430 return
431
432 super.toString() + " | " +
433
434 "Id = " +
435 String.valueOf(Id) + " | " +
436
437 "Time = " +
438 String.valueOf(Time) + " | " +
439
440 "Direction = " +
441 String.valueOf(Direction) + " | " +
442
443 "Location = " +
444 String.valueOf(Location) + " | " +
445
446 "Velocity = " +
447 String.valueOf(Velocity) + " | " +
448
449 "Speed = " +
450 String.valueOf(Speed) + " | " +
451
452 "Origin = " +
453 String.valueOf(Origin) + " | " +
454
455 "DamageRadius = " +
456 String.valueOf(DamageRadius) + " | " +
457
458 "Type = " +
459 String.valueOf(Type) + " | " +
460 "";
461
462 }
463
464 public String toHtmlString() {
465 return super.toString() +
466
467 "<b>Id</b> : " +
468 String.valueOf(Id) +
469 " <br/> " +
470
471 "<b>Time</b> : " +
472 String.valueOf(Time) +
473 " <br/> " +
474
475 "<b>Direction</b> : " +
476 String.valueOf(Direction) +
477 " <br/> " +
478
479 "<b>Location</b> : " +
480 String.valueOf(Location) +
481 " <br/> " +
482
483 "<b>Velocity</b> : " +
484 String.valueOf(Velocity) +
485 " <br/> " +
486
487 "<b>Speed</b> : " +
488 String.valueOf(Speed) +
489 " <br/> " +
490
491 "<b>Origin</b> : " +
492 String.valueOf(Origin) +
493 " <br/> " +
494
495 "<b>DamageRadius</b> : " +
496 String.valueOf(DamageRadius) +
497 " <br/> " +
498
499 "<b>Type</b> : " +
500 String.valueOf(Type) +
501 " <br/> " +
502 "";
503 }
504
505
506
507 }
508
509