Class ArtilleryHandlerHelper

java.lang.Object
megamek.common.weapons.ArtilleryHandlerHelper

public final class ArtilleryHandlerHelper extends Object
Contains some helper methods for artillery and similar weapon handlers.
  • Method Details

    • findSpotter

      public static Optional<Entity> findSpotter(List<Integer> spottersBefore, int playerId, Game game, Targetable target)
    • isForwardObserver

      public static boolean isForwardObserver(Entity entity)
      Parameters:
      entity - The unit in question
      Returns:
      True when the given unit has the Forward Observer ability
      See Also:
    • clearMines

      public static void clearMines(Vector<Report> reports, Coords coords, Game game, Entity attacker, TWGameManager gameManager)
    • getMinefields

      public static void getMinefields(Vector<Report> reports, Coords coords, Game game, Entity attacker, TWGameManager gameManager)
    • nearestOnBoardHexTowardOffBoard

      @Nullable public static Coords nearestOnBoardHexTowardOffBoard(Board board, Coords aimedHex, Coords offBoardScatter)
      Finds the board-edge hex an artillery round crossed when it scattered off the board: the last on-board hex along the straight line from where it was aimed to the (off-board) hex it scattered to. The board view can then draw the drift arrow to that edge hex, showing the direction the round drifted off, since there is no on-board landing hex.
      Parameters:
      board - The board the round was fired onto
      aimedHex - The on-board hex the round was aimed at (the drift line's origin)
      offBoardScatter - The off-board hex the round scattered to
      Returns:
      The last on-board hex along the line toward offBoardScatter (the edge it crossed), or null if aimedHex is not even on the board