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 PLR contains also its Local/Shared/Static subpart class definitions..
19
20 *
21 * <p></p><p></p>
22 * Complete message documentation:
23 *
24 Synchronous message. Contains information about other players in
25 the game, like their current velocity, position, weapon and
26 reachability. Only reports those players that are visible.
27 (within field of view and not occluded).
28
29 */
30 public class PlayerMessage
31 extends
32 Player
33 implements IWorldObjectUpdatedEvent, ICompositeWorldObjectUpdatedEvent
34
35 {
36
37
38
39 /**
40 * Parameter-less contructor for the message.
41 */
42 public PlayerMessage()
43 {
44 }
45
46
47
48
49 /**
50 * Creates new instance of the message Player.
51 *
52 Synchronous message. Contains information about other players in
53 the game, like their current velocity, position, weapon and
54 reachability. Only reports those players that are visible.
55 (within field of view and not occluded).
56
57 * Corresponding GameBots message
58 *
59 * is
60 * PLR.
61 *
62 *
63 *
64 * @param Id Unique Id of the player.
65 *
66 *
67 *
68 * @param Jmx
69 Exported just for control server. Holds jmx address we need to connect to
70 when we want to debug our bot.
71
72 *
73 *
74 *
75 * @param Name
76 Human readable name of the player.
77
78 *
79 *
80 *
81 * @param Action
82 Atomic action this bot is doing (BDI).
83
84 *
85 *
86 *
87 * @param Visible
88 If the player is in the field of view of the bot.
89
90 *
91 *
92 *
93 * @param Rotation
94 Which direction the player is facing in absolute terms.
95
96 *
97 *
98 *
99 * @param Location
100 An absolute location of the player within the map.
101
102 *
103 *
104 *
105 * @param Velocity
106 Absolute velocity of the player as a vector of movement per one
107 game second.
108
109 *
110 *
111 *
112 * @param Team
113 What team the player is on. 255 is no team. 0-3 are red,
114 blue, green, gold in that order.
115
116 *
117 *
118 *
119 * @param Weapon
120 Class of the weapon the player is holding. Weapon strings to
121 look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
122 "BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
123 "RocketLauncher", "Minigun", "LightingGun", "Translocator".
124 TODO: Look if this is all.
125
126 *
127 *
128 *
129 * @param Crouched
130 True if the bot is crouched.
131
132 *
133 *
134 *
135 * @param Firing
136 0 means is not firing, 1 - firing in primary mode, 2 -
137 firing in secondary mode (alt firing).
138
139 *
140 *
141 *
142 * @param EmotLeft
143 For UE2. Holds left emoticon of the bot, "None" means none set.
144
145 *
146 *
147 *
148 * @param EmotCenter
149 For UE2. Holds center emoticon of the bot, "None" means none set.
150
151 *
152 *
153 *
154 * @param EmotRight
155 For UE2. Holds right emoticon of the bot, "None" means none set.
156
157 *
158 *
159 *
160 * @param Bubble
161 For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
162
163 *
164 *
165 *
166 * @param Anim
167 For UE2. Current played animation of the bot.
168
169 *
170 *
171 */
172 public PlayerMessage(
173 UnrealId Id, String Jmx, String Name, String Action, boolean Visible, Rotation Rotation, Location Location, Velocity Velocity, int Team, String Weapon, boolean Crouched, int Firing, String EmotLeft, String EmotCenter, String EmotRight, String Bubble, String Anim
174 ) {
175
176 this.Id = Id;
177
178 this.Jmx = Jmx;
179
180 this.Name = Name;
181
182 this.Action = Action;
183
184 this.Visible = Visible;
185
186 this.Rotation = Rotation;
187
188 this.Location = Location;
189
190 this.Velocity = Velocity;
191
192 this.Team = Team;
193
194 this.Weapon = Weapon;
195
196 this.Crouched = Crouched;
197
198 this.Firing = Firing;
199
200 this.EmotLeft = EmotLeft;
201
202 this.EmotCenter = EmotCenter;
203
204 this.EmotRight = EmotRight;
205
206 this.Bubble = Bubble;
207
208 this.Anim = Anim;
209
210 }
211
212 /**
213 * Cloning constructor from the full message.
214 *
215 * @param original
216 */
217 public PlayerMessage(PlayerMessage original) {
218
219 this.Id = original.getId()
220 ;
221
222 this.Jmx = original.getJmx()
223 ;
224
225 this.Name = original.getName()
226 ;
227
228 this.Action = original.getAction()
229 ;
230
231 this.Visible = original.isVisible()
232 ;
233
234 this.Rotation = original.getRotation()
235 ;
236
237 this.Location = original.getLocation()
238 ;
239
240 this.Velocity = original.getVelocity()
241 ;
242
243 this.Team = original.getTeam()
244 ;
245
246 this.Weapon = original.getWeapon()
247 ;
248
249 this.Crouched = original.isCrouched()
250 ;
251
252 this.Firing = original.getFiring()
253 ;
254
255 this.EmotLeft = original.getEmotLeft()
256 ;
257
258 this.EmotCenter = original.getEmotCenter()
259 ;
260
261 this.EmotRight = original.getEmotRight()
262 ;
263
264 this.Bubble = original.getBubble()
265 ;
266
267 this.Anim = original.getAnim()
268 ;
269
270 this.TeamId = original.getTeamId();
271
272 this.SimTime = original.getSimTime();
273 }
274
275
276 protected ITeamId TeamId;
277
278 /**
279 * Used by Yylex to slip corretn TeamId.
280 */
281 protected void setTeamId(ITeamId TeamId) {
282 this.TeamId = TeamId;
283 }
284
285 public ITeamId getTeamId() {
286 return TeamId;
287 }
288
289
290
291
292 /**
293 * Unique Id of the player.
294 */
295 protected
296 UnrealId Id =
297 null;
298
299
300 /**
301 * Whether property 'Id' was received from GB2004.
302 */
303 protected boolean Id_Set = false;
304
305 @Override
306
307 /**
308 * Unique Id of the player.
309 */
310 public UnrealId getId()
311 {
312 return Id;
313 }
314
315
316 /**
317 *
318 Exported just for control server. Holds jmx address we need to connect to
319 when we want to debug our bot.
320
321 */
322 protected
323 String Jmx =
324 null;
325
326
327 /**
328 * Whether property 'Jmx' was received from GB2004.
329 */
330 protected boolean Jmx_Set = false;
331
332 @Override
333
334 /**
335 *
336 Exported just for control server. Holds jmx address we need to connect to
337 when we want to debug our bot.
338
339 */
340 public String getJmx()
341 {
342 return Jmx;
343 }
344
345
346 /**
347 *
348 Human readable name of the player.
349
350 */
351 protected
352 String Name =
353 null;
354
355
356 /**
357 * Whether property 'Name' was received from GB2004.
358 */
359 protected boolean Name_Set = false;
360
361 @Override
362
363 /**
364 *
365 Human readable name of the player.
366
367 */
368 public String getName()
369 {
370 return Name;
371 }
372
373
374 /**
375 *
376 Atomic action this bot is doing (BDI).
377
378 */
379 protected
380 String Action =
381 null;
382
383
384 /**
385 * Whether property 'Action' was received from GB2004.
386 */
387 protected boolean Action_Set = false;
388
389 @Override
390
391 /**
392 *
393 Atomic action this bot is doing (BDI).
394
395 */
396 public String getAction()
397 {
398 return Action;
399 }
400
401
402 /**
403 *
404 If the player is in the field of view of the bot.
405
406 */
407 protected
408 boolean Visible =
409 true;
410
411
412 /**
413 * Whether property 'Visible' was received from GB2004.
414 */
415 protected boolean Visible_Set = false;
416
417 @Override
418
419 /**
420 *
421 If the player is in the field of view of the bot.
422
423 */
424 public boolean isVisible()
425 {
426 return Visible;
427 }
428
429
430 /**
431 *
432 Which direction the player is facing in absolute terms.
433
434 */
435 protected
436 Rotation Rotation =
437 null;
438
439
440 /**
441 * Whether property 'Rotation' was received from GB2004.
442 */
443 protected boolean Rotation_Set = false;
444
445 @Override
446
447 /**
448 *
449 Which direction the player is facing in absolute terms.
450
451 */
452 public Rotation getRotation()
453 {
454 return Rotation;
455 }
456
457
458 /**
459 *
460 An absolute location of the player within the map.
461
462 */
463 protected
464 Location Location =
465 null;
466
467
468 /**
469 * Whether property 'Location' was received from GB2004.
470 */
471 protected boolean Location_Set = false;
472
473 @Override
474
475 /**
476 *
477 An absolute location of the player within the map.
478
479 */
480 public Location getLocation()
481 {
482 return Location;
483 }
484
485
486 /**
487 *
488 Absolute velocity of the player as a vector of movement per one
489 game second.
490
491 */
492 protected
493 Velocity Velocity =
494 null;
495
496
497 /**
498 * Whether property 'Velocity' was received from GB2004.
499 */
500 protected boolean Velocity_Set = false;
501
502 @Override
503
504 /**
505 *
506 Absolute velocity of the player as a vector of movement per one
507 game second.
508
509 */
510 public Velocity getVelocity()
511 {
512 return Velocity;
513 }
514
515
516 /**
517 *
518 What team the player is on. 255 is no team. 0-3 are red,
519 blue, green, gold in that order.
520
521 */
522 protected
523 int Team =
524 0;
525
526
527 /**
528 * Whether property 'Team' was received from GB2004.
529 */
530 protected boolean Team_Set = false;
531
532 @Override
533
534 /**
535 *
536 What team the player is on. 255 is no team. 0-3 are red,
537 blue, green, gold in that order.
538
539 */
540 public int getTeam()
541 {
542 return Team;
543 }
544
545
546 /**
547 *
548 Class of the weapon the player is holding. Weapon strings to
549 look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
550 "BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
551 "RocketLauncher", "Minigun", "LightingGun", "Translocator".
552 TODO: Look if this is all.
553
554 */
555 protected
556 String Weapon =
557 null;
558
559
560 /**
561 * Whether property 'Weapon' was received from GB2004.
562 */
563 protected boolean Weapon_Set = false;
564
565 @Override
566
567 /**
568 *
569 Class of the weapon the player is holding. Weapon strings to
570 look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
571 "BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
572 "RocketLauncher", "Minigun", "LightingGun", "Translocator".
573 TODO: Look if this is all.
574
575 */
576 public String getWeapon()
577 {
578 return Weapon;
579 }
580
581
582 /**
583 *
584 True if the bot is crouched.
585
586 */
587 protected
588 boolean Crouched =
589 false;
590
591
592 /**
593 * Whether property 'Crouched' was received from GB2004.
594 */
595 protected boolean Crouched_Set = false;
596
597 @Override
598
599 /**
600 *
601 True if the bot is crouched.
602
603 */
604 public boolean isCrouched()
605 {
606 return Crouched;
607 }
608
609
610 /**
611 *
612 0 means is not firing, 1 - firing in primary mode, 2 -
613 firing in secondary mode (alt firing).
614
615 */
616 protected
617 int Firing =
618 0;
619
620
621 /**
622 * Whether property 'Firing' was received from GB2004.
623 */
624 protected boolean Firing_Set = false;
625
626 @Override
627
628 /**
629 *
630 0 means is not firing, 1 - firing in primary mode, 2 -
631 firing in secondary mode (alt firing).
632
633 */
634 public int getFiring()
635 {
636 return Firing;
637 }
638
639
640 /**
641 *
642 For UE2. Holds left emoticon of the bot, "None" means none set.
643
644 */
645 protected
646 String EmotLeft =
647 null;
648
649
650 /**
651 * Whether property 'EmotLeft' was received from GB2004.
652 */
653 protected boolean EmotLeft_Set = false;
654
655 @Override
656
657 /**
658 *
659 For UE2. Holds left emoticon of the bot, "None" means none set.
660
661 */
662 public String getEmotLeft()
663 {
664 return EmotLeft;
665 }
666
667
668 /**
669 *
670 For UE2. Holds center emoticon of the bot, "None" means none set.
671
672 */
673 protected
674 String EmotCenter =
675 null;
676
677
678 /**
679 * Whether property 'EmotCenter' was received from GB2004.
680 */
681 protected boolean EmotCenter_Set = false;
682
683 @Override
684
685 /**
686 *
687 For UE2. Holds center emoticon of the bot, "None" means none set.
688
689 */
690 public String getEmotCenter()
691 {
692 return EmotCenter;
693 }
694
695
696 /**
697 *
698 For UE2. Holds right emoticon of the bot, "None" means none set.
699
700 */
701 protected
702 String EmotRight =
703 null;
704
705
706 /**
707 * Whether property 'EmotRight' was received from GB2004.
708 */
709 protected boolean EmotRight_Set = false;
710
711 @Override
712
713 /**
714 *
715 For UE2. Holds right emoticon of the bot, "None" means none set.
716
717 */
718 public String getEmotRight()
719 {
720 return EmotRight;
721 }
722
723
724 /**
725 *
726 For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
727
728 */
729 protected
730 String Bubble =
731 null;
732
733
734 /**
735 * Whether property 'Bubble' was received from GB2004.
736 */
737 protected boolean Bubble_Set = false;
738
739 @Override
740
741 /**
742 *
743 For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
744
745 */
746 public String getBubble()
747 {
748 return Bubble;
749 }
750
751
752 /**
753 *
754 For UE2. Current played animation of the bot.
755
756 */
757 protected
758 String Anim =
759 null;
760
761
762 /**
763 * Whether property 'Anim' was received from GB2004.
764 */
765 protected boolean Anim_Set = false;
766
767 @Override
768
769 /**
770 *
771 For UE2. Current played animation of the bot.
772
773 */
774 public String getAnim()
775 {
776 return Anim;
777 }
778
779
780 private PlayerLocal localPart = null;
781
782 @Override
783 public PlayerLocal
784 getLocal() {
785 if (localPart != null) return localPart;
786 return localPart = new
787 PlayerLocalMessage();
788 }
789
790 private PlayerShared sharedPart = null;
791
792 @Override
793 public PlayerShared
794 getShared() {
795 if (sharedPart != null) return sharedPart;
796 return sharedPart = new
797 PlayerSharedMessage();
798 }
799
800 private PlayerStatic staticPart = null;
801
802 @Override
803 public PlayerStatic
804 getStatic() {
805 if (staticPart != null) return staticPart;
806 return staticPart = new
807 PlayerStaticMessage();
808 }
809
810 /**
811 *
812 Implementation of the local part of the GameBots2004 message PLR, used
813 to facade PLRMessage.
814
815 *
816 * <p></p><p></p>
817 * Complete message documentation:
818 *
819 Synchronous message. Contains information about other players in
820 the game, like their current velocity, position, weapon and
821 reachability. Only reports those players that are visible.
822 (within field of view and not occluded).
823
824 */
825 public class PlayerLocalMessage
826 extends
827 PlayerLocal
828 {
829
830 @Override
831 public
832 PlayerLocalMessage clone() {
833 return this;
834 }
835
836 public PlayerLocalMessage getLocal() {
837 return this;
838 }
839 public ISharedWorldObject getShared() {
840 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
841 }
842 public IStaticWorldObject getStatic() {
843 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
844 }
845
846 /**
847 * Unique Id of the player.
848 */
849 public UnrealId getId()
850 {
851 return Id;
852 }
853
854 /**
855 *
856 Exported just for control server. Holds jmx address we need to connect to
857 when we want to debug our bot.
858
859 */
860 public String getJmx()
861 {
862 return Jmx;
863 }
864
865 /**
866 *
867 If the player is in the field of view of the bot.
868
869 */
870 public boolean isVisible()
871 {
872 return Visible;
873 }
874
875
876 public String toString() {
877 return
878 super.toString() + "[" +
879
880 "Id = " + String.valueOf(getId()
881 ) + " | " +
882
883 "Jmx = " + String.valueOf(getJmx()
884 ) + " | " +
885
886 "Visible = " + String.valueOf(isVisible()
887 ) + " | " +
888
889 "]";
890 }
891
892
893 public String toHtmlString() {
894 return super.toString() + "[<br/>" +
895
896 "<b>Id</b> = " + String.valueOf(getId()
897 ) + " <br/> " +
898
899 "<b>Jmx</b> = " + String.valueOf(getJmx()
900 ) + " <br/> " +
901
902 "<b>Visible</b> = " + String.valueOf(isVisible()
903 ) + " <br/> " +
904
905 "<br/>]";
906 }
907
908
909 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
910
911 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
912
913 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=local+classtype[@name=message]) ---
914
915 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=local+classtype[@name=message]) ---
916
917 }
918
919 /**
920 *
921 Implementation of the static part of the GameBots2004 message PLR, used
922 to facade PLRMessage.
923
924 *
925 * <p></p><p></p>
926 * Complete message documentation:
927 *
928 Synchronous message. Contains information about other players in
929 the game, like their current velocity, position, weapon and
930 reachability. Only reports those players that are visible.
931 (within field of view and not occluded).
932
933 */
934 public class PlayerStaticMessage
935 extends
936 PlayerStatic
937 {
938
939 @Override
940 public
941 PlayerStaticMessage clone() {
942 return this;
943 }
944
945 /**
946 * Unique Id of the player.
947 */
948 public UnrealId getId()
949 {
950 return Id;
951 }
952
953
954 @Override
955 public boolean isDifferentFrom(IStaticWorldObject other)
956 {
957 if (other == null) //early fail
958 {
959 return true;
960 }
961 else if (other == this) //early out
962 {
963 return false;
964 }
965 else
966 {
967 PlayerStatic obj = (PlayerStatic) other;
968
969
970 if ( !(
971 AdvancedEquals.equalsOrNull(this.getId()
972 , obj.getId()
973 )
974 ) )
975 {
976 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class PlayerStatic");
977 return true;
978 }
979
980 }
981 return false;
982 }
983
984
985 public String toString() {
986 return
987 super.toString() + "[" +
988
989 "Id = " + String.valueOf(getId()
990 ) + " | " +
991
992 "]";
993 }
994
995
996 public String toHtmlString() {
997 return super.toString() + "[<br/>" +
998
999 "<b>Id</b> = " + String.valueOf(getId()
1000 ) + " <br/> " +
1001
1002 "<br/>]";
1003 }
1004
1005
1006 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1007
1008 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1009
1010 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=static+classtype[@name=message]) ---
1011
1012 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=static+classtype[@name=message]) ---
1013
1014 }
1015
1016 /**
1017 *
1018 Implementation of the shared part of the GameBots2004 message PLR, used
1019 to facade PLRMessage.
1020
1021 *
1022 * <p></p><p></p>
1023 * Complete message documentation:
1024 *
1025 Synchronous message. Contains information about other players in
1026 the game, like their current velocity, position, weapon and
1027 reachability. Only reports those players that are visible.
1028 (within field of view and not occluded).
1029
1030 */
1031 public class PlayerSharedMessage
1032 extends
1033 PlayerShared
1034 {
1035
1036
1037
1038 public PlayerSharedMessage()
1039 {
1040
1041 propertyMap.put(myName.getPropertyId(), myName);
1042
1043 propertyMap.put(myAction.getPropertyId(), myAction);
1044
1045 propertyMap.put(myRotation.getPropertyId(), myRotation);
1046
1047 propertyMap.put(myLocation.getPropertyId(), myLocation);
1048
1049 propertyMap.put(myVelocity.getPropertyId(), myVelocity);
1050
1051 propertyMap.put(myTeam.getPropertyId(), myTeam);
1052
1053 propertyMap.put(myWeapon.getPropertyId(), myWeapon);
1054
1055 propertyMap.put(myCrouched.getPropertyId(), myCrouched);
1056
1057 propertyMap.put(myFiring.getPropertyId(), myFiring);
1058
1059 propertyMap.put(myEmotLeft.getPropertyId(), myEmotLeft);
1060
1061 propertyMap.put(myEmotCenter.getPropertyId(), myEmotCenter);
1062
1063 propertyMap.put(myEmotRight.getPropertyId(), myEmotRight);
1064
1065 propertyMap.put(myBubble.getPropertyId(), myBubble);
1066
1067 propertyMap.put(myAnim.getPropertyId(), myAnim);
1068
1069 }
1070
1071 @Override
1072 public
1073 PlayerSharedMessage clone() {
1074 return this;
1075 }
1076
1077
1078
1079
1080 protected HashMap<PropertyId, ISharedProperty> propertyMap = new HashMap<PropertyId, ISharedProperty>(
1081 14
1082 );
1083
1084 @Override
1085 public ISharedProperty getProperty(PropertyId id) {
1086 return propertyMap.get(id);
1087 }
1088
1089 @Override
1090 public Map<PropertyId, ISharedProperty> getProperties() {
1091 return propertyMap;
1092 }
1093
1094
1095
1096 /**
1097 * Unique Id of the player.
1098 */
1099 public UnrealId getId()
1100 {
1101 return Id;
1102 }
1103
1104
1105 /**
1106 *
1107 Human readable name of the player.
1108
1109 */
1110 protected
1111 StringProperty
1112 myName
1113 = new
1114 StringProperty
1115 (
1116 getId(),
1117 "Name",
1118 Name,
1119 Player.class
1120 );
1121
1122 /**
1123 *
1124 Human readable name of the player.
1125
1126 */
1127 public String getName()
1128 {
1129 return myName.getValue();
1130 }
1131
1132
1133 /**
1134 *
1135 Atomic action this bot is doing (BDI).
1136
1137 */
1138 protected
1139 StringProperty
1140 myAction
1141 = new
1142 StringProperty
1143 (
1144 getId(),
1145 "Action",
1146 Action,
1147 Player.class
1148 );
1149
1150 /**
1151 *
1152 Atomic action this bot is doing (BDI).
1153
1154 */
1155 public String getAction()
1156 {
1157 return myAction.getValue();
1158 }
1159
1160
1161 /**
1162 *
1163 Which direction the player is facing in absolute terms.
1164
1165 */
1166 protected
1167 RotationProperty
1168 myRotation
1169 = new
1170 RotationProperty
1171 (
1172 getId(),
1173 "Rotation",
1174 Rotation,
1175 Player.class
1176 );
1177
1178 /**
1179 *
1180 Which direction the player is facing in absolute terms.
1181
1182 */
1183 public Rotation getRotation()
1184 {
1185 return myRotation.getValue();
1186 }
1187
1188
1189 /**
1190 *
1191 An absolute location of the player within the map.
1192
1193 */
1194 protected
1195 LocationProperty
1196 myLocation
1197 = new
1198 LocationProperty
1199 (
1200 getId(),
1201 "Location",
1202 Location,
1203 Player.class
1204 );
1205
1206 /**
1207 *
1208 An absolute location of the player within the map.
1209
1210 */
1211 public Location getLocation()
1212 {
1213 return myLocation.getValue();
1214 }
1215
1216
1217 /**
1218 *
1219 Absolute velocity of the player as a vector of movement per one
1220 game second.
1221
1222 */
1223 protected
1224 VelocityProperty
1225 myVelocity
1226 = new
1227 VelocityProperty
1228 (
1229 getId(),
1230 "Velocity",
1231 Velocity,
1232 Player.class
1233 );
1234
1235 /**
1236 *
1237 Absolute velocity of the player as a vector of movement per one
1238 game second.
1239
1240 */
1241 public Velocity getVelocity()
1242 {
1243 return myVelocity.getValue();
1244 }
1245
1246
1247 /**
1248 *
1249 What team the player is on. 255 is no team. 0-3 are red,
1250 blue, green, gold in that order.
1251
1252 */
1253 protected
1254 IntProperty
1255 myTeam
1256 = new
1257 IntProperty
1258 (
1259 getId(),
1260 "Team",
1261 Team,
1262 Player.class
1263 );
1264
1265 /**
1266 *
1267 What team the player is on. 255 is no team. 0-3 are red,
1268 blue, green, gold in that order.
1269
1270 */
1271 public int getTeam()
1272 {
1273 return myTeam.getValue();
1274 }
1275
1276
1277 /**
1278 *
1279 Class of the weapon the player is holding. Weapon strings to
1280 look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
1281 "BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
1282 "RocketLauncher", "Minigun", "LightingGun", "Translocator".
1283 TODO: Look if this is all.
1284
1285 */
1286 protected
1287 StringProperty
1288 myWeapon
1289 = new
1290 StringProperty
1291 (
1292 getId(),
1293 "Weapon",
1294 Weapon,
1295 Player.class
1296 );
1297
1298 /**
1299 *
1300 Class of the weapon the player is holding. Weapon strings to
1301 look for include: "AssaultRifle", "ShieldGun", "FlakCannon",
1302 "BioRifle", "ShockRifle", "LinkGun", "SniperRifle",
1303 "RocketLauncher", "Minigun", "LightingGun", "Translocator".
1304 TODO: Look if this is all.
1305
1306 */
1307 public String getWeapon()
1308 {
1309 return myWeapon.getValue();
1310 }
1311
1312
1313 /**
1314 *
1315 True if the bot is crouched.
1316
1317 */
1318 protected
1319 BooleanProperty
1320 myCrouched
1321 = new
1322 BooleanProperty
1323 (
1324 getId(),
1325 "Crouched",
1326 Crouched,
1327 Player.class
1328 );
1329
1330 /**
1331 *
1332 True if the bot is crouched.
1333
1334 */
1335 public boolean isCrouched()
1336 {
1337 return myCrouched.getValue();
1338 }
1339
1340
1341 /**
1342 *
1343 0 means is not firing, 1 - firing in primary mode, 2 -
1344 firing in secondary mode (alt firing).
1345
1346 */
1347 protected
1348 IntProperty
1349 myFiring
1350 = new
1351 IntProperty
1352 (
1353 getId(),
1354 "Firing",
1355 Firing,
1356 Player.class
1357 );
1358
1359 /**
1360 *
1361 0 means is not firing, 1 - firing in primary mode, 2 -
1362 firing in secondary mode (alt firing).
1363
1364 */
1365 public int getFiring()
1366 {
1367 return myFiring.getValue();
1368 }
1369
1370
1371 /**
1372 *
1373 For UE2. Holds left emoticon of the bot, "None" means none set.
1374
1375 */
1376 protected
1377 StringProperty
1378 myEmotLeft
1379 = new
1380 StringProperty
1381 (
1382 getId(),
1383 "EmotLeft",
1384 EmotLeft,
1385 Player.class
1386 );
1387
1388 /**
1389 *
1390 For UE2. Holds left emoticon of the bot, "None" means none set.
1391
1392 */
1393 public String getEmotLeft()
1394 {
1395 return myEmotLeft.getValue();
1396 }
1397
1398
1399 /**
1400 *
1401 For UE2. Holds center emoticon of the bot, "None" means none set.
1402
1403 */
1404 protected
1405 StringProperty
1406 myEmotCenter
1407 = new
1408 StringProperty
1409 (
1410 getId(),
1411 "EmotCenter",
1412 EmotCenter,
1413 Player.class
1414 );
1415
1416 /**
1417 *
1418 For UE2. Holds center emoticon of the bot, "None" means none set.
1419
1420 */
1421 public String getEmotCenter()
1422 {
1423 return myEmotCenter.getValue();
1424 }
1425
1426
1427 /**
1428 *
1429 For UE2. Holds right emoticon of the bot, "None" means none set.
1430
1431 */
1432 protected
1433 StringProperty
1434 myEmotRight
1435 = new
1436 StringProperty
1437 (
1438 getId(),
1439 "EmotRight",
1440 EmotRight,
1441 Player.class
1442 );
1443
1444 /**
1445 *
1446 For UE2. Holds right emoticon of the bot, "None" means none set.
1447
1448 */
1449 public String getEmotRight()
1450 {
1451 return myEmotRight.getValue();
1452 }
1453
1454
1455 /**
1456 *
1457 For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
1458
1459 */
1460 protected
1461 StringProperty
1462 myBubble
1463 = new
1464 StringProperty
1465 (
1466 getId(),
1467 "Bubble",
1468 Bubble,
1469 Player.class
1470 );
1471
1472 /**
1473 *
1474 For UE2. Holds the bubble of the emoticon of the bot, "None" means none set.
1475
1476 */
1477 public String getBubble()
1478 {
1479 return myBubble.getValue();
1480 }
1481
1482
1483 /**
1484 *
1485 For UE2. Current played animation of the bot.
1486
1487 */
1488 protected
1489 StringProperty
1490 myAnim
1491 = new
1492 StringProperty
1493 (
1494 getId(),
1495 "Anim",
1496 Anim,
1497 Player.class
1498 );
1499
1500 /**
1501 *
1502 For UE2. Current played animation of the bot.
1503
1504 */
1505 public String getAnim()
1506 {
1507 return myAnim.getValue();
1508 }
1509
1510
1511 public String toString() {
1512 return
1513 super.toString() + "[" +
1514
1515 "Id = " + String.valueOf(getId()
1516 ) + " | " +
1517
1518 "Name = " + String.valueOf(getName()
1519 ) + " | " +
1520
1521 "Action = " + String.valueOf(getAction()
1522 ) + " | " +
1523
1524 "Rotation = " + String.valueOf(getRotation()
1525 ) + " | " +
1526
1527 "Location = " + String.valueOf(getLocation()
1528 ) + " | " +
1529
1530 "Velocity = " + String.valueOf(getVelocity()
1531 ) + " | " +
1532
1533 "Team = " + String.valueOf(getTeam()
1534 ) + " | " +
1535
1536 "Weapon = " + String.valueOf(getWeapon()
1537 ) + " | " +
1538
1539 "Crouched = " + String.valueOf(isCrouched()
1540 ) + " | " +
1541
1542 "Firing = " + String.valueOf(getFiring()
1543 ) + " | " +
1544
1545 "EmotLeft = " + String.valueOf(getEmotLeft()
1546 ) + " | " +
1547
1548 "EmotCenter = " + String.valueOf(getEmotCenter()
1549 ) + " | " +
1550
1551 "EmotRight = " + String.valueOf(getEmotRight()
1552 ) + " | " +
1553
1554 "Bubble = " + String.valueOf(getBubble()
1555 ) + " | " +
1556
1557 "Anim = " + String.valueOf(getAnim()
1558 ) + " | " +
1559
1560 "]";
1561 }
1562
1563
1564 public String toHtmlString() {
1565 return super.toString() + "[<br/>" +
1566
1567 "<b>Id</b> = " + String.valueOf(getId()
1568 ) + " <br/> " +
1569
1570 "<b>Name</b> = " + String.valueOf(getName()
1571 ) + " <br/> " +
1572
1573 "<b>Action</b> = " + String.valueOf(getAction()
1574 ) + " <br/> " +
1575
1576 "<b>Rotation</b> = " + String.valueOf(getRotation()
1577 ) + " <br/> " +
1578
1579 "<b>Location</b> = " + String.valueOf(getLocation()
1580 ) + " <br/> " +
1581
1582 "<b>Velocity</b> = " + String.valueOf(getVelocity()
1583 ) + " <br/> " +
1584
1585 "<b>Team</b> = " + String.valueOf(getTeam()
1586 ) + " <br/> " +
1587
1588 "<b>Weapon</b> = " + String.valueOf(getWeapon()
1589 ) + " <br/> " +
1590
1591 "<b>Crouched</b> = " + String.valueOf(isCrouched()
1592 ) + " <br/> " +
1593
1594 "<b>Firing</b> = " + String.valueOf(getFiring()
1595 ) + " <br/> " +
1596
1597 "<b>EmotLeft</b> = " + String.valueOf(getEmotLeft()
1598 ) + " <br/> " +
1599
1600 "<b>EmotCenter</b> = " + String.valueOf(getEmotCenter()
1601 ) + " <br/> " +
1602
1603 "<b>EmotRight</b> = " + String.valueOf(getEmotRight()
1604 ) + " <br/> " +
1605
1606 "<b>Bubble</b> = " + String.valueOf(getBubble()
1607 ) + " <br/> " +
1608
1609 "<b>Anim</b> = " + String.valueOf(getAnim()
1610 ) + " <br/> " +
1611
1612 "<br/>]";
1613 }
1614
1615
1616 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1617
1618 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1619
1620 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=message]) ---
1621
1622 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=shared+classtype[@name=message]) ---
1623
1624 }
1625
1626
1627
1628
1629 @Override
1630 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject object) {
1631 if (object == null)
1632 {
1633 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.CREATED, this);
1634 }
1635 if (!( object instanceof PlayerMessage) ) {
1636 throw new PogamutException("Can't update different class than PlayerMessage, got class " + object.getClass().getSimpleName() + "!", this);
1637 }
1638 PlayerMessage toUpdate = (PlayerMessage)object;
1639
1640 boolean updated = false;
1641
1642 // UPDATING LOCAL PROPERTIES
1643
1644 if (!SafeEquals.equals(toUpdate.Jmx, getJmx()
1645 )) {
1646 toUpdate.Jmx=getJmx()
1647 ;
1648 updated = true;
1649 }
1650
1651 if (toUpdate.Visible != isVisible()
1652 ) {
1653 toUpdate.Visible=isVisible()
1654 ;
1655 updated = true;
1656 }
1657
1658
1659 // UPDATING SHARED PROPERTIES
1660
1661 if (!SafeEquals.equals(toUpdate.Name, getName()
1662 )) {
1663 toUpdate.Name=getName()
1664 ;
1665 updated = true;
1666 }
1667
1668 if (!SafeEquals.equals(toUpdate.Action, getAction()
1669 )) {
1670 toUpdate.Action=getAction()
1671 ;
1672 updated = true;
1673 }
1674
1675 if (!SafeEquals.equals(toUpdate.Rotation, getRotation()
1676 )) {
1677 toUpdate.Rotation=getRotation()
1678 ;
1679 updated = true;
1680 }
1681
1682 if (getLocation()
1683 != null) {
1684
1685 if (!SafeEquals.equals(toUpdate.Location, getLocation()
1686 )) {
1687 toUpdate.Location=getLocation()
1688 ;
1689 updated = true;
1690 }
1691
1692 }
1693
1694 if (!SafeEquals.equals(toUpdate.Velocity, getVelocity()
1695 )) {
1696 toUpdate.Velocity=getVelocity()
1697 ;
1698 updated = true;
1699 }
1700
1701 if (toUpdate.Team != getTeam()
1702 ) {
1703 toUpdate.Team=getTeam()
1704 ;
1705 updated = true;
1706 }
1707
1708 if (!SafeEquals.equals(toUpdate.Weapon, getWeapon()
1709 )) {
1710 toUpdate.Weapon=getWeapon()
1711 ;
1712 updated = true;
1713 }
1714
1715 if (toUpdate.Crouched != isCrouched()
1716 ) {
1717 toUpdate.Crouched=isCrouched()
1718 ;
1719 updated = true;
1720 }
1721
1722 if (toUpdate.Firing != getFiring()
1723 ) {
1724 toUpdate.Firing=getFiring()
1725 ;
1726 updated = true;
1727 }
1728
1729 if (!SafeEquals.equals(toUpdate.EmotLeft, getEmotLeft()
1730 )) {
1731 toUpdate.EmotLeft=getEmotLeft()
1732 ;
1733 updated = true;
1734 }
1735
1736 if (!SafeEquals.equals(toUpdate.EmotCenter, getEmotCenter()
1737 )) {
1738 toUpdate.EmotCenter=getEmotCenter()
1739 ;
1740 updated = true;
1741 }
1742
1743 if (!SafeEquals.equals(toUpdate.EmotRight, getEmotRight()
1744 )) {
1745 toUpdate.EmotRight=getEmotRight()
1746 ;
1747 updated = true;
1748 }
1749
1750 if (!SafeEquals.equals(toUpdate.Bubble, getBubble()
1751 )) {
1752 toUpdate.Bubble=getBubble()
1753 ;
1754 updated = true;
1755 }
1756
1757 if (!SafeEquals.equals(toUpdate.Anim, getAnim()
1758 )) {
1759 toUpdate.Anim=getAnim()
1760 ;
1761 updated = true;
1762 }
1763
1764
1765 // UPDATE TIME
1766 toUpdate.SimTime = SimTime;
1767
1768 if (updated) {
1769 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, toUpdate);
1770 } else {
1771 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IWorldObject>(IWorldObjectUpdateResult.Result.SAME, toUpdate);
1772 }
1773 }
1774
1775 @Override
1776 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
1777 return new PlayerLocalImpl.PlayerLocalUpdate
1778 (this.getLocal(), SimTime);
1779 }
1780
1781 @Override
1782 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
1783 return new PlayerSharedImpl.PlayerSharedUpdate
1784 (this.getShared(), SimTime, this.getTeamId());
1785 }
1786
1787 @Override
1788 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
1789 return new PlayerStaticImpl.PlayerStaticUpdate
1790 (this.getStatic(), SimTime);
1791 }
1792
1793
1794 public String toString() {
1795 return
1796 super.toString() + "[" +
1797
1798 "Id = " + String.valueOf(getId()
1799 ) + " | " +
1800
1801 "Jmx = " + String.valueOf(getJmx()
1802 ) + " | " +
1803
1804 "Name = " + String.valueOf(getName()
1805 ) + " | " +
1806
1807 "Action = " + String.valueOf(getAction()
1808 ) + " | " +
1809
1810 "Visible = " + String.valueOf(isVisible()
1811 ) + " | " +
1812
1813 "Rotation = " + String.valueOf(getRotation()
1814 ) + " | " +
1815
1816 "Location = " + String.valueOf(getLocation()
1817 ) + " | " +
1818
1819 "Velocity = " + String.valueOf(getVelocity()
1820 ) + " | " +
1821
1822 "Team = " + String.valueOf(getTeam()
1823 ) + " | " +
1824
1825 "Weapon = " + String.valueOf(getWeapon()
1826 ) + " | " +
1827
1828 "Crouched = " + String.valueOf(isCrouched()
1829 ) + " | " +
1830
1831 "Firing = " + String.valueOf(getFiring()
1832 ) + " | " +
1833
1834 "EmotLeft = " + String.valueOf(getEmotLeft()
1835 ) + " | " +
1836
1837 "EmotCenter = " + String.valueOf(getEmotCenter()
1838 ) + " | " +
1839
1840 "EmotRight = " + String.valueOf(getEmotRight()
1841 ) + " | " +
1842
1843 "Bubble = " + String.valueOf(getBubble()
1844 ) + " | " +
1845
1846 "Anim = " + String.valueOf(getAnim()
1847 ) + " | " +
1848
1849 "]";
1850 }
1851
1852
1853 public String toHtmlString() {
1854 return super.toString() + "[<br/>" +
1855
1856 "<b>Id</b> = " + String.valueOf(getId()
1857 ) + " <br/> " +
1858
1859 "<b>Jmx</b> = " + String.valueOf(getJmx()
1860 ) + " <br/> " +
1861
1862 "<b>Name</b> = " + String.valueOf(getName()
1863 ) + " <br/> " +
1864
1865 "<b>Action</b> = " + String.valueOf(getAction()
1866 ) + " <br/> " +
1867
1868 "<b>Visible</b> = " + String.valueOf(isVisible()
1869 ) + " <br/> " +
1870
1871 "<b>Rotation</b> = " + String.valueOf(getRotation()
1872 ) + " <br/> " +
1873
1874 "<b>Location</b> = " + String.valueOf(getLocation()
1875 ) + " <br/> " +
1876
1877 "<b>Velocity</b> = " + String.valueOf(getVelocity()
1878 ) + " <br/> " +
1879
1880 "<b>Team</b> = " + String.valueOf(getTeam()
1881 ) + " <br/> " +
1882
1883 "<b>Weapon</b> = " + String.valueOf(getWeapon()
1884 ) + " <br/> " +
1885
1886 "<b>Crouched</b> = " + String.valueOf(isCrouched()
1887 ) + " <br/> " +
1888
1889 "<b>Firing</b> = " + String.valueOf(getFiring()
1890 ) + " <br/> " +
1891
1892 "<b>EmotLeft</b> = " + String.valueOf(getEmotLeft()
1893 ) + " <br/> " +
1894
1895 "<b>EmotCenter</b> = " + String.valueOf(getEmotCenter()
1896 ) + " <br/> " +
1897
1898 "<b>EmotRight</b> = " + String.valueOf(getEmotRight()
1899 ) + " <br/> " +
1900
1901 "<b>Bubble</b> = " + String.valueOf(getBubble()
1902 ) + " <br/> " +
1903
1904 "<b>Anim</b> = " + String.valueOf(getAnim()
1905 ) + " <br/> " +
1906
1907 "<br/>]";
1908 }
1909
1910
1911 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=all]) ---
1912
1913 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=all]) ---
1914
1915 // --- Extra Java from XML BEGIN (extra/code/java/javapart/classcategory[@name=base+classtype[@name=message]) ---
1916
1917 // --- Extra Java from XML END (extra/code/java/javapart/classcategory[@name=base+classtype[@name=message]) ---
1918
1919 }
1920