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