1
2
3
4
5
6
7
8
9
10
11
12
13 package cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages;
14
15 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.*;
16
17 public class UT2004SharedObjectCreator {
18
19 public static interface ISharedObjectCreator<T extends ICompositeWorldObject>
20 {
21 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c);
22 }
23
24
25 public static class SelfSharedCreator implements ISharedObjectCreator<Self>
26 {
27 @Override
28 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
29 return new SelfSharedImpl(id, c);
30 }
31 }
32
33 public static class BombInfoSharedCreator implements ISharedObjectCreator<BombInfo>
34 {
35 @Override
36 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
37 return new BombInfoSharedImpl(id, c);
38 }
39 }
40
41 public static class FlagInfoSharedCreator implements ISharedObjectCreator<FlagInfo>
42 {
43 @Override
44 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
45 return new FlagInfoSharedImpl(id, c);
46 }
47 }
48
49 public static class InitedMessageSharedCreator implements ISharedObjectCreator<InitedMessage>
50 {
51 @Override
52 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
53 return new InitedMessageSharedImpl(id, c);
54 }
55 }
56
57 public static class TeamScoreSharedCreator implements ISharedObjectCreator<TeamScore>
58 {
59 @Override
60 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
61 return new TeamScoreSharedImpl(id, c);
62 }
63 }
64
65 public static class AutoTraceRaySharedCreator implements ISharedObjectCreator<AutoTraceRay>
66 {
67 @Override
68 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
69 return new AutoTraceRaySharedImpl(id, c);
70 }
71 }
72
73 public static class MoverSharedCreator implements ISharedObjectCreator<Mover>
74 {
75 @Override
76 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
77 return new MoverSharedImpl(id, c);
78 }
79 }
80
81 public static class ConfigChangeSharedCreator implements ISharedObjectCreator<ConfigChange>
82 {
83 @Override
84 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
85 return new ConfigChangeSharedImpl(id, c);
86 }
87 }
88
89 public static class LocationUpdateSharedCreator implements ISharedObjectCreator<LocationUpdate>
90 {
91 @Override
92 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
93 return new LocationUpdateSharedImpl(id, c);
94 }
95 }
96
97 public static class VehicleSharedCreator implements ISharedObjectCreator<Vehicle>
98 {
99 @Override
100 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
101 return new VehicleSharedImpl(id, c);
102 }
103 }
104
105 public static class AliveMessageSharedCreator implements ISharedObjectCreator<AliveMessage>
106 {
107 @Override
108 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
109 return new AliveMessageSharedImpl(id, c);
110 }
111 }
112
113 public static class MyInventorySharedCreator implements ISharedObjectCreator<MyInventory>
114 {
115 @Override
116 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
117 return new MyInventorySharedImpl(id, c);
118 }
119 }
120
121 public static class PlayerSharedCreator implements ISharedObjectCreator<Player>
122 {
123 @Override
124 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
125 return new PlayerSharedImpl(id, c);
126 }
127 }
128
129 public static class ItemSharedCreator implements ISharedObjectCreator<Item>
130 {
131 @Override
132 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
133 return new ItemSharedImpl(id, c);
134 }
135 }
136
137 public static class GameInfoSharedCreator implements ISharedObjectCreator<GameInfo>
138 {
139 @Override
140 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
141 return new GameInfoSharedImpl(id, c);
142 }
143 }
144
145 public static class IncomingProjectileSharedCreator implements ISharedObjectCreator<IncomingProjectile>
146 {
147 @Override
148 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
149 return new IncomingProjectileSharedImpl(id, c);
150 }
151 }
152
153 public static class EntitySharedCreator implements ISharedObjectCreator<Entity>
154 {
155 @Override
156 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
157 return new EntitySharedImpl(id, c);
158 }
159 }
160
161 public static class NavPointSharedCreator implements ISharedObjectCreator<NavPoint>
162 {
163 @Override
164 public ISharedWorldObject create(WorldObjectId id, Collection<ISharedProperty> c) {
165 return new NavPointSharedImpl(id, c);
166 }
167 }
168
169
170 private static HashMap<Class, ISharedObjectCreator> map = new HashMap<Class, ISharedObjectCreator>();
171
172 static {
173
174 map.put(
175 Self
176 .class,
177 new SelfSharedCreator()
178 );
179
180 map.put(
181 BombInfo
182 .class,
183 new BombInfoSharedCreator()
184 );
185
186 map.put(
187 FlagInfo
188 .class,
189 new FlagInfoSharedCreator()
190 );
191
192 map.put(
193 InitedMessage
194 .class,
195 new InitedMessageSharedCreator()
196 );
197
198 map.put(
199 TeamScore
200 .class,
201 new TeamScoreSharedCreator()
202 );
203
204 map.put(
205 AutoTraceRay
206 .class,
207 new AutoTraceRaySharedCreator()
208 );
209
210 map.put(
211 Mover
212 .class,
213 new MoverSharedCreator()
214 );
215
216 map.put(
217 ConfigChange
218 .class,
219 new ConfigChangeSharedCreator()
220 );
221
222 map.put(
223 LocationUpdate
224 .class,
225 new LocationUpdateSharedCreator()
226 );
227
228 map.put(
229 Vehicle
230 .class,
231 new VehicleSharedCreator()
232 );
233
234 map.put(
235 AliveMessage
236 .class,
237 new AliveMessageSharedCreator()
238 );
239
240 map.put(
241 MyInventory
242 .class,
243 new MyInventorySharedCreator()
244 );
245
246 map.put(
247 Player
248 .class,
249 new PlayerSharedCreator()
250 );
251
252 map.put(
253 Item
254 .class,
255 new ItemSharedCreator()
256 );
257
258 map.put(
259 GameInfo
260 .class,
261 new GameInfoSharedCreator()
262 );
263
264 map.put(
265 IncomingProjectile
266 .class,
267 new IncomingProjectileSharedCreator()
268 );
269
270 map.put(
271 Entity
272 .class,
273 new EntitySharedCreator()
274 );
275
276 map.put(
277 NavPoint
278 .class,
279 new NavPointSharedCreator()
280 );
281
282 }
283
284 public static ISharedWorldObject create(Class msgClass, WorldObjectId objectId, Collection<ISharedProperty> properties )
285 {
286 NullCheck.check(msgClass, "msgClass");
287 NullCheck.check(objectId, "objectId");
288 NullCheck.check(properties, "properties");
289
290 ISharedObjectCreator creator = map.get(msgClass);
291 if (creator == null) {
292 throw new PogamutException("There is no shared obejct creator for class " + msgClass + ".", UT2004SharedObjectCreator.class);
293 }
294 return creator.create(objectId, properties);
295 }
296 }
297