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