megamek.common
Class MoveStep

java.lang.Object
  extended by megamek.common.MoveStep
All Implemented Interfaces:
java.io.Serializable

public class MoveStep
extends java.lang.Object
implements java.io.Serializable

A single step in the entity's movment.

See Also:
Serialized Form

Field Summary
(package private)  java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> launched
           
 
Constructor Summary
MoveStep(MovePath path, MovePath.MoveStepType type)
          Create a step of the given type.
MoveStep(MovePath path, MovePath.MoveStepType type, boolean noCost)
           
MoveStep(MovePath path, MovePath.MoveStepType type, boolean noCost, boolean isManeuver)
           
MoveStep(MovePath path, MovePath.MoveStepType type, int mineToLay)
          Create a step with the given mine to lay.
MoveStep(MovePath path, MovePath.MoveStepType type, int recovery, int mineToLay)
           
MoveStep(MovePath path, MovePath.MoveStepType type, int recovery, int mineToLay, int manType)
           
MoveStep(MovePath path, MovePath.MoveStepType type, Minefield mf)
           
MoveStep(MovePath path, MovePath.MoveStepType type, Targetable target)
          Create a step with the given target.
MoveStep(MovePath path, MovePath.MoveStepType type, java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> targets)
          Create a step with the units to launch or drop.
 
Method Summary
 void addDistance(int increment)
          Adds a certain amount to the distance parameter.
 void addMpUsed(int increment)
          Adds a certain amount to the mpUsed parameter.
 void adjustFacing(MovePath.MoveStepType stepType)
          Adjusts facing to comply with the type of step indicated.
protected  void calcMovementCostFor(IGame game, Coords prev, int prevEl)
          Amount of movement points required to move from start to dest
 boolean canAeroTurn(IGame game)
          can this aero turn for any reason in atmosphere?
 boolean canReuseSprite(MoveStep other)
           
 boolean climbMode()
           
protected  void compile(IGame game, Entity entity, MoveStep prev)
          Compile the static move data for this step.
 void copy(IGame game, MoveStep prev)
          Takes the given state as the previous state and sets flags from it.
 boolean dueFreeTurn()
           
 int getAltitude()
           
 int getDistance()
           
 int getElevation()
           
 int getFacing()
           
 int getHeat()
           
 java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> getLaunched()
           
 int getLeapDistance()
           
 int getManeuverType()
           
 Minefield getMinefield()
           
 int getMineToLay()
           
 EntityMovementType getMovementType()
          Return this step's movement type.
 int getMp()
          Returns the mp used for just this step.
 int getMpUsed()
           
 int getNDown()
           
 int getNMoved()
           
 int getNRolls()
           
 int getNStraight()
           
 int getNTurns()
           
 MovePath getParent()
           
 MovePath getParentUpToThisStep()
          get a copy of this MoveStep's parent, but only upto this step
 Coords getPosition()
           
 int getRecoveryUnit()
           
 Targetable getTarget(IGame game)
          Get the target of the current step.
 int getTargetNumberMASC()
           
 int getTotalHeat()
           
 MovePath.MoveStepType getType()
           
 int[] getVectors()
           
 int getVelocity()
           
 int getVelocityLeft()
           
 int getVelocityN()
           
 boolean hasFreeTurn()
           
 boolean hasNoCost()
           
 boolean isDanger()
           
 boolean isEvading()
           
 boolean isFirstStep()
           
 boolean isFlying()
          Returns true if the entity is flying on this step.
 boolean isHasJustStood()
           
 boolean isHullDown()
           
 boolean isLegal()
          Determine if this is a legal step.
 boolean isLegalEndPos()
          Check to see if this step's position is a valid end of a path.
 boolean isManeuver()
           
 boolean isMovementPossible(IGame game, Coords src, int srcEl)
          Is movement possible from a previous position to this one?
 boolean isOffBoard()
           
 boolean isOnlyPavement()
           
 boolean isPastDanger()
           
 boolean isPavementStep()
           
 boolean isPrevStepOnPavement()
           
 boolean isProne()
           
 boolean isRolled()
           
(package private)  boolean isRunProhibited()
           
(package private)  boolean isStackingViolation()
           
 boolean isThisStepBackwards()
           
 boolean isTurning()
           
 boolean isUnloaded()
           
 boolean isUsingMASC()
           
 void moveInDir(int dir)
          Moves the position one hex in the direction indicated.
(package private)  boolean oppositeTurn(MoveStep turn2)
          Returns whether the two step types contain opposite turns
 void reverseFacing()
          For yaws, reverse the current facing
 void setAltitude(int alt)
           
 void setClimbMode(boolean b)
           
 void setDanger(boolean b)
           
 void setDistance(int i)
           
 void setElevation(int el)
           
 boolean setEndPos(boolean isEnd)
          Update this step's status as the ending position of a path.
 void setEvading(boolean b)
           
 void setFacing(int i)
           
 void setFirstStep(boolean b)
           
 void setFlying(boolean b)
          Sets whether the entity is flying or not.
 void setFreeTurn(boolean b)
           
 void setFromEntity(Entity entity, IGame game)
          Sets this state as coming from the entity.
 void setHasJustStood(boolean b)
           
 void setHullDown(boolean b)
           
 void setLeapDistance(int i)
           
 void setMineToLay(int mineId)
           
 void setMovementType(EntityMovementType i)
           
 void setMp(int i)
          sets the mp for this step.
 void setNDown(int i)
           
 void setNMoved(int moved)
           
 void setNRolls(int rolls)
           
 void setNStraight(int i)
           
 void setNTurns(int turns)
           
 void setOffBoard(boolean b)
           
 void setOnlyPavement(boolean b)
           
(package private)  void setParent(MovePath path)
           
 void setPavementStep(boolean b)
           
 void setProne(boolean b)
           
 void setRecoveryUnit(int i)
           
(package private)  void setRunProhibited(boolean isRunProhibited)
           
(package private)  void setStackingViolation(boolean isStackingViolation)
           
 void setTarget(Targetable target)
          Set the target of the current step.
 void setTargetNumberMASC(int i)
           
 void setThisStepBackwards(boolean b)
           
 void setTurning(boolean b)
           
 void setUnloaded(boolean b)
           
 void setUsingMASC(boolean b)
           
 void setVectors(int[] v)
           
 void setVelocity(int vel)
           
 void setVelocityLeft(int vel)
           
 void setVelocityN(int vel)
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

launched

java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> launched
Constructor Detail

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type)
Create a step of the given type.

Parameters:
type - - should match one of the MovePath constants, but this is not currently checked.

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                Targetable target)
Create a step with the given target.

Parameters:
type - - should match one of the MovePath constants, but this is not currently checked.
target - - the Targetable that is the target of this step. For example, the enemy being charged.

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                int mineToLay)
Create a step with the given mine to lay.

Parameters:
path -
type - - should match one of the MovePath constants, but this is not currently checked.
mineToLay - - the int that is the id of the mine that should be laid in this step.

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> targets)
Create a step with the units to launch or drop.

Parameters:
path -
type - - should match one of the MovePath constants, but this is not currently checked.
targets - - vector of integers identifying the entities to launch

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                int recovery,
                int mineToLay)

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                boolean noCost)

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                boolean noCost,
                boolean isManeuver)

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                int recovery,
                int mineToLay,
                int manType)

MoveStep

public MoveStep(MovePath path,
                MovePath.MoveStepType type,
                Minefield mf)
Method Detail

setParent

void setParent(MovePath path)

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

getType

public MovePath.MoveStepType getType()

getParent

public MovePath getParent()

getParentUpToThisStep

public MovePath getParentUpToThisStep()
get a copy of this MoveStep's parent, but only upto this step

Returns:

setTarget

public void setTarget(Targetable target)
Set the target of the current step.

Parameters:
target - - the Targetable that is the target of this step. For example, the enemy being charged. If there is no target, pass a null

getTarget

public Targetable getTarget(IGame game)
Get the target of the current step.

Parameters:
game - - The Game object.
Returns:
The Targetable that is the target of this step. For example, the enemy being charged. This value may be null

getLaunched

public java.util.TreeMap<java.lang.Integer,java.util.Vector<java.lang.Integer>> getLaunched()

compile

protected void compile(IGame game,
                       Entity entity,
                       MoveStep prev)
Compile the static move data for this step.

Parameters:
game - the Game being played.
entity - the Entity taking this step.
prev - the previous step in the path.

oppositeTurn

boolean oppositeTurn(MoveStep turn2)
Returns whether the two step types contain opposite turns


setElevation

public void setElevation(int el)

setAltitude

public void setAltitude(int alt)

copy

public void copy(IGame game,
                 MoveStep prev)
Takes the given state as the previous state and sets flags from it.

Parameters:
game -
prev -

setFromEntity

public void setFromEntity(Entity entity,
                          IGame game)
Sets this state as coming from the entity.

Parameters:
entity -

adjustFacing

public void adjustFacing(MovePath.MoveStepType stepType)
Adjusts facing to comply with the type of step indicated.

Parameters:
stepType -

reverseFacing

public void reverseFacing()
For yaws, reverse the current facing


moveInDir

public void moveInDir(int dir)
Moves the position one hex in the direction indicated. Does not change facing.

Parameters:
dir -

addDistance

public void addDistance(int increment)
Adds a certain amount to the distance parameter.

Parameters:
increment -

addMpUsed

public void addMpUsed(int increment)
Adds a certain amount to the mpUsed parameter.

Parameters:
increment -

isDanger

public boolean isDanger()
Returns:

getDistance

public int getDistance()
Returns:

getLeapDistance

public int getLeapDistance()
Returns:

getFacing

public int getFacing()
Returns:

isFirstStep

public boolean isFirstStep()
Returns:

isHasJustStood

public boolean isHasJustStood()
Returns:

isPavementStep

public boolean isPavementStep()

isProne

public boolean isProne()
Returns:

isFlying

public boolean isFlying()
Returns true if the entity is flying on this step.

Returns:

isHullDown

public boolean isHullDown()

climbMode

public boolean climbMode()

isTurning

public boolean isTurning()
Returns:

isUnloaded

public boolean isUnloaded()
Returns:

isUsingMASC

public boolean isUsingMASC()
Returns:

isEvading

public boolean isEvading()

isRolled

public boolean isRolled()

isLegal

public boolean isLegal()
Determine if this is a legal step.

Returns:
true if the step is legal. false otherwise.

getMovementType

public EntityMovementType getMovementType()
Return this step's movement type.

Returns:
the int constant for this step's movement type.

isLegalEndPos

public boolean isLegalEndPos()
Check to see if this step's position is a valid end of a path.

Returns:
true if this step's position is a legal end of a path. If the step is not legal for an end of a path, then false is returned.

setEndPos

public boolean setEndPos(boolean isEnd)
Update this step's status as the ending position of a path.

Parameters:
isEnd - the boolean flag that specifies that this step's position is the end of a path.
Returns:
true if the path needs to keep updating the steps. false if the update of the path is complete.
See Also:
#isLegalEndPos(), #isEndPos, MovePath#addStep( MoveStep )

getMpUsed

public int getMpUsed()
Returns:

isOnlyPavement

public boolean isOnlyPavement()
Returns:

isPastDanger

public boolean isPastDanger()
Returns:

getPosition

public Coords getPosition()
Returns:

isPrevStepOnPavement

public boolean isPrevStepOnPavement()
Returns:

getTargetNumberMASC

public int getTargetNumberMASC()
Returns:

isThisStepBackwards

public boolean isThisStepBackwards()
Returns:

setDanger

public void setDanger(boolean b)
Parameters:
b -

setDistance

public void setDistance(int i)
Parameters:
i -

setLeapDistance

public void setLeapDistance(int i)
Parameters:
i -

setFacing

public void setFacing(int i)
Parameters:
i -

setFirstStep

public void setFirstStep(boolean b)
Parameters:
b -

setHasJustStood

public void setHasJustStood(boolean b)
Parameters:
b -

setPavementStep

public void setPavementStep(boolean b)
Parameters:
b -

setProne

public void setProne(boolean b)
Parameters:
b -

setFlying

public void setFlying(boolean b)
Sets whether the entity is flying or not.

Parameters:
b - is this entity flying?

setHullDown

public void setHullDown(boolean b)

setClimbMode

public void setClimbMode(boolean b)

setTurning

public void setTurning(boolean b)
Parameters:
b -

setUnloaded

public void setUnloaded(boolean b)
Parameters:
b -

setUsingMASC

public void setUsingMASC(boolean b)
Parameters:
b -

setMovementType

public void setMovementType(EntityMovementType i)
Parameters:
i -

setEvading

public void setEvading(boolean b)

setOnlyPavement

public void setOnlyPavement(boolean b)
Parameters:
b -

setTargetNumberMASC

public void setTargetNumberMASC(int i)

setThisStepBackwards

public void setThisStepBackwards(boolean b)

getMp

public int getMp()
Returns the mp used for just this step.


setMp

public void setMp(int i)
sets the mp for this step.

Parameters:
i - the mp for this step.

setRunProhibited

void setRunProhibited(boolean isRunProhibited)

isRunProhibited

boolean isRunProhibited()

setStackingViolation

void setStackingViolation(boolean isStackingViolation)

isStackingViolation

boolean isStackingViolation()

getTotalHeat

public int getTotalHeat()

getHeat

public int getHeat()

calcMovementCostFor

protected void calcMovementCostFor(IGame game,
                                   Coords prev,
                                   int prevEl)
Amount of movement points required to move from start to dest


isMovementPossible

public boolean isMovementPossible(IGame game,
                                  Coords src,
                                  int srcEl)
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.


canReuseSprite

public boolean canReuseSprite(MoveStep other)

getElevation

public int getElevation()

getAltitude

public int getAltitude()

getMineToLay

public int getMineToLay()

setMineToLay

public void setMineToLay(int mineId)

setVelocity

public void setVelocity(int vel)

getVelocity

public int getVelocity()

setVelocityN

public void setVelocityN(int vel)

getVelocityN

public int getVelocityN()

setVelocityLeft

public void setVelocityLeft(int vel)

getVelocityLeft

public int getVelocityLeft()

setNTurns

public void setNTurns(int turns)

getNTurns

public int getNTurns()

setNMoved

public void setNMoved(int moved)

getNMoved

public int getNMoved()

setNRolls

public void setNRolls(int rolls)

getNRolls

public int getNRolls()

setOffBoard

public void setOffBoard(boolean b)

isOffBoard

public boolean isOffBoard()

getVectors

public int[] getVectors()

setVectors

public void setVectors(int[] v)

hasFreeTurn

public boolean hasFreeTurn()

setFreeTurn

public void setFreeTurn(boolean b)

getNStraight

public int getNStraight()

setNStraight

public void setNStraight(int i)

canAeroTurn

public boolean canAeroTurn(IGame game)
can this aero turn for any reason in atmosphere?


dueFreeTurn

public boolean dueFreeTurn()

setNDown

public void setNDown(int i)

getNDown

public int getNDown()

getRecoveryUnit

public int getRecoveryUnit()

setRecoveryUnit

public void setRecoveryUnit(int i)

getManeuverType

public int getManeuverType()

hasNoCost

public boolean hasNoCost()

isManeuver

public boolean isManeuver()

getMinefield

public Minefield getMinefield()