Package megamek.common.moves
Class MoveStep
java.lang.Object
megamek.common.moves.MoveStep
- All Implemented Interfaces:
Serializable
A single step in the entity's movement. Since the path planner uses shallow copies of MovePaths, multiple paths may
share the same MoveStep, so this class needs to be agnostic of what path it belongs to.
- Since:
- Aug 28, 2003
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final intstatic final intAdditional int data keys for a BUILD_BRIDGE step (keys are scoped per step type): the target hex coordinates, the exits bitmask of the two connected hexsides, and the bridge type (light/medium).static final intstatic final intstatic final intWhen supplying additional int data, use this to key the location of the cargo being picked up (i.e.static final intWhen supplying additional int data, use this to key the index of the cargo being picked up -
Constructor Summary
ConstructorsConstructorDescriptionMoveStep(MovePath path, MoveStepType type) Create a step of the given type.MoveStep(MovePath path, MoveStepType type, boolean noCost) MoveStep(MovePath path, MoveStepType type, boolean noCost, boolean isManeuver, int maneuverType) MoveStep(MovePath path, MoveStepType type, int additionalIntData) Create a step with the given mine to lay.MoveStep(MovePath path, MoveStepType type, int recovery, int mineToLay) MoveStep(MovePath path, MoveStepType type, int recovery, int mineToLay, int manType) Creates a step with an arbitrary int-to-int mapping of additional data.Create a step with the units to launch or drop.MoveStep(MovePath path, MoveStepType type, Minefield mf) MoveStep(MovePath path, MoveStepType type, Targetable target) Create a step with the given target.MoveStep(MovePath path, MoveStepType type, Targetable target, Coords pos) Create a step with the given target and a position for that target -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDistance(int increment) voidaddMpUsed(int increment) voidadjustFacing(MoveStepType stepType) Adjusts facing to comply with the type of step indicated.intasfTurnCost(Game game, MoveStepType direction, Entity entity) protected voidcalcMovementCostFor(Game game, MoveStep prevStep, CachedEntityState cachedEntityState) Amount of movement points required to move from start to destbooleancanAeroTurn(Game game) can this aero turn for any reason in atmosphere?booleancanUseSprint(Game game) Helper function to determine whether sprint is available as a game option to the entitybooleanprotected voidcompile(Game game, Entity entity, MoveStep prev, CachedEntityState cachedEntityState) Compile the static move data for this step.voidTakes the given state as the previous state and sets flags from it.static MoveStepcreateChangeBoardMoveStep(MovePath path, Coords finalPosition, int finalBoardId) Deprecated, for removal: This API element is subject to removal in a future version.booleanFor serialization purposesgetAdditionalData(int key) intintintintintintIn hexes with buildings, returns the elevation relative to the roof.intReturns the number of climbing levels actually charged this turn (the player's chosen count, capped at the full delta).intReturns the total remaining levels for this climbing step, used for turn count display.intintintDeprecated.Use getEscapePodLandingCoords() instead for hex-based selectionReturns the landing coordinates for Combat Vehicle Escape Pod launch.intgetGame()intgetHeat()intintgetMovementType(boolean isLastStep) Return this step's movement type.intgetMp()Returns the mp used for just this step.intintgetNDown()intintintintintintGet the target of the current step.intintgetType()int[]intintintintbooleanbooleanbooleanbooleanbooleanbooleanisDanger()booleanbooleanA step is in an end position if it is the last legal step, or is an illegal step past the last legal step.booleanbooleanbooleanbooleanisFlying()static booleanisFortifiableTerrain(Hex hex) Determines whether a hex allows digging in or building a fortified hex.booleanbooleanbooleanbooleanDetermine if this is a legal step as part of the supplied MovePath.booleanCheck to see if this step's position is a valid end of a path.booleanbooleanisMovementPossible(Game game, Coords src, int srcEl, CachedEntityState cachedEntityState) Is movement possible from a previous position to this one?booleanbooleanbooleanbooleanbooleanisProne()booleanisRolled()booleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanbooleanvoidmoveInDir(int dir) voidFor yaws, reverse the current facingprotected voidsetAltitude(int alt) protected voidsetBraceLocation(int value) protected voidsetClimbMode(boolean b) voidsetDanger(boolean b) protected voidsetDistance(int i) voidsetDocking(boolean tf) protected voidsetElevation(int el) booleansetEndPos(boolean isEnd) Update this step's status as the ending position of a path.protected voidsetEvading(boolean b) protected voidsetFacing(int i) protected voidprotected voidsetFreeTurn(boolean b) voidsetFromEntity(Entity entity, Game game) Sets this state as coming from the entity.protected voidsetHasEverUnloaded(boolean b) Deprecated, for removal: This API element is subject to removal in a future version.protected voidsetHasJustStood(boolean b) protected voidsetHullDown(boolean b) voidsetIsClimbing(boolean climbing) protected voidsetLeapDistance(int i) voidprotected voidsetMp(int i) sets the mp for this step.protected voidsetNDown(int i) protected voidsetNMoved(int moved) protected voidsetNRolls(int rolls) protected voidsetNStraight(int i) protected voidsetNTurns(int turns) protected voidsetOffBoard(boolean b) protected voidsetOnlyPavementOrRoad(boolean b) voidsetPastDanger(boolean pastDanger) protected voidsetPavementStep(boolean b) voidprotected voidsetProne(boolean b) protected voidsetRunProhibited(boolean isRunProhibited) protected voidsetSelfDestructing(boolean b) protected voidsetShuttingDown(boolean b) protected voidsetStackingViolation(boolean isStackingViolation) protected voidsetStartingUp(boolean b) voidsetStrafing(boolean strafing) Turns VTOL strafing on or off for this step.voidsetTarget(Targetable target) Set the target of the current step.protected voidsetTargetNumberMASC(int i) protected voidsetTargetNumberSupercharger(int i) protected voidsetThisStepBackwards(boolean b) protected voidsetTurning(boolean b) protected voidsetUnloaded(boolean b) protected voidsetUsingMASC(boolean b) protected voidsetUsingSupercharger(boolean b) protected voidsetVectors(int[] v) protected voidsetVelocity(int vel) protected voidsetVelocityLeft(int vel) protected voidsetVelocityN(int vel) voidsetVTOLBombing(boolean bombing) Turns VTOL bombing on or off for this step.toString()booleanuseSpheroidAtmosphere(Game game, Entity en) Should we treat this movement as if it is occurring for a spheroid unit flying in atmosphere?
-
Field Details
-
CARGO_PICKUP_KEY
public static final int CARGO_PICKUP_KEYWhen supplying additional int data, use this to key the index of the cargo being picked up- See Also:
-
CARGO_LOCATION_KEY
public static final int CARGO_LOCATION_KEYWhen supplying additional int data, use this to key the location of the cargo being picked up (i.e. mek left arm/right arm, vehicle body, etc.)- See Also:
-
BRIDGE_TARGET_X_KEY
public static final int BRIDGE_TARGET_X_KEYAdditional int data keys for a BUILD_BRIDGE step (keys are scoped per step type): the target hex coordinates, the exits bitmask of the two connected hexsides, and the bridge type (light/medium).- See Also:
-
BRIDGE_TARGET_Y_KEY
public static final int BRIDGE_TARGET_Y_KEY- See Also:
-
BRIDGE_EXITS_KEY
public static final int BRIDGE_EXITS_KEY- See Also:
-
BRIDGE_TYPE_KEY
public static final int BRIDGE_TYPE_KEY- See Also:
-
-
Constructor Details
-
MoveStep
Create a step of the given type.- Parameters:
type- - should match one of the MovePath constants, but this is not currently checked.
-
MoveStep
Create a step with the given target and a position for that target- Parameters:
type- - should match one of the MovePath constants, but this is not currently checked.target- - theTargetablethat is the target of this step. For example, the enemy being charged.pos- = theCoordsfor the target position.
-
MoveStep
Create a step with the given target.- Parameters:
type- - should match one of the MovePath constants, but this is not currently checked.target- - theTargetablethat is the target of this step. For example, the enemy being charged.
-
MoveStep
Create a step with the given mine to lay.- Parameters:
path-MovePathto work through.type- should match one of the MovePath constants, but this is not currently checked.additionalIntData- "mineToLay" by default to retain compatibility with existing code "braceLocation" if the move step type is BRACE
-
MoveStep
Creates a step with an arbitrary int-to-int mapping of additional data. -
MoveStep
Create a step with the units to launch or drop. -
MoveStep
-
MoveStep
-
MoveStep
public MoveStep(MovePath path, MoveStepType type, boolean noCost, boolean isManeuver, int maneuverType) -
MoveStep
-
MoveStep
-
-
Method Details
-
createChangeBoardMoveStep
@Deprecated(since="0.51.0", forRemoval=true) public static MoveStep createChangeBoardMoveStep(MovePath path, Coords finalPosition, int finalBoardId) Deprecated, for removal: This API element is subject to removal in a future version. -
isFortifiableTerrain
Determines whether a hex allows digging in or building a fortified hex. Water, pavement, building and road hexes are excluded, as is an already-fortified hex (TO:AR p.106 / TO:AUE p.153). Shared by the move-step legality check and the UI so both agree on the terrain rule.- Parameters:
hex- the hex to test, or null- Returns:
trueif a unit may dig in or fortify in the given hex
-
toString
-
getType
-
setTarget
Set the target of the current step.- Parameters:
target- - theTargetablethat is the target of this step. For example, the enemy being charged. If there is no target, pass anull
-
setVTOLBombing
public void setVTOLBombing(boolean bombing) Turns VTOL bombing on or off for this step. -
setStrafing
public void setStrafing(boolean strafing) Turns VTOL strafing on or off for this step. -
getTarget
Get the target of the current step.- Parameters:
game- The currentGame- Returns:
- The
Targetablethat is the target of this step. For example, the enemy being charged. This value may benull
-
getTargetPosition
-
getAdditionalData
-
getLaunched
-
compile
protected void compile(Game game, Entity entity, MoveStep prev, CachedEntityState cachedEntityState) Compile the static move data for this step.- Parameters:
game- The currentGameentity- theEntitytaking this step.prev- the previous step in the path.
-
setElevation
protected void setElevation(int el) -
setAltitude
protected void setAltitude(int alt) -
copy
Takes the given state as the previous state and sets flags from it. -
setFromEntity
Sets this state as coming from the entity.- Parameters:
entity- Set localEntitywith passed in one.
-
adjustFacing
Adjusts facing to comply with the type of step indicated.- Parameters:
stepType-MoveStepTypeStep to adjust facing to.
-
reverseFacing
public void reverseFacing()For yaws, reverse the current facing -
moveInDir
public void moveInDir(int dir) - Parameters:
dir- Moves the position one hex in the direction indicated. Does not change facing.
-
addDistance
public void addDistance(int increment) - Parameters:
increment- Adds a certain amount to the distance parameter.
-
addMpUsed
public void addMpUsed(int increment) - Parameters:
increment- Adds a certain amount to the mpUsed parameter.
-
isDanger
public boolean isDanger() -
getDistance
public int getDistance() -
getFacing
public int getFacing() -
isFirstStep
public boolean isFirstStep() -
isHasJustStood
public boolean isHasJustStood() -
isPavementStep
public boolean isPavementStep() -
isProne
public boolean isProne() -
isFlying
public boolean isFlying() -
isHullDown
public boolean isHullDown() -
climbMode
public boolean climbMode() -
isClimbing
public boolean isClimbing() -
setIsClimbing
public void setIsClimbing(boolean climbing) -
getClimbingTotalLevels
public int getClimbingTotalLevels()Returns the total remaining levels for this climbing step, used for turn count display. -
getClimbingChargedLevels
public int getClimbingChargedLevels()Returns the number of climbing levels actually charged this turn (the player's chosen count, capped at the full delta). Differs fromgetClimbingTotalLevels()when the player picked a partial climb. Used by the turn-count display to compute non-climbing MP correctly without going negative. -
isTurning
public boolean isTurning() -
isUnloaded
public boolean isUnloaded() -
isUsingMASC
public boolean isUsingMASC() -
isUsingSupercharger
public boolean isUsingSupercharger() -
isUsingMekJumpBooster
public boolean isUsingMekJumpBooster() -
isEvading
public boolean isEvading() -
isSelfDestructing
public boolean isSelfDestructing() -
isRolled
public boolean isRolled() -
isVTOLBombingStep
public boolean isVTOLBombingStep() -
isStrafingStep
public boolean isStrafingStep() -
isLegal
Determine if this is a legal step as part of the supplied MovePath.- Parameters:
path- A MovePath that contains this step.- Returns:
trueif the step is legal.falseotherwise.
-
getMovementType
Return this step's movement type.- Returns:
- the
intconstant for this step's movement type.
-
getMovementMode
-
isLegalEndPos
public boolean isLegalEndPos()Check to see if this step's position is a valid end of a path.- Returns:
trueif this step's position is a legal end of a path. If the step is not legal for an end of a path, thenfalseis returned.
-
setEndPos
public boolean setEndPos(boolean isEnd) Update this step's status as the ending position of a path. SeeisLegalEndPos(),isEndPos(MovePath), andMovePath.addStep(MoveStep)for additional information.- Parameters:
isEnd- thebooleanflag that specifies that this step's position is the end of a path.- Returns:
trueif the path needs to keep updating the steps.falseif the update of the path is complete.
-
isEndPos
A step is in an end position if it is the last legal step, or is an illegal step past the last legal step.- Parameters:
path-MovePathto check- Returns:
- true if a step is considered to be in an end position for the given MovePath.
-
getMpUsed
public int getMpUsed() -
isOnlyPavementOrRoad
public boolean isOnlyPavementOrRoad() -
getWiGEBonus
public int getWiGEBonus() -
getNWigeDescent
public int getNWigeDescent() -
isPastDanger
public boolean isPastDanger() -
setPastDanger
public void setPastDanger(boolean pastDanger) -
isDocking
public boolean isDocking() -
setDocking
public void setDocking(boolean tf) -
getPosition
-
setPosition
-
getTargetNumberMASC
public int getTargetNumberMASC() -
getTargetNumberSupercharger
public int getTargetNumberSupercharger() -
isThisStepBackwards
public boolean isThisStepBackwards() -
setDanger
public void setDanger(boolean b) -
setDistance
protected void setDistance(int i) -
setLeapDistance
protected void setLeapDistance(int i) -
setFacing
protected void setFacing(int i) -
setFirstStep
protected void setFirstStep() -
setHasJustStood
protected void setHasJustStood(boolean b) -
setPavementStep
protected void setPavementStep(boolean b) -
setProne
protected void setProne(boolean b) -
setHullDown
protected void setHullDown(boolean b) -
setClimbMode
protected void setClimbMode(boolean b) -
setTurning
protected void setTurning(boolean b) -
setUnloaded
protected void setUnloaded(boolean b) -
setHasEverUnloaded
Deprecated, for removal: This API element is subject to removal in a future version.This function is POSSIBLY A HACK!DO NOT CALL THIS FUNCTION! I need to find out why this value is being set directly through a couple off functions in the MoveStep compilation process. It should use the
setUnloaded(boolean)but I don't know why it does this instead.- Parameters:
b- sets hasEverUnloaded to this value
-
setUsingMASC
protected void setUsingMASC(boolean b) -
setUsingSupercharger
protected void setUsingSupercharger(boolean b) -
setMovementType
-
setEvading
protected void setEvading(boolean b) -
setShuttingDown
protected void setShuttingDown(boolean b) -
setStartingUp
protected void setStartingUp(boolean b) -
setSelfDestructing
protected void setSelfDestructing(boolean b) -
setOnlyPavementOrRoad
protected void setOnlyPavementOrRoad(boolean b) -
setTargetNumberMASC
protected void setTargetNumberMASC(int i) -
setTargetNumberSupercharger
protected void setTargetNumberSupercharger(int i) -
setThisStepBackwards
protected void setThisStepBackwards(boolean b) -
getMp
public int getMp()Returns the mp used for just this step. -
setMp
protected void setMp(int i) sets the mp for this step.- Parameters:
i- the mp for this step.
-
setRunProhibited
protected void setRunProhibited(boolean isRunProhibited) -
setStackingViolation
protected void setStackingViolation(boolean isStackingViolation) -
getHeat
public int getHeat() -
calcMovementCostFor
protected void calcMovementCostFor(Game game, MoveStep prevStep, CachedEntityState cachedEntityState) Amount of movement points required to move from start to dest -
isMovementPossible
public boolean isMovementPossible(Game game, Coords src, int srcEl, CachedEntityState cachedEntityState) Is movement possible from a previous position to this one?This function does not comment on whether an overall movement path is possible, just whether the current step is possible.
-
getElevation
public int getElevation() -
getClearance
public int getClearance()In hexes with buildings, returns the elevation relative to the roof. Otherwise, returns the elevation relative to the surface.Defensive against a deserialized MoveStep whose transient entity reference exists but whose
Entity.getGame()hasn't been re-bound on the server. Hit by GameDatasetLogger → SharedUtility.getPSRList while logging a freshly-received path. Falls back to raw elevation when game/hex aren't reachable; the dataset metric is best-effort, not authoritative. -
getAltitude
public int getAltitude() -
getMineToLay
public int getMineToLay() -
getEscapePodDistance
Deprecated.Use getEscapePodLandingCoords() instead for hex-based selectionReturns the distance for Combat Vehicle Escape Pod launch (0-4 hexes). Per TO:AUE p.121, the player chooses how far the pod travels behind the vehicle. -
getEscapePodLandingCoords
Returns the landing coordinates for Combat Vehicle Escape Pod launch. Per TO:AUE p.121, the player chooses a hex in the rear arc within 4 hexes.- Returns:
- The landing coordinates, or null if not set
-
getBraceLocation
public int getBraceLocation() -
setBraceLocation
protected void setBraceLocation(int value) -
setVelocity
protected void setVelocity(int vel) -
getVelocity
public int getVelocity() -
setVelocityN
protected void setVelocityN(int vel) -
getVelocityN
public int getVelocityN() -
setVelocityLeft
protected void setVelocityLeft(int vel) -
getVelocityLeft
public int getVelocityLeft() -
asfTurnCost
-
setNTurns
protected void setNTurns(int turns) -
getNTurns
public int getNTurns() -
setNMoved
protected void setNMoved(int moved) -
getNMoved
public int getNMoved() -
setNRolls
protected void setNRolls(int rolls) -
getNRolls
public int getNRolls() -
setOffBoard
protected void setOffBoard(boolean b) -
isOffBoard
public boolean isOffBoard() -
getVectors
public int[] getVectors() -
setVectors
protected void setVectors(int[] v) -
hasFreeTurn
public boolean hasFreeTurn() -
setFreeTurn
protected void setFreeTurn(boolean b) -
getNStraight
public int getNStraight() -
setNStraight
protected void setNStraight(int i) -
canAeroTurn
can this aero turn for any reason in atmosphere? -
dueFreeTurn
public boolean dueFreeTurn() -
setNDown
protected void setNDown(int i) -
getNDown
public int getNDown() -
getRecoveryUnit
public int getRecoveryUnit() -
getManeuverType
public int getManeuverType() -
hasNoCost
public boolean hasNoCost() -
isManeuver
public boolean isManeuver() -
isFacingChangeManeuver
public boolean isFacingChangeManeuver()- Returns:
- Whether this step is a maneuver that allows a free facing change.
-
getMinefield
-
getBridgeTargetCoords
- Returns:
- The hex a BUILD_BRIDGE step raises its bridge in, from the step's additional data, or null if the step does not carry target coordinates.
-
getBridgeExits
public int getBridgeExits()- Returns:
- The exits bitmask of the two hexsides the bridge of a BUILD_BRIDGE step will connect.
-
getBridgeType
public int getBridgeType()- Returns:
- The bridge type of a BUILD_BRIDGE step,
ConvInfantry.BRIDGE_TYPE_LIGHTorConvInfantry.BRIDGE_TYPE_MEDIUM.
-
getAdditionalData
For serialization purposes -
useSpheroidAtmosphere
Should we treat this movement as if it is occurring for a spheroid unit flying in atmosphere? -
getCrushedBuildingLocs
-
getEntity
-
getGame
-
isJumping
public boolean isJumping() -
isCareful
public boolean isCareful() -
canUseSprint
Helper function to determine whether sprint is available as a game option to the entity -
getBoardId
public int getBoardId() -
isClimbMode
public boolean isClimbMode()- Returns:
- True if this move step is a climb mode change (on or off)
-