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 AutoTraceRayMessage
31 extends
32 AutoTraceRay
33 implements IWorldObjectUpdatedEvent, ICompositeWorldObjectUpdatedEvent
34
35 {
36
37
38
39
40
41
42 public AutoTraceRayMessage()
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
132
133 public AutoTraceRayMessage(
134 UnrealId Id, Location From, Location To, boolean FastTrace, boolean FloorCorrection, boolean Result, Vector3d HitNormal, Location HitLocation, boolean TraceActors, UnrealId HitId
135 ) {
136
137 this.Id = Id;
138
139 this.From = From;
140
141 this.To = To;
142
143 this.FastTrace = FastTrace;
144
145 this.FloorCorrection = FloorCorrection;
146
147 this.Result = Result;
148
149 this.HitNormal = HitNormal;
150
151 this.HitLocation = HitLocation;
152
153 this.TraceActors = TraceActors;
154
155 this.HitId = HitId;
156
157 }
158
159
160
161
162
163
164 public AutoTraceRayMessage(AutoTraceRayMessage original) {
165
166 this.Id = original.getId()
167 ;
168
169 this.From = original.getFrom()
170 ;
171
172 this.To = original.getTo()
173 ;
174
175 this.FastTrace = original.isFastTrace()
176 ;
177
178 this.FloorCorrection = original.isFloorCorrection()
179 ;
180
181 this.Result = original.isResult()
182 ;
183
184 this.HitNormal = original.getHitNormal()
185 ;
186
187 this.HitLocation = original.getHitLocation()
188 ;
189
190 this.TraceActors = original.isTraceActors()
191 ;
192
193 this.HitId = original.getHitId()
194 ;
195
196 this.TeamId = original.getTeamId();
197
198 this.SimTime = original.getSimTime();
199 }
200
201
202 protected ITeamId TeamId;
203
204
205
206
207 protected void setTeamId(ITeamId TeamId) {
208 this.TeamId = TeamId;
209 }
210
211 public ITeamId getTeamId() {
212 return TeamId;
213 }
214
215
216
217
218
219
220
221
222
223
224 protected
225 UnrealId Id =
226 null;
227
228
229
230
231
232 protected boolean Id_Set = false;
233
234 @Override
235
236
237
238
239
240
241
242 public UnrealId getId()
243 {
244 return Id;
245 }
246
247
248
249
250
251
252
253 protected
254 Location From =
255 null;
256
257
258
259
260
261 protected boolean From_Set = false;
262
263 @Override
264
265
266
267
268
269
270 public Location getFrom()
271 {
272 return From;
273 }
274
275
276
277
278
279
280
281 protected
282 Location To =
283 null;
284
285
286
287
288
289 protected boolean To_Set = false;
290
291 @Override
292
293
294
295
296
297
298 public Location getTo()
299 {
300 return To;
301 }
302
303
304
305
306
307
308
309
310
311
312 protected
313 boolean FastTrace =
314 false;
315
316
317
318
319
320 protected boolean FastTrace_Set = false;
321
322 @Override
323
324
325
326
327
328
329
330
331
332 public boolean isFastTrace()
333 {
334 return FastTrace;
335 }
336
337
338
339
340
341
342
343 protected
344 boolean FloorCorrection =
345 false;
346
347
348
349
350
351 protected boolean FloorCorrection_Set = false;
352
353 @Override
354
355
356
357
358
359
360 public boolean isFloorCorrection()
361 {
362 return FloorCorrection;
363 }
364
365
366
367
368
369
370
371 protected
372 boolean Result =
373 false;
374
375
376
377
378
379 protected boolean Result_Set = false;
380
381 @Override
382
383
384
385
386
387
388 public boolean isResult()
389 {
390 return Result;
391 }
392
393
394
395
396
397
398
399
400 protected
401 Vector3d HitNormal =
402 null;
403
404
405
406
407
408 protected boolean HitNormal_Set = false;
409
410 @Override
411
412
413
414
415
416
417
418 public Vector3d getHitNormal()
419 {
420 return HitNormal;
421 }
422
423
424
425
426
427
428
429
430 protected
431 Location HitLocation =
432 null;
433
434
435
436
437
438 protected boolean HitLocation_Set = false;
439
440 @Override
441
442
443
444
445
446
447
448 public Location getHitLocation()
449 {
450 return HitLocation;
451 }
452
453
454
455
456
457
458
459
460
461 protected
462 boolean TraceActors =
463 false;
464
465
466
467
468
469 protected boolean TraceActors_Set = false;
470
471 @Override
472
473
474
475
476
477
478
479
480 public boolean isTraceActors()
481 {
482 return TraceActors;
483 }
484
485
486
487
488
489
490
491
492 protected
493 UnrealId HitId =
494 null;
495
496
497
498
499
500 protected boolean HitId_Set = false;
501
502 @Override
503
504
505
506
507
508
509
510 public UnrealId getHitId()
511 {
512 return HitId;
513 }
514
515
516 private AutoTraceRayLocal localPart = null;
517
518 @Override
519 public AutoTraceRayLocal
520 getLocal() {
521 if (localPart != null) return localPart;
522 return localPart = new
523 AutoTraceRayLocalMessage();
524 }
525
526 private AutoTraceRayShared sharedPart = null;
527
528 @Override
529 public AutoTraceRayShared
530 getShared() {
531 if (sharedPart != null) return sharedPart;
532 return sharedPart = new
533 AutoTraceRaySharedMessage();
534 }
535
536 private AutoTraceRayStatic staticPart = null;
537
538 @Override
539 public AutoTraceRayStatic
540 getStatic() {
541 if (staticPart != null) return staticPart;
542 return staticPart = new
543 AutoTraceRayStaticMessage();
544 }
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561 public class AutoTraceRayLocalMessage
562 extends
563 AutoTraceRayLocal
564 {
565
566 @Override
567 public
568 AutoTraceRayLocalMessage clone() {
569 return this;
570 }
571
572 public AutoTraceRayLocalMessage getLocal() {
573 return this;
574 }
575 public ISharedWorldObject getShared() {
576 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
577 }
578 public IStaticWorldObject getStatic() {
579 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
580 }
581
582
583
584
585
586
587
588 public UnrealId getId()
589 {
590 return Id;
591 }
592
593
594
595
596
597
598 public Location getFrom()
599 {
600 return From;
601 }
602
603
604
605
606
607
608 public Location getTo()
609 {
610 return To;
611 }
612
613
614
615
616
617
618
619
620
621 public boolean isFastTrace()
622 {
623 return FastTrace;
624 }
625
626
627
628
629
630
631 public boolean isFloorCorrection()
632 {
633 return FloorCorrection;
634 }
635
636
637
638
639
640
641 public boolean isResult()
642 {
643 return Result;
644 }
645
646
647
648
649
650
651
652 public Vector3d getHitNormal()
653 {
654 return HitNormal;
655 }
656
657
658
659
660
661
662
663 public Location getHitLocation()
664 {
665 return HitLocation;
666 }
667
668
669
670
671
672
673
674
675 public boolean isTraceActors()
676 {
677 return TraceActors;
678 }
679
680
681
682
683
684
685
686 public UnrealId getHitId()
687 {
688 return HitId;
689 }
690
691
692 public String toString() {
693 return
694 super.toString() + "[" +
695
696 "Id = " + String.valueOf(getId()
697 ) + " | " +
698
699 "From = " + String.valueOf(getFrom()
700 ) + " | " +
701
702 "To = " + String.valueOf(getTo()
703 ) + " | " +
704
705 "FastTrace = " + String.valueOf(isFastTrace()
706 ) + " | " +
707
708 "FloorCorrection = " + String.valueOf(isFloorCorrection()
709 ) + " | " +
710
711 "Result = " + String.valueOf(isResult()
712 ) + " | " +
713
714 "HitNormal = " + String.valueOf(getHitNormal()
715 ) + " | " +
716
717 "HitLocation = " + String.valueOf(getHitLocation()
718 ) + " | " +
719
720 "TraceActors = " + String.valueOf(isTraceActors()
721 ) + " | " +
722
723 "HitId = " + String.valueOf(getHitId()
724 ) + " | " +
725
726 "]";
727 }
728
729
730 public String toHtmlString() {
731 return super.toString() + "[<br/>" +
732
733 "<b>Id</b> = " + String.valueOf(getId()
734 ) + " <br/> " +
735
736 "<b>From</b> = " + String.valueOf(getFrom()
737 ) + " <br/> " +
738
739 "<b>To</b> = " + String.valueOf(getTo()
740 ) + " <br/> " +
741
742 "<b>FastTrace</b> = " + String.valueOf(isFastTrace()
743 ) + " <br/> " +
744
745 "<b>FloorCorrection</b> = " + String.valueOf(isFloorCorrection()
746 ) + " <br/> " +
747
748 "<b>Result</b> = " + String.valueOf(isResult()
749 ) + " <br/> " +
750
751 "<b>HitNormal</b> = " + String.valueOf(getHitNormal()
752 ) + " <br/> " +
753
754 "<b>HitLocation</b> = " + String.valueOf(getHitLocation()
755 ) + " <br/> " +
756
757 "<b>TraceActors</b> = " + String.valueOf(isTraceActors()
758 ) + " <br/> " +
759
760 "<b>HitId</b> = " + String.valueOf(getHitId()
761 ) + " <br/> " +
762
763 "<br/>]";
764 }
765
766
767
768
769
770
771
772
773
774
775 }
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792 public class AutoTraceRayStaticMessage
793 extends
794 AutoTraceRayStatic
795 {
796
797 @Override
798 public
799 AutoTraceRayStaticMessage clone() {
800 return this;
801 }
802
803
804
805
806
807
808
809 public UnrealId getId()
810 {
811 return Id;
812 }
813
814
815 @Override
816 public boolean isDifferentFrom(IStaticWorldObject other)
817 {
818 if (other == null)
819 {
820 return true;
821 }
822 else if (other == this)
823 {
824 return false;
825 }
826 else
827 {
828 AutoTraceRayStatic obj = (AutoTraceRayStatic) other;
829
830
831 if ( !(
832 AdvancedEquals.equalsOrNull(this.getId()
833 , obj.getId()
834 )
835 ) )
836 {
837 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class AutoTraceRayStatic");
838 return true;
839 }
840
841 }
842 return false;
843 }
844
845
846 public String toString() {
847 return
848 super.toString() + "[" +
849
850 "Id = " + String.valueOf(getId()
851 ) + " | " +
852
853 "]";
854 }
855
856
857 public String toHtmlString() {
858 return super.toString() + "[<br/>" +
859
860 "<b>Id</b> = " + String.valueOf(getId()
861 ) + " <br/> " +
862
863 "<br/>]";
864 }
865
866
867
868
869
870
871
872
873
874
875 }
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892 public class AutoTraceRaySharedMessage
893 extends
894 AutoTraceRayShared
895 {
896
897
898
899 public AutoTraceRaySharedMessage()
900 {
901
902 }
903
904 @Override
905 public
906 AutoTraceRaySharedMessage clone() {
907 return this;
908 }
909
910
911
912
913 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
914 0
915 );
916
917 @Override
918 public ISharedProperty getProperty(PropertyId id) {
919 return propertyMap.get(id);
920 }
921
922 @Override
923 public Map<PropertyId, ISharedProperty> getProperties() {
924 return propertyMap;
925 }
926
927
928
929
930
931
932
933
934
935 public UnrealId getId()
936 {
937 return Id;
938 }
939
940
941 public String toString() {
942 return
943 super.toString() + "[" +
944
945 "Id = " + String.valueOf(getId()
946 ) + " | " +
947
948 "]";
949 }
950
951
952 public String toHtmlString() {
953 return super.toString() + "[<br/>" +
954
955 "<b>Id</b> = " + String.valueOf(getId()
956 ) + " <br/> " +
957
958 "<br/>]";
959 }
960
961
962
963
964
965
966
967
968
969
970 }
971
972
973
974
975 @Override
976 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject object) {
977 if (object == null)
978 {
979 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.CREATED, this);
980 }
981 if (!( object instanceof AutoTraceRayMessage) ) {
982 throw new PogamutException("Can't update different class than AutoTraceRayMessage, got class " + object.getClass().getSimpleName() + "!", this);
983 }
984 AutoTraceRayMessage toUpdate = (AutoTraceRayMessage)object;
985
986 boolean updated = false;
987
988
989
990 if (!SafeEquals.equals(toUpdate.From, getFrom()
991 )) {
992 toUpdate.From=getFrom()
993 ;
994 updated = true;
995 }
996
997 if (!SafeEquals.equals(toUpdate.To, getTo()
998 )) {
999 toUpdate.To=getTo()
1000 ;
1001 updated = true;
1002 }
1003
1004 if (toUpdate.FastTrace != isFastTrace()
1005 ) {
1006 toUpdate.FastTrace=isFastTrace()
1007 ;
1008 updated = true;
1009 }
1010
1011 if (toUpdate.FloorCorrection != isFloorCorrection()
1012 ) {
1013 toUpdate.FloorCorrection=isFloorCorrection()
1014 ;
1015 updated = true;
1016 }
1017
1018 if (toUpdate.Result != isResult()
1019 ) {
1020 toUpdate.Result=isResult()
1021 ;
1022 updated = true;
1023 }
1024
1025 if (!SafeEquals.equals(toUpdate.HitNormal, getHitNormal()
1026 )) {
1027 toUpdate.HitNormal=getHitNormal()
1028 ;
1029 updated = true;
1030 }
1031
1032 if (!SafeEquals.equals(toUpdate.HitLocation, getHitLocation()
1033 )) {
1034 toUpdate.HitLocation=getHitLocation()
1035 ;
1036 updated = true;
1037 }
1038
1039 if (toUpdate.TraceActors != isTraceActors()
1040 ) {
1041 toUpdate.TraceActors=isTraceActors()
1042 ;
1043 updated = true;
1044 }
1045
1046 if (!SafeEquals.equals(toUpdate.HitId, getHitId()
1047 )) {
1048 toUpdate.HitId=getHitId()
1049 ;
1050 updated = true;
1051 }
1052
1053
1054
1055
1056
1057
1058 toUpdate.SimTime = SimTime;
1059
1060 if (updated) {
1061 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
1062 } else {
1063 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.SAME, toUpdate);
1064 }
1065 }
1066
1067 @Override
1068 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
1069 return new AutoTraceRayLocalImpl.AutoTraceRayLocalUpdate
1070 (this.getLocal(), SimTime);
1071 }
1072
1073 @Override
1074 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
1075 return new AutoTraceRaySharedImpl.AutoTraceRaySharedUpdate
1076 (this.getShared(), SimTime, this.getTeamId());
1077 }
1078
1079 @Override
1080 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
1081 return new AutoTraceRayStaticImpl.AutoTraceRayStaticUpdate
1082 (this.getStatic(), SimTime);
1083 }
1084
1085
1086 public String toString() {
1087 return
1088 super.toString() + "[" +
1089
1090 "Id = " + String.valueOf(getId()
1091 ) + " | " +
1092
1093 "From = " + String.valueOf(getFrom()
1094 ) + " | " +
1095
1096 "To = " + String.valueOf(getTo()
1097 ) + " | " +
1098
1099 "FastTrace = " + String.valueOf(isFastTrace()
1100 ) + " | " +
1101
1102 "FloorCorrection = " + String.valueOf(isFloorCorrection()
1103 ) + " | " +
1104
1105 "Result = " + String.valueOf(isResult()
1106 ) + " | " +
1107
1108 "HitNormal = " + String.valueOf(getHitNormal()
1109 ) + " | " +
1110
1111 "HitLocation = " + String.valueOf(getHitLocation()
1112 ) + " | " +
1113
1114 "TraceActors = " + String.valueOf(isTraceActors()
1115 ) + " | " +
1116
1117 "HitId = " + String.valueOf(getHitId()
1118 ) + " | " +
1119
1120 "]";
1121 }
1122
1123
1124 public String toHtmlString() {
1125 return super.toString() + "[<br/>" +
1126
1127 "<b>Id</b> = " + String.valueOf(getId()
1128 ) + " <br/> " +
1129
1130 "<b>From</b> = " + String.valueOf(getFrom()
1131 ) + " <br/> " +
1132
1133 "<b>To</b> = " + String.valueOf(getTo()
1134 ) + " <br/> " +
1135
1136 "<b>FastTrace</b> = " + String.valueOf(isFastTrace()
1137 ) + " <br/> " +
1138
1139 "<b>FloorCorrection</b> = " + String.valueOf(isFloorCorrection()
1140 ) + " <br/> " +
1141
1142 "<b>Result</b> = " + String.valueOf(isResult()
1143 ) + " <br/> " +
1144
1145 "<b>HitNormal</b> = " + String.valueOf(getHitNormal()
1146 ) + " <br/> " +
1147
1148 "<b>HitLocation</b> = " + String.valueOf(getHitLocation()
1149 ) + " <br/> " +
1150
1151 "<b>TraceActors</b> = " + String.valueOf(isTraceActors()
1152 ) + " <br/> " +
1153
1154 "<b>HitId</b> = " + String.valueOf(getHitId()
1155 ) + " <br/> " +
1156
1157 "<br/>]";
1158 }
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169 }
1170