1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3 // --- IMPORTS FROM /messages/settings/javasettings/javaimport BEGIN
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 // --- IMPORTS FROM /messages/settings/javasettings/javaimport END
6
7
8 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] BEGIN
9
10 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name='all'] END
11
12 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=message] BEGIN
13
14 // --- IMPORTS FROM extra/code/java/javapart/classcategory[@name=base]+classtype[@name=message] END
15
16 /**
17 *
18 Implementation of the GameBots2004 message MOV contains also its Local/Shared/Static subpart class definitions..
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Synchronous message. Movers can be doors, elevators, or any
25 other chunk of architecture that can move. They generally need
26 to be either run into, or activated by shooting or pressing a
27 button. We are working on ways to provide bots with more of the
28 information they need to deal with movers appropriately.
29
30 */
31 public class MoverMessage
32 extends
33 Mover
34 implements IWorldObjectUpdatedEvent, ICompositeWorldObjectUpdatedEvent
35
36 {
37
38
39
40 /**
41 * Parameter-less contructor for the message.
42 */
43 public MoverMessage()
44 {
45 }
46
47
48
49
50 /**
51 * Creates new instance of the message Mover.
52 *
53 Synchronous message. Movers can be doors, elevators, or any
54 other chunk of architecture that can move. They generally need
55 to be either run into, or activated by shooting or pressing a
56 button. We are working on ways to provide bots with more of the
57 information they need to deal with movers appropriately.
58
59 * Corresponding GameBots message
60 *
61 * is
62 * MOV.
63 *
64 *
65 *
66 * @param Id
67 A unique Id of this mover assigned by the game.
68
69 *
70 *
71 *
72 * @param Location Location of the mover.
73 *
74 *
75 *
76 * @param Visible If the mover is in the field of view of the bot.
77 *
78 *
79 *
80 * @param DamageTrig
81 True if the mover needs to be shot to be activated.
82
83 *
84 *
85 *
86 * @param Type String class of the mover.
87 *
88 *
89 *
90 * @param IsMoving Does the mover move right now?
91 *
92 *
93 *
94 * @param Velocity Velocity vector.
95 *
96 *
97 *
98 * @param MoveTime How long the mover moves, when it becomes triggered, before it stops.
99 *
100 *
101 *
102 * @param OpenTime How long the mover stands still when it reaches its destination position. After
103 this time, the mover returns back to its initial position.
104 *
105 *
106 *
107 * @param BasePos Base position of the mover.
108 *
109 *
110 *
111 * @param BaseRot Base rotation of the mover.
112 *
113 *
114 *
115 * @param DelayTime Delay before starting to open (or before lift starts to move).
116 *
117 *
118 *
119 * @param State Name of the state Mover is currently in. Can be used to determine the type of the mover.
120 *
121 *
122 *
123 * @param NavPointMarker Navigation point marking this mover. We can parse this Id to get information about type of the mover. Marker Id contains "lift" string if it is a lift, "door" string if it is a door, etc.
124 *
125 *
126 */
127 public MoverMessage(
128 UnrealId Id, Location Location, boolean Visible, boolean DamageTrig, String Type, boolean IsMoving, Velocity Velocity, double MoveTime, double OpenTime, Location BasePos, Location BaseRot, double DelayTime, String State, UnrealId NavPointMarker
129 ) {
130
131 this.Id = Id;
132
133 this.Location = Location;
134
135 this.Visible = Visible;
136
137 this.DamageTrig = DamageTrig;
138
139 this.Type = Type;
140
141 this.IsMoving = IsMoving;
142
143 this.Velocity = Velocity;
144
145 this.MoveTime = MoveTime;
146
147 this.OpenTime = OpenTime;
148
149 this.BasePos = BasePos;
150
151 this.BaseRot = BaseRot;
152
153 this.DelayTime = DelayTime;
154
155 this.State = State;
156
157 this.NavPointMarker = NavPointMarker;
158
159 }
160
161 /**
162 * Cloning constructor from the full message.
163 *
164 * @param original
165 */
166 public MoverMessage(MoverMessage original) {
167
168 this.Id = original.getId()
169 ;
170
171 this.Location = original.getLocation()
172 ;
173
174 this.Visible = original.isVisible()
175 ;
176
177 this.DamageTrig = original.isDamageTrig()
178 ;
179
180 this.Type = original.getType()
181 ;
182
183 this.IsMoving = original.isIsMoving()
184 ;
185
186 this.Velocity = original.getVelocity()
187 ;
188
189 this.MoveTime = original.getMoveTime()
190 ;
191
192 this.OpenTime = original.getOpenTime()
193 ;
194
195 this.BasePos = original.getBasePos()
196 ;
197
198 this.BaseRot = original.getBaseRot()
199 ;
200
201 this.DelayTime = original.getDelayTime()
202 ;
203
204 this.State = original.getState()
205 ;
206
207 this.NavPointMarker = original.getNavPointMarker()
208 ;
209
210 this.TeamId = original.getTeamId();
211
212 this.SimTime = original.getSimTime();
213 }
214
215
216 protected ITeamId TeamId;
217
218 /**
219 * Used by Yylex to slip corretn TeamId.
220 */
221 protected void setTeamId(ITeamId TeamId) {
222 this.TeamId = TeamId;
223 }
224
225 public ITeamId getTeamId() {
226 return TeamId;
227 }
228
229
230
231
232 /**
233 *
234 A unique Id of this mover assigned by the game.
235
236 */
237 protected
238 UnrealId Id =
239 null;
240
241
242 /**
243 * Whether property 'Id' was received from GB2004.
244 */
245 protected boolean Id_Set = false;
246
247 @Override
248
249 /**
250 *
251 A unique Id of this mover assigned by the game.
252
253 */
254 public UnrealId getId()
255 {
256 return Id;
257 }
258
259
260 /**
261 * Location of the mover.
262 */
263 protected
264 Location Location =
265 null;
266
267
268 /**
269 * Whether property 'Location' was received from GB2004.
270 */
271 protected boolean Location_Set = false;
272
273 @Override
274
275 /**
276 * Location of the mover.
277 */
278 public Location getLocation()
279 {
280 return Location;
281 }
282
283
284 /**
285 * If the mover is in the field of view of the bot.
286 */
287 protected
288 boolean Visible =
289 false;
290
291
292 /**
293 * Whether property 'Visible' was received from GB2004.
294 */
295 protected boolean Visible_Set = false;
296
297 @Override
298
299 /**
300 * If the mover is in the field of view of the bot.
301 */
302 public boolean isVisible()
303 {
304 return Visible;
305 }
306
307
308 /**
309 *
310 True if the mover needs to be shot to be activated.
311
312 */
313 protected
314 boolean DamageTrig =
315 false;
316
317
318 /**
319 * Whether property 'DamageTrig' was received from GB2004.
320 */
321 protected boolean DamageTrig_Set = false;
322
323 @Override
324
325 /**
326 *
327 True if the mover needs to be shot to be activated.
328
329 */
330 public boolean isDamageTrig()
331 {
332 return DamageTrig;
333 }
334
335
336 /**
337 * String class of the mover.
338 */
339 protected
340 String Type =
341 null;
342
343
344 /**
345 * Whether property 'Type' was received from GB2004.
346 */
347 protected boolean Type_Set = false;
348
349 @Override
350
351 /**
352 * String class of the mover.
353 */
354 public String getType()
355 {
356 return Type;
357 }
358
359
360 /**
361 * Does the mover move right now?
362 */
363 protected
364 boolean IsMoving =
365 false;
366
367
368 /**
369 * Whether property 'IsMoving' was received from GB2004.
370 */
371 protected boolean IsMoving_Set = false;
372
373 @Override
374
375 /**
376 * Does the mover move right now?
377 */
378 public boolean isIsMoving()
379 {
380 return IsMoving;
381 }
382
383
384 /**
385 * Velocity vector.
386 */
387 protected
388 Velocity Velocity =
389 null;
390
391
392 /**
393 * Whether property 'Velocity' was received from GB2004.
394 */
395 protected boolean Velocity_Set = false;
396
397 @Override
398
399 /**
400 * Velocity vector.
401 */
402 public Velocity getVelocity()
403 {
404 return Velocity;
405 }
406
407
408 /**
409 * How long the mover moves, when it becomes triggered, before it stops.
410 */
411 protected
412 double MoveTime =
413 0;
414
415
416 /**
417 * Whether property 'MoveTime' was received from GB2004.
418 */
419 protected boolean MoveTime_Set = false;
420
421 @Override
422
423 /**
424 * How long the mover moves, when it becomes triggered, before it stops.
425 */
426 public double getMoveTime()
427 {
428 return MoveTime;
429 }
430
431
432 /**
433 * How long the mover stands still when it reaches its destination position. After
434 this time, the mover returns back to its initial position.
435 */
436 protected
437 double OpenTime =
438 0;
439
440
441 /**
442 * Whether property 'OpenTime' was received from GB2004.
443 */
444 protected boolean OpenTime_Set = false;
445
446 @Override
447
448 /**
449 * How long the mover stands still when it reaches its destination position. After
450 this time, the mover returns back to its initial position.
451 */
452 public double getOpenTime()
453 {
454 return OpenTime;
455 }
456
457
458 /**
459 * Base position of the mover.
460 */
461 protected
462 Location BasePos =
463 null;
464
465
466 /**
467 * Whether property 'BasePos' was received from GB2004.
468 */
469 protected boolean BasePos_Set = false;
470
471 @Override
472
473 /**
474 * Base position of the mover.
475 */
476 public Location getBasePos()
477 {
478 return BasePos;
479 }
480
481
482 /**
483 * Base rotation of the mover.
484 */
485 protected
486 Location BaseRot =
487 null;
488
489
490 /**
491 * Whether property 'BaseRot' was received from GB2004.
492 */
493 protected boolean BaseRot_Set = false;
494
495 @Override
496
497 /**
498 * Base rotation of the mover.
499 */
500 public Location getBaseRot()
501 {
502 return BaseRot;
503 }
504
505
506 /**
507 * Delay before starting to open (or before lift starts to move).
508 */
509 protected
510 double DelayTime =
511 0;
512
513
514 /**
515 * Whether property 'DelayTime' was received from GB2004.
516 */
517 protected boolean DelayTime_Set = false;
518
519 @Override
520
521 /**
522 * Delay before starting to open (or before lift starts to move).
523 */
524 public double getDelayTime()
525 {
526 return DelayTime;
527 }
528
529
530 /**
531 * Name of the state Mover is currently in. Can be used to determine the type of the mover.
532 */
533 protected
534 String State =
535 null;
536
537
538 /**
539 * Whether property 'State' was received from GB2004.
540 */
541 protected boolean State_Set = false;
542
543 @Override
544
545 /**
546 * Name of the state Mover is currently in. Can be used to determine the type of the mover.
547 */
548 public String getState()
549 {
550 return State;
551 }
552
553
554 /**
555 * Navigation point marking this mover. We can parse this Id to get information about type of the mover. Marker Id contains "lift" string if it is a lift, "door" string if it is a door, etc.
556 */
557 protected
558 UnrealId NavPointMarker =
559 null;
560
561
562 /**
563 * Whether property 'NavPointMarker' was received from GB2004.
564 */
565 protected boolean NavPointMarker_Set = false;
566
567 @Override
568
569 /**
570 * Navigation point marking this mover. We can parse this Id to get information about type of the mover. Marker Id contains "lift" string if it is a lift, "door" string if it is a door, etc.
571 */
572 public UnrealId getNavPointMarker()
573 {
574 return NavPointMarker;
575 }
576
577
578 private MoverLocal localPart = null;
579
580 @Override
581 public MoverLocal
582 getLocal() {
583 if (localPart != null) return localPart;
584 return localPart = new
585 MoverLocalMessage();
586 }
587
588 private MoverShared sharedPart = null;
589
590 @Override
591 public MoverShared
592 getShared() {
593 if (sharedPart != null) return sharedPart;
594 return sharedPart = new
595 MoverSharedMessage();
596 }
597
598 private MoverStatic staticPart = null;
599
600 @Override
601 public MoverStatic
602 getStatic() {
603 if (staticPart != null) return staticPart;
604 return staticPart = new
605 MoverStaticMessage();
606 }
607
608 /**
609 *
610 Implementation of the local part of the GameBots2004 message MOV, used
611 to facade MOVMessage.
612
613 *
614 * <p></p><p></p>
615 * Complete message documentation:
616 *
617 Synchronous message. Movers can be doors, elevators, or any
618 other chunk of architecture that can move. They generally need
619 to be either run into, or activated by shooting or pressing a
620 button. We are working on ways to provide bots with more of the
621 information they need to deal with movers appropriately.
622
623 */
624 public class MoverLocalMessage
625 extends
626 MoverLocal
627 {
628
629 @Override
630 public
631 MoverLocalMessage clone() {
632 return this;
633 }
634
635 public MoverLocalMessage getLocal() {
636 return this;
637 }
638 public ISharedWorldObject getShared() {
639 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
640 }
641 public IStaticWorldObject getStatic() {
642 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
643 }
644
645 /**
646 *
647 A unique Id of this mover assigned by the game.
648
649 */
650 public UnrealId getId()
651 {
652 return Id;
653 }
654
655 /**
656 * If the mover is in the field of view of the bot.
657 */
658 public boolean isVisible()
659 {
660 return Visible;
661 }
662
663
664 public String toString() {
665 return
666 super.toString() + "[" +
667
668 "Id = " + String.valueOf(getId()
669 ) + " | " +
670
671 "Visible = " + String.valueOf(isVisible()
672 ) + " | " +
673
674 "]";
675 }
676
677
678 public String toHtmlString() {
679 return super.toString() + "[<br/>" +
680
681 "<b>Id</b> = " + String.valueOf(getId()
682 ) + " <br/> " +
683
684 "<b>Visible</b> = " + String.valueOf(isVisible()
685 ) + " <br/> " +
686
687 "<br/>]";
688 }
689
690
691 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
692
693 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
694
695 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=local+classtype[@name=message]) ---
696
697 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=local+classtype[@name=message]) ---
698
699 }
700
701 /**
702 *
703 Implementation of the static part of the GameBots2004 message MOV, used
704 to facade MOVMessage.
705
706 *
707 * <p></p><p></p>
708 * Complete message documentation:
709 *
710 Synchronous message. Movers can be doors, elevators, or any
711 other chunk of architecture that can move. They generally need
712 to be either run into, or activated by shooting or pressing a
713 button. We are working on ways to provide bots with more of the
714 information they need to deal with movers appropriately.
715
716 */
717 public class MoverStaticMessage
718 extends
719 MoverStatic
720 {
721
722 @Override
723 public
724 MoverStaticMessage clone() {
725 return this;
726 }
727
728 /**
729 *
730 A unique Id of this mover assigned by the game.
731
732 */
733 public UnrealId getId()
734 {
735 return Id;
736 }
737
738 /**
739 *
740 True if the mover needs to be shot to be activated.
741
742 */
743 public boolean isDamageTrig()
744 {
745 return DamageTrig;
746 }
747
748 /**
749 * String class of the mover.
750 */
751 public String getType()
752 {
753 return Type;
754 }
755
756 /**
757 * Does the mover move right now?
758 */
759 public boolean isIsMoving()
760 {
761 return IsMoving;
762 }
763
764 /**
765 * How long the mover moves, when it becomes triggered, before it stops.
766 */
767 public double getMoveTime()
768 {
769 return MoveTime;
770 }
771
772 /**
773 * How long the mover stands still when it reaches its destination position. After
774 this time, the mover returns back to its initial position.
775 */
776 public double getOpenTime()
777 {
778 return OpenTime;
779 }
780
781 /**
782 * Base position of the mover.
783 */
784 public Location getBasePos()
785 {
786 return BasePos;
787 }
788
789 /**
790 * Base rotation of the mover.
791 */
792 public Location getBaseRot()
793 {
794 return BaseRot;
795 }
796
797 /**
798 * Delay before starting to open (or before lift starts to move).
799 */
800 public double getDelayTime()
801 {
802 return DelayTime;
803 }
804
805 /**
806 * Navigation point marking this mover. We can parse this Id to get information about type of the mover. Marker Id contains "lift" string if it is a lift, "door" string if it is a door, etc.
807 */
808 public UnrealId getNavPointMarker()
809 {
810 return NavPointMarker;
811 }
812
813
814 @Override
815 public boolean isDifferentFrom(IStaticWorldObject other)
816 {
817 if (other == null) //early fail
818 {
819 return true;
820 }
821 else if (other == this) //early out
822 {
823 return false;
824 }
825 else
826 {
827 MoverStatic obj = (MoverStatic) other;
828
829
830 if ( !(
831 AdvancedEquals.equalsOrNull(this.getId()
832 , obj.getId()
833 )
834 ) )
835 {
836 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class MoverStatic");
837 return true;
838 }
839
840 if ( !(this.isDamageTrig()
841
842 == obj.isDamageTrig()
843 ) )
844 {
845 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property DamageTrig on object class MoverStatic");
846 return true;
847 }
848
849 if ( !(
850 AdvancedEquals.equalsOrNull(this.getType()
851 , obj.getType()
852 )
853 ) )
854 {
855 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Type on object class MoverStatic");
856 return true;
857 }
858
859 if ( !(this.isIsMoving()
860
861 == obj.isIsMoving()
862 ) )
863 {
864 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property IsMoving on object class MoverStatic");
865 return true;
866 }
867
868 if ( !(this.getMoveTime()
869
870 == obj.getMoveTime()
871 ) )
872 {
873 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property MoveTime on object class MoverStatic");
874 return true;
875 }
876
877 if ( !(this.getOpenTime()
878
879 == obj.getOpenTime()
880 ) )
881 {
882 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property OpenTime on object class MoverStatic");
883 return true;
884 }
885
886 if ( !(
887 AdvancedEquals.equalsOrNull(this.getBasePos()
888 , obj.getBasePos()
889 )
890 ) )
891 {
892 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property BasePos on object class MoverStatic");
893 return true;
894 }
895
896 if ( !(
897 AdvancedEquals.equalsOrNull(this.getBaseRot()
898 , obj.getBaseRot()
899 )
900 ) )
901 {
902 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property BaseRot on object class MoverStatic");
903 return true;
904 }
905
906 if ( !(this.getDelayTime()
907
908 == obj.getDelayTime()
909 ) )
910 {
911 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property DelayTime on object class MoverStatic");
912 return true;
913 }
914
915 if ( !(
916 AdvancedEquals.equalsOrNull(this.getNavPointMarker()
917 , obj.getNavPointMarker()
918 )
919 ) )
920 {
921 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property NavPointMarker on object class MoverStatic");
922 return true;
923 }
924
925 }
926 return false;
927 }
928
929
930 public String toString() {
931 return
932 super.toString() + "[" +
933
934 "Id = " + String.valueOf(getId()
935 ) + " | " +
936
937 "DamageTrig = " + String.valueOf(isDamageTrig()
938 ) + " | " +
939
940 "Type = " + String.valueOf(getType()
941 ) + " | " +
942
943 "IsMoving = " + String.valueOf(isIsMoving()
944 ) + " | " +
945
946 "MoveTime = " + String.valueOf(getMoveTime()
947 ) + " | " +
948
949 "OpenTime = " + String.valueOf(getOpenTime()
950 ) + " | " +
951
952 "BasePos = " + String.valueOf(getBasePos()
953 ) + " | " +
954
955 "BaseRot = " + String.valueOf(getBaseRot()
956 ) + " | " +
957
958 "DelayTime = " + String.valueOf(getDelayTime()
959 ) + " | " +
960
961 "NavPointMarker = " + String.valueOf(getNavPointMarker()
962 ) + " | " +
963
964 "]";
965 }
966
967
968 public String toHtmlString() {
969 return super.toString() + "[<br/>" +
970
971 "<b>Id</b> = " + String.valueOf(getId()
972 ) + " <br/> " +
973
974 "<b>DamageTrig</b> = " + String.valueOf(isDamageTrig()
975 ) + " <br/> " +
976
977 "<b>Type</b> = " + String.valueOf(getType()
978 ) + " <br/> " +
979
980 "<b>IsMoving</b> = " + String.valueOf(isIsMoving()
981 ) + " <br/> " +
982
983 "<b>MoveTime</b> = " + String.valueOf(getMoveTime()
984 ) + " <br/> " +
985
986 "<b>OpenTime</b> = " + String.valueOf(getOpenTime()
987 ) + " <br/> " +
988
989 "<b>BasePos</b> = " + String.valueOf(getBasePos()
990 ) + " <br/> " +
991
992 "<b>BaseRot</b> = " + String.valueOf(getBaseRot()
993 ) + " <br/> " +
994
995 "<b>DelayTime</b> = " + String.valueOf(getDelayTime()
996 ) + " <br/> " +
997
998 "<b>NavPointMarker</b> = " + String.valueOf(getNavPointMarker()
999 ) + " <br/> " +
1000
1001 "<br/>]";
1002 }
1003
1004
1005 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1006
1007 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1008
1009 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=message]) ---
1010
1011 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=message]) ---
1012
1013 }
1014
1015 /**
1016 *
1017 Implementation of the shared part of the GameBots2004 message MOV, used
1018 to facade MOVMessage.
1019
1020 *
1021 * <p></p><p></p>
1022 * Complete message documentation:
1023 *
1024 Synchronous message. Movers can be doors, elevators, or any
1025 other chunk of architecture that can move. They generally need
1026 to be either run into, or activated by shooting or pressing a
1027 button. We are working on ways to provide bots with more of the
1028 information they need to deal with movers appropriately.
1029
1030 */
1031 public class MoverSharedMessage
1032 extends
1033 MoverShared
1034 {
1035
1036
1037
1038 public MoverSharedMessage()
1039 {
1040
1041 propertyMap.put(myLocation.getPropertyId(), myLocation);
1042
1043 propertyMap.put(myVelocity.getPropertyId(), myVelocity);
1044
1045 propertyMap.put(myState.getPropertyId(), myState);
1046
1047 }
1048
1049 @Override
1050 public
1051 MoverSharedMessage clone() {
1052 return this;
1053 }
1054
1055
1056
1057
1058 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
1059 3
1060 );
1061
1062 @Override
1063 public ISharedProperty getProperty(PropertyId id) {
1064 return propertyMap.get(id);
1065 }
1066
1067 @Override
1068 public Map<PropertyId, ISharedProperty> getProperties() {
1069 return propertyMap;
1070 }
1071
1072
1073
1074 /**
1075 *
1076 A unique Id of this mover assigned by the game.
1077
1078 */
1079 public UnrealId getId()
1080 {
1081 return Id;
1082 }
1083
1084
1085 /**
1086 * Location of the mover.
1087 */
1088 protected
1089 LocationProperty
1090 myLocation
1091 = new
1092 LocationProperty
1093 (
1094 getId(),
1095 "Location",
1096 Location,
1097 Mover.class
1098 );
1099
1100 /**
1101 * Location of the mover.
1102 */
1103 public Location getLocation()
1104 {
1105 return myLocation.getValue();
1106 }
1107
1108
1109 /**
1110 * Velocity vector.
1111 */
1112 protected
1113 VelocityProperty
1114 myVelocity
1115 = new
1116 VelocityProperty
1117 (
1118 getId(),
1119 "Velocity",
1120 Velocity,
1121 Mover.class
1122 );
1123
1124 /**
1125 * Velocity vector.
1126 */
1127 public Velocity getVelocity()
1128 {
1129 return myVelocity.getValue();
1130 }
1131
1132
1133 /**
1134 * Name of the state Mover is currently in. Can be used to determine the type of the mover.
1135 */
1136 protected
1137 StringProperty
1138 myState
1139 = new
1140 StringProperty
1141 (
1142 getId(),
1143 "State",
1144 State,
1145 Mover.class
1146 );
1147
1148 /**
1149 * Name of the state Mover is currently in. Can be used to determine the type of the mover.
1150 */
1151 public String getState()
1152 {
1153 return myState.getValue();
1154 }
1155
1156
1157 public String toString() {
1158 return
1159 super.toString() + "[" +
1160
1161 "Id = " + String.valueOf(getId()
1162 ) + " | " +
1163
1164 "Location = " + String.valueOf(getLocation()
1165 ) + " | " +
1166
1167 "Velocity = " + String.valueOf(getVelocity()
1168 ) + " | " +
1169
1170 "State = " + String.valueOf(getState()
1171 ) + " | " +
1172
1173 "]";
1174 }
1175
1176
1177 public String toHtmlString() {
1178 return super.toString() + "[<br/>" +
1179
1180 "<b>Id</b> = " + String.valueOf(getId()
1181 ) + " <br/> " +
1182
1183 "<b>Location</b> = " + String.valueOf(getLocation()
1184 ) + " <br/> " +
1185
1186 "<b>Velocity</b> = " + String.valueOf(getVelocity()
1187 ) + " <br/> " +
1188
1189 "<b>State</b> = " + String.valueOf(getState()
1190 ) + " <br/> " +
1191
1192 "<br/>]";
1193 }
1194
1195
1196 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1197
1198 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1199
1200 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=message]) ---
1201
1202 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=message]) ---
1203
1204 }
1205
1206
1207
1208
1209 @Override
1210 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject object) {
1211 if (object == null)
1212 {
1213 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.CREATED, this);
1214 }
1215 if (!( object instanceof MoverMessage) ) {
1216 throw new PogamutException("Can't update different class than MoverMessage, got class " + object.getClass().getSimpleName() + "!", this);
1217 }
1218 MoverMessage toUpdate = (MoverMessage)object;
1219
1220 boolean updated = false;
1221
1222 // UPDATING LOCAL PROPERTIES
1223
1224 if (toUpdate.Visible != isVisible()
1225 ) {
1226 toUpdate.Visible=isVisible()
1227 ;
1228 updated = true;
1229 }
1230
1231
1232 // UPDATING SHARED PROPERTIES
1233
1234 if (!SafeEquals.equals(toUpdate.Location, getLocation()
1235 )) {
1236 toUpdate.Location=getLocation()
1237 ;
1238 updated = true;
1239 }
1240
1241 if (!SafeEquals.equals(toUpdate.Velocity, getVelocity()
1242 )) {
1243 toUpdate.Velocity=getVelocity()
1244 ;
1245 updated = true;
1246 }
1247
1248 if (!SafeEquals.equals(toUpdate.State, getState()
1249 )) {
1250 toUpdate.State=getState()
1251 ;
1252 updated = true;
1253 }
1254
1255
1256 // UPDATE TIME
1257 toUpdate.SimTime = SimTime;
1258
1259 if (updated) {
1260 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
1261 } else {
1262 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.SAME, toUpdate);
1263 }
1264 }
1265
1266 @Override
1267 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
1268 return new MoverLocalImpl.MoverLocalUpdate
1269 (this.getLocal(), SimTime);
1270 }
1271
1272 @Override
1273 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
1274 return new MoverSharedImpl.MoverSharedUpdate
1275 (this.getShared(), SimTime, this.getTeamId());
1276 }
1277
1278 @Override
1279 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
1280 return new MoverStaticImpl.MoverStaticUpdate
1281 (this.getStatic(), SimTime);
1282 }
1283
1284
1285 public String toString() {
1286 return
1287 super.toString() + "[" +
1288
1289 "Id = " + String.valueOf(getId()
1290 ) + " | " +
1291
1292 "Location = " + String.valueOf(getLocation()
1293 ) + " | " +
1294
1295 "Visible = " + String.valueOf(isVisible()
1296 ) + " | " +
1297
1298 "DamageTrig = " + String.valueOf(isDamageTrig()
1299 ) + " | " +
1300
1301 "Type = " + String.valueOf(getType()
1302 ) + " | " +
1303
1304 "IsMoving = " + String.valueOf(isIsMoving()
1305 ) + " | " +
1306
1307 "Velocity = " + String.valueOf(getVelocity()
1308 ) + " | " +
1309
1310 "MoveTime = " + String.valueOf(getMoveTime()
1311 ) + " | " +
1312
1313 "OpenTime = " + String.valueOf(getOpenTime()
1314 ) + " | " +
1315
1316 "BasePos = " + String.valueOf(getBasePos()
1317 ) + " | " +
1318
1319 "BaseRot = " + String.valueOf(getBaseRot()
1320 ) + " | " +
1321
1322 "DelayTime = " + String.valueOf(getDelayTime()
1323 ) + " | " +
1324
1325 "State = " + String.valueOf(getState()
1326 ) + " | " +
1327
1328 "NavPointMarker = " + String.valueOf(getNavPointMarker()
1329 ) + " | " +
1330
1331 "]";
1332 }
1333
1334
1335 public String toHtmlString() {
1336 return super.toString() + "[<br/>" +
1337
1338 "<b>Id</b> = " + String.valueOf(getId()
1339 ) + " <br/> " +
1340
1341 "<b>Location</b> = " + String.valueOf(getLocation()
1342 ) + " <br/> " +
1343
1344 "<b>Visible</b> = " + String.valueOf(isVisible()
1345 ) + " <br/> " +
1346
1347 "<b>DamageTrig</b> = " + String.valueOf(isDamageTrig()
1348 ) + " <br/> " +
1349
1350 "<b>Type</b> = " + String.valueOf(getType()
1351 ) + " <br/> " +
1352
1353 "<b>IsMoving</b> = " + String.valueOf(isIsMoving()
1354 ) + " <br/> " +
1355
1356 "<b>Velocity</b> = " + String.valueOf(getVelocity()
1357 ) + " <br/> " +
1358
1359 "<b>MoveTime</b> = " + String.valueOf(getMoveTime()
1360 ) + " <br/> " +
1361
1362 "<b>OpenTime</b> = " + String.valueOf(getOpenTime()
1363 ) + " <br/> " +
1364
1365 "<b>BasePos</b> = " + String.valueOf(getBasePos()
1366 ) + " <br/> " +
1367
1368 "<b>BaseRot</b> = " + String.valueOf(getBaseRot()
1369 ) + " <br/> " +
1370
1371 "<b>DelayTime</b> = " + String.valueOf(getDelayTime()
1372 ) + " <br/> " +
1373
1374 "<b>State</b> = " + String.valueOf(getState()
1375 ) + " <br/> " +
1376
1377 "<b>NavPointMarker</b> = " + String.valueOf(getNavPointMarker()
1378 ) + " <br/> " +
1379
1380 "<br/>]";
1381 }
1382
1383
1384 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1385
1386 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1387
1388 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=message]) ---
1389
1390 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=message]) ---
1391
1392 }
1393