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 public class ItemStaticImpl
29 extends
30 ItemStatic
31 {
32
33
34
35
36
37
38 public ItemStaticImpl()
39 {
40 }
41
42
43
44
45
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 public ItemStaticImpl(
104 UnrealId Id, UnrealId NavPointId, NavPoint NavPoint, int Amount, ItemType Type, ItemDescriptor Descriptor
105 ) {
106
107 this.Id = Id;
108
109 this.NavPointId = NavPointId;
110
111 this.NavPoint = NavPoint;
112
113 this.Amount = Amount;
114
115 this.Type = Type;
116
117 this.Descriptor = Descriptor;
118
119 }
120
121
122
123
124
125
126 public ItemStaticImpl(Item original) {
127
128 this.Id = original.getId()
129 ;
130
131 this.NavPointId = original.getNavPointId()
132 ;
133
134 this.NavPoint = original.getNavPoint()
135 ;
136
137 this.Amount = original.getAmount()
138 ;
139
140 this.Type = original.getType()
141 ;
142
143 this.Descriptor = original.getDescriptor()
144 ;
145
146 this.SimTime = original.getSimTime();
147 }
148
149
150
151
152
153
154 public ItemStaticImpl(ItemStaticImpl original) {
155
156 this.Id = original.getId()
157 ;
158
159 this.NavPointId = original.getNavPointId()
160 ;
161
162 this.NavPoint = original.getNavPoint()
163 ;
164
165 this.Amount = original.getAmount()
166 ;
167
168 this.Type = original.getType()
169 ;
170
171 this.Descriptor = original.getDescriptor()
172 ;
173
174 this.SimTime = original.getSimTime();
175 }
176
177
178
179
180
181
182 public ItemStaticImpl(ItemStatic original) {
183
184 this.Id = original.getId()
185 ;
186
187 this.NavPointId = original.getNavPointId()
188 ;
189
190 this.NavPoint = original.getNavPoint()
191 ;
192
193 this.Amount = original.getAmount()
194 ;
195
196 this.Type = original.getType()
197 ;
198
199 this.Descriptor = original.getDescriptor()
200 ;
201
202 }
203
204
205 @Override
206 public void setSimTime(long SimTime) {
207 super.setSimTime(SimTime);
208 }
209
210 @Override
211 public
212 ItemStaticImpl clone() {
213 return new
214 ItemStaticImpl(this);
215 }
216
217
218
219
220
221
222
223
224
225 protected
226 UnrealId Id =
227 null;
228
229
230
231
232
233
234
235 public UnrealId getId()
236 {
237 return Id;
238 }
239
240
241
242
243
244
245
246 protected
247 UnrealId NavPointId =
248 null;
249
250
251
252
253
254
255 public UnrealId getNavPointId()
256 {
257 return NavPointId;
258 }
259
260
261
262
263
264
265
266
267 protected
268 NavPoint NavPoint =
269 null;
270
271
272
273
274
275
276
277 public NavPoint getNavPoint()
278 {
279 return NavPoint;
280 }
281
282
283
284
285
286
287
288
289 protected
290 int Amount =
291 0;
292
293
294
295
296
297
298
299 public int getAmount()
300 {
301 return Amount;
302 }
303
304
305
306
307
308
309
310 protected
311 ItemType Type =
312 null;
313
314
315
316
317
318
319 public ItemType getType()
320 {
321 return Type;
322 }
323
324
325
326
327
328
329
330 protected
331 ItemDescriptor Descriptor =
332 null;
333
334
335
336
337
338
339 public ItemDescriptor getDescriptor()
340 {
341 return Descriptor;
342 }
343
344
345
346 public static class ItemStaticUpdate
347 implements IStaticWorldObjectUpdatedEvent
348 {
349
350 private ItemStatic data;
351 private long time;
352
353 public ItemStaticUpdate
354 (ItemStatic source, long time)
355 {
356 this.data = source;
357 this.time = time;
358 }
359
360
361
362
363 @Override
364 public long getSimTime() {
365 return time;
366 }
367
368 @Override
369 public WorldObjectId getId() {
370 return data.getId();
371 }
372
373 @Override
374 public IWorldObjectUpdateResult<IStaticWorldObject> update(
375 IStaticWorldObject object) {
376 if ( object == null)
377 {
378 data = new ItemStaticImpl(data);
379 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
380 }
381
382 if ( object instanceof ItemStaticImpl)
383 {
384 ItemStaticImpl orig = (ItemStaticImpl)object;
385
386 if ( data.isDifferentFrom(orig) )
387 {
388
389
390 System.out.println("!!!!!ERROR!!!!!! in static object modification. Object class : ItemStaticImpl to see which property was different see !!!!PROPERTY UPDATE ERROR!!!!");
391 }
392 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<IStaticWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
393 }
394 throw new PogamutException("Unexpected object type for update, ItemStaticImpl expected not class " + object.getClass().getSimpleName() + ".", this);
395 }
396 }
397
398
399
400 @Override
401 public boolean isDifferentFrom(IStaticWorldObject other)
402 {
403 if (other == null)
404 {
405 return true;
406 }
407 else if (other == this)
408 {
409 return false;
410 }
411 else
412 {
413 ItemStatic obj = (ItemStatic) other;
414
415
416 if ( !(
417 AdvancedEquals.equalsOrNull(this.getId()
418 , obj.getId()
419 )
420 ) )
421 {
422 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Id on object class ItemStatic");
423 return true;
424 }
425
426 if ( !(
427 AdvancedEquals.equalsOrNull(this.getNavPointId()
428 , obj.getNavPointId()
429 )
430 ) )
431 {
432 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property NavPointId on object class ItemStatic");
433 return true;
434 }
435
436 if ( !(
437 AdvancedEquals.equalsOrNull(this.getNavPoint()
438 , obj.getNavPoint()
439 )
440 ) )
441 {
442 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property NavPoint on object class ItemStatic");
443 return true;
444 }
445
446 if ( !(this.getAmount()
447
448 == obj.getAmount()
449 ) )
450 {
451 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Amount on object class ItemStatic");
452 return true;
453 }
454
455 if ( !(
456 AdvancedEquals.equalsOrNull(this.getType()
457 , obj.getType()
458 )
459 ) )
460 {
461 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Type on object class ItemStatic");
462 return true;
463 }
464
465 if ( !(
466 AdvancedEquals.equalsOrNull(this.getDescriptor()
467 , obj.getDescriptor()
468 )
469 ) )
470 {
471 System.out.println("!!!!!PROPERTY UPDATE ERROR!!!! on property Descriptor on object class ItemStatic");
472 return true;
473 }
474
475 }
476 return false;
477 }
478
479
480 public String toString() {
481 return
482 super.toString() + "[" +
483
484 "Id = " + String.valueOf(getId()
485 ) + " | " +
486
487 "NavPointId = " + String.valueOf(getNavPointId()
488 ) + " | " +
489
490 "Amount = " + String.valueOf(getAmount()
491 ) + " | " +
492
493 "Type = " + String.valueOf(getType()
494 ) + " | " +
495
496 "]";
497 }
498
499
500 public String toHtmlString() {
501 return super.toString() + "[<br/>" +
502
503 "<b>Id</b> = " + String.valueOf(getId()
504 ) + " <br/> " +
505
506 "<b>NavPointId</b> = " + String.valueOf(getNavPointId()
507 ) + " <br/> " +
508
509 "<b>Amount</b> = " + String.valueOf(getAmount()
510 ) + " <br/> " +
511
512 "<b>Type</b> = " + String.valueOf(getType()
513 ) + " <br/> " +
514
515 "<br/>]";
516 }
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537 public void setNavPoint(NavPoint navPoint) {
538 NavPoint = navPoint;
539 }
540
541
542
543 }
544