LazyLib

org.lazywizard.lazylib.combat
Class WeaponUtils

java.lang.Object
  extended by org.lazywizard.lazylib.combat.WeaponUtils

public class WeaponUtils
extends java.lang.Object

Contains methods that deal with weapons and weapon arcs.

Since:
1.0
Author:
LazyWizard

Method Summary
static void aimTowardsPoint(com.fs.starfarer.api.combat.WeaponAPI weapon, org.lwjgl.util.vector.Vector2f point, float time)
          Manually adjusts a weapon's aim towards a point.
static float calculateActualDamage(float baseDamage, com.fs.starfarer.api.combat.WeaponAPI weapon)
          Calculates the damage done by a weapon after MutableShipStats are applied.
static float calculateDamagePerBurst(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Calculates the damage done per burst by a weapon after MutableShipStats are applied.
static float calculateDamagePerSecond(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Calculates the damage done per second by a weapon after MutableShipStats are applied.
static float calculateDamagePerShot(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Calculates the damage done per shot by a weapon after MutableShipStats are applied.
static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getEnemiesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Finds all enemy ships within range of a WeaponAPI.
static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getEnemiesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon, boolean sortByDistance)
          Finds all enemy ships within range of a WeaponAPI.
static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getEnemyMissilesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Finds all enemy missiles within range of a WeaponAPI.
static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getEnemyMissilesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon, boolean sortByDistance)
          Finds all enemy missiles within range of a WeaponAPI.
static com.fs.starfarer.api.combat.ShipAPI getNearestEnemyInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Find the closest enemy in range of a WeaponAPI.
static com.fs.starfarer.api.combat.MissileAPI getNearestEnemyMissileInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
          Find the closest enemy missile in range of a WeaponAPI.
static float getTimeToAim(com.fs.starfarer.api.combat.WeaponAPI weapon, org.lwjgl.util.vector.Vector2f aimAt)
          Calculate how long it would take to turn a WeaponAPI to aim at a location.
static boolean isWithinArc(com.fs.starfarer.api.combat.CombatEntityAPI entity, com.fs.starfarer.api.combat.WeaponAPI weapon)
          Checks if a CombatEntityAPI is within the arc and range of a WeaponAPI.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

calculateActualDamage

public static float calculateActualDamage(float baseDamage,
                                          com.fs.starfarer.api.combat.WeaponAPI weapon)
Calculates the damage done by a weapon after MutableShipStats are applied.

Parameters:
baseDamage - The base damage of this weapon.
weapon - The WeaponAPI to check for bonuses on.
Returns:
The actual damage done by weapon after bonuses are applied.
Since:
1.0

calculateDamagePerShot

public static float calculateDamagePerShot(com.fs.starfarer.api.combat.WeaponAPI weapon)
Calculates the damage done per shot by a weapon after MutableShipStats are applied.

Parameters:
weapon - The weapon to check.
Returns:
The actual damage done by weapon per shot, after bonuses.
Since:
1.0

calculateDamagePerSecond

public static float calculateDamagePerSecond(com.fs.starfarer.api.combat.WeaponAPI weapon)
Calculates the damage done per second by a weapon after MutableShipStats are applied.

Parameters:
weapon - The weapon to check.
Returns:
The actual damage done by weapon per second, after bonuses.
Since:
1.0

calculateDamagePerBurst

public static float calculateDamagePerBurst(com.fs.starfarer.api.combat.WeaponAPI weapon)
Calculates the damage done per burst by a weapon after MutableShipStats are applied.

Parameters:
weapon - The weapon to check.
Returns:
The actual damage done by weapon per burst, after bonuses.
Since:
1.0

isWithinArc

public static boolean isWithinArc(com.fs.starfarer.api.combat.CombatEntityAPI entity,
                                  com.fs.starfarer.api.combat.WeaponAPI weapon)
Checks if a CombatEntityAPI is within the arc and range of a WeaponAPI.

Parameters:
entity - The CombatEntityAPI to check if weapon is aimed at.
weapon - The WeaponAPI to test against.
Returns:
true if in arc and in range, false otherwise.
Since:
1.0

getTimeToAim

public static float getTimeToAim(com.fs.starfarer.api.combat.WeaponAPI weapon,
                                 org.lwjgl.util.vector.Vector2f aimAt)
Calculate how long it would take to turn a WeaponAPI to aim at a location.

Parameters:
weapon - The WeaponAPI to turn.
aimAt - The Vector2f to aim at.
Returns:
The time in seconds it would take to aim weapon.
Since:
1.0

getNearestEnemyInArc

public static com.fs.starfarer.api.combat.ShipAPI getNearestEnemyInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
Find the closest enemy in range of a WeaponAPI.

Parameters:
weapon - The WeaponAPI to search around.
Returns:
The enemy ShipAPI closest to weapon, or null if none are in range.
Since:
1.4

getEnemiesInArc

public static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getEnemiesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon,
                                                                                  boolean sortByDistance)
Finds all enemy ships within range of a WeaponAPI.

Parameters:
weapon - The weapon to detect enemies in range of.
sortByDistance - Whether to sort the results by distance from weapon.
Returns:
A List containing all enemy ships within range.
Since:
1.4

getEnemiesInArc

public static java.util.List<com.fs.starfarer.api.combat.ShipAPI> getEnemiesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
Finds all enemy ships within range of a WeaponAPI.

Parameters:
weapon - The weapon to detect enemies in range of.
Returns:
A List containing all enemy ships within range.
Since:
1.4
See Also:
getEnemiesInArc(com.fs.starfarer.api.combat.WeaponAPI, boolean)

getNearestEnemyMissileInArc

public static com.fs.starfarer.api.combat.MissileAPI getNearestEnemyMissileInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
Find the closest enemy missile in range of a WeaponAPI.

Parameters:
weapon - The WeaponAPI to search around.
Returns:
The enemy MissileAPI closest to weapon, or null if none are in range.
Since:
1.4

getEnemyMissilesInArc

public static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getEnemyMissilesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon,
                                                                                           boolean sortByDistance)
Finds all enemy missiles within range of a WeaponAPI.

Parameters:
weapon - The weapon to detect enemies in range of.
sortByDistance - Whether to sort the results by distance from weapon.
Returns:
A List containing all enemy missiles within range.
Since:
1.4

getEnemyMissilesInArc

public static java.util.List<com.fs.starfarer.api.combat.MissileAPI> getEnemyMissilesInArc(com.fs.starfarer.api.combat.WeaponAPI weapon)
Finds all enemy missiles within range of a WeaponAPI.

Parameters:
weapon - The weapon to detect enemies in range of.
Returns:
A List containing all enemy missiles within range.
Since:
1.4
See Also:
WeaponUtils#getEnemyMissilesInRange(com.fs.starfarer.api.combat.WeaponAPI, boolean)

aimTowardsPoint

public static void aimTowardsPoint(com.fs.starfarer.api.combat.WeaponAPI weapon,
                                   org.lwjgl.util.vector.Vector2f point,
                                   float time)
Manually adjusts a weapon's aim towards a point.

Parameters:
weapon - The weapon to aim.
point - The point this weapon should try to aim at.
time - How long since the last frame (for turn rate calculations).
Since:
1.4

LazyLib