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
42
43
44 public class
45 NavPoint
46 extends GBObjectUpdate
47
48 implements IGBWorldObjectEvent, IWorldObject, ILocated, ILocomotive, IGBViewable
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147 public NavPoint(
148 UnrealId Id, Location Location, Velocity Velocity, boolean Visible, UnrealId Item, ItemType ItemClass, boolean ItemSpawned, boolean DoorOpened, UnrealId Mover, Vector3d LiftOffset, boolean LiftJumpExit, boolean NoDoubleJump, boolean InvSpot, boolean PlayerStart, int TeamNumber, boolean Door, boolean LiftCenter, boolean LiftExit, boolean AIMarker, boolean JumpSpot, boolean JumpDest, boolean Teleporter, Rotation Rotation, boolean RoamingSpot, boolean SnipingSpot, Item ItemInstance, Map<UnrealId, NavPointNeighbourLink> OutgoingEdges, Map<UnrealId, NavPointNeighbourLink> IncomingEdges, String PreferedWeapon, int FlagOfTeam) {
149
150 this.Id = Id;
151
152 this.Location = Location;
153
154 this.Velocity = Velocity;
155
156 this.Visible = Visible;
157
158 this.Item = Item;
159
160 this.ItemClass = ItemClass;
161
162 this.ItemSpawned = ItemSpawned;
163
164 this.DoorOpened = DoorOpened;
165
166 this.Mover = Mover;
167
168 this.LiftOffset = LiftOffset;
169
170 this.LiftJumpExit = LiftJumpExit;
171
172 this.NoDoubleJump = NoDoubleJump;
173
174 this.InvSpot = InvSpot;
175
176 this.PlayerStart = PlayerStart;
177
178 this.TeamNumber = TeamNumber;
179
180 this.Door = Door;
181
182 this.LiftCenter = LiftCenter;
183
184 this.LiftExit = LiftExit;
185
186 this.AIMarker = AIMarker;
187
188 this.JumpSpot = JumpSpot;
189
190 this.JumpDest = JumpDest;
191
192 this.Teleporter = Teleporter;
193
194 this.Rotation = Rotation;
195
196 this.RoamingSpot = RoamingSpot;
197
198 this.SnipingSpot = SnipingSpot;
199
200 this.ItemInstance = ItemInstance;
201
202 this.OutgoingEdges = OutgoingEdges;
203
204 this.IncomingEdges = IncomingEdges;
205
206 this.PreferedWeapon = PreferedWeapon;
207
208 this.FlagOfTeam = FlagOfTeam;
209
210 }
211
212
213
214 public static final String PROTOTYPE =
215 "NAV {Id unreal_id} {Location 0,0,0} {Velocity 0,0,0} {Visible False} {Item unreal_id} {ItemClass xWeapons.FlakCannonPickup} {ItemSpawned False} {DoorOpened False} {Mover unreal_id} {LiftOffset 0,0,0} {LiftJumpExit False} {NoDoubleJump False} {InvSpot False} {PlayerStart False} {TeamNumber 0} {Door False} {LiftCenter False} {LiftExit False} {AIMarker False} {JumpSpot False} {JumpDest False} {Teleporter False} {Rotation 0,0,0} {RoamingSpot False} {SnipingSpot False} {PreferedWeapon text} {FlagOfTeam 0}";
216
217
218
219
220
221
222
223
224 protected
225 UnrealId Id =
226 null;
227
228
229
230
231
232
233 public
234 UnrealId getId() {
235 return
236 Id;
237 }
238
239
240
241
242
243 protected
244 Location Location =
245 null;
246
247
248
249
250 public
251 Location getLocation() {
252 return
253 Location;
254 }
255
256
257
258
259
260
261
262
263 protected
264 Velocity Velocity =
265 null;
266
267
268
269
270
271
272
273 public
274 Velocity getVelocity() {
275 return
276 Velocity;
277 }
278
279
280
281
282
283
284
285 protected
286 boolean Visible =
287 false;
288
289
290
291
292
293
294 public
295 boolean isVisible() {
296 return
297 Visible;
298 }
299
300
301
302
303
304
305
306
307 protected
308 UnrealId Item =
309 null;
310
311
312
313
314
315
316
317 public
318 UnrealId getItem() {
319 return
320 Item;
321 }
322
323
324
325
326
327
328
329 protected
330 ItemType ItemClass =
331 null;
332
333
334
335
336
337
338 public
339 ItemType getItemClass() {
340 return
341 ItemClass;
342 }
343
344
345
346
347
348
349
350 protected
351 boolean ItemSpawned =
352 false;
353
354
355
356
357
358
359 public
360 boolean isItemSpawned() {
361 return
362 ItemSpawned;
363 }
364
365
366
367
368
369
370
371 protected
372 boolean DoorOpened =
373 false;
374
375
376
377
378
379
380 public
381 boolean isDoorOpened() {
382 return
383 DoorOpened;
384 }
385
386
387
388
389
390
391
392 protected
393 UnrealId Mover =
394 null;
395
396
397
398
399
400
401 public
402 UnrealId getMover() {
403 return
404 Mover;
405 }
406
407
408
409
410
411
412
413 protected
414 Vector3d LiftOffset =
415 null;
416
417
418
419
420
421
422 public
423 Vector3d getLiftOffset() {
424 return
425 LiftOffset;
426 }
427
428
429
430
431
432
433
434 protected
435 boolean LiftJumpExit =
436 false;
437
438
439
440
441
442
443 public
444 boolean isLiftJumpExit() {
445 return
446 LiftJumpExit;
447 }
448
449
450
451
452
453
454
455 protected
456 boolean NoDoubleJump =
457 false;
458
459
460
461
462
463
464 public
465 boolean isNoDoubleJump() {
466 return
467 NoDoubleJump;
468 }
469
470
471
472
473
474
475
476 protected
477 boolean InvSpot =
478 false;
479
480
481
482
483
484
485 public
486 boolean isInvSpot() {
487 return
488 InvSpot;
489 }
490
491
492
493
494
495
496
497 protected
498 boolean PlayerStart =
499 false;
500
501
502
503
504
505
506 public
507 boolean isPlayerStart() {
508 return
509 PlayerStart;
510 }
511
512
513
514
515
516
517
518 protected
519 int TeamNumber =
520 0;
521
522
523
524
525
526
527 public
528 int getTeamNumber() {
529 return
530 TeamNumber;
531 }
532
533
534
535
536
537
538
539 protected
540 boolean Door =
541 false;
542
543
544
545
546
547
548 public
549 boolean isDoor() {
550 return
551 Door;
552 }
553
554
555
556
557
558
559
560 protected
561 boolean LiftCenter =
562 false;
563
564
565
566
567
568
569 public
570 boolean isLiftCenter() {
571 return
572 LiftCenter;
573 }
574
575
576
577
578
579
580
581 protected
582 boolean LiftExit =
583 false;
584
585
586
587
588
589
590 public
591 boolean isLiftExit() {
592 return
593 LiftExit;
594 }
595
596
597
598
599
600
601
602 protected
603 boolean AIMarker =
604 false;
605
606
607
608
609
610
611 public
612 boolean isAIMarker() {
613 return
614 AIMarker;
615 }
616
617
618
619
620
621
622
623 protected
624 boolean JumpSpot =
625 false;
626
627
628
629
630
631
632 public
633 boolean isJumpSpot() {
634 return
635 JumpSpot;
636 }
637
638
639
640
641
642
643
644 protected
645 boolean JumpDest =
646 false;
647
648
649
650
651
652
653 public
654 boolean isJumpDest() {
655 return
656 JumpDest;
657 }
658
659
660
661
662
663
664
665 protected
666 boolean Teleporter =
667 false;
668
669
670
671
672
673
674 public
675 boolean isTeleporter() {
676 return
677 Teleporter;
678 }
679
680
681
682
683
684
685
686
687 protected
688 Rotation Rotation =
689 null;
690
691
692
693
694
695
696
697 public
698 Rotation getRotation() {
699 return
700 Rotation;
701 }
702
703
704
705
706
707
708
709
710 protected
711 boolean RoamingSpot =
712 false;
713
714
715
716
717
718
719
720 public
721 boolean isRoamingSpot() {
722 return
723 RoamingSpot;
724 }
725
726
727
728
729
730 protected
731 boolean SnipingSpot =
732 false;
733
734
735
736
737 public
738 boolean isSnipingSpot() {
739 return
740 SnipingSpot;
741 }
742
743
744
745
746
747 protected
748 Item ItemInstance =
749 null;
750
751
752
753
754 public
755 Item getItemInstance() {
756 return
757 ItemInstance;
758 }
759
760
761
762
763
764 protected
765 Map<UnrealId, NavPointNeighbourLink> OutgoingEdges =
766 new HashMap<UnrealId, NavPointNeighbourLink>();
767
768
769
770
771 public
772 Map<UnrealId, NavPointNeighbourLink> getOutgoingEdges() {
773 return
774 OutgoingEdges;
775 }
776
777
778
779
780
781 protected
782 Map<UnrealId, NavPointNeighbourLink> IncomingEdges =
783 new HashMap<UnrealId, NavPointNeighbourLink>();
784
785
786
787
788 public
789 Map<UnrealId, NavPointNeighbourLink> getIncomingEdges() {
790 return
791 IncomingEdges;
792 }
793
794
795
796
797
798
799
800
801 protected
802 String PreferedWeapon =
803 null;
804
805
806
807
808
809
810
811 public
812 String getPreferedWeapon() {
813 return
814 PreferedWeapon;
815 }
816
817
818
819
820
821
822
823 protected
824 int FlagOfTeam =
825 0;
826
827
828
829
830
831
832 public
833 int getFlagOfTeam() {
834 return
835 FlagOfTeam;
836 }
837
838
839
840
841
842
843
844
845
846 protected double Time = 0;
847
848 protected double getTime() {
849 return Time;
850 }
851
852 protected void setTime(double time) {
853 this.Time = time;
854 }
855
856 public double getLastSeenTime() {
857 return Time;
858 }
859
860
861 public ILocalWorldObject getLocal() {
862 return null;
863 }
864
865 public ISharedWorldObject getShared() {
866 return null;
867 }
868
869 public IStaticWorldObject getStatic() {
870 return null;
871 }
872
873 @Override
874 public long getSimTime() {
875 return (long)getLastSeenTime();
876 }
877
878 public boolean equals(Object obj) {
879 if (!(obj instanceof NavPoint)) return false;
880 NavPoint cast = (NavPoint)obj;
881 if (this.getId() != null) return this.getId().equals(cast.getId());
882 else return cast.getId() == null;
883 }
884
885 public int hashCode() {
886 if (getId() != null) return getId().hashCode();
887 return 0;
888 }
889
890
891
892
893
894
895
896
897
898
899
900
901 public void setItem(Item item) {
902 this.ItemInstance = item;
903 if (item != null) {
904 this.Item = item.getId();
905 }
906 }
907
908
909
910
911
912
913
914
915
916
917 public NavPoint(NavPoint original) {
918
919 this.Id=original.Id;
920
921 this.Location=original.Location;
922
923 this.Velocity=original.Velocity;
924
925 this.Visible=original.Visible;
926
927 this.Item=original.Item;
928
929 this.ItemClass=original.ItemClass;
930
931 this.ItemSpawned=original.ItemSpawned;
932
933 this.DoorOpened=original.DoorOpened;
934
935 this.Mover=original.Mover;
936
937 this.LiftOffset=original.LiftOffset;
938
939 this.LiftJumpExit=original.LiftJumpExit;
940
941 this.NoDoubleJump=original.NoDoubleJump;
942
943 this.InvSpot=original.InvSpot;
944
945 this.PlayerStart=original.PlayerStart;
946
947 this.TeamNumber=original.TeamNumber;
948
949 this.Door=original.Door;
950
951 this.LiftCenter=original.LiftCenter;
952
953 this.LiftExit=original.LiftExit;
954
955 this.AIMarker=original.AIMarker;
956
957 this.JumpSpot=original.JumpSpot;
958
959 this.JumpDest=original.JumpDest;
960
961 this.Teleporter=original.Teleporter;
962
963 this.Rotation=original.Rotation;
964
965 this.RoamingSpot=original.RoamingSpot;
966
967 this.SnipingSpot=original.SnipingSpot;
968
969 this.ItemInstance=original.ItemInstance;
970
971 this.OutgoingEdges=original.OutgoingEdges;
972
973 this.IncomingEdges=original.IncomingEdges;
974
975 this.PreferedWeapon=original.PreferedWeapon;
976
977 this.FlagOfTeam=original.FlagOfTeam;
978
979 }
980
981
982
983
984
985 public NavPoint() {
986 }
987
988
989
990
991
992 public static class ObjectDisappeared implements IGBWorldObjectDisappeared {
993
994 private IWorldObject orig;
995
996 public ObjectDisappeared(IWorldObject orig) {
997 this.orig = orig;
998 }
999
1000 public WorldObjectId getId() {
1001 return orig.getId();
1002 }
1003
1004 public long getSimTime() {
1005 return 0;
1006 }
1007
1008 public IWorldObjectUpdateResult update(IWorldObject obj) {
1009 if (obj == null) {
1010 throw new PogamutException("not meant to create new object, probably wanted to update non-existing object of id: " + getId(), this);
1011 }
1012 if (!(obj instanceof NavPoint)) {
1013 throw new PogamutException("can't update object of class " + obj.getClass() + ", meant to update NavPoint", this);
1014 }
1015 orig = obj;
1016 NavPoint toUpdate = (NavPoint)obj;
1017 if (toUpdate.Visible) {
1018 toUpdate.Visible = false;
1019 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
1020 } else {
1021 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, toUpdate);
1022 }
1023 }
1024
1025 public IWorldObject getObject() {
1026 return orig;
1027 }
1028
1029 public String toString() {
1030 return "ObjectDisappeared[" + orig.getClass().getSimpleName() + " " + orig.getId().getStringId() + "]";
1031 }
1032
1033 }
1034
1035
1036
1037
1038 public NavPoint(NavPoint Original, boolean Visible) {
1039 this(Original);
1040 this.Visible = Visible;
1041 }
1042
1043 public IGBWorldObjectDisappeared createDisappearEvent() {
1044 return new ObjectDisappeared(this);
1045 }
1046
1047
1048
1049
1050
1051 private IWorldObject orig = null;
1052
1053 public IWorldObjectUpdateResult update(IWorldObject obj) {
1054 if(obj == null) {
1055 orig = this;
1056 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
1057 }
1058 orig = obj;
1059
1060 NavPoint o = (NavPoint)obj;
1061
1062 boolean updated = false;
1063
1064
1065 if (!SafeEquals.equals(o.Location, Location)) {
1066 o.Location=Location;
1067 updated = true;
1068 }
1069
1070 if (!SafeEquals.equals(o.Velocity, Velocity)) {
1071 o.Velocity=Velocity;
1072 updated = true;
1073 }
1074
1075 if (o.Visible != Visible) {
1076 o.Visible=Visible;
1077 updated = true;
1078 }
1079
1080 o.Time = Time;
1081
1082
1083 if (updated) {
1084 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
1085 } else {
1086 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
1087 }
1088 }
1089
1090
1091
1092
1093
1094 public IWorldObject getObject() {
1095 if (orig == null) return this;
1096 return orig;
1097 }
1098
1099
1100
1101 public String toString() {
1102 return
1103
1104 super.toString() + " | " +
1105
1106 "Id = " +
1107 String.valueOf(Id) + " | " +
1108
1109 "Location = " +
1110 String.valueOf(Location) + " | " +
1111
1112 "Velocity = " +
1113 String.valueOf(Velocity) + " | " +
1114
1115 "Visible = " +
1116 String.valueOf(Visible) + " | " +
1117
1118 "Item = " +
1119 String.valueOf(Item) + " | " +
1120
1121 "ItemClass = " +
1122 String.valueOf(ItemClass) + " | " +
1123
1124 "ItemSpawned = " +
1125 String.valueOf(ItemSpawned) + " | " +
1126
1127 "DoorOpened = " +
1128 String.valueOf(DoorOpened) + " | " +
1129
1130 "Mover = " +
1131 String.valueOf(Mover) + " | " +
1132
1133 "LiftOffset = " +
1134 String.valueOf(LiftOffset) + " | " +
1135
1136 "LiftJumpExit = " +
1137 String.valueOf(LiftJumpExit) + " | " +
1138
1139 "NoDoubleJump = " +
1140 String.valueOf(NoDoubleJump) + " | " +
1141
1142 "InvSpot = " +
1143 String.valueOf(InvSpot) + " | " +
1144
1145 "PlayerStart = " +
1146 String.valueOf(PlayerStart) + " | " +
1147
1148 "TeamNumber = " +
1149 String.valueOf(TeamNumber) + " | " +
1150
1151 "Door = " +
1152 String.valueOf(Door) + " | " +
1153
1154 "LiftCenter = " +
1155 String.valueOf(LiftCenter) + " | " +
1156
1157 "LiftExit = " +
1158 String.valueOf(LiftExit) + " | " +
1159
1160 "AIMarker = " +
1161 String.valueOf(AIMarker) + " | " +
1162
1163 "JumpSpot = " +
1164 String.valueOf(JumpSpot) + " | " +
1165
1166 "JumpDest = " +
1167 String.valueOf(JumpDest) + " | " +
1168
1169 "Teleporter = " +
1170 String.valueOf(Teleporter) + " | " +
1171
1172 "Rotation = " +
1173 String.valueOf(Rotation) + " | " +
1174
1175 "RoamingSpot = " +
1176 String.valueOf(RoamingSpot) + " | " +
1177
1178 "SnipingSpot = " +
1179 String.valueOf(SnipingSpot) + " | " +
1180
1181 "PreferedWeapon = " +
1182 String.valueOf(PreferedWeapon) + " | " +
1183
1184 "FlagOfTeam = " +
1185 String.valueOf(FlagOfTeam) + " | " +
1186 "";
1187
1188 }
1189
1190 public String toHtmlString() {
1191 return super.toString() +
1192
1193 "<b>Id</b> : " +
1194 String.valueOf(Id) +
1195 " <br/> " +
1196
1197 "<b>Location</b> : " +
1198 String.valueOf(Location) +
1199 " <br/> " +
1200
1201 "<b>Velocity</b> : " +
1202 String.valueOf(Velocity) +
1203 " <br/> " +
1204
1205 "<b>Visible</b> : " +
1206 String.valueOf(Visible) +
1207 " <br/> " +
1208
1209 "<b>Item</b> : " +
1210 String.valueOf(Item) +
1211 " <br/> " +
1212
1213 "<b>ItemClass</b> : " +
1214 String.valueOf(ItemClass) +
1215 " <br/> " +
1216
1217 "<b>ItemSpawned</b> : " +
1218 String.valueOf(ItemSpawned) +
1219 " <br/> " +
1220
1221 "<b>DoorOpened</b> : " +
1222 String.valueOf(DoorOpened) +
1223 " <br/> " +
1224
1225 "<b>Mover</b> : " +
1226 String.valueOf(Mover) +
1227 " <br/> " +
1228
1229 "<b>LiftOffset</b> : " +
1230 String.valueOf(LiftOffset) +
1231 " <br/> " +
1232
1233 "<b>LiftJumpExit</b> : " +
1234 String.valueOf(LiftJumpExit) +
1235 " <br/> " +
1236
1237 "<b>NoDoubleJump</b> : " +
1238 String.valueOf(NoDoubleJump) +
1239 " <br/> " +
1240
1241 "<b>InvSpot</b> : " +
1242 String.valueOf(InvSpot) +
1243 " <br/> " +
1244
1245 "<b>PlayerStart</b> : " +
1246 String.valueOf(PlayerStart) +
1247 " <br/> " +
1248
1249 "<b>TeamNumber</b> : " +
1250 String.valueOf(TeamNumber) +
1251 " <br/> " +
1252
1253 "<b>Door</b> : " +
1254 String.valueOf(Door) +
1255 " <br/> " +
1256
1257 "<b>LiftCenter</b> : " +
1258 String.valueOf(LiftCenter) +
1259 " <br/> " +
1260
1261 "<b>LiftExit</b> : " +
1262 String.valueOf(LiftExit) +
1263 " <br/> " +
1264
1265 "<b>AIMarker</b> : " +
1266 String.valueOf(AIMarker) +
1267 " <br/> " +
1268
1269 "<b>JumpSpot</b> : " +
1270 String.valueOf(JumpSpot) +
1271 " <br/> " +
1272
1273 "<b>JumpDest</b> : " +
1274 String.valueOf(JumpDest) +
1275 " <br/> " +
1276
1277 "<b>Teleporter</b> : " +
1278 String.valueOf(Teleporter) +
1279 " <br/> " +
1280
1281 "<b>Rotation</b> : " +
1282 String.valueOf(Rotation) +
1283 " <br/> " +
1284
1285 "<b>RoamingSpot</b> : " +
1286 String.valueOf(RoamingSpot) +
1287 " <br/> " +
1288
1289 "<b>SnipingSpot</b> : " +
1290 String.valueOf(SnipingSpot) +
1291 " <br/> " +
1292
1293 "<b>ItemInstance</b> : " +
1294 String.valueOf(ItemInstance) +
1295 " <br/> " +
1296
1297 "<b>OutgoingEdges</b> : " +
1298 String.valueOf(OutgoingEdges) +
1299 " <br/> " +
1300
1301 "<b>IncomingEdges</b> : " +
1302 String.valueOf(IncomingEdges) +
1303 " <br/> " +
1304
1305 "<b>PreferedWeapon</b> : " +
1306 String.valueOf(PreferedWeapon) +
1307 " <br/> " +
1308
1309 "<b>FlagOfTeam</b> : " +
1310 String.valueOf(FlagOfTeam) +
1311 " <br/> " +
1312 "";
1313 }
1314
1315
1316
1317 }
1318
1319