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