Package megamek.common
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, orBulldozerMovePath.CANNOT_LEVELwhen no leveling is needed or possibleadditionalCost- extra cost that slows the move without raising MP (deep water, minefield),0if none
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 Summary
ConstructorsConstructorDescriptionMovePathTerrainCost(int levelingCost, int additionalCost) Creates an instance of aMovePathTerrainCostrecord class. -
Method Summary
Modifier and TypeMethodDescriptionintReturns the value of theadditionalCostrecord component.final booleanIndicates whether some other object is "equal to" this one.static MovePathTerrainCostComputes the leveling and additional costs incurred by the most recently added step of the given path.final inthashCode()Returns a hash code value for this object.intReturns the value of thelevelingCostrecord component.booleanfinal StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
MovePathTerrainCost
public MovePathTerrainCost(int levelingCost, int additionalCost) Creates an instance of aMovePathTerrainCostrecord class.- Parameters:
levelingCost- the value for thelevelingCostrecord componentadditionalCost- the value for theadditionalCostrecord component
-
-
Method Details
-
forFinalStep
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
MovePathTerrainCostfor that step
-
requiresLeveling
public boolean requiresLeveling()- Returns:
trueif the step needs (and is able to perform) terrain leveling to be traversable
-
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. -
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. -
equals
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 '=='. -
levelingCost
public int levelingCost()Returns the value of thelevelingCostrecord component.- Returns:
- the value of the
levelingCostrecord component
-
additionalCost
public int additionalCost()Returns the value of theadditionalCostrecord component.- Returns:
- the value of the
additionalCostrecord component
-