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