} else { while(elevation >= -hex.depth()) { if(unit.isElevationValid(elevation, hex)) { unit.setElevation(elevation); break; } elevation--; unit.moved = IEntityMovementType.MOVE_JUMP; } if(!unit.isElevationValid(elevation, hex)) { return false; }
    private boolean unloadUnit( Entity unloader, Targetable unloaded,                             Coords pos, int facing, int elevation ) {        // We can only unload Entities.        Entity unit = null;        if ( unloaded instanceof Entity ) {            unit = (Entity) unloaded;        } else {            return false;        }        // Unload the unit.        if ( !unloader.unload( unit ) ) {            return false;        }        // The unloaded unit is no longer being carried.        unit.setTransportId( Entity.NONE );        // Place the unloaded unit onto the screen.        unit.setPosition( pos );        // Units unloaded onto the screen are deployed.        if ( pos != null ) {            unit.setDeployed( true );        }        // Point the unloaded unit in the given direction.        unit.setFacing( facing );        unit.setSecondaryFacing( facing );        IHex hex = game.getBoard().getHex(pos);        boolean isBridge = hex.containsTerrain(Terrains.PAVEMENT);        if (unloader.getMovementMode() == IEntityMovementMode.VTOL) {            if (unit.getMovementMode() == IEntityMovementMode.VTOL) {                // Flying units onload to the same elevation as the flying transport                unit.setElevation(elevation);            } else if (game.getBoard().getBuildingAt(pos) != null) {                // non-flying unit onloaded from a flying onto a building                // -> sit on the roff                unit.setElevation(hex.terrainLevel(Terrains.BLDG_ELEV));            }        } else if (game.getBoard().getBuildingAt(pos) != null) {            // non flying unit unloading units into a building            // -> sit in the building at the same elevation            unit.setElevation(elevation);        } else if (hex.terrainLevel(Terrains.WATER)>0) {            if (unit.getMovementMode() == IEntityMovementMode.HOVER ||                unit.getMovementMode() == IEntityMovementMode.HYDROFOIL ||                unit.getMovementMode() == IEntityMovementMode.NAVAL ||                unit.getMovementMode() == IEntityMovementMode.SUBMARINE ||                unit.getMovementMode() == IEntityMovementMode.INF_UMU ||                hex.containsTerrain(Terrains.ICE) ||                isBridge) {                // units that can float stay on the surface, or we go on the bridge                // this means elevation 0, because elevation is relative to the surface                unit.setElevation(0);            }        } else {            // default to the floor of the hex.            // unit elevation is relative to the surface            unit.setElevation(hex.floor() - hex.surface());        }        doSetLocationsExposure(unit, hex, false, unit.getElevation());        // Update the unloaded unit.        entityUpdate( unit.getId() );        // Unloaded successfully.        return true;    }