1
2 /**
3 IMPORTANT !!!
4
5 DO NOT EDIT THIS FILE. IT IS GENERATED FROM approriate xml file in xmlresources/gbinfomessages BY
6 THE JavaClassesGenerator.xslt. MODIFY THESE FILES INSTEAD OF THIS ONE.
7
8 IMPORTANT END !!!
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 Synchronous message. NavPoint carries information about UT
35 navigation point - location, reachability... Also some item can
36 be respawned at this point. Or some additional information can
37 be stored here (if it is an ambush point, or sniper point..).
38
39 Corresponding GameBots message is
40 NAV.
41
42 */
43
44 public class
45 NavPoint
46 extends GBObjectUpdate
47
48 implements IGBWorldObjectEvent, IWorldObject, ILocated, ILocomotive, IGBViewable
49
50 {
51
52 /**
53 Creates new instance of command NavPoint.
54
55 Synchronous message. NavPoint carries information about UT
56 navigation point - location, reachability... Also some item can
57 be respawned at this point. Or some additional information can
58 be stored here (if it is an ambush point, or sniper point..).
59 Corresponding GameBots message for this command is
60 .
61 @param Id
62 A unique Id of this navigation point assigned by the game.
63
64 @param Location Location of navigation point.
65 @param Velocity
66 Velocity of the navigation point (if the navigation point is
67 currently moving). Not sent at the moment.
68
69 @param Visible
70 If the point is in the field of view of the bot.
71
72 @param Item
73 Unique Id of the respawned item (the item respawns at this
74 point). Not sent if point is not an inventory spot. Sent only in HandShake.
75
76 @param ItemClass
77 Class of the item (e.g. LinkGun.WeaponPickup). Not sent if point is not an inventory spot. Sent only in HandShake.
78
79 @param ItemSpawned
80 True if the item is spawned at the point. Not sent if point is not an inventory spot.
81
82 @param DoorOpened
83 True if this NavPoint is a Door and door is opened. Not sent if point is not a door.
84
85 @param Mover
86 If this NavPoint is marking some mover, the mover id will be here. Not sent if point is not a Door, a LiftCenter or a LiftExit. Sent only in HandShake.
87
88 @param LiftOffset
89 Starting vector between MyLift location and LiftCenter location. Not sent if point is not a LiftCenter. Sent only in HandShake.
90
91 @param LiftJumpExit
92 Boolean. If we can/should exit the lift by a jump when near the destination place. Not sent if point is not a LiftExit. Sent only in HandShake.
93
94 @param NoDoubleJump
95 Boolean. If we should or not use double jump when exiting lift with a jump. Not sent if point is not a LiftExit. Sent only in HandShake.
96
97 @param InvSpot
98 If this is an inventory spot (item is respawned at this point).
99
100 @param PlayerStart
101 If this is a player start (players and/or bots are respawned at this point).
102
103 @param TeamNumber
104 Will be sent if this is a player start. In Team games (team deathmatch, capture the flag) holds information about which team respawns at this player start spot. In non-team games will return 0!
105
106 @param Door
107 If this point marks a door mover.
108
109 @param LiftCenter
110 If this point marks a lift center (used to mark center of a lift mover, note that this point will be always moved with the lift).
111
112 @param LiftExit
113 If this point marks a lift exit (used to mark exit point of a lift mover).
114
115 @param AIMarker
116 If this point is an AI marker - marks an interesting spot in the environment. May be ambush point or sniping spot, etc.
117
118 @param JumpSpot
119 If this point marks a jump spot (a special device that causes the bot to jump high or far).
120
121 @param JumpDest
122 If this point marks a jump destination - some place that can be reached by some special jump.
123
124 @param Teleporter
125 If this point marks a teleport.
126
127 @param Rotation
128 If the type is AIMarker. The rotation the bot should be
129 facing, when doing the action specified by AIMarker. Sent only in HandShake.
130
131 @param RoamingSpot
132 Some ambush point, where is good chance to intercept
133 approaching opponents. Sent only in HandShake.
134
135 @param SnipingSpot Point good for sniping. Sent only in HandShake.
136 @param ItemInstance If item should be present at this navpoint it's instance will be here.
137 @param OutgoingEdges Maps edge-LEADING_TO-navpoint-UnrealId to neighbour link, those are outgoing edges (those edges that originates in this navpoint going to another one, those you may usually travel).
138 @param IncomingEdges Maps edge-ORIGINATES_FROM-navpoint-UnrealId to neighbour link, those are incoming edges (those edges that originates in different navpoint and ends here, do not use this to ask whether you can get to navpoint of specific unreal id, use OutgoingEdges instead).
139 @param PreferedWeapon
140 Class of the weapon that should be prefered when using this
141 point for AIMarker specified action. Sent only in HandShake.
142
143 @param FlagOfTeam
144 If this is a CTF game, then this contains team number that owns the flag located at this NavPoint.
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 /** Example how the message looks like - used during parser tests. */
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 /////// Properties BEGIN
219
220 /**
221
222 A unique Id of this navigation point assigned by the game.
223 */
224 protected
225 UnrealId Id =
226 null;
227
228
229 /**
230
231 A unique Id of this navigation point assigned by the game.
232 */
233 public
234 UnrealId getId() {
235 return
236 Id;
237 }
238
239
240
241 /**
242 Location of navigation point. */
243 protected
244 Location Location =
245 null;
246
247
248 /**
249 Location of navigation point. */
250 public
251 Location getLocation() {
252 return
253 Location;
254 }
255
256
257
258 /**
259
260 Velocity of the navigation point (if the navigation point is
261 currently moving). Not sent at the moment.
262 */
263 protected
264 Velocity Velocity =
265 null;
266
267
268 /**
269
270 Velocity of the navigation point (if the navigation point is
271 currently moving). Not sent at the moment.
272 */
273 public
274 Velocity getVelocity() {
275 return
276 Velocity;
277 }
278
279
280
281 /**
282
283 If the point is in the field of view of the bot.
284 */
285 protected
286 boolean Visible =
287 false;
288
289
290 /**
291
292 If the point is in the field of view of the bot.
293 */
294 public
295 boolean isVisible() {
296 return
297 Visible;
298 }
299
300
301
302 /**
303
304 Unique Id of the respawned item (the item respawns at this
305 point). Not sent if point is not an inventory spot. Sent only in HandShake.
306 */
307 protected
308 UnrealId Item =
309 null;
310
311
312 /**
313
314 Unique Id of the respawned item (the item respawns at this
315 point). Not sent if point is not an inventory spot. Sent only in HandShake.
316 */
317 public
318 UnrealId getItem() {
319 return
320 Item;
321 }
322
323
324
325 /**
326
327 Class of the item (e.g. LinkGun.WeaponPickup). Not sent if point is not an inventory spot. Sent only in HandShake.
328 */
329 protected
330 ItemType ItemClass =
331 null;
332
333
334 /**
335
336 Class of the item (e.g. LinkGun.WeaponPickup). Not sent if point is not an inventory spot. Sent only in HandShake.
337 */
338 public
339 ItemType getItemClass() {
340 return
341 ItemClass;
342 }
343
344
345
346 /**
347
348 True if the item is spawned at the point. Not sent if point is not an inventory spot.
349 */
350 protected
351 boolean ItemSpawned =
352 false;
353
354
355 /**
356
357 True if the item is spawned at the point. Not sent if point is not an inventory spot.
358 */
359 public
360 boolean isItemSpawned() {
361 return
362 ItemSpawned;
363 }
364
365
366
367 /**
368
369 True if this NavPoint is a Door and door is opened. Not sent if point is not a door.
370 */
371 protected
372 boolean DoorOpened =
373 false;
374
375
376 /**
377
378 True if this NavPoint is a Door and door is opened. Not sent if point is not a door.
379 */
380 public
381 boolean isDoorOpened() {
382 return
383 DoorOpened;
384 }
385
386
387
388 /**
389
390 If this NavPoint is marking some mover, the mover id will be here. Not sent if point is not a Door, a LiftCenter or a LiftExit. Sent only in HandShake.
391 */
392 protected
393 UnrealId Mover =
394 null;
395
396
397 /**
398
399 If this NavPoint is marking some mover, the mover id will be here. Not sent if point is not a Door, a LiftCenter or a LiftExit. Sent only in HandShake.
400 */
401 public
402 UnrealId getMover() {
403 return
404 Mover;
405 }
406
407
408
409 /**
410
411 Starting vector between MyLift location and LiftCenter location. Not sent if point is not a LiftCenter. Sent only in HandShake.
412 */
413 protected
414 Vector3d LiftOffset =
415 null;
416
417
418 /**
419
420 Starting vector between MyLift location and LiftCenter location. Not sent if point is not a LiftCenter. Sent only in HandShake.
421 */
422 public
423 Vector3d getLiftOffset() {
424 return
425 LiftOffset;
426 }
427
428
429
430 /**
431
432 Boolean. If we can/should exit the lift by a jump when near the destination place. Not sent if point is not a LiftExit. Sent only in HandShake.
433 */
434 protected
435 boolean LiftJumpExit =
436 false;
437
438
439 /**
440
441 Boolean. If we can/should exit the lift by a jump when near the destination place. Not sent if point is not a LiftExit. Sent only in HandShake.
442 */
443 public
444 boolean isLiftJumpExit() {
445 return
446 LiftJumpExit;
447 }
448
449
450
451 /**
452
453 Boolean. If we should or not use double jump when exiting lift with a jump. Not sent if point is not a LiftExit. Sent only in HandShake.
454 */
455 protected
456 boolean NoDoubleJump =
457 false;
458
459
460 /**
461
462 Boolean. If we should or not use double jump when exiting lift with a jump. Not sent if point is not a LiftExit. Sent only in HandShake.
463 */
464 public
465 boolean isNoDoubleJump() {
466 return
467 NoDoubleJump;
468 }
469
470
471
472 /**
473
474 If this is an inventory spot (item is respawned at this point).
475 */
476 protected
477 boolean InvSpot =
478 false;
479
480
481 /**
482
483 If this is an inventory spot (item is respawned at this point).
484 */
485 public
486 boolean isInvSpot() {
487 return
488 InvSpot;
489 }
490
491
492
493 /**
494
495 If this is a player start (players and/or bots are respawned at this point).
496 */
497 protected
498 boolean PlayerStart =
499 false;
500
501
502 /**
503
504 If this is a player start (players and/or bots are respawned at this point).
505 */
506 public
507 boolean isPlayerStart() {
508 return
509 PlayerStart;
510 }
511
512
513
514 /**
515
516 Will be sent if this is a player start. In Team games (team deathmatch, capture the flag) holds information about which team respawns at this player start spot. In non-team games will return 0!
517 */
518 protected
519 int TeamNumber =
520 0;
521
522
523 /**
524
525 Will be sent if this is a player start. In Team games (team deathmatch, capture the flag) holds information about which team respawns at this player start spot. In non-team games will return 0!
526 */
527 public
528 int getTeamNumber() {
529 return
530 TeamNumber;
531 }
532
533
534
535 /**
536
537 If this point marks a door mover.
538 */
539 protected
540 boolean Door =
541 false;
542
543
544 /**
545
546 If this point marks a door mover.
547 */
548 public
549 boolean isDoor() {
550 return
551 Door;
552 }
553
554
555
556 /**
557
558 If this point marks a lift center (used to mark center of a lift mover, note that this point will be always moved with the lift).
559 */
560 protected
561 boolean LiftCenter =
562 false;
563
564
565 /**
566
567 If this point marks a lift center (used to mark center of a lift mover, note that this point will be always moved with the lift).
568 */
569 public
570 boolean isLiftCenter() {
571 return
572 LiftCenter;
573 }
574
575
576
577 /**
578
579 If this point marks a lift exit (used to mark exit point of a lift mover).
580 */
581 protected
582 boolean LiftExit =
583 false;
584
585
586 /**
587
588 If this point marks a lift exit (used to mark exit point of a lift mover).
589 */
590 public
591 boolean isLiftExit() {
592 return
593 LiftExit;
594 }
595
596
597
598 /**
599
600 If this point is an AI marker - marks an interesting spot in the environment. May be ambush point or sniping spot, etc.
601 */
602 protected
603 boolean AIMarker =
604 false;
605
606
607 /**
608
609 If this point is an AI marker - marks an interesting spot in the environment. May be ambush point or sniping spot, etc.
610 */
611 public
612 boolean isAIMarker() {
613 return
614 AIMarker;
615 }
616
617
618
619 /**
620
621 If this point marks a jump spot (a special device that causes the bot to jump high or far).
622 */
623 protected
624 boolean JumpSpot =
625 false;
626
627
628 /**
629
630 If this point marks a jump spot (a special device that causes the bot to jump high or far).
631 */
632 public
633 boolean isJumpSpot() {
634 return
635 JumpSpot;
636 }
637
638
639
640 /**
641
642 If this point marks a jump destination - some place that can be reached by some special jump.
643 */
644 protected
645 boolean JumpDest =
646 false;
647
648
649 /**
650
651 If this point marks a jump destination - some place that can be reached by some special jump.
652 */
653 public
654 boolean isJumpDest() {
655 return
656 JumpDest;
657 }
658
659
660
661 /**
662
663 If this point marks a teleport.
664 */
665 protected
666 boolean Teleporter =
667 false;
668
669
670 /**
671
672 If this point marks a teleport.
673 */
674 public
675 boolean isTeleporter() {
676 return
677 Teleporter;
678 }
679
680
681
682 /**
683
684 If the type is AIMarker. The rotation the bot should be
685 facing, when doing the action specified by AIMarker. Sent only in HandShake.
686 */
687 protected
688 Rotation Rotation =
689 null;
690
691
692 /**
693
694 If the type is AIMarker. The rotation the bot should be
695 facing, when doing the action specified by AIMarker. Sent only in HandShake.
696 */
697 public
698 Rotation getRotation() {
699 return
700 Rotation;
701 }
702
703
704
705 /**
706
707 Some ambush point, where is good chance to intercept
708 approaching opponents. Sent only in HandShake.
709 */
710 protected
711 boolean RoamingSpot =
712 false;
713
714
715 /**
716
717 Some ambush point, where is good chance to intercept
718 approaching opponents. Sent only in HandShake.
719 */
720 public
721 boolean isRoamingSpot() {
722 return
723 RoamingSpot;
724 }
725
726
727
728 /**
729 Point good for sniping. Sent only in HandShake. */
730 protected
731 boolean SnipingSpot =
732 false;
733
734
735 /**
736 Point good for sniping. Sent only in HandShake. */
737 public
738 boolean isSnipingSpot() {
739 return
740 SnipingSpot;
741 }
742
743
744
745 /**
746 If item should be present at this navpoint it's instance will be here. */
747 protected
748 Item ItemInstance =
749 null;
750
751
752 /**
753 If item should be present at this navpoint it's instance will be here. */
754 public
755 Item getItemInstance() {
756 return
757 ItemInstance;
758 }
759
760
761
762 /**
763 Maps edge-LEADING_TO-navpoint-UnrealId to neighbour link, those are outgoing edges (those edges that originates in this navpoint going to another one, those you may usually travel). */
764 protected
765 Map<UnrealId, NavPointNeighbourLink> OutgoingEdges =
766 new HashMap<UnrealId, NavPointNeighbourLink>();
767
768
769 /**
770 Maps edge-LEADING_TO-navpoint-UnrealId to neighbour link, those are outgoing edges (those edges that originates in this navpoint going to another one, those you may usually travel). */
771 public
772 Map<UnrealId, NavPointNeighbourLink> getOutgoingEdges() {
773 return
774 OutgoingEdges;
775 }
776
777
778
779 /**
780 Maps edge-ORIGINATES_FROM-navpoint-UnrealId to neighbour link, those are incoming edges (those edges that originates in different navpoint and ends here, do not use this to ask whether you can get to navpoint of specific unreal id, use OutgoingEdges instead). */
781 protected
782 Map<UnrealId, NavPointNeighbourLink> IncomingEdges =
783 new HashMap<UnrealId, NavPointNeighbourLink>();
784
785
786 /**
787 Maps edge-ORIGINATES_FROM-navpoint-UnrealId to neighbour link, those are incoming edges (those edges that originates in different navpoint and ends here, do not use this to ask whether you can get to navpoint of specific unreal id, use OutgoingEdges instead). */
788 public
789 Map<UnrealId, NavPointNeighbourLink> getIncomingEdges() {
790 return
791 IncomingEdges;
792 }
793
794
795
796 /**
797
798 Class of the weapon that should be prefered when using this
799 point for AIMarker specified action. Sent only in HandShake.
800 */
801 protected
802 String PreferedWeapon =
803 null;
804
805
806 /**
807
808 Class of the weapon that should be prefered when using this
809 point for AIMarker specified action. Sent only in HandShake.
810 */
811 public
812 String getPreferedWeapon() {
813 return
814 PreferedWeapon;
815 }
816
817
818
819 /**
820
821 If this is a CTF game, then this contains team number that owns the flag located at this NavPoint.
822 */
823 protected
824 int FlagOfTeam =
825 0;
826
827
828 /**
829
830 If this is a CTF game, then this contains team number that owns the flag located at this NavPoint.
831 */
832 public
833 int getFlagOfTeam() {
834 return
835 FlagOfTeam;
836 }
837
838
839
840 /////// Properties END
841
842 /////// Extra Java code BEGIN
843
844 /////// Additional code from xslt BEGIN
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 /////// Additional code from xslt END
894
895 /////// Extra Java from XML BEGIN
896
897 /**
898 * DO NOT USE THIS METHOD! Reserved for GaviaLib (Pogamut core)! It's used
899 * to set correct item instance into the NavPoint.
900 */
901 public void setItem(Item item) {
902 this.ItemInstance = item;
903 if (item != null) {
904 this.Item = item.getId();
905 }
906 }
907
908 /////// Extra Java from XML END
909
910 /////// Extra Java code END
911
912
913
914 /**
915 * Cloning constructor.
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 * Used by Yylex to create empty message then to fill it's protected fields (Yylex is in the same package).
984 */
985 public NavPoint() {
986 }
987
988
989 /**
990 * Used to drop Visible flag from the object.
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 * Used to create event that drops the Visible flag of the item.
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 * Here we save the original object for which this object is an update.
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 // typecast
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 * Returns original object (if method update() has already been called, for bot-programmer that is always true
1092 * as the original object is updated and then the event is propagated).
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