1
2
3
4
5
6
7
8
9
10 package
11 cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12 import java.util.*;
13 import javax.vecmath.*;
14 import cz.cuni.amis.pogamut.base.communication.messages.*;
15 import cz.cuni.amis.pogamut.base.communication.worldview.*;
16 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19 import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20 import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22 import cz.cuni.amis.pogamut.udk.communication.messages.*;
23 import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24 import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25 import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26 import cz.cuni.amis.utils.exception.*;
27 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28 import cz.cuni.amis.utils.SafeEquals;
29 import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30
31
32
33
34
35
36
37
38
39
40
41 public class
42 Self
43 extends GBObjectUpdate
44
45 implements IGBWorldObjectEvent, IWorldObject, IPerson
46
47 {
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129 public Self(
130 UnrealId Id, String Name, boolean Vehicle, Location Location, Velocity Velocity, Rotation Rotation, int Team, UnrealId Weapon, boolean Shooting, int Health, int PrimaryAmmo, int SecondaryAmmo, int Armor, int SmallArmor, boolean AltFiring, boolean Crouched, boolean Walking, Location FloorLocation, Location FloorNormal, double UDamageTime, String Action) {
131
132 this.Id = Id;
133
134 this.Name = Name;
135
136 this.Vehicle = Vehicle;
137
138 this.Location = Location;
139
140 this.Velocity = Velocity;
141
142 this.Rotation = Rotation;
143
144 this.Team = Team;
145
146 this.Weapon = Weapon;
147
148 this.Shooting = Shooting;
149
150 this.Health = Health;
151
152 this.PrimaryAmmo = PrimaryAmmo;
153
154 this.SecondaryAmmo = SecondaryAmmo;
155
156 this.Armor = Armor;
157
158 this.SmallArmor = SmallArmor;
159
160 this.AltFiring = AltFiring;
161
162 this.Crouched = Crouched;
163
164 this.Walking = Walking;
165
166 this.FloorLocation = FloorLocation;
167
168 this.FloorNormal = FloorNormal;
169
170 this.UDamageTime = UDamageTime;
171
172 this.Action = Action;
173
174 }
175
176
177
178 public static final String PROTOTYPE =
179 "SLF {Id unreal_id} {Name text} {Vehicle False} {Location 0,0,0} {Velocity 0,0,0} {Rotation 0,0,0} {Team 0} {Weapon unreal_id} {Shooting False} {Health 0} {PrimaryAmmo 0} {SecondaryAmmo 0} {Armor 0} {SmallArmor 0} {AltFiring False} {Crouched False} {Walking False} {FloorLocation 0,0,0} {FloorNormal 0,0,0} {UDamageTime 0} {Action text}";
180
181
182
183
184
185
186 protected
187 UnrealId Id =
188 null;
189
190
191
192
193 public
194 UnrealId getId() {
195 return
196 Id;
197 }
198
199
200
201
202
203 protected
204 String Name =
205 null;
206
207
208
209
210 public
211 String getName() {
212 return
213 Name;
214 }
215
216
217
218
219
220
221 protected
222 boolean Vehicle =
223 false;
224
225
226
227
228
229 public
230 boolean isVehicle() {
231 return
232 Vehicle;
233 }
234
235
236
237
238
239
240
241 protected
242 Location Location =
243 null;
244
245
246
247
248
249
250 public
251 Location getLocation() {
252 return
253 Location;
254 }
255
256
257
258
259
260
261
262
263 protected
264 Velocity Velocity =
265 null;
266
267
268
269
270
271
272
273 public
274 Velocity getVelocity() {
275 return
276 Velocity;
277 }
278
279
280
281
282
283
284
285 protected
286 Rotation Rotation =
287 null;
288
289
290
291
292
293
294 public
295 Rotation getRotation() {
296 return
297 Rotation;
298 }
299
300
301
302
303
304
305
306
307 protected
308 int Team =
309 0;
310
311
312
313
314
315
316
317 public
318 int getTeam() {
319 return
320 Team;
321 }
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336 protected
337 UnrealId Weapon =
338 null;
339
340
341
342
343
344
345
346
347
348
349
350
351
352 public
353 UnrealId getWeapon() {
354 return
355 Weapon;
356 }
357
358
359
360
361
362 protected
363 boolean Shooting =
364 false;
365
366
367
368
369 public
370 boolean isShooting() {
371 return
372 Shooting;
373 }
374
375
376
377
378
379
380
381
382 protected
383 int Health =
384 0;
385
386
387
388
389
390
391
392 public
393 int getHealth() {
394 return
395 Health;
396 }
397
398
399
400
401
402
403
404
405 protected
406 int PrimaryAmmo =
407 0;
408
409
410
411
412
413
414
415 public
416 int getPrimaryAmmo() {
417 return
418 PrimaryAmmo;
419 }
420
421
422
423
424
425
426
427
428 protected
429 int SecondaryAmmo =
430 0;
431
432
433
434
435
436
437
438 public
439 int getSecondaryAmmo() {
440 return
441 SecondaryAmmo;
442 }
443
444
445
446
447
448
449
450
451
452
453
454 protected
455 int Armor =
456 0;
457
458
459
460
461
462
463
464
465
466
467 public
468 int getArmor() {
469 return
470 Armor;
471 }
472
473
474
475
476
477
478
479 protected
480 int SmallArmor =
481 0;
482
483
484
485
486
487
488 public
489 int getSmallArmor() {
490 return
491 SmallArmor;
492 }
493
494
495
496
497
498
499
500 protected
501 boolean AltFiring =
502 false;
503
504
505
506
507
508
509 public
510 boolean isAltFiring() {
511 return
512 AltFiring;
513 }
514
515
516
517
518
519
520
521 protected
522 boolean Crouched =
523 false;
524
525
526
527
528
529
530 public
531 boolean isCrouched() {
532 return
533 Crouched;
534 }
535
536
537
538
539
540
541
542 protected
543 boolean Walking =
544 false;
545
546
547
548
549
550
551 public
552 boolean isWalking() {
553 return
554 Walking;
555 }
556
557
558
559
560
561
562
563 protected
564 Location FloorLocation =
565 null;
566
567
568
569
570
571
572 public
573 Location getFloorLocation() {
574 return
575 FloorLocation;
576 }
577
578
579
580
581
582
583
584 protected
585 Location FloorNormal =
586 null;
587
588
589
590
591
592
593 public
594 Location getFloorNormal() {
595 return
596 FloorNormal;
597 }
598
599
600
601
602
603
604
605
606 protected
607 double UDamageTime =
608 0;
609
610
611
612
613
614
615
616 public
617 double getUDamageTime() {
618 return
619 UDamageTime;
620 }
621
622
623
624
625
626
627
628 protected
629 String Action =
630 null;
631
632
633
634
635
636
637 public
638 String getAction() {
639 return
640 Action;
641 }
642
643
644
645
646
647
648
649
650
651 protected double Time = 0;
652
653 protected double getTime() {
654 return Time;
655 }
656
657 protected void setTime(double time) {
658 this.Time = time;
659 }
660
661 public double getLastSeenTime() {
662 return Time;
663 }
664
665
666 public ILocalWorldObject getLocal() {
667 return null;
668 }
669
670 public ISharedWorldObject getShared() {
671 return null;
672 }
673
674 public IStaticWorldObject getStatic() {
675 return null;
676 }
677
678 @Override
679 public long getSimTime() {
680 return (long)getLastSeenTime();
681 }
682
683 public boolean equals(Object obj) {
684 if (!(obj instanceof Self)) return false;
685 Self cast = (Self)obj;
686 if (this.getId() != null) return this.getId().equals(cast.getId());
687 else return cast.getId() == null;
688 }
689
690 public int hashCode() {
691 if (getId() != null) return getId().hashCode();
692 return 0;
693 }
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711 public Self(Self original) {
712
713 this.Id=original.Id;
714
715 this.Name=original.Name;
716
717 this.Vehicle=original.Vehicle;
718
719 this.Location=original.Location;
720
721 this.Velocity=original.Velocity;
722
723 this.Rotation=original.Rotation;
724
725 this.Team=original.Team;
726
727 this.Weapon=original.Weapon;
728
729 this.Shooting=original.Shooting;
730
731 this.Health=original.Health;
732
733 this.PrimaryAmmo=original.PrimaryAmmo;
734
735 this.SecondaryAmmo=original.SecondaryAmmo;
736
737 this.Armor=original.Armor;
738
739 this.SmallArmor=original.SmallArmor;
740
741 this.AltFiring=original.AltFiring;
742
743 this.Crouched=original.Crouched;
744
745 this.Walking=original.Walking;
746
747 this.FloorLocation=original.FloorLocation;
748
749 this.FloorNormal=original.FloorNormal;
750
751 this.UDamageTime=original.UDamageTime;
752
753 this.Action=original.Action;
754
755 }
756
757
758
759
760
761 public Self() {
762 }
763
764
765
766
767
768 private IWorldObject orig = null;
769
770 public IWorldObjectUpdateResult update(IWorldObject obj) {
771 if(obj == null) {
772 orig = this;
773 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
774 }
775 orig = obj;
776
777 Self o = (Self)obj;
778
779 boolean updated = false;
780
781
782 if (!SafeEquals.equals(o.Name, Name)) {
783 o.Name=Name;
784 updated = true;
785 }
786
787 if (o.Vehicle != Vehicle) {
788 o.Vehicle=Vehicle;
789 updated = true;
790 }
791
792 if (!SafeEquals.equals(o.Location, Location)) {
793 o.Location=Location;
794 updated = true;
795 }
796
797 if (!SafeEquals.equals(o.Velocity, Velocity)) {
798 o.Velocity=Velocity;
799 updated = true;
800 }
801
802 if (!SafeEquals.equals(o.Rotation, Rotation)) {
803 o.Rotation=Rotation;
804 updated = true;
805 }
806
807 if (o.Team != Team) {
808 o.Team=Team;
809 updated = true;
810 }
811
812 if (!SafeEquals.equals(o.Weapon, Weapon)) {
813 o.Weapon=Weapon;
814 updated = true;
815 }
816
817 if (o.Shooting != Shooting) {
818 o.Shooting=Shooting;
819 updated = true;
820 }
821
822 if (o.Health != Health) {
823 o.Health=Health;
824 updated = true;
825 }
826
827 if (o.PrimaryAmmo != PrimaryAmmo) {
828 o.PrimaryAmmo=PrimaryAmmo;
829 updated = true;
830 }
831
832 if (o.SecondaryAmmo != SecondaryAmmo) {
833 o.SecondaryAmmo=SecondaryAmmo;
834 updated = true;
835 }
836
837 if (o.Armor != Armor) {
838 o.Armor=Armor;
839 updated = true;
840 }
841
842 if (o.SmallArmor != SmallArmor) {
843 o.SmallArmor=SmallArmor;
844 updated = true;
845 }
846
847 if (o.AltFiring != AltFiring) {
848 o.AltFiring=AltFiring;
849 updated = true;
850 }
851
852 if (o.Crouched != Crouched) {
853 o.Crouched=Crouched;
854 updated = true;
855 }
856
857 if (o.Walking != Walking) {
858 o.Walking=Walking;
859 updated = true;
860 }
861
862 if (!SafeEquals.equals(o.FloorLocation, FloorLocation)) {
863 o.FloorLocation=FloorLocation;
864 updated = true;
865 }
866
867 if (!SafeEquals.equals(o.FloorNormal, FloorNormal)) {
868 o.FloorNormal=FloorNormal;
869 updated = true;
870 }
871
872 if (o.UDamageTime != UDamageTime) {
873 o.UDamageTime=UDamageTime;
874 updated = true;
875 }
876
877 if (!SafeEquals.equals(o.Action, Action)) {
878 o.Action=Action;
879 updated = true;
880 }
881
882 o.Time = Time;
883
884
885 if (updated) {
886 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
887 } else {
888 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
889 }
890 }
891
892
893
894
895
896 public IWorldObject getObject() {
897 if (orig == null) return this;
898 return orig;
899 }
900
901
902
903 public String toString() {
904 return
905
906 super.toString() + " | " +
907
908 "Id = " +
909 String.valueOf(Id) + " | " +
910
911 "Name = " +
912 String.valueOf(Name) + " | " +
913
914 "Vehicle = " +
915 String.valueOf(Vehicle) + " | " +
916
917 "Location = " +
918 String.valueOf(Location) + " | " +
919
920 "Velocity = " +
921 String.valueOf(Velocity) + " | " +
922
923 "Rotation = " +
924 String.valueOf(Rotation) + " | " +
925
926 "Team = " +
927 String.valueOf(Team) + " | " +
928
929 "Weapon = " +
930 String.valueOf(Weapon) + " | " +
931
932 "Shooting = " +
933 String.valueOf(Shooting) + " | " +
934
935 "Health = " +
936 String.valueOf(Health) + " | " +
937
938 "PrimaryAmmo = " +
939 String.valueOf(PrimaryAmmo) + " | " +
940
941 "SecondaryAmmo = " +
942 String.valueOf(SecondaryAmmo) + " | " +
943
944 "Armor = " +
945 String.valueOf(Armor) + " | " +
946
947 "SmallArmor = " +
948 String.valueOf(SmallArmor) + " | " +
949
950 "AltFiring = " +
951 String.valueOf(AltFiring) + " | " +
952
953 "Crouched = " +
954 String.valueOf(Crouched) + " | " +
955
956 "Walking = " +
957 String.valueOf(Walking) + " | " +
958
959 "FloorLocation = " +
960 String.valueOf(FloorLocation) + " | " +
961
962 "FloorNormal = " +
963 String.valueOf(FloorNormal) + " | " +
964
965 "UDamageTime = " +
966 String.valueOf(UDamageTime) + " | " +
967
968 "Action = " +
969 String.valueOf(Action) + " | " +
970 "";
971
972 }
973
974 public String toHtmlString() {
975 return super.toString() +
976
977 "<b>Id</b> : " +
978 String.valueOf(Id) +
979 " <br/> " +
980
981 "<b>Name</b> : " +
982 String.valueOf(Name) +
983 " <br/> " +
984
985 "<b>Vehicle</b> : " +
986 String.valueOf(Vehicle) +
987 " <br/> " +
988
989 "<b>Location</b> : " +
990 String.valueOf(Location) +
991 " <br/> " +
992
993 "<b>Velocity</b> : " +
994 String.valueOf(Velocity) +
995 " <br/> " +
996
997 "<b>Rotation</b> : " +
998 String.valueOf(Rotation) +
999 " <br/> " +
1000
1001 "<b>Team</b> : " +
1002 String.valueOf(Team) +
1003 " <br/> " +
1004
1005 "<b>Weapon</b> : " +
1006 String.valueOf(Weapon) +
1007 " <br/> " +
1008
1009 "<b>Shooting</b> : " +
1010 String.valueOf(Shooting) +
1011 " <br/> " +
1012
1013 "<b>Health</b> : " +
1014 String.valueOf(Health) +
1015 " <br/> " +
1016
1017 "<b>PrimaryAmmo</b> : " +
1018 String.valueOf(PrimaryAmmo) +
1019 " <br/> " +
1020
1021 "<b>SecondaryAmmo</b> : " +
1022 String.valueOf(SecondaryAmmo) +
1023 " <br/> " +
1024
1025 "<b>Armor</b> : " +
1026 String.valueOf(Armor) +
1027 " <br/> " +
1028
1029 "<b>SmallArmor</b> : " +
1030 String.valueOf(SmallArmor) +
1031 " <br/> " +
1032
1033 "<b>AltFiring</b> : " +
1034 String.valueOf(AltFiring) +
1035 " <br/> " +
1036
1037 "<b>Crouched</b> : " +
1038 String.valueOf(Crouched) +
1039 " <br/> " +
1040
1041 "<b>Walking</b> : " +
1042 String.valueOf(Walking) +
1043 " <br/> " +
1044
1045 "<b>FloorLocation</b> : " +
1046 String.valueOf(FloorLocation) +
1047 " <br/> " +
1048
1049 "<b>FloorNormal</b> : " +
1050 String.valueOf(FloorNormal) +
1051 " <br/> " +
1052
1053 "<b>UDamageTime</b> : " +
1054 String.valueOf(UDamageTime) +
1055 " <br/> " +
1056
1057 "<b>Action</b> : " +
1058 String.valueOf(Action) +
1059 " <br/> " +
1060 "";
1061 }
1062
1063
1064
1065 }
1066
1067