Package megamek.common.moves
Class MovePath
java.lang.Object
megamek.common.moves.MovePath
- All Implemented Interfaces:
Serializable,Cloneable
- Direct Known Subclasses:
AtmosphericLandingMovePath,BulldozerMovePath
Holds movement path for an entity.
- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddManeuver(int manType) addStep(MoveStepType type) Add a new step to the movement path.addStep(MoveStepType type, boolean noCost) addStep(MoveStepType type, boolean noCost, boolean isManeuver, int maneuverType) addStep(MoveStepType type, int additionalIntData) addStep(MoveStepType type, int recover, int mineToLay) addStep(MoveStepType type, Map<Integer, Integer> additionalIntData) addStep(MoveStepType type, Minefield mf) addStep(MoveStepType type, Targetable target) Add a new step to the movement path with the given target.addStep(MoveStepType type, Targetable target, Coords pos) protected MovePathInitializes a step as part of this movement path.voidbooleanautomaticWiGELanding(boolean includeMovePathHexes) Airborne WiGEs that move less than five hexes (four for glider protomek) in a movement phase must land unless it has taken off in the same phase, jumped, or it is a LAM or glider ProtoMek that is using hover movement.booleancanShift()voidclear()voidRemoves impossible steps.clone()Clones this path, will contain a new clone of the steps so that the clone is independent of the original.voidvoidbooleancontains(MoveStepType type) Check for any of the specified type of step in the pathbooleanReturns true if this MovePath contains a lateral shiftbooleanDeprecated, for removal: This API element is subject to removal in a future version.protected voidcopyFields(MovePath copy) intcountMp(boolean jumping) booleanvoidfindPathTo(Coords dest, MoveStepType type) Extend the current path to the destinationCoords.voidfindSimplePathTo(Coords dest, MoveStepType type, int direction, int facing) Extend the current path to the destinationCoords, moving only in one direction.booleanConvenience function to determine whether this path results in the unit explicitly moving off board More relevant for aircraftstatic intgetAdjustedFacing(int facing, MoveStepType movement) Returns the adjusted facing, given the start facing.static MoveStepTypegetDirection(int facing, int destFacing) Returns the direction (either MovePath.MoveStepType.TURN_LEFT or MoveStepType.TURN_RIGHT) that the destination facing lies in.intReturns the linear distance between the first and last hexes in the path.intgetEndStepCount(MoveStepType stepType) Worker function that counts the number of steps of the given type at the end of the given path before another step type occurs.intget final altitudeintbooleanReturns whether a unit would be in climb mode after all the stepsIf the path contains mode conversions, this will determine the movement mode at the end of movement.intget final elevation relative to the hex.intReturns the final facing if a mek were to perform all the steps in this path.booleanReturns whether a unit would end up hull-down after all the stepsintbooleanReturns whether a unit would end up prone after all the stepsint[]Returns the final vector for advanced movementintintgetGame()intReturns the logical number of hexes moved the path (does not count turns, etc.).intReturns the distance between the highest elevation in the jump path and the elevation at the landing point.Returns the highest elevation along a jump path.getKey()intReturns the highest elevation in the current pathintgetMaxMP()intReturns the number of MPs used in the pathgetNextMoves(boolean backward, boolean forward) Returns a list of possible moves that result in a facing/position/(jumping|prone) change, special steps (mine clearing and such) must be handled elsewhere.getSecondFinalPosition(Coords startPos) Returns the startingCoordsof this path.getStep(int index) getSteps()Returns the waypoint referenced by this MovePath.booleanCheck for MASC usebooleanCheck for Supercharger useinthashCode()booleanChecks if there is a waypoint referenced by this MovePath.booleanreturns if the unit had any altitude above 0 during the movement pathbooleanisAllUnderwater(Game game) booleanbooleanDeprecated, for removal: This API element is subject to removal in a future version.booleanbooleanReturns true if the entity is jumping or if it's a flying lam.booleanbooleanConvenience method to determine whether this path is happening on a ground map with an atmospherebooleanisValidPositionForBrace(Coords coords, int boardId, int facing) Given a set of coordinates and a facing, is the entity taking this path in a valid position to execute a brace?booleanstatic MoveStepTypelateralShiftForTurn(MoveStepType turn, MoveStepType direction) Returns the lateral shift that corresponds to the turn directionintlength()Returns the number of steps in this movementbooleanConvenience function encapsulating logic for whether, if we continue forward along the current path in the current direction, we will run off the boardvoidDeprecated, for removal: This API element is subject to removal in a future version.voidvoidreplaceSteps(Vector<MoveStep> path) voidrotatePathfinder(int destFacing, boolean isManeuver, int maneuverType) Rotate from the current facing to the destination facing.voidsetCareful(boolean b) voidvoidsetFlightPathHex(BoardLocation flightPathHex) voidvoidsetStrafingStep(Coords pos) Searches the path for the firstMoveStepthat matches the given position and sets it as a strafing step.voidsetVTOLBombStep(Coords pos) Searches the movement path for the first step that has the given position and sets it as a VTOL bombing step.booleantoString()boolean
-
Field Details
-
DEFAULT_PATHFINDER_TIME_LIMIT
public static final int DEFAULT_PATHFINDER_TIME_LIMIT- See Also:
-
-
Constructor Details
-
MovePath
Generates a new, empty, movement path object. -
MovePath
Generates a new, empty, movement path object.
-
-
Method Details
-
getGame
-
setGame
-
setEntity
-
hasWaypoint
public boolean hasWaypoint()Checks if there is a waypoint referenced by this MovePath.- Returns:
- true if there is a waypoint, false otherwise.
-
getWaypoint
Returns the waypoint referenced by this MovePath.- Returns:
- the waypoint, or null if there is none.
-
getEntity
-
getCachedEntityState
-
getKey
-
toString
-
length
public int length()Returns the number of steps in this movement -
addStep
Add a new step to the movement path.- Parameters:
type- the type of movement.
-
addStep
Add a new step to the movement path with the given target.- Parameters:
type- the type of movement.target- theTargetableobject that is the target of this step. For example, the enemy being charged.
-
addStep
-
addStep
-
addStep
-
addStep
-
addStep
-
addStep
-
addStep
-
addStep
-
addManeuver
public void addManeuver(int manType) -
canShift
public boolean canShift() -
containsLateralShift
public boolean containsLateralShift()Returns true if this MovePath contains a lateral shift -
containsVTOLBomb
Deprecated, for removal: This API element is subject to removal in a future version. -
addStep
-
getCoordsSet
-
addStep
Initializes a step as part of this movement path. Then adds it to the list. -
compile
-
compile
-
removeLastStep
public void removeLastStep() -
clear
public void clear() -
isValidPositionForBrace
-
isValidPositionForBrace
Given a set of coordinates and a facing, is the entity taking this path in a valid position to execute a brace? -
getSteps
-
getStep
-
contains
Check for any of the specified type of step in the path- Parameters:
type- The step type to check for- Returns:
- Whether this step type is contained within this path
-
fliesOffBoard
public boolean fliesOffBoard()Convenience function to determine whether this path results in the unit explicitly moving off board More relevant for aircraft- Returns:
- Whether this path will result in the unit moving off board
-
hasActiveMASC
public boolean hasActiveMASC()Check for MASC use -
hasActiveSupercharger
public boolean hasActiveSupercharger()Check for Supercharger use -
getFinalCoords
- Returns:
- the final coordinates if a mek were to perform all the steps in this path, or null if there's an issue with determining the coords
-
getFinalBoardId
public int getFinalBoardId()- Returns:
- the board ID of the final position of this move path or the unit's own board ID if the path has no steps.
-
getStartCoords
Returns the startingCoordsof this path. -
getFinalFacing
public int getFinalFacing()Returns the final facing if a mek were to perform all the steps in this path. -
getFinalProne
public boolean getFinalProne()Returns whether a unit would end up prone after all the steps -
getFinalHullDown
public boolean getFinalHullDown()Returns whether a unit would end up hull-down after all the steps -
getFinalClimbMode
public boolean getFinalClimbMode()Returns whether a unit would be in climb mode after all the steps -
getFinalElevation
public int getFinalElevation()get final elevation relative to the hex. -
getMaxElevation
public int getMaxElevation()Returns the highest elevation in the current path -
isAirborne
public boolean isAirborne()returns if the unit had any altitude above 0 during the movement path -
getFinalAltitude
public int getFinalAltitude()get final altitude -
getFinalVelocity
public int getFinalVelocity() -
getFinalVelocityLeft
public int getFinalVelocityLeft() -
getFinalNDown
public int getFinalNDown() -
getFinalConversionMode
If the path contains mode conversions, this will determine the movement mode at the end of movement. Note that LAMs converting from AirMek to Biped mode require two convert commands.- Returns:
- The movement mode resulting from any mode conversions in the path.
-
getFinalVectors
public int[] getFinalVectors()Returns the final vector for advanced movement -
getLastStepMovementType
-
getStepVector
-
getLastStep
-
getSecondLastStep
-
printAllSteps
Deprecated, for removal: This API element is subject to removal in a future version. -
clipToPossible
public void clipToPossible()Removes impossible steps. -
lateralShiftForTurn
Returns the lateral shift that corresponds to the turn direction -
getDirection
Returns the direction (either MovePath.MoveStepType.TURN_LEFT or MoveStepType.TURN_RIGHT) that the destination facing lies in. -
getAdjustedFacing
Returns the adjusted facing, given the start facing. -
getMpUsed
public int getMpUsed()Returns the number of MPs used in the path -
getHexesMoved
public int getHexesMoved()Returns the logical number of hexes moved the path (does not count turns, etc.). -
getDistanceTravelled
public int getDistanceTravelled()Returns the linear distance between the first and last hexes in the path. -
isJumping
public boolean isJumping()Returns true if the entity is jumping or if it's a flying lam. -
isChangingMode
Deprecated, for removal: This API element is subject to removal in a future version.- Returns:
- true if the entity is a QuadVee or LAM changing movement mode
-
findSimplePathTo
Extend the current path to the destinationCoords, moving only in one direction. This method works by applying the supplied move step as long as it moves closer to the destination. If the destination cannot be reached solely by the provided move step, the pathfinder will quit once it gets as closer as it can. Only used for Mek Mechanical Jump Boosters.- Parameters:
dest- the destinationCoordsof the move.type- the type of movement step required.direction- the direction of movement.
-
findPathTo
Extend the current path to the destinationCoords.- Parameters:
dest- the destinationCoordsof the move.type- the type of movement step required.
-
isMoveLegal
public boolean isMoveLegal() -
getNextMoves
Returns a list of possible moves that result in a facing/position/(jumping|prone) change, special steps (mine clearing and such) must be handled elsewhere. -
clone
Clones this path, will contain a new clone of the steps so that the clone is independent of the original. -
copyFields
-
rotatePathfinder
public void rotatePathfinder(int destFacing, boolean isManeuver, int maneuverType) Rotate from the current facing to the destination facing. -
shouldMechanicalJumpCauseFallDamage
public boolean shouldMechanicalJumpCauseFallDamage()- Returns:
- true if a jump using mechanical jump boosters would cause falling damage. Mechanical jump boosters are only designed to handle the stress of falls from a height equal to their jumpMP; if a jump has a fall that is further than the jumpMP of the unit, fall damage applies.
-
getJumpPathHighestPoint
Returns the highest elevation along a jump path. -
getJumpMaxElevationChange
public int getJumpMaxElevationChange()Returns the distance between the highest elevation in the jump path and the elevation at the landing point. This gives the largest distance the unit has fallen during the jump. -
willCrushBuildings
public boolean willCrushBuildings()- Returns:
- TRUE if there are any buildings in a dropship's landing zone.
-
automaticWiGELanding
public boolean automaticWiGELanding(boolean includeMovePathHexes) Airborne WiGEs that move less than five hexes (four for glider protomek) in a movement phase must land unless it has taken off in the same phase, jumped, or it is a LAM or glider ProtoMek that is using hover movement.- Parameters:
includeMovePathHexes- Whether to include the hexes plotted in this MovePath in the total distance moved. This should be true when plotting movement in the client and false when the server checks for automatic landing at the end of movement.- Returns:
- whether the unit is an airborne WiGE that must land at the end of movement.
-
isAllUnderwater
- Returns:
- Whether the entire path is submerged. A unit is only considered submerged when entirely underwater.
-
getSecondFinalPosition
-
isCareful
public boolean isCareful() -
setCareful
public void setCareful(boolean b) -
countMp
public int countMp(boolean jumping) -
addSteps
-
replaceSteps
-
isEndStep
-
isOnAtmosphericGroundMap
public boolean isOnAtmosphericGroundMap()Convenience method to determine whether this path is happening on a ground map with an atmosphere -
setVTOLBombStep
Searches the movement path for the first step that has the given position and sets it as a VTOL bombing step. If found, any previous bombing step is cleared. If the coordinates are not part of the path nothing is changed.- Parameters:
pos- TheCoordsof the hex to be bombed.
-
setStrafingStep
Searches the path for the firstMoveStepthat matches the given position and sets it as a strafing step. In cases where there are multiple steps with the same coordinates, we want the first one because it is the one that enters the hex. In the rare case where the path crosses itself, select the one closest to the end of the path.FIXME: this does not deal with paths that cross themselves
- Parameters:
pos- TheCoordsof the hex to be strafed
-
getDroppedUnits
- Returns:
- A list of entity ids for all units that have previously been plotted to be dropped/launched.
-
nextForwardStepOffBoard
public boolean nextForwardStepOffBoard()Convenience function encapsulating logic for whether, if we continue forward along the current path in the current direction, we will run off the board -
getEndStepCount
Worker function that counts the number of steps of the given type at the end of the given path before another step type occurs. -
getMaxMP
public int getMaxMP()- Returns:
- The maximum MP based on the current movement type of this path, including sprint if available
-
equals
-
hashCode
public int hashCode() -
setFlightPathHex
-
getFlightPathHex
-