View Javadoc

1   package cz.cuni.amis.pogamut.ut3.communication.messages;
2   
3   /*
4    * Copyright (C) 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic
5    *
6    * This program is free software: you can redistribute it and/or modify
7    * it under the terms of the GNU General Public License as published by
8    * the Free Software Foundation, either version 3 of the License, or
9    * (at your option) any later version.
10   *
11   * This program is distributed in the hope that it will be useful,
12   * but WITHOUT ANY WARRANTY; without even the implied warranty of
13   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14   * GNU General Public License for more details.
15   *
16   * You should have received a copy of the GNU General Public License
17   * along with this program.  If not, see <http://www.gnu.org/licenses/>.
18   */
19  import cz.cuni.amis.pogamut.unreal.communication.messages.UnrealId;
20  import cz.cuni.amis.pogamut.ut2004.communication.messages.ItemType;
21  import cz.cuni.amis.pogamut.ut2004.communication.messages.gbinfomessages.Self;
22  import cz.cuni.amis.utils.maps.HashMapSet;
23  
24  import java.util.HashMap;
25  import java.util.Iterator;
26  import java.util.Map;
27  import java.util.Set;
28  
29  /**
30   * 
31   * @author Evers
32   */
33  public class UT3ItemType extends ItemType {
34  
35  	/**
36  	 * 
37  	 */
38  	private static final long serialVersionUID = 6128208226173615461L;
39  
40  	/**
41  	 * Map of all registered ItemType prototypes.
42  	 */
43  	protected static Map<String, ItemType> protos = new HashMap<String, ItemType>();
44  
45  	/**
46  	 * Contains item types that belongs to their groups.
47  	 */
48  	public static final HashMapSet<UT3Group, ItemType> GROUPS = new HashMapSet<UT3Group, ItemType>();
49  
50  	/**
51  	 * Category of this item.
52  	 */
53  	private Category category;
54  
55  	/**
56  	 * Group of this item.
57  	 */
58  	private UT3Group group;
59  
60  	/**
61  	 * Human readable name of the item.
62  	 */
63  	private String name;
64  
65  	public static UT3ItemType getWeaponForAmmo(ItemType itemType) {
66  		if (itemType == null)
67  			return UT3ItemType.NONE;
68  		Set<ItemType> mySet = GROUPS.get(itemType.getGroup());
69  		if (mySet != null) {
70  			Iterator<ItemType> myIterator = mySet.iterator();
71  			while (myIterator.hasNext()) {
72  				ItemType type = myIterator.next();
73  				if (type.getGroup() == itemType.getGroup()
74  						&& type.getCategory() == Category.WEAPON)
75  					return (UT3ItemType) type;
76  			}
77  		}
78  
79  		return UT3ItemType.NONE;
80  	}
81  
82  	public static UT3ItemType getAmmoForWeapon(ItemType itemType) {
83  		if (itemType == null)
84  			return UT3ItemType.NONE;
85  		Set<ItemType> mySet = GROUPS.get(itemType.getGroup());
86  		if (mySet != null) {
87  			Iterator<ItemType> myIterator = mySet.iterator();
88  			while (myIterator.hasNext()) {
89  				ItemType type = myIterator.next();
90  				if (type.getGroup() == itemType.getGroup()
91  						&& type.getCategory() == Category.AMMO)
92  					return (UT3ItemType) type;
93  			}
94  		}
95  
96  		return UT3ItemType.NONE;
97  	}
98  
99  	@Override
100 	public String toString() {
101 		return "ItemType[name = " + name + ", category = " + category
102 				+ ", group = " + group + "]";
103 	}
104 
105 	@Override
106 	public Category getCategory() {
107 		return category;
108 	}
109 
110 	@Override
111 	public UT3Group getGroup() {
112 		return group;
113 	}
114 
115 	@Override
116 	public boolean equals(Object obj) {
117 		// the same object?
118 		if (this == obj)
119 			return true;
120 
121 		// the same type?
122 		if (obj instanceof UT3ItemType) {
123 			// same value
124 			if ((category == ((UT3ItemType) obj).getCategory())
125 					&& (group == ((UT3ItemType) obj).getGroup())
126 					&& (name == ((UT3ItemType) obj).getName()))
127 				return true;
128 		}
129 
130 		return false;
131 	}
132 
133 	@Override
134 	public int hashCode() {
135 		return getName().hashCode();
136 	}
137 
138 	@Override
139 	public int compareTo(ItemType o) {
140 		if (o == null)
141 			return 1;
142 
143 		if (getName() == null) {
144 			if (o.getName() == null)
145 				return 0;
146 			return 1;
147 		} else {
148 			if (o.getName() == null)
149 				return -1;
150 			return getName().compareTo(o.getName());
151 		}
152 	}
153 
154 	/**
155 	 * List of all item groups. Groups fine down the categories into specific
156 	 * groups, based on what the item belongs to. Also, groups join items from
157 	 * different categories together, if they belong together (e.g. weapon with
158 	 * its ammo).
159 	 */
160 	public enum UT3Group implements Group {
161 		/** Translocating weapon and accessory. */
162 		TRANSLOCATOR("Translocator"),
163 		/** ShieldGun weapon and accessory. */
164 		IMPACT_HAMMER("ImpactHammer"),
165 		/** AssaultRifle weapon and accessory. */
166 		ENFORCER("Enforcer"),
167 		/** BioRifle weapon and accessory. */
168 		BIO_RIFLE("BioRifle"),
169 		/** ShockRifle weapon and accessory. */
170 		SHOCK_RIFLE("ShockRifle"),
171 		/** LinkGun weapon and accessory. */
172 		LINK_GUN("LinkGun"),
173 		/** Minigun weapon and accessory. */
174 		STINGER_MINIGUN("Stinger"),
175 		/** FlakCannon weapon and accessory. */
176 		FLAK_CANNON("FlakCannon"),
177 		/** RocketLauncher weapon and accessory. */
178 		ROCKET_LAUNCHER("RocketLauncher"),
179 		/** Avril weapon and accessory. */
180 		AVRIL("Avril"),
181 		/** SniperRifle weapon and accessory. */
182 		SNIPER_RIFLE("SniperRifle"),
183 		/** Redeemer */
184 		REDEEMER("Redeemer"),
185 		/** Weaponlocker */
186 		WEAPON_LOCKER("WeaponLocker"),
187 		/** SlowField */
188 		SLOW_FIELD("SlowField"),
189 
190 		/** Classic health pack. */
191 		MEDIUM_HEALTH("MediumHealth"),
192 		/** Mini health vial. */
193 		HEALTH_VIAL("HealthVial"),
194 		/** Big health recharger. */
195 		SUPER_HEALTH("SuperHealth"),
196 
197 		/** Armor parts. */
198 		ARMOR_HELMET("Helmet"), ARMOR_VEST("Vest"), ARMOR_THIGHPADS("Thighpads"), ARMOR_SHIELD_BELT(
199 				"ShieldBelt"),
200 
201 		/** POWERUPS **/
202 		JUMP_BOOTS("JumpBoots"),
203 		/** UDamage bonus items. */
204 		UDAMAGE("UDamage"), BERSERK("Berserk"), INVULNERABILITY(
205 				"Invulnerability"), INVISIBILITY("Invisibility"),
206 
207 		/** Keys. */
208 		KEY("Key"),
209 		/** Other items with user-defined group. */
210 		OTHER("Unknown"),
211 		/** DEPLOYABLES **/
212 		XRAY_VOLUME("XRayVolume"), SPIDERMINE_TRAP("SpiderMineTrap"), ENERGY_SHIELD(
213 				"EnergyShield"), EMP_MINE("EMPMine"), LINK_GENERATOR(
214 				"LinkGenerator"), SHAPED_CHARGE("ShapedCharge"), SLOW_VOLUME(
215 				"SlowVolume"),
216 
217 		/** No group, used for the prototype None */
218 		NONE("None");
219 
220 		/* =================================================================== */
221 
222 		/** Human-readable name of the group. */
223 		public String name;
224 
225 		/* =================================================================== */
226 
227 		/**
228 		 * Constructor.
229 		 * 
230 		 * @param name
231 		 *            Human-readable name of the group.
232 		 */
233 		UT3Group(String name) {
234 			this.name = name;
235 		}
236 
237 		@Override
238 		public Set<ItemType> getTypes() {
239 			return GROUPS.get(this);
240 		}
241 
242 		@Override
243 		public String getName() {
244 			return this.name;
245 		}
246 	}
247 
248 	/* ======================================================================== */
249 
250         // TODO: Only 2 parameters actually needed, the first one is the name (Enforcer, ImpactHammer, etc.)
251         // and the second one the pickup-type (ShockRifle.WeaponPickup, BioRifle.WeaponPickup), unfortunately 
252         // GBUT3 is not always consistent in sending the right type, so until GBUT3 is completely done, some
253         // extra UT3 names are needed
254         
255         // First parameter added to support spawning items from this type in the control connection
256         
257 	/** Translocator. */
258 	public static final UT3ItemType TRANSLOCATOR = MakePrototype(
259 			Category.WEAPON, UT3Group.TRANSLOCATOR, new String[] {"UTGame.UTWeap_Translocator_Content",
260 					"Translocator", "Translocator.WeaponPickup" });
261 
262 	/** Translocator Beacon. */
263 	public static final UT3ItemType TRANSLOCATOR_PROJECTILE = MakePrototype(
264 			Category.PROJECTILE, UT3Group.TRANSLOCATOR, new String[] {
265 					"UTProj_TransDisc", "UT_Proj_TransDisc_ContentBlue",
266 					"UT_Proj_TransDisc_ContentRed" });
267 
268 	/** ImpactHammer weapon. */
269 	public static final UT3ItemType IMPACT_HAMMER = MakePrototype(
270 			Category.WEAPON, UT3Group.IMPACT_HAMMER, new String[] { "UTGame.UTWeap_ImpactHammer",
271 					"ImpactHammer", "ImpactHammer.WeaponPickup" });
272 
273 	/** ImpactHammer ammo - sent when the bot is spawned. */
274 	public static final UT3ItemType IMPACT_HAMMER_AMMO = MakePrototype(
275 			Category.AMMO, UT3Group.IMPACT_HAMMER, new String[] {
276 					"ImpactHammerAmmo", "ImpactHammerAmmo.AmmoPickup" });
277 
278 	/** Enforcer weapon. */
279 	public static final UT3ItemType ENFORCER = MakePrototype(Category.WEAPON,
280 			UT3Group.ENFORCER, new String[] { "UTGame.UTWeap_Enforcer", "Enforcer",
281 					"Enforcer.WeaponPickup" });
282 	/** Enforcer ammo. */
283 	public static final UT3ItemType ENFORCER_AMMO = MakePrototype(
284 			Category.AMMO, UT3Group.ENFORCER, new String[] { "GameBotsUT3.GBAmmo_Enforcer", "EnforcerAmmo",
285 					"EnforcerAmmo.AmmoPickup" });
286 
287 	/** BioRifle weapon. */
288 	public static final UT3ItemType BIO_RIFLE = MakePrototype(Category.WEAPON,
289 			UT3Group.BIO_RIFLE, new String[] { "UTGameContent.UTWeap_BioRifle_Content", "BioRifle",
290 					"BioRifle.WeaponPickup" });
291 	/** BioRifle ammo. */
292 	public static final UT3ItemType BIO_RIFLE_AMMO = MakePrototype(
293 			Category.AMMO, UT3Group.BIO_RIFLE, new String[] { "GameBotsUT3.GBAmmo_BioRifle_Content", "BioRifleAmmo",
294 					"BioRifleAmmo.AmmoPickup" });
295 
296 	/** BioRifle projectile. */
297 	public static final UT3ItemType BIO_RIFLE_PROJECTILE = MakePrototype(
298 			Category.PROJECTILE, UT3Group.BIO_RIFLE, new String[] {
299 					"UTProj_BioShot", "UTProj_BioGlob", "UTProj_BioGlobling" });
300 
301 	/** ShockRifle weapon. */
302 	public static final UT3ItemType SHOCK_RIFLE = MakePrototype(
303 			Category.WEAPON, UT3Group.SHOCK_RIFLE, new String[] { "UTGame.UTWeap_ShockRifle", "ShockRifle",
304 					"ShockRifle.WeaponPickup" });
305 	/** ShockRifle ammo. */
306 	public static final UT3ItemType SHOCK_RIFLE_AMMO = MakePrototype(
307 			Category.AMMO, UT3Group.SHOCK_RIFLE, new String[] { "GameBotsUT3.GBAmmo_ShockRifle",
308 					"ShockRifleAmmo", "ShockRifleAmmo.AmmoPickup" });
309 
310 	/** ShockRifle projectile. */
311 	public static final UT3ItemType SHOCK_RIFLE_PROJECTILE = MakePrototype(
312 			Category.PROJECTILE, UT3Group.SHOCK_RIFLE, new String[] {
313 					"UTProj_ShockBall", "UTProj_HeroShockBall" });
314 
315 	/** LinkGun weapon. */
316 	public static final UT3ItemType LINK_GUN = MakePrototype(Category.WEAPON,
317 			UT3Group.LINK_GUN, new String[] { "UTGame.UTWeap_LinkGun", "LinkGun",
318 					"LinkGun.WeaponPickup" });
319 	/** LinkGun ammo. */
320 	public static final UT3ItemType LINK_GUN_AMMO = MakePrototype(
321 			Category.AMMO, UT3Group.LINK_GUN, new String[] { "GameBotsUT3.GBAmmo_LinkGun", "LinkGunAmmo",
322 					"LinkGunAmmo.AmmoPickup" });
323 
324 	/** LinkGun projectile. */
325 	public static final UT3ItemType LINK_GUN_PROJECTILE = MakePrototype(
326 			Category.PROJECTILE, UT3Group.LINK_GUN,
327 			new String[] { "XWeapons.LinkProjectile" });
328 
329 	/** Minigun weapon. */
330 	public static final UT3ItemType STINGER_MINIGUN = MakePrototype(
331 			Category.WEAPON, UT3Group.STINGER_MINIGUN, new String[] { "UTGame.UTWeap_Stinger",
332 					"Stinger", "Stinger.WeaponPickup" });
333 	/** Minigun ammo. */
334 	public static final UT3ItemType STINGER_MINIGUN_AMMO = MakePrototype(
335 			Category.AMMO, UT3Group.STINGER_MINIGUN, new String[] { "GameBotsUT3.GBAmmo_Stinger",
336 					"StingerAmmo", "StingerAmmo.AmmoPickup" });
337 
338 	public static final UT3ItemType STINGER_MINIGUN_SHARD = MakePrototype(
339 			Category.PROJECTILE, UT3Group.STINGER_MINIGUN,
340 			new String[] { "UTProj_StingerShard" });
341 
342 	/** FlakCannon weapon. */
343 	public static final UT3ItemType FLAK_CANNON = MakePrototype(
344 			Category.WEAPON, UT3Group.FLAK_CANNON, new String[] { "UTGame.UTWeap_FlakCannon", "FlakCannon",
345 					"FlakCannon.WeaponPickup" });
346 	/** FlakCannon ammo. */
347 	public static final UT3ItemType FLAK_CANNON_AMMO = MakePrototype(
348 			Category.AMMO, UT3Group.FLAK_CANNON, new String[] { "GameBotsUT3.GBAmmo_FlakCannon",
349 					"FlakCannonAmmo", "FlakCannonAmmo.AmmoPickup" });
350 
351 	/** FlakCannon chunk projectile. */
352 	public static final UT3ItemType FLAK_CANNON_CHUNK = MakePrototype(
353 			Category.PROJECTILE, UT3Group.FLAK_CANNON, new String[] {
354 					"UTProj_FlakShard", "UTProj_FlakShardMain" });
355 
356 	/** FlakCannon shell projectile. */
357 	public static final UT3ItemType FLAK_CANNON_SHELL = MakePrototype(
358 			Category.PROJECTILE, UT3Group.FLAK_CANNON,
359 			new String[] { "UTProj_FlakShell" });
360         
361         /** AVRIL weapon */
362 	public static final UT3ItemType AVRIL = MakePrototype(Category.WEAPON,
363 			UT3Group.AVRIL, new String[] { "UTGameContent.UTWeap_Avril_Content", "Avril",
364 					"Avril.WeaponPickup" });
365 	/** AVRIL ammo */
366 	public static final UT3ItemType AVRIL_AMMO = MakePrototype(
367 			Category.AMMO,
368 			UT3Group.AVRIL,
369 			new String[] { "GameBotsUT3.GBAmmo_AVRiL", "AVRiLAmmo",
370 					"AVRiLAmmo.AmmoPickup" });
371 
372 	/** RocketLauncher weapon. */
373 	public static final UT3ItemType ROCKET_LAUNCHER = MakePrototype(
374 			Category.WEAPON, UT3Group.ROCKET_LAUNCHER, new String[] { "UTGame.UTWeap_RocketLauncher",
375 					"RocketLauncher", "RocketLauncher.WeaponPickup" });
376 	/** RocketLauncher ammo. */
377 	public static final UT3ItemType ROCKET_LAUNCHER_AMMO = MakePrototype(
378 			Category.AMMO, UT3Group.ROCKET_LAUNCHER, new String[] { "GameBotsUT3.RocketLauncher",
379 					"RocketLauncherAmmo", "RocketLauncherAmmo.AmmoPickup" });
380 
381 	/** RocketLauncher projectile. */
382 	public static final UT3ItemType ROCKET_LAUNCHER_PROJECTILE = MakePrototype(
383 			Category.PROJECTILE, UT3Group.ROCKET_LAUNCHER, new String[] {
384 					"UTProj_Rocket", "UTProj_HeroRocket",
385 					"UTProj_LoadedRocket", "UTProj_SeekingRocket" });
386 
387 	/** SniperRifle weapon (classic sniper weapon). */
388 	public static final UT3ItemType SNIPER_RIFLE = MakePrototype(
389 			Category.WEAPON, UT3Group.SNIPER_RIFLE, new String[] { "UTGame.UTWeap_SniperRifle",
390 					"SniperRifle", "SniperRifle.WeaponPickup" });
391 	/** SniperRifle ammo. */
392 	public static final UT3ItemType SNIPER_RIFLE_AMMO = MakePrototype(
393 			Category.AMMO, UT3Group.SNIPER_RIFLE, new String[] { "GameBotsUT3.GBAmmo_SniperRifle",
394 					"SniperRifleAmmo", "SniperRifleAmmo.AmmoPickup" });
395 
396 	/** SniperRifle weapon (classic sniper weapon). */
397 	public static final UT3ItemType REDEEMER = MakePrototype(Category.WEAPON,
398 			UT3Group.REDEEMER, new String[] { "UTGameContent.UTWeap_Redeemer_Content", "Redeemer",
399 					"Redeemer.WeaponPickup" });
400 
401 	public static final UT3ItemType REDEEMER_AMMO = MakePrototype(
402 			Category.AMMO, UT3Group.REDEEMER, new String[] { "UTGameContent.UTAmmo_Redeemer_Content", "RedeemerAmmo",
403 					"RedeemerAmmo.AmmoPickup" });
404 
405 	public static final UT3ItemType REDEEMER_PROJECTILE = MakePrototype(
406 			Category.PROJECTILE, UT3Group.REDEEMER, new String[] { 
407 					"UTProj_Redeemer", "UTProj_RedeemerRed" });
408 
409 	/** Health kit. */
410 	public static final UT3ItemType MEDIUM_HEALTH = MakePrototype(
411 			Category.HEALTH, UT3Group.MEDIUM_HEALTH, new String[] { "UTGame.UTPickup_MediumHealth",
412 					"MediumHealth", "MediumHealth.HealthPickup" });
413 	/** Health vial. */
414 	public static final UT3ItemType HEALTH_VIAL = MakePrototype(
415 			Category.HEALTH, UT3Group.HEALTH_VIAL, new String[] { "UTGame.UTPickup_HealthVial", "HealthVial",
416 					"HealthVial.HealthPickup" });
417 	/** SuperHealth charger. */
418 	public static final UT3ItemType SUPER_HEALTH_PACK = MakePrototype(
419 			Category.HEALTH, UT3Group.SUPER_HEALTH, new String[] { "UTGame.UTPickup_SuperHealth",
420 					"SuperHealth", "SuperHealth.HealthPickup" });
421 
422 	/** Helmet. */
423 	public static final UT3ItemType ARMOR_HELMET = MakePrototype(
424 			Category.ARMOR, UT3Group.ARMOR_HELMET, new String[] { "UTGame.UTArmorHelmet", "Helmet",
425 					"Helmet.ArmorPickup" });
426 	/** Shieldbelt. */
427 	public static final UT3ItemType ARMOR_SHIELD_BELT = MakePrototype(
428 			Category.ARMOR, UT3Group.ARMOR_SHIELD_BELT, new String[] { "UTGame.UTArmor_ShieldBelt",
429 					"ShieldBelt", "ShieldBelt.ArmorPickup" });
430 	/** Thighpads. */
431 	public static final UT3ItemType ARMOR_THIGHPADS = MakePrototype(
432 			Category.ARMOR, UT3Group.ARMOR_THIGHPADS, new String[] { "UTGame.UTArmor_Thighpads",
433 					"Thighpads", "Thighpads.ArmorPickup" });
434 	/** Vest. */
435 	public static final UT3ItemType ARMOR_VEST = MakePrototype(Category.ARMOR,
436 			UT3Group.ARMOR_VEST, new String[] { "UTGame.UTArmor_Vest", "Vest", "Vest.ArmorPickup" });
437 
438 	/** UDamage bonus (damage multiplier). */
439 	public static final UT3ItemType U_DAMAGE_PACK = MakePrototype(
440 			Category.OTHER, UT3Group.UDAMAGE, new String[] { "UTGameContent.UTUDamage", "UDamage",
441 					"UDamage.Pickup" });
442 
443 	public static final UT3ItemType BERSERK_PACK = MakePrototype(
444 			Category.OTHER, UT3Group.BERSERK, new String[] { "UTGameContent.UTBerserk", "Berserk",
445 					"Berserk.Pickup" });
446 
447 	public static final UT3ItemType JUMP_BOOTS = MakePrototype(Category.OTHER,
448 			UT3Group.JUMP_BOOTS, new String[] { "UTGameContent.UTJumpBoots", "JumpBoots",
449 					"JumpBoots.Pickup" });
450         
451         // @NOTE: The volume_ammo's are needed for correct functioning of the weaponry
452 
453 	/** XRay Volume **/
454 	public static final UT3ItemType XRAY_VOLUME = MakePrototype(
455 			Category.WEAPON, UT3Group.XRAY_VOLUME, new String[] { "UT3Gold.UTDeployableXRayVolume", "UTDeployableXRayVolume",
456 					"UTDeployableXRayVolume.WeaponPickup" });
457 
458 	/** XRay Ammo **/
459 	public static final UT3ItemType XRAY_VOLUME_AMMO = MakePrototype(
460 			Category.AMMO, UT3Group.XRAY_VOLUME, new String[] {
461 					"UTDeployableXRayVolumeAmmo", "UTDeployableXRayVolume.AmmoPickup" });
462 
463 	/** SpiderMine Trap **/
464 	public static final UT3ItemType SPIDERMINE_TRAP = MakePrototype(
465 			Category.WEAPON, UT3Group.SPIDERMINE_TRAP, new String[] { "UTGameContent.UTDeployableSpiderMineTrap",
466 					"UTDeployableSpiderMineTrap", "UTDeployableSpiderMineTrap.WeaponPickup" });
467 
468 	/** SpiderMine Trap Ammo **/
469 	public static final UT3ItemType SPIDERMINE_TRAP_AMMO = MakePrototype(
470 			Category.AMMO, UT3Group.SPIDERMINE_TRAP, new String[] {
471 					"UTDeployableSpiderMineTrapAmmo", "UTDeployableSpiderMineTrap.AmmoPickup" });
472 
473 	/** EnergyShield **/
474 	public static final UT3ItemType ENERGY_SHIELD = MakePrototype(
475 			Category.WEAPON, UT3Group.ENERGY_SHIELD, new String[] { "UTGameContent.UTDeployableEnergyShield",
476 					"UTDeployableEnergyShield", "UTDeployableEnergyShield.WeaponPickup" });
477 
478 	/** EnergyShield Ammo **/
479 	public static final UT3ItemType ENERGY_SHIELD_AMMO = MakePrototype(
480 			Category.AMMO, UT3Group.ENERGY_SHIELD, new String[] {
481 					"UTDeployableEnergyShieldAmmo", "UTDeployableEnergyShield.AmmoPickup" });
482 
483 	/** EMP Mine **/
484 	public static final UT3ItemType EMP_MINE = MakePrototype(Category.WEAPON,
485 			UT3Group.EMP_MINE, new String[] { "EMPMine",
486 					"EMPMine.WeaponPickup", "UTDeployableEMPMine" });
487 
488 	/** EMP Mine Ammo **/
489 	public static final UT3ItemType EMP_MINE_AMMO = MakePrototype(
490 			Category.AMMO, UT3Group.EMP_MINE, new String[] { "UTGameContent.UTDeployableEMPMine", 
491                                 "UTDeployableEMPMineAmmo", "UTDeployableEMPMine.AmmoPickup" });
492 
493 	/** Link generator **/
494 	public static final UT3ItemType LINK_GENERATOR = MakePrototype(
495 			Category.WEAPON, UT3Group.LINK_GENERATOR, new String[] { "UTGameContent.UTDeployableLinkGenerator",
496 					"UTDeployableLinkGenerator", "UTDeployableLinkGenerator.WeaponPickup" });
497 
498 	/** Link generator Ammo **/
499 	public static final UT3ItemType LINK_GENERATOR_AMMO = MakePrototype(
500 			Category.AMMO, UT3Group.LINK_GENERATOR, new String[] {
501 					"UTDeployableLinkGeneratorAmmo", "UTDeployableLinkGenerator.AmmoPickup" });
502 
503 	/** ShapedCharge **/
504 	public static final UT3ItemType SHAPED_CHARGE = MakePrototype(
505 			Category.WEAPON, UT3Group.SHAPED_CHARGE, new String[] { "UTGameContent.UTDeployableShapedCharge",
506 					"UTDeployableShapedCharge", "UTDeployableShapedCharge.WeaponPickup" });
507 
508 	/** ShapedCharge Ammo **/
509 	public static final UT3ItemType SHAPED_CHARGE_AMMO = MakePrototype(
510 			Category.AMMO, UT3Group.SHAPED_CHARGE, new String[] {
511 					"UTDeployableShapedChargeAmmo", "ShapedCharge.AmmoPickup" });
512 
513 	/** Slow Volume **/
514 	public static final UT3ItemType SLOW_VOLUME = MakePrototype(
515 			Category.WEAPON, UT3Group.SLOW_VOLUME, new String[] { "UTGameContent.UTDeployableSlowVolume",
516                                 "UTDeployableSlowVolume", "UTDeployableSlowVolume.WeaponPickup" });
517         
518         /** Slow Volume content, this is the field itself **/
519         public static final UT3ItemType SLOW_VOLUME_CONTENT = MakePrototype (
520                         Category.OTHER, UT3Group.SLOW_VOLUME, new String[] { "UTSlowVolume_Content" });
521 
522 	/** Slow Volume Ammo **/
523 	public static final UT3ItemType SLOW_VOLUME_AMMO = MakePrototype(
524 			Category.AMMO, UT3Group.SLOW_VOLUME, new String[] {
525 					"UTDeployableSlowVolumeAmmo", "UTDeployableSlowVolume.AmmoPickup" });
526 
527 	/** Slow Field **/
528 	public static final UT3ItemType SLOW_FIELD = MakePrototype(Category.OTHER,
529 			UT3Group.SLOW_FIELD, new String[] { "SlowField",
530 					"SlowField.Pickup" });
531         
532         /** Invisibility **/
533 	public static final UT3ItemType INVISIBILITY = MakePrototype(
534 			Category.OTHER, UT3Group.INVISIBILITY, new String[] {
535 					"Invisibility", "Invisibility.Pickup" });
536 
537 	/** Invulnerability **/
538 	public static final UT3ItemType INVULNERABILITY = MakePrototype(
539 			Category.OTHER,
540 			UT3Group.INVULNERABILITY,
541 			new String[] { "Invulnerability",
542 					"Invulnerability.Pickup", });
543 
544         /** WeaponLocker. */
545         public static final UT3ItemType WEAPON_LOCKER = MakePrototype(Category.OTHER,
546 			UT3Group.WEAPON_LOCKER, new String[] { "WeaponLocker", "WeaponLocker.Pickup" });
547         
548 	/** Key. */
549 	public static final UT3ItemType KEY = MakePrototype(Category.OTHER,
550 			UT3Group.KEY, new String[] { "UnrealGame.KeyPickup" });
551 
552 	/** No UT3ItemType */
553 	public static final UT3ItemType NONE = MakePrototype(Category.OTHER,
554 			UT3Group.NONE, new String[] { "None", "NONE", "none" });
555 
556 	/**
557 	 * Public constructor - creates ItemType of the EXTRA category and Group
558 	 * OTHER.
559 	 * 
560 	 * @param name
561 	 *            Type name from GB engine.
562 	 */
563 	public UT3ItemType(String name) {
564 		this.name = name;
565 		this.category = Category.OTHER;
566 		this.group = UT3Group.OTHER;
567 	}
568 
569 	/**
570 	 * Prototypes constructor.
571 	 */
572 	private UT3ItemType(String name, Category category, UT3Group group) {
573 		this.name = name;
574 		this.category = category;
575 		this.group = group;
576 	}
577 
578 	/**
579 	 * Proto-constructor.
580 	 * 
581 	 * @param category
582 	 *            Category of the item.
583 	 * @param group
584 	 *            Group of the item.
585 	 * @param utNames
586 	 *            Names of the item in UT engine.
587 	 * @return Prototype of known ItemType.
588 	 */
589 	public static UT3ItemType MakePrototype(Category category, UT3Group group,
590 			String[] utNames) {
591 		UT3ItemType type;
592 		synchronized (protos) {
593 			// create new itemtype prototype
594 			type = new UT3ItemType(utNames[0], category, group);
595 			// register the itemtype prototype
596 			for (String utName : utNames)
597 				protos.put(utName, type);
598 			// C'est la vie..
599 			if (category != null) {
600 				CATEGORIES.get(category).add(type);
601 			}
602 			if (group != null) {
603 				GROUPS.get(group).add(type);
604 			}
605 		}
606 		return type;
607 	}
608 
609 	public static UT3ItemType getWeaponItemType(UnrealId id) {
610 		if (id == null)
611 			return null;
612 
613 		return getWeaponItemType(id.getStringId());
614 	}
615 
616 	/**
617 	 * Attempts to recognize the weapon you are currently holding...
618 	 * <p>
619 	 * <p>
620 	 * See {@link Self#getWeapon()}.
621 	 * <p>
622 	 * <p>
623 	 * May return null == weapon was not recognized. ALWAYS CHECK!
624 	 * 
625 	 * @return
626 	 */
627 	public static UT3ItemType getWeaponItemType(String str) {
628 		str = str.toLowerCase();
629 		if (str.contains("enforcer"))
630 			return UT3ItemType.ENFORCER;
631 		if (str.contains("impacthammer"))
632 			return UT3ItemType.IMPACT_HAMMER;
633 		if (str.contains("flakcannon"))
634 			return UT3ItemType.FLAK_CANNON;
635 		if (str.contains("biorifle"))
636 			return UT3ItemType.BIO_RIFLE;
637 		if (str.contains("shockrifle"))
638 			return UT3ItemType.SHOCK_RIFLE;
639 		if (str.contains("linkgun"))
640 			return UT3ItemType.LINK_GUN;
641 		if (str.contains("sniperrifle"))
642 			return UT3ItemType.SNIPER_RIFLE;
643 		if (str.contains("rocketlauncher"))
644 			return UT3ItemType.ROCKET_LAUNCHER;
645 		if (str.contains("minigun"))
646 			return UT3ItemType.STINGER_MINIGUN;
647 		if (str.contains("translocator"))
648 			return UT3ItemType.TRANSLOCATOR;
649 		if (str.contains("translauncher"))
650 			return UT3ItemType.TRANSLOCATOR;
651 		if (str.contains("xrayvolume"))
652 			return UT3ItemType.XRAY_VOLUME;
653 		if (str.contains("spiderminetrap"))
654 			return UT3ItemType.SPIDERMINE_TRAP;
655 		if (str.contains("energyshield"))
656 			return UT3ItemType.ENERGY_SHIELD;
657 		if (str.contains("empmine"))
658 			return UT3ItemType.EMP_MINE;
659 		if (str.contains("linkgenerator"))
660 			return UT3ItemType.LINK_GENERATOR;
661 		if (str.contains("shapedcharge"))
662 			return UT3ItemType.SHAPED_CHARGE;
663 		if (str.contains("slowvolume"))
664 			return UT3ItemType.SLOW_VOLUME;
665 		return null;
666 	}
667 
668 	/**
669 	 * Check if this weapon is a deployable.
670 	 * 
671 	 * @param item
672 	 *            item to be checked.
673 	 * @note can be removed if we refactor everything in the hunter-bot to
674 	 *       support deployables.
675 	 */
676 	public static boolean isDeployable(ItemType item) {
677 		return (item == UT3ItemType.EMP_MINE
678 				|| item == UT3ItemType.ENERGY_SHIELD
679 				|| item == UT3ItemType.LINK_GENERATOR
680 				|| item == UT3ItemType.SHAPED_CHARGE
681 				|| item == UT3ItemType.SLOW_VOLUME
682 				|| item == UT3ItemType.SPIDERMINE_TRAP || item == UT3ItemType.XRAY_VOLUME);
683 	}
684 
685 	@Override
686 	public String getName() {
687 		return name;
688 	}
689 
690 	/**
691 	 * Retrieves an ItemType for the specified item type name.
692 	 * 
693 	 * @param utName
694 	 *            e.g. Item.getType()
695 	 * @return
696 	 */
697 	public static ItemType getItemType(String utName) {
698 		ItemType type;
699 
700 		synchronized (protos) {
701 			type = protos.get(utName);
702 			if (type != null)
703 				return type;
704 
705 			type = new UT3ItemType(utName);
706 			protos.put(utName, type);
707 		}
708 		return type;
709 	}
710 
711 	/* ======================================================================== */
712 
713 }