1 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
2
3
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
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27 public abstract class NavPoint
28 extends
29 InfoMessage
30 implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31
32 ,ILocated
33 ,ILocomotive
34 ,IGBViewable
35 {
36
37
38 public static final String PROTOTYPE =
39 "NAV {Id unreal_id} {Location 0,0,0} {Velocity 0,0,0} {Visible False} {Item unreal_id} {ItemClass xWeapons.FlakCannonPickup} {ItemSpawned False} {DoorOpened False} {Mover unreal_id} {LiftOffset 0,0,0} {LiftJumpExit False} {NoDoubleJump False} {InvSpot False} {PlayerStart False} {TeamNumber 0} {DomPoint False} {DomPointController 0} {Door False} {LiftCenter False} {LiftExit False} {AIMarker False} {JumpSpot False} {JumpPad False} {JumpDest False} {Teleporter False} {Rotation 0,0,0} {RoamingSpot False} {SnipingSpot False} {PreferedWeapon text} ";
40
41
42
43
44
45
46 public NavPoint()
47 {
48 }
49
50
51
52
53 protected long SimTime;
54
55
56
57
58 @Override
59 public long getSimTime() {
60 return SimTime;
61 }
62
63
64
65
66 protected void setSimTime(long SimTime) {
67 this.SimTime = SimTime;
68 }
69
70
71
72
73
74
75 public abstract UnrealId getId()
76 ;
77
78
79
80
81 public abstract Location getLocation()
82 ;
83
84
85
86
87
88
89
90 public abstract Velocity getVelocity()
91 ;
92
93
94
95
96
97
98 public abstract boolean isVisible()
99 ;
100
101
102
103
104
105
106
107 public abstract UnrealId getItem()
108 ;
109
110
111
112
113
114
115 public abstract ItemType getItemClass()
116 ;
117
118
119
120
121
122
123 public abstract boolean isItemSpawned()
124 ;
125
126
127
128
129
130
131 public abstract boolean isDoorOpened()
132 ;
133
134
135
136
137
138
139 public abstract UnrealId getMover()
140 ;
141
142
143
144
145
146
147 public abstract Vector3d getLiftOffset()
148 ;
149
150
151
152
153
154
155 public abstract boolean isLiftJumpExit()
156 ;
157
158
159
160
161
162
163 public abstract boolean isNoDoubleJump()
164 ;
165
166
167
168
169
170
171 public abstract boolean isInvSpot()
172 ;
173
174
175
176
177
178
179 public abstract boolean isPlayerStart()
180 ;
181
182
183
184
185
186
187 public abstract int getTeamNumber()
188 ;
189
190
191
192
193 public abstract boolean isDomPoint()
194 ;
195
196
197
198
199 public abstract int getDomPointController()
200 ;
201
202
203
204
205
206
207 public abstract boolean isDoor()
208 ;
209
210
211
212
213
214
215 public abstract boolean isLiftCenter()
216 ;
217
218
219
220
221
222
223 public abstract boolean isLiftExit()
224 ;
225
226
227
228
229
230
231 public abstract boolean isAIMarker()
232 ;
233
234
235
236
237
238
239 public abstract boolean isJumpSpot()
240 ;
241
242
243
244
245
246
247 public abstract boolean isJumpPad()
248 ;
249
250
251
252
253
254
255 public abstract boolean isJumpDest()
256 ;
257
258
259
260
261
262
263 public abstract boolean isTeleporter()
264 ;
265
266
267
268
269
270
271
272 public abstract Rotation getRotation()
273 ;
274
275
276
277
278
279
280
281 public abstract boolean isRoamingSpot()
282 ;
283
284
285
286
287 public abstract boolean isSnipingSpot()
288 ;
289
290
291
292
293 public abstract Item getItemInstance()
294 ;
295
296
297
298
299 public abstract Map<UnrealId, NavPointNeighbourLink> getOutgoingEdges()
300 ;
301
302
303
304
305 public abstract Map<UnrealId, NavPointNeighbourLink> getIncomingEdges()
306 ;
307
308
309
310
311
312
313
314 public abstract String getPreferedWeapon()
315 ;
316
317 @Override
318 public IWorldObjectUpdatedEvent createDisappearEvent() {
319 return new ObjectDisappeared(this, getSimTime());
320 }
321
322 public static class ObjectDisappeared implements IWorldObjectUpdatedEvent
323 {
324
325 public ObjectDisappeared(NavPoint obj, long time) {
326 this.obj = obj;
327 this.time = time;
328 }
329
330 private NavPoint obj;
331 private long time;
332
333 @Override
334 public WorldObjectId getId() {
335 return obj.getId();
336 }
337
338
339
340
341 @Override
342 public long getSimTime() {
343 return time;
344 }
345
346 @Override
347 public IWorldObjectUpdateResult<IWorldObject> update(IWorldObject obj) {
348 if (obj == null) {
349 throw new PogamutException("Can't 'disappear' null!", this);
350 }
351 if (!(obj instanceof NavPointMessage)) {
352 throw new PogamutException("Can't update different class than NavPointMessage, got class " + obj.getClass().getSimpleName() + "!", this);
353 }
354 NavPointMessage toUpdate = (NavPointMessage)obj;
355 if (toUpdate.Visible) {
356 toUpdate.Visible = false;
357 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.UPDATED, obj);
358 } else {
359 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.SAME, obj);
360 }
361 }
362
363 }
364
365
366
367 public static class NavPointUpdate
368 extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {
369 private NavPoint object;
370 private long time;
371 private ITeamId teamId;
372
373 public NavPointUpdate
374 (NavPoint source, long eventTime, ITeamId teamId) {
375 this.object = source;
376 this.time = eventTime;
377 this.teamId = teamId;
378 }
379
380
381
382
383 @Override
384 public long getSimTime() {
385 return time;
386 }
387
388 @Override
389 public IWorldObject getObject() {
390 return object;
391 }
392
393 @Override
394 public WorldObjectId getId() {
395 return object.getId();
396 }
397
398 @Override
399 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
400 return new NavPointLocalImpl.NavPointLocalUpdate
401 ((NavPointLocal)object.getLocal(), time);
402 }
403
404 @Override
405 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
406 return new NavPointSharedImpl.NavPointSharedUpdate
407 ((NavPointShared)object.getShared(), time, teamId);
408 }
409
410 @Override
411 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
412 return new NavPointStaticImpl.NavPointStaticUpdate
413 ((NavPointStatic)object.getStatic(), time);
414 }
415
416 }
417
418
419 public String toString() {
420 return
421 super.toString() + "[" +
422
423 "Id = " + String.valueOf(getId()
424 ) + " | " +
425
426 "Location = " + String.valueOf(getLocation()
427 ) + " | " +
428
429 "Velocity = " + String.valueOf(getVelocity()
430 ) + " | " +
431
432 "Visible = " + String.valueOf(isVisible()
433 ) + " | " +
434
435 "Item = " + String.valueOf(getItem()
436 ) + " | " +
437
438 "ItemClass = " + String.valueOf(getItemClass()
439 ) + " | " +
440
441 "ItemSpawned = " + String.valueOf(isItemSpawned()
442 ) + " | " +
443
444 "DoorOpened = " + String.valueOf(isDoorOpened()
445 ) + " | " +
446
447 "Mover = " + String.valueOf(getMover()
448 ) + " | " +
449
450 "LiftOffset = " + String.valueOf(getLiftOffset()
451 ) + " | " +
452
453 "LiftJumpExit = " + String.valueOf(isLiftJumpExit()
454 ) + " | " +
455
456 "NoDoubleJump = " + String.valueOf(isNoDoubleJump()
457 ) + " | " +
458
459 "InvSpot = " + String.valueOf(isInvSpot()
460 ) + " | " +
461
462 "PlayerStart = " + String.valueOf(isPlayerStart()
463 ) + " | " +
464
465 "TeamNumber = " + String.valueOf(getTeamNumber()
466 ) + " | " +
467
468 "DomPoint = " + String.valueOf(isDomPoint()
469 ) + " | " +
470
471 "DomPointController = " + String.valueOf(getDomPointController()
472 ) + " | " +
473
474 "Door = " + String.valueOf(isDoor()
475 ) + " | " +
476
477 "LiftCenter = " + String.valueOf(isLiftCenter()
478 ) + " | " +
479
480 "LiftExit = " + String.valueOf(isLiftExit()
481 ) + " | " +
482
483 "AIMarker = " + String.valueOf(isAIMarker()
484 ) + " | " +
485
486 "JumpSpot = " + String.valueOf(isJumpSpot()
487 ) + " | " +
488
489 "JumpPad = " + String.valueOf(isJumpPad()
490 ) + " | " +
491
492 "JumpDest = " + String.valueOf(isJumpDest()
493 ) + " | " +
494
495 "Teleporter = " + String.valueOf(isTeleporter()
496 ) + " | " +
497
498 "Rotation = " + String.valueOf(getRotation()
499 ) + " | " +
500
501 "RoamingSpot = " + String.valueOf(isRoamingSpot()
502 ) + " | " +
503
504 "SnipingSpot = " + String.valueOf(isSnipingSpot()
505 ) + " | " +
506
507 "PreferedWeapon = " + String.valueOf(getPreferedWeapon()
508 ) + " | " +
509
510 "]";
511 }
512
513
514 public String toHtmlString() {
515 return super.toString() + "[<br/>" +
516
517 "<b>Id</b> = " + String.valueOf(getId()
518 ) + " <br/> " +
519
520 "<b>Location</b> = " + String.valueOf(getLocation()
521 ) + " <br/> " +
522
523 "<b>Velocity</b> = " + String.valueOf(getVelocity()
524 ) + " <br/> " +
525
526 "<b>Visible</b> = " + String.valueOf(isVisible()
527 ) + " <br/> " +
528
529 "<b>Item</b> = " + String.valueOf(getItem()
530 ) + " <br/> " +
531
532 "<b>ItemClass</b> = " + String.valueOf(getItemClass()
533 ) + " <br/> " +
534
535 "<b>ItemSpawned</b> = " + String.valueOf(isItemSpawned()
536 ) + " <br/> " +
537
538 "<b>DoorOpened</b> = " + String.valueOf(isDoorOpened()
539 ) + " <br/> " +
540
541 "<b>Mover</b> = " + String.valueOf(getMover()
542 ) + " <br/> " +
543
544 "<b>LiftOffset</b> = " + String.valueOf(getLiftOffset()
545 ) + " <br/> " +
546
547 "<b>LiftJumpExit</b> = " + String.valueOf(isLiftJumpExit()
548 ) + " <br/> " +
549
550 "<b>NoDoubleJump</b> = " + String.valueOf(isNoDoubleJump()
551 ) + " <br/> " +
552
553 "<b>InvSpot</b> = " + String.valueOf(isInvSpot()
554 ) + " <br/> " +
555
556 "<b>PlayerStart</b> = " + String.valueOf(isPlayerStart()
557 ) + " <br/> " +
558
559 "<b>TeamNumber</b> = " + String.valueOf(getTeamNumber()
560 ) + " <br/> " +
561
562 "<b>DomPoint</b> = " + String.valueOf(isDomPoint()
563 ) + " <br/> " +
564
565 "<b>DomPointController</b> = " + String.valueOf(getDomPointController()
566 ) + " <br/> " +
567
568 "<b>Door</b> = " + String.valueOf(isDoor()
569 ) + " <br/> " +
570
571 "<b>LiftCenter</b> = " + String.valueOf(isLiftCenter()
572 ) + " <br/> " +
573
574 "<b>LiftExit</b> = " + String.valueOf(isLiftExit()
575 ) + " <br/> " +
576
577 "<b>AIMarker</b> = " + String.valueOf(isAIMarker()
578 ) + " <br/> " +
579
580 "<b>JumpSpot</b> = " + String.valueOf(isJumpSpot()
581 ) + " <br/> " +
582
583 "<b>JumpPad</b> = " + String.valueOf(isJumpPad()
584 ) + " <br/> " +
585
586 "<b>JumpDest</b> = " + String.valueOf(isJumpDest()
587 ) + " <br/> " +
588
589 "<b>Teleporter</b> = " + String.valueOf(isTeleporter()
590 ) + " <br/> " +
591
592 "<b>Rotation</b> = " + String.valueOf(getRotation()
593 ) + " <br/> " +
594
595 "<b>RoamingSpot</b> = " + String.valueOf(isRoamingSpot()
596 ) + " <br/> " +
597
598 "<b>SnipingSpot</b> = " + String.valueOf(isSnipingSpot()
599 ) + " <br/> " +
600
601 "<b>PreferedWeapon</b> = " + String.valueOf(getPreferedWeapon()
602 ) + " <br/> " +
603
604 "<br/>]";
605 }
606
607 public String toJsonLiteral() {
608 return "navpoint( "
609 +
610 (getId()
611 == null ? "null" :
612 "\"" + getId()
613 .getStringId() + "\""
614 )
615 + ", " +
616 (getLocation()
617 == null ? "null" :
618 "[" + getLocation()
619 .getX() + ", " + getLocation()
620 .getY() + ", " + getLocation()
621 .getZ() + "]"
622 )
623 + ", " +
624 (getVelocity()
625 == null ? "null" :
626 "[" + getVelocity()
627 .getX() + ", " + getVelocity()
628 .getY() + ", " + getVelocity()
629 .getZ() + "]"
630 )
631 + ", " +
632 String.valueOf(isVisible()
633 )
634 + ", " +
635 (getItem()
636 == null ? "null" :
637 "\"" + getItem()
638 .getStringId() + "\""
639 )
640 + ", " +
641 (getItemClass()
642 == null ? "null" :
643 "\"" + getItemClass()
644 .getName() + "\""
645 )
646 + ", " +
647 String.valueOf(isItemSpawned()
648 )
649 + ", " +
650 String.valueOf(isDoorOpened()
651 )
652 + ", " +
653 (getMover()
654 == null ? "null" :
655 "\"" + getMover()
656 .getStringId() + "\""
657 )
658 + ", " +
659 (getLiftOffset()
660 == null ? "null" :
661 "[" + getLiftOffset()
662 .getX() + ", " + getLiftOffset()
663 .getY() + ", " + getLiftOffset()
664 .getZ() + "]"
665 )
666 + ", " +
667 String.valueOf(isLiftJumpExit()
668 )
669 + ", " +
670 String.valueOf(isNoDoubleJump()
671 )
672 + ", " +
673 String.valueOf(isInvSpot()
674 )
675 + ", " +
676 String.valueOf(isPlayerStart()
677 )
678 + ", " +
679 String.valueOf(getTeamNumber()
680 )
681 + ", " +
682 String.valueOf(isDomPoint()
683 )
684 + ", " +
685 String.valueOf(getDomPointController()
686 )
687 + ", " +
688 String.valueOf(isDoor()
689 )
690 + ", " +
691 String.valueOf(isLiftCenter()
692 )
693 + ", " +
694 String.valueOf(isLiftExit()
695 )
696 + ", " +
697 String.valueOf(isAIMarker()
698 )
699 + ", " +
700 String.valueOf(isJumpSpot()
701 )
702 + ", " +
703 String.valueOf(isJumpPad()
704 )
705 + ", " +
706 String.valueOf(isJumpDest()
707 )
708 + ", " +
709 String.valueOf(isTeleporter()
710 )
711 + ", " +
712 (getRotation()
713 == null ? "null" :
714 "[" + getRotation()
715 .getPitch() + ", " + getRotation()
716 .getYaw() + ", " + getRotation()
717 .getRoll() + "]"
718 )
719 + ", " +
720 String.valueOf(isRoamingSpot()
721 )
722 + ", " +
723 String.valueOf(isSnipingSpot()
724 )
725 + ", " +
726 (getPreferedWeapon()
727 == null ? "null" :
728 "\"" + getPreferedWeapon()
729 + "\""
730 )
731
732 + ")";
733 }
734
735
736
737
738
739
740
741
742
743
744 }
745