LazyLib

org.lazywizard.lazylib.combat
Class WeaponUtils

Object
  extended by WeaponUtils

public class WeaponUtils
extends Object

Contains methods that deal with weapons and weapon arcs.

Since:
1.0
Author:
LazyWizard

Method Summary
static void aimTowardsPoint(WeaponAPI weapon, Vector2f point, float time)
          Manually adjusts a weapon's aim towards a point.
static float calculateActualDamage(float baseDamage, WeaponAPI weapon)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateActualDamage(float baseDamage, WeaponAPI weapon, ShipAPI target, DefenseType defense)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerBurst(WeaponAPI weapon)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerBurst(WeaponAPI weapon, ShipAPI target, DefenseType defense)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerSecond(WeaponAPI weapon)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerSecond(WeaponAPI weapon, ShipAPI target, DefenseType defense)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerShot(WeaponAPI weapon)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static float calculateDamagePerShot(WeaponAPI weapon, ShipAPI target, DefenseType defense)
          Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.
static List<ShipAPI> getAlliesInArc(WeaponAPI weapon)
          Finds all allied ships within range of a WeaponAPI.
static List<ShipAPI> getEnemiesInArc(WeaponAPI weapon)
          Finds all enemy ships within range of a WeaponAPI.
static List<ShipAPI> getEnemiesInArc(WeaponAPI weapon, 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<MissileAPI> getEnemyMissilesInArc(WeaponAPI weapon)
          Finds all enemy missiles within range of a WeaponAPI.
static List<MissileAPI> getEnemyMissilesInArc(WeaponAPI weapon, boolean sortByDistance)
          Deprecated. Use the normal version of this method and call Collections.sort(List, Comparator) using a CollectionUtils.SortEntitiesByDistance as the Comparator.
static ShipAPI getNearestAllyInArc(WeaponAPI weapon)
          Find the closest ally in range of a WeaponAPI.
static ShipAPI getNearestEnemyInArc(WeaponAPI weapon)
          Find the closest enemy in range of a WeaponAPI.
static MissileAPI getNearestEnemyMissileInArc(WeaponAPI weapon)
          Find the closest enemy missile in range of a WeaponAPI.
static float getTimeToAim(WeaponAPI weapon, Vector2f aimAt)
          Calculate how long it would take to turn a WeaponAPI to aim at a location.
static boolean isWithinArc(CombatEntityAPI entity, WeaponAPI weapon)
          Checks if a CombatEntityAPI is within the arc and range of a WeaponAPI.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

isWithinArc

public static boolean isWithinArc(CombatEntityAPI entity,
                                  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(WeaponAPI weapon,
                                 Vector2f aimAt)
Calculate how long it would take to turn a WeaponAPI to aim at a location. Does NOT factor in current ship turn speed.

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

getNearestAllyInArc

public static ShipAPI getNearestAllyInArc(WeaponAPI weapon)
Find the closest ally in range of a WeaponAPI.

Parameters:
weapon - The WeaponAPI to search around.

Returns:
The allied ShipAPI closest to weapon, or null if none are in range.

Since:
1.7

getAlliesInArc

public static List<ShipAPI> getAlliesInArc(WeaponAPI weapon)
Finds all allied ships within range of a WeaponAPI.

Parameters:
weapon - The weapon to detect allies in range of.

Returns:
A List containing all allied ships within range.

Since:
1.7

getNearestEnemyInArc

public static ShipAPI getNearestEnemyInArc(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 List<ShipAPI> getEnemiesInArc(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

getNearestEnemyMissileInArc

public static MissileAPI getNearestEnemyMissileInArc(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 List<MissileAPI> getEnemyMissilesInArc(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

aimTowardsPoint

public static void aimTowardsPoint(WeaponAPI weapon,
                                   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

calculateActualDamage

@Deprecated
public static float calculateActualDamage(float baseDamage,
                                                     WeaponAPI weapon)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

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 damage done by weapon after bonuses are applied.

Since:
1.0

calculateActualDamage

@Deprecated
public static float calculateActualDamage(float baseDamage,
                                                     WeaponAPI weapon,
                                                     ShipAPI target,
                                                     DefenseType defense)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

Calculates the damage done by a weapon to a ship after all MutableShipStats on both sides are applied.

Parameters:
baseDamage - The base damage of this weapon.
weapon - The WeaponAPI to check for bonuses on.
target - The ship weapon is aiming at.
defense - The defense of target aimed at (used for calculating penalties).

Returns:
The damage dealt by weapon after all bonuses and penalties are applied.

Since:
1.5

calculateDamagePerShot

@Deprecated
public static float calculateDamagePerShot(WeaponAPI weapon)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

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

calculateDamagePerShot

@Deprecated
public static float calculateDamagePerShot(WeaponAPI weapon,
                                                      ShipAPI target,
                                                      DefenseType defense)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

Calculates the damage done per shot by a weapon to a ship after all MutableShipStats on both sides are applied.

Parameters:
weapon - The weapon to check.
target - The ship weapon is aiming at.
defense - The defense of target aimed at (used for calculating penalties).

Returns:
The damage dealt by weapon per shot after all bonuses and penalties are applied.

Since:
1.5

calculateDamagePerSecond

@Deprecated
public static float calculateDamagePerSecond(WeaponAPI weapon)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

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

calculateDamagePerSecond

@Deprecated
public static float calculateDamagePerSecond(WeaponAPI weapon,
                                                        ShipAPI target,
                                                        DefenseType defense)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

Calculates the damage done per second by a weapon to a ship after all MutableShipStats on both sides are applied.

Parameters:
weapon - The weapon to check.
target - The ship weapon is aiming at.
defense - The defense of target aimed at (used for calculating penalties).

Returns:
The damage dealt by weapon per second after all bonuses and penalties are applied.

Since:
1.5

calculateDamagePerBurst

@Deprecated
public static float calculateDamagePerBurst(WeaponAPI weapon)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

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

calculateDamagePerBurst

@Deprecated
public static float calculateDamagePerBurst(WeaponAPI weapon,
                                                       ShipAPI target,
                                                       DefenseType defense)
Deprecated. Too complicated to test/maintain. These methods will be removed after the next Starsector release.

Calculates the damage done per burst by a weapon to a ship after all MutableShipStats on both sides are applied.

Parameters:
weapon - The weapon to check.
target - The ship weapon is aiming at.
defense - The defense of target aimed at (used for calculating penalties).

Returns:
The damage dealt by weapon per burst after all bonuses and penalties are applied.

Since:
1.5

getEnemiesInArc

@Deprecated
public static List<ShipAPI> getEnemiesInArc(WeaponAPI weapon,
                                                       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.4

getEnemyMissilesInArc

@Deprecated
public static List<MissileAPI> getEnemyMissilesInArc(WeaponAPI weapon,
                                                                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.4

LazyLib