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