if(climbMode()) { setElevation(Math.max(getElevation(), hex.terrainLevel(Terrains.BRIDGE_ELEV))); }
    protected void compile(final IGame game, final Entity entity, MoveStep prev)    {        final boolean isInfantry = entity instanceof Infantry;        copy(game, prev);        // Is this the first step?        if (prev == null) {            setFirstStep( true );            prev = new MoveStep(parent, MovePath.STEP_FORWARDS);            prev.setFromEntity(entity, game);        }        IHex destHex = game.getBoard().getHex(getPosition());        switch (getType()) {            case MovePath.STEP_UNLOAD :                // Infantry in immobilized transporters get                // a special "unload stranded" game turn.                hasEverUnloaded=true;                setMp(1);                break;            case MovePath.STEP_LOAD :                setMp(1);                break;            case MovePath.STEP_TURN_LEFT :            case MovePath.STEP_TURN_RIGHT :                // Check for pavement movement.                if (Compute.canMoveOnPavement(game, prev.getPosition(),                                              getPosition())) {                    setPavementStep(true);                } else {                    setPavementStep(false);                    setOnlyPavement(false);                }                // Infantry can turn for free.                setMp( ( parent.isJumping() || isHasJustStood()                         || isInfantry ) ? 0 : 1 );                adjustFacing(getType());                break;            case MovePath.STEP_FORWARDS :            case MovePath.STEP_BACKWARDS :            case MovePath.STEP_CHARGE :            case MovePath.STEP_DFA :                // step forwards or backwards                if (getType() == MovePath.STEP_BACKWARDS) {                    moveInDir((getFacing() + 3) % 6);                    setThisStepBackwards(true);                    setRunProhibited(true);                } else {                    moveInDir(getFacing());                    setThisStepBackwards(false);                }                // Check for pavement movement.                if (Compute.canMoveOnPavement(game, prev.getPosition(),                                              getPosition())) {                    setPavementStep(true);                } else {                    setPavementStep(false);                    setOnlyPavement(false);                }                // check for water                if (!isPavementStep()                        && destHex.terrainLevel(Terrains.WATER) > 0                        && !(destHex.containsTerrain(Terrains.ICE) && elevation >= 0)                        && entity.getMovementMode() != IEntityMovementMode.HOVER                        && entity.getMovementMode() != IEntityMovementMode.NAVAL                        && entity.getMovementMode() != IEntityMovementMode.HYDROFOIL                        && entity.getMovementMode() != IEntityMovementMode.SUBMARINE                        && entity.getMovementMode() != IEntityMovementMode.VTOL) {                    setRunProhibited(true);                }                setHasJustStood(false);                if (prev.isThisStepBackwards() != isThisStepBackwards()) {                    setDistance(0); //start over after shifting gears                }                addDistance(1);                if(getType() == MovePath.STEP_DFA) {                    setElevation(1 + Math.max(entity.elevationOccupied(game.getBoard().getHex(prev.getPosition())), entity.elevationOccupied(game.getBoard().getHex(getPosition()))));                } else if (parent.isJumping()) {                    IHex hex = game.getBoard().getHex(getPosition());                    setElevation(Math.max(-hex.depth(), hex.terrainLevel(Terrains.BLDG_ELEV)));                } else {                    setElevation(entity.calcElevation(game.getBoard().getHex(prev.getPosition()),game.getBoard().getHex(getPosition()),elevation, climbMode()));                }                calcMovementCostFor(game, prev.getPosition(), prev.getElevation());                break;            case MovePath.STEP_LATERAL_LEFT :            case MovePath.STEP_LATERAL_RIGHT :            case MovePath.STEP_LATERAL_LEFT_BACKWARDS :            case MovePath.STEP_LATERAL_RIGHT_BACKWARDS :                if (getType() == MovePath.STEP_LATERAL_LEFT_BACKWARDS                    || getType() == MovePath.STEP_LATERAL_RIGHT_BACKWARDS) {                    moveInDir(                        (MovePath                            .getAdjustedFacing(                                getFacing(),                                MovePath.turnForLateralShift(getType()))                            + 3)                            % 6);                    setThisStepBackwards(true);                    setRunProhibited(true);                } else {                    moveInDir(                        MovePath.getAdjustedFacing(                            getFacing(),                            MovePath.turnForLateralShift(getType())));                    setThisStepBackwards(false);                }                // Check for pavement movement.                if (Compute.canMoveOnPavement(game, prev.getPosition(),                                              getPosition())) {                    setPavementStep(true);                } else {                    setPavementStep(false);                    setOnlyPavement(false);                }                calcMovementCostFor(game, prev.getPosition(), prev.getElevation());                setMp(getMp() + 1);                // check for water                if (!isPavementStep() &&                    destHex.terrainLevel(Terrains.WATER) > 0                    && !(destHex.containsTerrain(Terrains.ICE) && elevation >= 0)                    && !(entity.getMovementMode() == IEntityMovementMode.VTOL)) {                    setRunProhibited(true);                }                setHasJustStood(false);                if (prev.isThisStepBackwards() != isThisStepBackwards()) {                    setDistance(0); //start over after shifting gears                }                addDistance(1);                break;            case MovePath.STEP_GET_UP :                // mechs with 1 MP are allowed to get up                setMp(entity.getRunMP() == 1 ? 1 : 2);                setHasJustStood(true);                break;            case MovePath.STEP_GO_PRONE :                setMp(1);                break;            case MovePath.STEP_START_JUMP :                break;            case MovePath.STEP_UP :                setElevation(elevation+1);                setMp(1);                break;            case MovePath.STEP_DOWN :                 setElevation(elevation-1);                setMp(1);                break;            case MovePath.STEP_HULL_DOWN :            	setMp(2);            	break;            case MovePath.STEP_CLIMB_MODE_ON:                setClimbMode(true);                break;            case MovePath.STEP_CLIMB_MODE_OFF:                setClimbMode(false);                break;            default :                setMp(0);        }        // Update the entity's total MP used.        addMpUsed(getMp());        int magmaLevel = destHex.terrainLevel(Terrains.MAGMA);        // Check for fire or magma crust in the new hex.        if (destHex.containsTerrain(Terrains.FIRE) || magmaLevel == 1) {            heat = 2;            totalHeat += 2;        }        // Check for liquid magma        else if(magmaLevel == 2) {            heat = 5;            totalHeat += 5;        }        // Check for a stacking violation.        final Entity violation =            Compute.stackingViolation( game, entity.getId(), getPosition() );        if ( violation != null             && getType() != MovePath.STEP_CHARGE             && getType() != MovePath.STEP_DFA ) {            setStackingViolation(true);        }        // set moveType, illegal, trouble flags        this.compileIllegal(game, entity, prev);    }