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 public abstract class LocationUpdate
28 extends
29 InfoMessage
30 implements IWorldEvent, IWorldChangeEvent, ICompositeWorldObject
31
32 {
33
34
35 public static final String PROTOTYPE =
36 "UPD {Id unreal_id} {Loc 0,0,0} {Vel 0,0,0} {Rot 0,0,0} ";
37
38
39
40
41
42
43 public LocationUpdate()
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
69
70 public abstract UnrealId getId()
71 ;
72
73
74
75
76
77
78 public abstract Location getLoc()
79 ;
80
81
82
83
84
85
86
87 public abstract Velocity getVel()
88 ;
89
90
91
92
93
94
95 public abstract Rotation getRot()
96 ;
97
98
99 public static class LocationUpdateUpdate
100 extends GBObjectUpdate implements ICompositeWorldObjectUpdatedEvent, IGBWorldObjectEvent {
101 private LocationUpdate object;
102 private long time;
103 private ITeamId teamId;
104
105 public LocationUpdateUpdate
106 (LocationUpdate source, long eventTime, ITeamId teamId) {
107 this.object = source;
108 this.time = eventTime;
109 this.teamId = teamId;
110 }
111
112
113
114
115 @Override
116 public long getSimTime() {
117 return time;
118 }
119
120 @Override
121 public IWorldObject getObject() {
122 return object;
123 }
124
125 @Override
126 public WorldObjectId getId() {
127 return object.getId();
128 }
129
130 @Override
131 public ILocalWorldObjectUpdatedEvent getLocalEvent() {
132 return new LocationUpdateLocalImpl.LocationUpdateLocalUpdate
133 ((LocationUpdateLocal)object.getLocal(), time);
134 }
135
136 @Override
137 public ISharedWorldObjectUpdatedEvent getSharedEvent() {
138 return new LocationUpdateSharedImpl.LocationUpdateSharedUpdate
139 ((LocationUpdateShared)object.getShared(), time, teamId);
140 }
141
142 @Override
143 public IStaticWorldObjectUpdatedEvent getStaticEvent() {
144 return new LocationUpdateStaticImpl.LocationUpdateStaticUpdate
145 ((LocationUpdateStatic)object.getStatic(), time);
146 }
147
148 }
149
150
151 public String toString() {
152 return
153 super.toString() + "[" +
154
155 "Id = " + String.valueOf(getId()
156 ) + " | " +
157
158 "Loc = " + String.valueOf(getLoc()
159 ) + " | " +
160
161 "Vel = " + String.valueOf(getVel()
162 ) + " | " +
163
164 "Rot = " + String.valueOf(getRot()
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>Loc</b> = " + String.valueOf(getLoc()
178 ) + " <br/> " +
179
180 "<b>Vel</b> = " + String.valueOf(getVel()
181 ) + " <br/> " +
182
183 "<b>Rot</b> = " + String.valueOf(getRot()
184 ) + " <br/> " +
185
186 "<br/>]";
187 }
188
189 public String toJsonLiteral() {
190 return "locationupdate( "
191 +
192 (getId()
193 == null ? "null" :
194 "\"" + getId()
195 .getStringId() + "\""
196 )
197 + ", " +
198 (getLoc()
199 == null ? "null" :
200 "[" + getLoc()
201 .getX() + ", " + getLoc()
202 .getY() + ", " + getLoc()
203 .getZ() + "]"
204 )
205 + ", " +
206 (getVel()
207 == null ? "null" :
208 "[" + getVel()
209 .getX() + ", " + getVel()
210 .getY() + ", " + getVel()
211 .getZ() + "]"
212 )
213 + ", " +
214 (getRot()
215 == null ? "null" :
216 "[" + getRot()
217 .getPitch() + ", " + getRot()
218 .getYaw() + ", " + getRot()
219 .getRoll() + "]"
220 )
221
222 + ")";
223 }
224
225
226
227
228
229
230
231
232
233
234 }
235