LazyLib

org.lazywizard.lazylib.combat
Class CombatUtils

java.lang.Object
  extended by org.lazywizard.lazylib.combat.CombatUtils
All Implemented Interfaces:
com.fs.starfarer.api.combat.CombatEnginePlugin, com.fs.starfarer.api.combat.EveryFrameCombatPlugin

public class CombatUtils
extends java.lang.Object
implements com.fs.starfarer.api.combat.EveryFrameCombatPlugin

Contains methods that deal with the battle map in general.

Since:
1.0
Author:
LazyWizard

Constructor Summary
protected CombatUtils()
           
 
Method Summary
 void advance(float amount, java.util.List<com.fs.starfarer.api.input.InputEventAPI> events)
          Automatically called by the game.
static void applyForce(com.fs.starfarer.api.combat.CombatEntityAPI entity, float direction, float force)
          Apply force to an object.
static void applyForce(com.fs.starfarer.api.combat.CombatEntityAPI entity, org.lwjgl.util.vector.Vector2f direction, float force)
          Apply force to an object.
static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getAsteroidsWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all asteroids in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getAsteroidsWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all asteroids in range of a given location.
static com.fs.starfarer.api.combat.CombatEngineAPI getCombatEngine()
          Returns the currently used CombatEngineAPI.
static float getElapsedCombatTime()
          Returns the length of the current battle.
static float getElapsedCombatTimeIncludingPaused()
          Returns the length of the current battle, including time spent paused.
static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getEntitiesWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all entities in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getEntitiesWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all entities in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getMissilesWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all missiles in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getMissilesWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all missiles in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.BattleObjectiveAPI> getObjectivesWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all objectives in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.BattleObjectiveAPI> getObjectivesWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all objectives in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.DamagingProjectileAPI> getProjectilesWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all projectiles in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.DamagingProjectileAPI> getProjectilesWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all projectiles in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getShipsWithinRange(org.lwjgl.util.vector.Vector2f location, float range)
          Returns all ships in range of a given location.
static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getShipsWithinRange(org.lwjgl.util.vector.Vector2f location, float range, boolean sortByDistance)
          Returns all ships in range of a given location.
static float getTimeSinceLastFrame()
          Returns the time since the last frame.
 void init(com.fs.starfarer.api.combat.CombatEngineAPI engine)
          Automatically called by the game.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CombatUtils

protected CombatUtils()
Method Detail

getCombatEngine

public static com.fs.starfarer.api.combat.CombatEngineAPI getCombatEngine()
Returns the currently used CombatEngineAPI.

Returns:
The CombatEngineAPI used by the current battle.
Since:
1.0

getElapsedCombatTimeIncludingPaused

public static float getElapsedCombatTimeIncludingPaused()
Returns the length of the current battle, including time spent paused.

Returns:
The total elapsed time (including time spent paused) for this combat encounter, in seconds.
Since:
1.2

getElapsedCombatTime

public static float getElapsedCombatTime()
Returns the length of the current battle.

Returns:
The total elapsed time for this combat encounter, in seconds.
Since:
1.0

getTimeSinceLastFrame

public static float getTimeSinceLastFrame()
Returns the time since the last frame.

Returns:
The time since the last frame, in seconds.
Since:
1.4

getProjectilesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.DamagingProjectileAPI> getProjectilesWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                                          float range,
                                                                                                          boolean sortByDistance)
Returns all projectiles in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of DamagingProjectileAPIs within range of location.
Since:
1.1

getProjectilesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.DamagingProjectileAPI> getProjectilesWithinRange(org.lwjgl.util.vector.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
See Also:
getProjectilesWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

getMissilesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getMissilesWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                            float range,
                                                                                            boolean sortByDistance)
Returns all missiles in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of MissileAPIs within range of location.
Since:
1.1

getMissilesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getMissilesWithinRange(org.lwjgl.util.vector.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
See Also:
getMissilesWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

getShipsWithinRange

public static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getShipsWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                      float range,
                                                                                      boolean sortByDistance)
Returns all ships in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of ShipAPIs within range of location.
Since:
1.1

getShipsWithinRange

public static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getShipsWithinRange(org.lwjgl.util.vector.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
See Also:
getShipsWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

getAsteroidsWithinRange

public static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getAsteroidsWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                                  float range,
                                                                                                  boolean sortByDistance)
Returns all asteroids in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of asteroids within range of location.
Since:
1.1

getAsteroidsWithinRange

public static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getAsteroidsWithinRange(org.lwjgl.util.vector.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
See Also:
getAsteroidsWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

getObjectivesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.BattleObjectiveAPI> getObjectivesWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                                      float range,
                                                                                                      boolean sortByDistance)
Returns all objectives in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of BattleObjectiveAPIs within range of location.
Since:
1.1

getObjectivesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.BattleObjectiveAPI> getObjectivesWithinRange(org.lwjgl.util.vector.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
See Also:
getObjectivesWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

getEntitiesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getEntitiesWithinRange(org.lwjgl.util.vector.Vector2f location,
                                                                                                 float range,
                                                                                                 boolean sortByDistance)
Returns all entities in range of a given location.

Parameters:
location - The location to search around.
range - How far around location to search.
sortByDistance - Whether to sort the results by distance from location.
Returns:
A List of CombatEntityAPIs within range of location.
Since:
1.1

getEntitiesWithinRange

public static java.util.List<com.fs.starfarer.api.combat.CombatEntityAPI> getEntitiesWithinRange(org.lwjgl.util.vector.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
See Also:
getEntitiesWithinRange(org.lwjgl.util.vector.Vector2f, float, boolean)

applyForce

public static void applyForce(com.fs.starfarer.api.combat.CombatEntityAPI entity,
                              org.lwjgl.util.vector.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(com.fs.starfarer.api.combat.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

advance

public void advance(float amount,
                    java.util.List<com.fs.starfarer.api.input.InputEventAPI> events)
Automatically called by the game. Don't call this manually.

Specified by:
advance in interface com.fs.starfarer.api.combat.EveryFrameCombatPlugin

init

public void init(com.fs.starfarer.api.combat.CombatEngineAPI engine)
Automatically called by the game. Don't call this manually.

Specified by:
init in interface com.fs.starfarer.api.combat.CombatEnginePlugin

LazyLib