Record Class MovePathTerrainCost

java.lang.Object
java.lang.Record
megamek.common.MovePathTerrainCost
Record Components:
levelingCost - MP-equivalent cost to level destructible terrain at the step's hex, or BulldozerMovePath.CANNOT_LEVEL when no leveling is needed or possible
additionalCost - extra cost that slows the move without raising MP (deep water, minefield), 0 if none

public record MovePathTerrainCost(int levelingCost, int additionalCost) extends Record
The extra pathfinding costs a single BulldozerMovePath step incurs beyond its raw MP: the cost to "level" impassable-but-destructible terrain in the way, plus additional costs that slow the unit without raising its MP total (wading into deep water, jumping into water, or crossing a minefield). This logic used to be inlined in BulldozerMovePath.addStep(megamek.common.enums.MoveStepType); it is pulled out here so it is cohesive and unit-testable, and so the (previously dead) deep-water cost can be exercised in isolation.
  • Constructor Details

    • MovePathTerrainCost

      public MovePathTerrainCost(int levelingCost, int additionalCost)
      Creates an instance of a MovePathTerrainCost record class.
      Parameters:
      levelingCost - the value for the levelingCost record component
      additionalCost - the value for the additionalCost record component
  • Method Details

    • forFinalStep

      public static MovePathTerrainCost forFinalStep(BulldozerMovePath path)
      Computes the leveling and additional costs incurred by the most recently added step of the given path.
      Parameters:
      path - the bulldozer path whose final step is being costed
      Returns:
      the MovePathTerrainCost for that step
    • requiresLeveling

      public boolean requiresLeveling()
      Returns:
      true if the step needs (and is able to perform) terrain leveling to be traversable
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with '=='.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • levelingCost

      public int levelingCost()
      Returns the value of the levelingCost record component.
      Returns:
      the value of the levelingCost record component
    • additionalCost

      public int additionalCost()
      Returns the value of the additionalCost record component.
      Returns:
      the value of the additionalCost record component