1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
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
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30 public class AutoTraceRayLocalImpl
31 extends
32 AutoTraceRayLocal
33 {
34
35
36
37
38
39
40 public AutoTraceRayLocalImpl()
41 {
42 }
43
44
45
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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 public AutoTraceRayLocalImpl(
132 UnrealId Id, Location From, Location To, boolean FastTrace, boolean FloorCorrection, boolean Result, Vector3d HitNormal, Location HitLocation, boolean TraceActors, UnrealId HitId
133 ) {
134
135 this.Id = Id;
136
137 this.From = From;
138
139 this.To = To;
140
141 this.FastTrace = FastTrace;
142
143 this.FloorCorrection = FloorCorrection;
144
145 this.Result = Result;
146
147 this.HitNormal = HitNormal;
148
149 this.HitLocation = HitLocation;
150
151 this.TraceActors = TraceActors;
152
153 this.HitId = HitId;
154
155 }
156
157
158
159
160
161
162 public AutoTraceRayLocalImpl(AutoTraceRay original) {
163
164 this.Id = original.getId()
165 ;
166
167 this.From = original.getFrom()
168 ;
169
170 this.To = original.getTo()
171 ;
172
173 this.FastTrace = original.isFastTrace()
174 ;
175
176 this.FloorCorrection = original.isFloorCorrection()
177 ;
178
179 this.Result = original.isResult()
180 ;
181
182 this.HitNormal = original.getHitNormal()
183 ;
184
185 this.HitLocation = original.getHitLocation()
186 ;
187
188 this.TraceActors = original.isTraceActors()
189 ;
190
191 this.HitId = original.getHitId()
192 ;
193
194 this.SimTime = original.getSimTime();
195 }
196
197
198
199
200
201
202 public AutoTraceRayLocalImpl(AutoTraceRayLocalImpl original) {
203
204 this.Id = original.getId()
205 ;
206
207 this.From = original.getFrom()
208 ;
209
210 this.To = original.getTo()
211 ;
212
213 this.FastTrace = original.isFastTrace()
214 ;
215
216 this.FloorCorrection = original.isFloorCorrection()
217 ;
218
219 this.Result = original.isResult()
220 ;
221
222 this.HitNormal = original.getHitNormal()
223 ;
224
225 this.HitLocation = original.getHitLocation()
226 ;
227
228 this.TraceActors = original.isTraceActors()
229 ;
230
231 this.HitId = original.getHitId()
232 ;
233
234 this.SimTime = original.getSimTime();
235 }
236
237
238
239
240
241
242 public AutoTraceRayLocalImpl(AutoTraceRayLocal original) {
243
244 this.Id = original.getId()
245 ;
246
247 this.From = original.getFrom()
248 ;
249
250 this.To = original.getTo()
251 ;
252
253 this.FastTrace = original.isFastTrace()
254 ;
255
256 this.FloorCorrection = original.isFloorCorrection()
257 ;
258
259 this.Result = original.isResult()
260 ;
261
262 this.HitNormal = original.getHitNormal()
263 ;
264
265 this.HitLocation = original.getHitLocation()
266 ;
267
268 this.TraceActors = original.isTraceActors()
269 ;
270
271 this.HitId = original.getHitId()
272 ;
273
274 }
275
276
277 @Override
278 public void setSimTime(long SimTime) {
279 super.setSimTime(SimTime);
280 }
281
282 @Override
283 public
284 AutoTraceRayLocalImpl clone() {
285 return new
286 AutoTraceRayLocalImpl(this);
287 }
288
289
290
291
292
293
294
295
296
297 protected
298 UnrealId Id =
299 null;
300
301
302
303
304
305
306
307 public UnrealId getId()
308 {
309 return Id;
310 }
311
312
313
314
315
316
317
318 protected
319 Location From =
320 null;
321
322
323
324
325
326
327 public Location getFrom()
328 {
329 return From;
330 }
331
332
333
334
335
336
337
338 protected
339 Location To =
340 null;
341
342
343
344
345
346
347 public Location getTo()
348 {
349 return To;
350 }
351
352
353
354
355
356
357
358
359
360
361 protected
362 boolean FastTrace =
363 false;
364
365
366
367
368
369
370
371
372
373 public boolean isFastTrace()
374 {
375 return FastTrace;
376 }
377
378
379
380
381
382
383
384 protected
385 boolean FloorCorrection =
386 false;
387
388
389
390
391
392
393 public boolean isFloorCorrection()
394 {
395 return FloorCorrection;
396 }
397
398
399
400
401
402
403
404 protected
405 boolean Result =
406 false;
407
408
409
410
411
412
413 public boolean isResult()
414 {
415 return Result;
416 }
417
418
419
420
421
422
423
424
425 protected
426 Vector3d HitNormal =
427 null;
428
429
430
431
432
433
434
435 public Vector3d getHitNormal()
436 {
437 return HitNormal;
438 }
439
440
441
442
443
444
445
446
447 protected
448 Location HitLocation =
449 null;
450
451
452
453
454
455
456
457 public Location getHitLocation()
458 {
459 return HitLocation;
460 }
461
462
463
464
465
466
467
468
469
470 protected
471 boolean TraceActors =
472 false;
473
474
475
476
477
478
479
480
481 public boolean isTraceActors()
482 {
483 return TraceActors;
484 }
485
486
487
488
489
490
491
492
493 protected
494 UnrealId HitId =
495 null;
496
497
498
499
500
501
502
503 public UnrealId getHitId()
504 {
505 return HitId;
506 }
507
508
509
510
511
512 public AutoTraceRayLocalImpl getLocal() {
513 return this;
514 }
515 public ISharedWorldObject getShared() {
516 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
517 }
518 public IStaticWorldObject getStatic() {
519 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
520 }
521
522 public static class AutoTraceRayLocalUpdate
523 implements ILocalWorldObjectUpdatedEvent, IGBWorldObjectEvent
524 {
525 protected long time;
526
527 protected AutoTraceRayLocal data = null;
528
529 public AutoTraceRayLocalUpdate
530 (AutoTraceRayLocal moverLocal, long time)
531 {
532 this.data = moverLocal;
533 this.time = time;
534 }
535
536 @Override
537 public IWorldObjectUpdateResult<ILocalWorldObject> update(
538 ILocalWorldObject object)
539 {
540 if ( object == null)
541 {
542 data = new AutoTraceRayLocalImpl(data);
543 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
544 }
545 if ( object instanceof AutoTraceRayLocalImpl )
546 {
547 AutoTraceRayLocalImpl toUpdate = (AutoTraceRayLocalImpl)object;
548
549 boolean updated = false;
550
551
552
553 if (!SafeEquals.equals(toUpdate.From, data.getFrom()
554 )) {
555 toUpdate.From=data.getFrom()
556 ;
557 updated = true;
558 }
559
560 if (!SafeEquals.equals(toUpdate.To, data.getTo()
561 )) {
562 toUpdate.To=data.getTo()
563 ;
564 updated = true;
565 }
566
567 if (toUpdate.FastTrace != data.isFastTrace()
568 ) {
569 toUpdate.FastTrace=data.isFastTrace()
570 ;
571 updated = true;
572 }
573
574 if (toUpdate.FloorCorrection != data.isFloorCorrection()
575 ) {
576 toUpdate.FloorCorrection=data.isFloorCorrection()
577 ;
578 updated = true;
579 }
580
581 if (toUpdate.Result != data.isResult()
582 ) {
583 toUpdate.Result=data.isResult()
584 ;
585 updated = true;
586 }
587
588 if (!SafeEquals.equals(toUpdate.HitNormal, data.getHitNormal()
589 )) {
590 toUpdate.HitNormal=data.getHitNormal()
591 ;
592 updated = true;
593 }
594
595 if (!SafeEquals.equals(toUpdate.HitLocation, data.getHitLocation()
596 )) {
597 toUpdate.HitLocation=data.getHitLocation()
598 ;
599 updated = true;
600 }
601
602 if (toUpdate.TraceActors != data.isTraceActors()
603 ) {
604 toUpdate.TraceActors=data.isTraceActors()
605 ;
606 updated = true;
607 }
608
609 if (!SafeEquals.equals(toUpdate.HitId, data.getHitId()
610 )) {
611 toUpdate.HitId=data.getHitId()
612 ;
613 updated = true;
614 }
615
616
617 data = toUpdate;
618
619 if ( updated )
620 {
621 toUpdate.SimTime = this.time;
622 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, data);
623 }
624
625 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
626 }
627 throw new PogamutException("Unsupported object type for update. Expected AutoTraceRayLocalImpl for object " + object.getId() +", not object of class " + object.getClass().getSimpleName() + ".", this);
628 }
629
630
631
632
633 @Override
634 public long getSimTime() {
635 return this.time;
636 }
637
638 @Override
639 public IWorldObject getObject() {
640 return data;
641 }
642
643 @Override
644 public WorldObjectId getId() {
645 return data.getId();
646 }
647
648 }
649
650
651 public String toString() {
652 return
653 super.toString() + "[" +
654
655 "Id = " + String.valueOf(getId()
656 ) + " | " +
657
658 "From = " + String.valueOf(getFrom()
659 ) + " | " +
660
661 "To = " + String.valueOf(getTo()
662 ) + " | " +
663
664 "FastTrace = " + String.valueOf(isFastTrace()
665 ) + " | " +
666
667 "FloorCorrection = " + String.valueOf(isFloorCorrection()
668 ) + " | " +
669
670 "Result = " + String.valueOf(isResult()
671 ) + " | " +
672
673 "HitNormal = " + String.valueOf(getHitNormal()
674 ) + " | " +
675
676 "HitLocation = " + String.valueOf(getHitLocation()
677 ) + " | " +
678
679 "TraceActors = " + String.valueOf(isTraceActors()
680 ) + " | " +
681
682 "HitId = " + String.valueOf(getHitId()
683 ) + " | " +
684
685 "]";
686 }
687
688
689 public String toHtmlString() {
690 return super.toString() + "[<br/>" +
691
692 "<b>Id</b> = " + String.valueOf(getId()
693 ) + " <br/> " +
694
695 "<b>From</b> = " + String.valueOf(getFrom()
696 ) + " <br/> " +
697
698 "<b>To</b> = " + String.valueOf(getTo()
699 ) + " <br/> " +
700
701 "<b>FastTrace</b> = " + String.valueOf(isFastTrace()
702 ) + " <br/> " +
703
704 "<b>FloorCorrection</b> = " + String.valueOf(isFloorCorrection()
705 ) + " <br/> " +
706
707 "<b>Result</b> = " + String.valueOf(isResult()
708 ) + " <br/> " +
709
710 "<b>HitNormal</b> = " + String.valueOf(getHitNormal()
711 ) + " <br/> " +
712
713 "<b>HitLocation</b> = " + String.valueOf(getHitLocation()
714 ) + " <br/> " +
715
716 "<b>TraceActors</b> = " + String.valueOf(isTraceActors()
717 ) + " <br/> " +
718
719 "<b>HitId</b> = " + String.valueOf(getHitId()
720 ) + " <br/> " +
721
722 "<br/>]";
723 }
724
725
726
727
728
729
730
731
732
733
734 }
735