Class WeaponUtils

Object
WeaponUtils

public class WeaponUtils extends Object
Contains methods that deal with weapons and weapon arcs.
Since:
1.0
Author:
LazyWizard
  • Method Details

    • 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

      @Nullable 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

      @Nullable 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

      @Nullable 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