/** * Generate a new unique flyout id for the given weapon. * * @param weapon The weapon * @return A new flyout id. */ private static int generateFlyoutId(Weapon weapon) { synchronized (flyoutIds) { String key = weapon.getEntity().getName() + "." + weapon.getName(); Integer id = flyoutIds.get(key); if (id == null) { id = 0; } flyoutIds.put(key, id + 1); return id; } }
/** * Generate a unique name for a missile. Exactly one of target or staticTarget must be non-null. * * @param weapon The associated weapon * @param target The target * @param staticTarget The target position * @return A new name */ private static String generateName(Weapon weapon, Entity target, Vector3 staticTarget) { int id = generateFlyoutId(weapon); if (target != null) { return weapon.getEntity().getName() + "." + weapon.getName() + "." + id + "." + target.getName(); } else if (staticTarget != null) { return weapon.getEntity().getName() + "." + weapon.getName() + "." + id + "." + staticTarget; } else { throw new IllegalArgumentException("One of target and staticTarget must be non-null"); } }