Class DefenseUtils

Object
DefenseUtils

public class DefenseUtils extends Object
Contains methods to make working with a ship's armor grid and defenses easier.
Since:
1.5
Author:
LazyWizard
  • Field Details

    • NOT_IN_GRID

      public static final float NOT_IN_GRID
      A constant that represents a point not in a ship's armor grid.
      See Also:
  • Method Details

    • getArmorValue

      public static float getArmorValue(ShipAPI ship, Vector2f loc)
      Get the armor value of a ShipAPI at a location. Equivalent to ArmorGridAPI.getArmorValue(int, int), but using world-space coordinates.
      Parameters:
      ship - The ShipAPI whose ArmorGridAPI we will use.
      loc - The world location we will be checking the armor value at.
      Returns:
      The armor value at loc, or NOT_IN_GRID if the point isn't within ship's ArmorGridAPI.
      Since:
      1.5
    • getArmorDamage

      public static float getArmorDamage(ShipAPI ship, Vector2f loc)
      Get the total damage taken by a ShipAPI's armor at a location.
      Parameters:
      ship - The ShipAPI whose ArmorGridAPI we will use.
      loc - The world location we will be checking the armor damage at.
      Returns:
      The armor damage taken at loc, or NOT_IN_GRID if the point isn't within ship's ArmorGridAPI.
      Since:
      1.5
    • getArmorLevel

      public static float getArmorLevel(ShipAPI ship, Vector2f loc)
      Get the armor level of a ShipAPI at a location. Equivalent to ArmorGridAPI.getArmorFraction(int, int), but using world-space coordinates.
      Parameters:
      ship - The ShipAPI whose ArmorGridAPI we will use.
      loc - The world location we will be checking the armor level at.
      Returns:
      The armor level at loc, or NOT_IN_GRID if the point isn't within ship's ArmorGridAPI.
      Since:
      1.5
    • getDefenseAtPoint

      public static DefenseType getDefenseAtPoint(ShipAPI ship, Vector2f loc)
      Determine what DefenseType is present at a specific location on a ShipAPI. This method will consider points not inside of the ship's bounds as a miss even if said point is still within the armor grid.
      Parameters:
      ship - The ShipAPI to examine.
      loc - The location to check at.
      Returns:
      The DefenseType present at loc.
      Since:
      1.5
    • hasArmorDamage

      public static boolean hasArmorDamage(ShipAPI ship)
      Checks if a ship has taken any armor damage.
      Parameters:
      ship - The ShipAPI to check for armor damage on.
      Returns:
      true if ship has armor damage, false otherwise.
      Since:
      2.0
    • hasHullDamage

      public static boolean hasHullDamage(ShipAPI ship)
      Checks if a ship has taken any hull damage.
      Parameters:
      ship - The ShipAPI to check for hull damage on.
      Returns:
      true if ship has hull damage, false otherwise.
      Since:
      2.0
    • getMostDamagedArmorCell

      @Nullable public static Point getMostDamagedArmorCell(ShipAPI ship)
      Returns the most damaged armor cell on a ShipAPI, or null if the ship hasn't taken any armor damage.
      Parameters:
      ship - The ShipAPI to check for armor damage on.
      Returns:
      A Point containing the armor grid coordinates of the most damaged armor cell, or null if no armor damage was found. If multiple cells are at 0 armor, the first found will be returned.
      Since:
      2.0