1
2
3
4
5
6
7
8
9
10 package
11 cz.cuni.amis.pogamut.udk.communication.messages.gbinfomessages;
12 import java.util.*;
13 import javax.vecmath.*;
14 import cz.cuni.amis.pogamut.base.communication.messages.*;
15 import cz.cuni.amis.pogamut.base.communication.worldview.*;
16 import cz.cuni.amis.pogamut.base.communication.worldview.event.*;
17 import cz.cuni.amis.pogamut.base.communication.worldview.object.*;
18 import cz.cuni.amis.pogamut.base.communication.translator.event.*;
19 import cz.cuni.amis.pogamut.base3d.worldview.object.*;
20 import cz.cuni.amis.pogamut.base3d.worldview.object.event.*;
21 import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
22 import cz.cuni.amis.pogamut.udk.communication.messages.*;
23 import cz.cuni.amis.pogamut.udk.communication.worldview.objects.*;
24 import cz.cuni.amis.pogamut.udk.communication.translator.itemdescriptor.*;
25 import cz.cuni.amis.pogamut.udk.communication.messages.ItemType.Category;
26 import cz.cuni.amis.utils.exception.*;
27 import cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result;
28 import cz.cuni.amis.utils.SafeEquals;
29 import cz.cuni.amis.pogamut.multi.communication.worldview.object.*;
30
31
32
33
34
35
36
37
38
39
40
41
42
43 public class
44 ConfigChange
45 extends GBObjectUpdate
46
47 implements IGBWorldObjectEvent, IWorldObject
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 public ConfigChange(
107 UnrealId Id, UnrealId BotId, boolean ManualSpawn, boolean AutoTrace, String Name, double SpeedMultiplier, Rotation RotationRate, boolean Invulnerable, double VisionTime, boolean ShowDebug, boolean ShowFocalPoint, boolean DrawTraceLines, boolean SynchronousOff, boolean AutoPickupOff, String Action) {
108
109 this.Id = Id;
110
111 this.BotId = BotId;
112
113 this.ManualSpawn = ManualSpawn;
114
115 this.AutoTrace = AutoTrace;
116
117 this.Name = Name;
118
119 this.SpeedMultiplier = SpeedMultiplier;
120
121 this.RotationRate = RotationRate;
122
123 this.Invulnerable = Invulnerable;
124
125 this.VisionTime = VisionTime;
126
127 this.ShowDebug = ShowDebug;
128
129 this.ShowFocalPoint = ShowFocalPoint;
130
131 this.DrawTraceLines = DrawTraceLines;
132
133 this.SynchronousOff = SynchronousOff;
134
135 this.AutoPickupOff = AutoPickupOff;
136
137 this.Action = Action;
138
139 }
140
141
142
143 public static final String PROTOTYPE =
144 "CONFCH {Id unreal_id} {BotId unreal_id} {ManualSpawn False} {AutoTrace False} {Name text} {SpeedMultiplier 0} {RotationRate 0,0,0} {Invulnerable False} {VisionTime 0} {ShowDebug False} {ShowFocalPoint False} {DrawTraceLines False} {SynchronousOff False} {AutoPickupOff False} {Action text}";
145
146
147
148
149
150
151 protected
152 UnrealId Id =
153 null;
154
155
156
157
158 public
159 UnrealId getId() {
160 return
161 Id;
162 }
163
164
165
166
167
168 protected
169 UnrealId BotId =
170 null;
171
172
173
174
175 public
176 UnrealId getBotId() {
177 return
178 BotId;
179 }
180
181
182
183
184
185
186
187 protected
188 boolean ManualSpawn =
189 false;
190
191
192
193
194
195
196 public
197 boolean isManualSpawn() {
198 return
199 ManualSpawn;
200 }
201
202
203
204
205
206
207
208
209
210 protected
211 boolean AutoTrace =
212 false;
213
214
215
216
217
218
219
220
221 public
222 boolean isAutoTrace() {
223 return
224 AutoTrace;
225 }
226
227
228
229
230
231 protected
232 String Name =
233 null;
234
235
236
237
238 public
239 String getName() {
240 return
241 Name;
242 }
243
244
245
246
247
248
249
250 protected
251 double SpeedMultiplier =
252 0;
253
254
255
256
257
258
259 public
260 double getSpeedMultiplier() {
261 return
262 SpeedMultiplier;
263 }
264
265
266
267
268
269
270
271 protected
272 Rotation RotationRate =
273 null;
274
275
276
277
278
279
280 public
281 Rotation getRotationRate() {
282 return
283 RotationRate;
284 }
285
286
287
288
289
290
291
292 protected
293 boolean Invulnerable =
294 false;
295
296
297
298
299
300
301 public
302 boolean isInvulnerable() {
303 return
304 Invulnerable;
305 }
306
307
308
309
310
311
312
313
314 protected
315 double VisionTime =
316 0;
317
318
319
320
321
322
323
324 public
325 double getVisionTime() {
326 return
327 VisionTime;
328 }
329
330
331
332
333
334
335
336
337 protected
338 boolean ShowDebug =
339 false;
340
341
342
343
344
345
346
347 public
348 boolean isShowDebug() {
349 return
350 ShowDebug;
351 }
352
353
354
355
356
357
358
359
360 protected
361 boolean ShowFocalPoint =
362 false;
363
364
365
366
367
368
369
370 public
371 boolean isShowFocalPoint() {
372 return
373 ShowFocalPoint;
374 }
375
376
377
378
379
380
381
382
383 protected
384 boolean DrawTraceLines =
385 false;
386
387
388
389
390
391
392
393 public
394 boolean isDrawTraceLines() {
395 return
396 DrawTraceLines;
397 }
398
399
400
401
402
403
404
405
406 protected
407 boolean SynchronousOff =
408 false;
409
410
411
412
413
414
415
416 public
417 boolean isSynchronousOff() {
418 return
419 SynchronousOff;
420 }
421
422
423
424
425
426
427
428 protected
429 boolean AutoPickupOff =
430 false;
431
432
433
434
435
436
437 public
438 boolean isAutoPickupOff() {
439 return
440 AutoPickupOff;
441 }
442
443
444
445
446
447
448
449 protected
450 String Action =
451 null;
452
453
454
455
456
457
458 public
459 String getAction() {
460 return
461 Action;
462 }
463
464
465
466
467
468
469
470
471
472 protected double Time = 0;
473
474 protected double getTime() {
475 return Time;
476 }
477
478 protected void setTime(double time) {
479 this.Time = time;
480 }
481
482 public double getLastSeenTime() {
483 return Time;
484 }
485
486
487 public ILocalWorldObject getLocal() {
488 return null;
489 }
490
491 public ISharedWorldObject getShared() {
492 return null;
493 }
494
495 public IStaticWorldObject getStatic() {
496 return null;
497 }
498
499 @Override
500 public long getSimTime() {
501 return (long)getLastSeenTime();
502 }
503
504 public boolean equals(Object obj) {
505 if (!(obj instanceof ConfigChange)) return false;
506 ConfigChange cast = (ConfigChange)obj;
507 if (this.getId() != null) return this.getId().equals(cast.getId());
508 else return cast.getId() == null;
509 }
510
511 public int hashCode() {
512 if (getId() != null) return getId().hashCode();
513 return 0;
514 }
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532 public ConfigChange(ConfigChange original) {
533
534 this.Id=original.Id;
535
536 this.BotId=original.BotId;
537
538 this.ManualSpawn=original.ManualSpawn;
539
540 this.AutoTrace=original.AutoTrace;
541
542 this.Name=original.Name;
543
544 this.SpeedMultiplier=original.SpeedMultiplier;
545
546 this.RotationRate=original.RotationRate;
547
548 this.Invulnerable=original.Invulnerable;
549
550 this.VisionTime=original.VisionTime;
551
552 this.ShowDebug=original.ShowDebug;
553
554 this.ShowFocalPoint=original.ShowFocalPoint;
555
556 this.DrawTraceLines=original.DrawTraceLines;
557
558 this.SynchronousOff=original.SynchronousOff;
559
560 this.AutoPickupOff=original.AutoPickupOff;
561
562 this.Action=original.Action;
563
564 }
565
566
567
568
569
570 public ConfigChange() {
571 }
572
573
574
575
576
577 private IWorldObject orig = null;
578
579 public IWorldObjectUpdateResult update(IWorldObject obj) {
580 if(obj == null) {
581 orig = this;
582 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.CREATED, this);
583 }
584 orig = obj;
585
586 ConfigChange o = (ConfigChange)obj;
587
588 boolean updated = false;
589
590
591 if (o.ManualSpawn != ManualSpawn) {
592 o.ManualSpawn=ManualSpawn;
593 updated = true;
594 }
595
596 if (o.AutoTrace != AutoTrace) {
597 o.AutoTrace=AutoTrace;
598 updated = true;
599 }
600
601 if (!SafeEquals.equals(o.Name, Name)) {
602 o.Name=Name;
603 updated = true;
604 }
605
606 if (o.SpeedMultiplier != SpeedMultiplier) {
607 o.SpeedMultiplier=SpeedMultiplier;
608 updated = true;
609 }
610
611 if (!SafeEquals.equals(o.RotationRate, RotationRate)) {
612 o.RotationRate=RotationRate;
613 updated = true;
614 }
615
616 if (o.Invulnerable != Invulnerable) {
617 o.Invulnerable=Invulnerable;
618 updated = true;
619 }
620
621 if (o.VisionTime != VisionTime) {
622 o.VisionTime=VisionTime;
623 updated = true;
624 }
625
626 if (o.ShowDebug != ShowDebug) {
627 o.ShowDebug=ShowDebug;
628 updated = true;
629 }
630
631 if (o.ShowFocalPoint != ShowFocalPoint) {
632 o.ShowFocalPoint=ShowFocalPoint;
633 updated = true;
634 }
635
636 if (o.DrawTraceLines != DrawTraceLines) {
637 o.DrawTraceLines=DrawTraceLines;
638 updated = true;
639 }
640
641 if (o.SynchronousOff != SynchronousOff) {
642 o.SynchronousOff=SynchronousOff;
643 updated = true;
644 }
645
646 if (o.AutoPickupOff != AutoPickupOff) {
647 o.AutoPickupOff=AutoPickupOff;
648 updated = true;
649 }
650
651 if (!SafeEquals.equals(o.Action, Action)) {
652 o.Action=Action;
653 updated = true;
654 }
655
656 o.Time = Time;
657
658
659 if (updated) {
660 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.UPDATED, o);
661 } else {
662 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(cz.cuni.amis.pogamut.base.communication.translator.event.IWorldObjectUpdateResult.Result.SAME, o);
663 }
664 }
665
666
667
668
669
670 public IWorldObject getObject() {
671 if (orig == null) return this;
672 return orig;
673 }
674
675
676
677 public String toString() {
678 return
679
680 super.toString() + " | " +
681
682 "Id = " +
683 String.valueOf(Id) + " | " +
684
685 "BotId = " +
686 String.valueOf(BotId) + " | " +
687
688 "ManualSpawn = " +
689 String.valueOf(ManualSpawn) + " | " +
690
691 "AutoTrace = " +
692 String.valueOf(AutoTrace) + " | " +
693
694 "Name = " +
695 String.valueOf(Name) + " | " +
696
697 "SpeedMultiplier = " +
698 String.valueOf(SpeedMultiplier) + " | " +
699
700 "RotationRate = " +
701 String.valueOf(RotationRate) + " | " +
702
703 "Invulnerable = " +
704 String.valueOf(Invulnerable) + " | " +
705
706 "VisionTime = " +
707 String.valueOf(VisionTime) + " | " +
708
709 "ShowDebug = " +
710 String.valueOf(ShowDebug) + " | " +
711
712 "ShowFocalPoint = " +
713 String.valueOf(ShowFocalPoint) + " | " +
714
715 "DrawTraceLines = " +
716 String.valueOf(DrawTraceLines) + " | " +
717
718 "SynchronousOff = " +
719 String.valueOf(SynchronousOff) + " | " +
720
721 "AutoPickupOff = " +
722 String.valueOf(AutoPickupOff) + " | " +
723
724 "Action = " +
725 String.valueOf(Action) + " | " +
726 "";
727
728 }
729
730 public String toHtmlString() {
731 return super.toString() +
732
733 "<b>Id</b> : " +
734 String.valueOf(Id) +
735 " <br/> " +
736
737 "<b>BotId</b> : " +
738 String.valueOf(BotId) +
739 " <br/> " +
740
741 "<b>ManualSpawn</b> : " +
742 String.valueOf(ManualSpawn) +
743 " <br/> " +
744
745 "<b>AutoTrace</b> : " +
746 String.valueOf(AutoTrace) +
747 " <br/> " +
748
749 "<b>Name</b> : " +
750 String.valueOf(Name) +
751 " <br/> " +
752
753 "<b>SpeedMultiplier</b> : " +
754 String.valueOf(SpeedMultiplier) +
755 " <br/> " +
756
757 "<b>RotationRate</b> : " +
758 String.valueOf(RotationRate) +
759 " <br/> " +
760
761 "<b>Invulnerable</b> : " +
762 String.valueOf(Invulnerable) +
763 " <br/> " +
764
765 "<b>VisionTime</b> : " +
766 String.valueOf(VisionTime) +
767 " <br/> " +
768
769 "<b>ShowDebug</b> : " +
770 String.valueOf(ShowDebug) +
771 " <br/> " +
772
773 "<b>ShowFocalPoint</b> : " +
774 String.valueOf(ShowFocalPoint) +
775 " <br/> " +
776
777 "<b>DrawTraceLines</b> : " +
778 String.valueOf(DrawTraceLines) +
779 " <br/> " +
780
781 "<b>SynchronousOff</b> : " +
782 String.valueOf(SynchronousOff) +
783 " <br/> " +
784
785 "<b>AutoPickupOff</b> : " +
786 String.valueOf(AutoPickupOff) +
787 " <br/> " +
788
789 "<b>Action</b> : " +
790 String.valueOf(Action) +
791 " <br/> " +
792 "";
793 }
794
795
796
797 }
798
799