LazyLib

org.lazywizard.lazylib.combat
Class CombatUtils

Object
  extended by CombatUtils

public class CombatUtils
extends Object

Contains methods that deal with the battle map in general.

Since:
1.0
Author:
LazyWizard

Method Summary
static void applyForce(CombatEntityAPI entity, float direction, float force)
          Apply force to an object.
static void applyForce(CombatEntityAPI entity, Vector2f direction, float force)
          Apply force to an object.
static List<CombatEntityAPI> getAsteroidsWithinRange(Vector2f location, float range)
          Returns all asteroids in range of a given location.
static List<CombatEntityAPI> getAsteroidsWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static CombatEngineAPI getCombatEngine()
          Deprecated. Use Global.getCombatEngine() instead.
static float getElapsedCombatTime()
          Deprecated. Use CombatEngineAPI.getTotalElapsedTime(boolean) instead.
static float getElapsedCombatTimeIncludingPaused()
          Deprecated. Use CombatEngineAPI.getTotalElapsedTime(boolean) instead.
static List<CombatEntityAPI> getEntitiesWithinRange(Vector2f location, float range)
          Returns all entities in range of a given location.
static List<CombatEntityAPI> getEntitiesWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static FleetMemberAPI getFleetMember(ShipAPI ship)
          Find a ShipAPI's corresponding FleetMemberAPI.
static List<MissileAPI> getMissilesWithinRange(Vector2f location, float range)
          Returns all missiles in range of a given location.
static List<MissileAPI> getMissilesWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static List<BattleObjectiveAPI> getObjectivesWithinRange(Vector2f location, float range)
          Returns all objectives in range of a given location.
static List<BattleObjectiveAPI> getObjectivesWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static List<DamagingProjectileAPI> getProjectilesWithinRange(Vector2f location, float range)
          Returns all projectiles in range of a given location.
static List<DamagingProjectileAPI> getProjectilesWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static List<ShipAPI> getShipsWithinRange(Vector2f location, float range)
          Returns all ships in range of a given location.
static List<ShipAPI> getShipsWithinRange(Vector2f location, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static float getTimeSinceLastFrame()
          Deprecated. Use CombatEngineAPI.getElapsedInLastFrame() instead.
static boolean isVisibleToSide(CombatEntityAPI entity, int side)
          Checks if a CombatEntityAPI is visible to a side of battle.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getFleetMember

public static FleetMemberAPI getFleetMember(ShipAPI ship)
Find a ShipAPI's corresponding FleetMemberAPI.

Parameters:
ship - The ShipAPI whose corresponding FleetMemberAPI we are trying to find.

Returns:
The FleetMemberAPI that represents this ShipAPI in the campaign, or null if no match is found.

Since:
1.5

isVisibleToSide

public static boolean isVisibleToSide(CombatEntityAPI entity,
                                      int side)
Checks if a CombatEntityAPI is visible to a side of battle. Note1: Allied and neutral entities are always visible. Note2: All AIUtils methods already filter by visibility, so use of this method is not necessary on their results.

Parameters:
entity - The CombatEntityAPI to check visibility of.
side - The side whose fog of war will be tested.

Returns:
true if entity is visible to side, false otherwise.

Since:
1.7

getProjectilesWithinRange

public static List<DamagingProjectileAPI> getProjectilesWithinRange(Vector2f location,
                                                                    float range)
Returns all projectiles in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of DamagingProjectileAPIs within range of location.

Since:
1.0

getMissilesWithinRange

public static List<MissileAPI> getMissilesWithinRange(Vector2f location,
                                                      float range)
Returns all missiles in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of MissileAPIs within range of location.

Since:
1.0

getShipsWithinRange

public static List<ShipAPI> getShipsWithinRange(Vector2f location,
                                                float range)
Returns all ships in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of ShipAPIs within range of location.

Since:
1.0

getAsteroidsWithinRange

public static List<CombatEntityAPI> getAsteroidsWithinRange(Vector2f location,
                                                            float range)
Returns all asteroids in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of asteroids within range of location.

Since:
1.0

getObjectivesWithinRange

public static List<BattleObjectiveAPI> getObjectivesWithinRange(Vector2f location,
                                                                float range)
Returns all objectives in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of BattleObjectiveAPIs within range of location.

Since:
1.0

getEntitiesWithinRange

public static List<CombatEntityAPI> getEntitiesWithinRange(Vector2f location,
                                                           float range)
Returns all entities in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.

Returns:
A List of CombatEntityAPIs within range of location.

Since:
1.0

applyForce

public static void applyForce(CombatEntityAPI entity,
                              Vector2f direction,
                              float force)
Apply force to an object. Remember Newton's Second Law. Force is multiplied by 100 to avoid requiring ridiculous force amounts.

Parameters:
entity - The CombatEntityAPI to apply the force to.
direction - The directional vector of the force (this will automatically be normalized).
force - How much force to apply.

Since:
1.2

applyForce

public static void applyForce(CombatEntityAPI entity,
                              float direction,
                              float force)
Apply force to an object. Remember Newton's Second Law.

Parameters:
entity - The CombatEntityAPI to apply the force to.
direction - The angle the force will be applied towards.
force - How much force to apply.

Since:
1.2

getProjectilesWithinRange

@Deprecated
public static List<DamagingProjectileAPI> getProjectilesWithinRange(Vector2f location,
                                                                               float range,
                                                                               boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getMissilesWithinRange

@Deprecated
public static List<MissileAPI> getMissilesWithinRange(Vector2f location,
                                                                 float range,
                                                                 boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getShipsWithinRange

@Deprecated
public static List<ShipAPI> getShipsWithinRange(Vector2f location,
                                                           float range,
                                                           boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getAsteroidsWithinRange

@Deprecated
public static List<CombatEntityAPI> getAsteroidsWithinRange(Vector2f location,
                                                                       float range,
                                                                       boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getObjectivesWithinRange

@Deprecated
public static List<BattleObjectiveAPI> getObjectivesWithinRange(Vector2f location,
                                                                           float range,
                                                                           boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getEntitiesWithinRange

@Deprecated
public static List<CombatEntityAPI> getEntitiesWithinRange(Vector2f location,
                                                                      float range,
                                                                      boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.

Since:
1.1

getCombatEngine

@Deprecated
public static CombatEngineAPI getCombatEngine()
Deprecated. Use Global.getCombatEngine() instead.

Since:
1.0

getElapsedCombatTimeIncludingPaused

@Deprecated
public static float getElapsedCombatTimeIncludingPaused()
Deprecated. Use CombatEngineAPI.getTotalElapsedTime(boolean) instead.

Since:
1.2

getElapsedCombatTime

@Deprecated
public static float getElapsedCombatTime()
Deprecated. Use CombatEngineAPI.getTotalElapsedTime(boolean) instead.

Since:
1.0

getTimeSinceLastFrame

@Deprecated
public static float getTimeSinceLastFrame()
Deprecated. Use CombatEngineAPI.getElapsedInLastFrame() instead.

Since:
1.4

LazyLib