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 class PlayerLocalImpl
31 extends
32 PlayerLocal
33 {
34
35
36
37
38
39
40 public PlayerLocalImpl()
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
104
105
106
107
108
109 public PlayerLocalImpl(
110 UnrealId Id, String Jmx, boolean Visible
111 ) {
112
113 this.Id = Id;
114
115 this.Jmx = Jmx;
116
117 this.Visible = Visible;
118
119 }
120
121
122
123
124
125
126 public PlayerLocalImpl(Player original) {
127
128 this.Id = original.getId()
129 ;
130
131 this.Jmx = original.getJmx()
132 ;
133
134 this.Visible = original.isVisible()
135 ;
136
137 this.SimTime = original.getSimTime();
138 }
139
140
141
142
143
144
145 public PlayerLocalImpl(PlayerLocalImpl original) {
146
147 this.Id = original.getId()
148 ;
149
150 this.Jmx = original.getJmx()
151 ;
152
153 this.Visible = original.isVisible()
154 ;
155
156 this.SimTime = original.getSimTime();
157 }
158
159
160
161
162
163
164 public PlayerLocalImpl(PlayerLocal original) {
165
166 this.Id = original.getId()
167 ;
168
169 this.Jmx = original.getJmx()
170 ;
171
172 this.Visible = original.isVisible()
173 ;
174
175 }
176
177
178 @Override
179 public void setSimTime(long SimTime) {
180 super.setSimTime(SimTime);
181 }
182
183 @Override
184 public
185 PlayerLocalImpl clone() {
186 return new
187 PlayerLocalImpl(this);
188 }
189
190
191
192
193
194
195 protected
196 UnrealId Id =
197 null;
198
199
200
201
202 public UnrealId getId()
203 {
204 return Id;
205 }
206
207
208
209
210
211
212
213
214 protected
215 String Jmx =
216 null;
217
218
219
220
221
222
223
224 public String getJmx()
225 {
226 return Jmx;
227 }
228
229
230
231
232
233
234
235 protected
236 boolean Visible =
237 true;
238
239
240
241
242
243
244 public boolean isVisible()
245 {
246 return Visible;
247 }
248
249
250
251
252
253 public PlayerLocalImpl getLocal() {
254 return this;
255 }
256 public ISharedWorldObject getShared() {
257 throw new UnsupportedOperationException("Could not return LOCAL as SHARED");
258 }
259 public IStaticWorldObject getStatic() {
260 throw new UnsupportedOperationException("Could not return LOCAL as STATIC");
261 }
262
263 public static class PlayerLocalUpdate
264 implements ILocalWorldObjectUpdatedEvent, IGBWorldObjectEvent
265 {
266 protected long time;
267
268 protected PlayerLocal data = null;
269
270 public PlayerLocalUpdate
271 (PlayerLocal moverLocal, long time)
272 {
273 this.data = moverLocal;
274 this.time = time;
275 }
276
277 @Override
278 public IWorldObjectUpdateResult<ILocalWorldObject> update(
279 ILocalWorldObject object)
280 {
281 if ( object == null)
282 {
283 data = new PlayerLocalImpl(data);
284 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.CREATED, data);
285 }
286 if ( object instanceof PlayerLocalImpl )
287 {
288 PlayerLocalImpl toUpdate = (PlayerLocalImpl)object;
289
290 boolean updated = false;
291
292
293
294 if (!SafeEquals.equals(toUpdate.Jmx, data.getJmx()
295 )) {
296 toUpdate.Jmx=data.getJmx()
297 ;
298 updated = true;
299 }
300
301 if (toUpdate.Visible != data.isVisible()
302 ) {
303 toUpdate.Visible=data.isVisible()
304 ;
305 updated = true;
306 }
307
308
309 data = toUpdate;
310
311 if ( updated )
312 {
313 toUpdate.SimTime = this.time;
314 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.UPDATED, data);
315 }
316
317 return new IWorldObjectUpdateResult.WorldObjectUpdateResult<ILocalWorldObject>(IWorldObjectUpdateResult.Result.SAME, data);
318 }
319 throw new PogamutException("Unsupported object type for update. Expected PlayerLocalImpl for object " + object.getId() +", not object of class " + object.getClass().getSimpleName() + ".", this);
320 }
321
322
323
324
325 @Override
326 public long getSimTime() {
327 return this.time;
328 }
329
330 @Override
331 public IWorldObject getObject() {
332 return data;
333 }
334
335 @Override
336 public WorldObjectId getId() {
337 return data.getId();
338 }
339
340 }
341
342
343 public String toString() {
344 return
345 super.toString() + "[" +
346
347 "Id = " + String.valueOf(getId()
348 ) + " | " +
349
350 "Jmx = " + String.valueOf(getJmx()
351 ) + " | " +
352
353 "Visible = " + String.valueOf(isVisible()
354 ) + " | " +
355
356 "]";
357 }
358
359
360 public String toHtmlString() {
361 return super.toString() + "[<br/>" +
362
363 "<b>Id</b> = " + String.valueOf(getId()
364 ) + " <br/> " +
365
366 "<b>Jmx</b> = " + String.valueOf(getJmx()
367 ) + " <br/> " +
368
369 "<b>Visible</b> = " + String.valueOf(isVisible()
370 ) + " <br/> " +
371
372 "<br/>]";
373 }
374
375
376
377
378
379
380
381
382
383
384 }
385