LazyLib

org.lazywizard.lazylib.campaign
Class FleetUtils

Object
  extended by FleetUtils

public class FleetUtils
extends Object

Contains methods for working with fleets and fleet data.

Since:
1.0
Author:
LazyWizard

Method Summary
static boolean areAllies(CampaignFleetAPI fleet1, CampaignFleetAPI fleet2)
          Checks if two fleets are allies.
static boolean areEnemies(CampaignFleetAPI fleet1, CampaignFleetAPI fleet2)
          Checks if two fleets are enemies.
static boolean areNeutral(CampaignFleetAPI fleet1, CampaignFleetAPI fleet2)
          Checks if two fleets are neutral towards each other.
static List<CampaignFleetAPI> getAlliedFleetsInSystem(CampaignFleetAPI fleet)
          Find all allies of a CampaignFleetAPI present in the system.
static List<CampaignFleetAPI> getAlliedFleetsInSystem(CampaignFleetAPI fleet, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.
static List<CampaignFleetAPI> getEnemyFleetsInSystem(CampaignFleetAPI fleet)
          Find all enemies of a CampaignFleetAPI present in the system.
static List<CampaignFleetAPI> getEnemyFleetsInSystem(CampaignFleetAPI fleet, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.
static List<CampaignFleetAPI> getNearbyAlliedFleets(CampaignFleetAPI fleet, float range)
          Finds all allied fleets within a certain range around a CampaignFleetAPI.
static List<CampaignFleetAPI> getNearbyAlliedFleets(CampaignFleetAPI fleet, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.
static List<CampaignFleetAPI> getNearbyEnemyFleets(CampaignFleetAPI fleet, float range)
          Finds all enemy fleets within a certain range around a CampaignFleetAPI.
static List<CampaignFleetAPI> getNearbyEnemyFleets(CampaignFleetAPI fleet, float range, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.
static List<CampaignFleetAPI> getNearbyFleets(CampaignFleetAPI fleet, float range)
          Finds all fleets within a certain range around a CampaignFleetAPI.
static CampaignFleetAPI getNearestAlliedFleet(CampaignFleetAPI fleet)
          Find the closest allied fleet to a CampaignFleetAPI.
static CampaignFleetAPI getNearestEnemyFleet(CampaignFleetAPI fleet)
          Find the closest enemy fleet to a CampaignFleetAPI.
static CampaignFleetAPI getNearestFleet(SectorEntityToken token)
          Find the closest CampaignFleetAPI near a SectorEntityToken.
static SectorEntityToken getNearestStation(SectorEntityToken token)
          Find the closest orbital station to a SectorEntityToken.
static float getRelation(CampaignFleetAPI fleet1, CampaignFleetAPI fleet2)
          Returns the faction relationship between two fleets.
static boolean isPlayer(CampaignFleetAPI fleet)
          Checks if a fleet is the player fleet.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isPlayer

public static boolean isPlayer(CampaignFleetAPI fleet)
Checks if a fleet is the player fleet.

Parameters:
fleet - The CampaignFleetAPI to be checked.

Returns:
true if fleet is the player fleet, false otherwise.

Since:
1.0

areAllies

public static boolean areAllies(CampaignFleetAPI fleet1,
                                CampaignFleetAPI fleet2)
Checks if two fleets are allies.

Parameters:
fleet1 - The first CampaignFleetAPI to check.
fleet2 - The second CampaignFleetAPI to check.

Returns:
true if the fleets are allies, false otherwise.

Since:
1.2

areEnemies

public static boolean areEnemies(CampaignFleetAPI fleet1,
                                 CampaignFleetAPI fleet2)
Checks if two fleets are enemies.

Parameters:
fleet1 - The first CampaignFleetAPI to check.
fleet2 - The second CampaignFleetAPI to check.

Returns:
true if the fleets are enemies, false otherwise.

Since:
1.2

getRelation

public static float getRelation(CampaignFleetAPI fleet1,
                                CampaignFleetAPI fleet2)
Returns the faction relationship between two fleets. Equivalent to calling fleet1.getFaction().getRelationship(fleet2.getFaction().getId()), but much more readable.

Parameters:
fleet1 - A CampaignFleetAPI whose faction relationship will be tested.
fleet2 - The CampaignFleetAPI to test relationship with.

Returns:
The faction relationship between fleet1 and fleet2.

Since:
1.7

areNeutral

public static boolean areNeutral(CampaignFleetAPI fleet1,
                                 CampaignFleetAPI fleet2)
Checks if two fleets are neutral towards each other.

Parameters:
fleet1 - The first CampaignFleetAPI to check.
fleet2 - The second CampaignFleetAPI to check.

Returns:
true if the fleets are neutral, false otherwise.

Since:
1.2

getNearestStation

public static SectorEntityToken getNearestStation(SectorEntityToken token)
Find the closest orbital station to a SectorEntityToken.

Parameters:
token - The SectorEntityToken to search around.

Returns:
The orbital station closest to token.

Since:
1.2

getNearestEnemyFleet

public static CampaignFleetAPI getNearestEnemyFleet(CampaignFleetAPI fleet)
Find the closest enemy fleet to a CampaignFleetAPI.

Parameters:
fleet - The CampaignFleetAPI to search around.

Returns:
The enemy CampaignFleetAPI closest to fleet.

Since:
1.2

getNearestAlliedFleet

public static CampaignFleetAPI getNearestAlliedFleet(CampaignFleetAPI fleet)
Find the closest allied fleet to a CampaignFleetAPI.

Parameters:
fleet - The CampaignFleetAPI to search around.

Returns:
The allied CampaignFleetAPI closest to fleet.

Since:
1.2

getNearestFleet

public static CampaignFleetAPI getNearestFleet(SectorEntityToken token)
Find the closest CampaignFleetAPI near a SectorEntityToken.

Parameters:
token - The SectorEntityToken to search around.

Returns:
The CampaignFleetAPI closest to token.

Since:
1.2

getEnemyFleetsInSystem

public static List<CampaignFleetAPI> getEnemyFleetsInSystem(CampaignFleetAPI fleet)
Find all enemies of a CampaignFleetAPI present in the system.

Parameters:
fleet - The CampaignFleetAPI to search around.

Returns:
All enemies of fleet in the system.

Since:
1.2

getNearbyEnemyFleets

public static List<CampaignFleetAPI> getNearbyEnemyFleets(CampaignFleetAPI fleet,
                                                          float range)
Finds all enemy fleets within a certain range around a CampaignFleetAPI.

Parameters:
fleet - The entity to search around.
range - How far around fleet to search.

Returns:
A List containing all enemy fleets within range.

Since:
1.2

getAlliedFleetsInSystem

public static List<CampaignFleetAPI> getAlliedFleetsInSystem(CampaignFleetAPI fleet)
Find all allies of a CampaignFleetAPI present in the system.

Parameters:
fleet - The CampaignFleetAPI to search around.

Returns:
All allies of fleet in the system.

Since:
1.2

getNearbyAlliedFleets

public static List<CampaignFleetAPI> getNearbyAlliedFleets(CampaignFleetAPI fleet,
                                                           float range)
Finds all allied fleets within a certain range around a CampaignFleetAPI.

Parameters:
fleet - The entity to search around.
range - How far around fleet to search.

Returns:
A List containing all allied fleets within range.

Since:
1.2

getNearbyFleets

public static List<CampaignFleetAPI> getNearbyFleets(CampaignFleetAPI fleet,
                                                     float range)
Finds all fleets within a certain range around a CampaignFleetAPI.

Parameters:
fleet - The entity to search around.
range - How far around fleet to search.

Returns:
A List containing all fleets within range.

Since:
1.7

getEnemyFleetsInSystem

@Deprecated
public static List<CampaignFleetAPI> getEnemyFleetsInSystem(CampaignFleetAPI fleet,
                                                                       boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.

Since:
1.2

getNearbyEnemyFleets

@Deprecated
public static List<CampaignFleetAPI> getNearbyEnemyFleets(CampaignFleetAPI fleet,
                                                                     float range,
                                                                     boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.

Since:
1.2

getAlliedFleetsInSystem

@Deprecated
public static List<CampaignFleetAPI> getAlliedFleetsInSystem(CampaignFleetAPI fleet,
                                                                        boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.

Since:
1.2

getNearbyAlliedFleets

@Deprecated
public static List<CampaignFleetAPI> getNearbyAlliedFleets(CampaignFleetAPI fleet,
                                                                      float range,
                                                                      boolean sortByDistance)
Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortTokensByDistance as the Comparator.

Since:
1.2

LazyLib