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 abstract class MoverLocal
32 extends InfoMessage
33 implements ILocalWorldObject
34
35 ,ILocalGBViewable
36 {
37
38
39
40
41
42
43 public MoverLocal()
44 {
45 }
46
47
48
49
50 protected long SimTime;
51
52
53
54
55 @Override
56 public long getSimTime() {
57 return SimTime;
58 }
59
60
61
62
63 protected void setSimTime(long SimTime) {
64 this.SimTime = SimTime;
65 }
66
67
68 @Override
69 public abstract
70 MoverLocal clone();
71
72 @Override
73 public Class getCompositeClass() {
74 return Mover.class;
75 }
76
77
78
79
80
81
82
83
84 public abstract UnrealId getId()
85 ;
86
87
88
89
90 public abstract boolean isVisible()
91 ;
92
93
94
95
96 public MoverLocal getLocal() {
97 return this;
98 }
99 public ISharedWorldObject getShared() {
100 throw new UnsupportedOperationException("Could not return LOCAL");
101 }
102 public IStaticWorldObject getStatic() {
103 throw new UnsupportedOperationException("Could not return LOCAL");
104 }
105
106
107 @Override
108 public ILocalWorldObjectUpdatedEvent createDisappearEvent() {
109 return new ObjectDisappeared(this, getSimTime());
110 }
111
112 public static class ObjectDisappeared implements ILocalWorldObjectUpdatedEvent
113 {
114
115 public ObjectDisappeared(MoverLocal obj, long time) {
116 this.obj = obj;
117 this.time = time;
118 }
119
120 private MoverLocal obj;
121 private long time;
122
123 @Override
124 public WorldObjectId getId() {
125 return obj.getId();
126 }
127
128
129
130
131 @Override
132 public long getSimTime() {
133 return time;
134 }
135
136 @Override
137 public IWorldObjectUpdateResult<ILocalWorldObject> update(ILocalWorldObject obj)
138 {
139 if (obj == null) {
140 throw new PogamutException("Can't 'disappear' null!", this);
141 }
142 if (!(obj instanceof MoverLocalImpl)) {
143 throw new PogamutException("Can't update different class than MoverLocalImpl, got class " + obj.getClass().getSimpleName() + "!", this);
144 }
145 MoverLocalImpl toUpdate = (MoverLocalImpl)obj;
146 if (toUpdate.Visible) {
147 toUpdate.Visible = false;
148 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.UPDATED, obj);
149 } else {
150 return new IWorldObjectUpdateResult.WorldObjectUpdateResult(IWorldObjectUpdateResult.Result.SAME, obj);
151 }
152 }
153
154 }
155
156
157
158 public String toString() {
159 return
160 super.toString() + "[" +
161
162 "Id = " + String.valueOf(getId()
163 ) + " | " +
164
165 "Visible = " + String.valueOf(isVisible()
166 ) + " | " +
167
168 "]";
169 }
170
171
172 public String toHtmlString() {
173 return super.toString() + "[<br/>" +
174
175 "<b>Id</b> = " + String.valueOf(getId()
176 ) + " <br/> " +
177
178 "<b>Visible</b> = " + String.valueOf(isVisible()
179 ) + " <br/> " +
180
181 "<br/>]";
182 }
183
184
185
186
187
188
189
190
191
192
193 }
194