walkableplatform does not get affected by platform_radius in Map component


Asura_Dis
  • Fixed

The walkableplatform component has a platform_radius property that is not used in some places for some reason, making it impossible to create custom boats or change size of platforms. 
Map component functions that need to change hard-coded values to platform_radius are:
GetPlatformAtPoint, IsPassableAtPointWithPlatformRadiusBias, CanDeployAtPointInWater

 Here's a way to fix it:

Spoiler

function GetPlatformAtPoint(pos_x, pos_y, pos_z, extra_radius)
    if pos_z == nil then -- to support passing in (x, z) instead of (x, y, x)
        pos_z = pos_y
        pos_y = 0
    end
    local entities = TheSim:FindEntities(pos_x, pos_y, pos_z, TUNING.MAX_WALKABLE_PLATFORM_RADIUS + (extra_radius or 0), WALKABLE_PLATFORM_TAGS)
    for i, v in ipairs(entities) do
        if v.components.walkableplatform and math.sqrt(v:GetDistanceSqToPoint(pos_x, 0, pos_z)) <= v.components.walkableplatform.platform_radius then
            return v 
        end
    end
    return nil
end

function IsPassableAtPointWithPlatformRadiusBias(x, y, z, allow_water, exclude_boats, platform_radius_bias, ignore_land_overhang)
    local valid_tile = self:IsAboveGroundAtPoint(x, y, z, allow_water)
    local is_overhang = false
    if not valid_tile then
        valid_tile = ((not ignore_land_overhang) and self:IsVisualGroundAtPoint(x,y,z) or false)
        if valid_tile then
            is_overhang = true
        end
    end
    if not allow_water and not valid_tile then
        if not exclude_boats then
            local entities = TheSim:FindEntities(x, 0, z, TUNING.MAX_WALKABLE_PLATFORM_RADIUS + platform_radius_bias, WALKABLE_PLATFORM_TAGS)
            for i, v in ipairs(entities) do
                local walkable_platform = v.components.walkableplatform
                if walkable_platform and math.sqrt(v:GetDistanceSqToPoint(x, 0, z)) <= (walkable_platform.platform_radius + platform_radius_bias) then
                    local platform_x, platform_y, platform_z = v.Transform:GetWorldPosition()
                    local distance_sq = VecUtil_LengthSq(x - platform_x, z - platform_z)
                    return distance_sq <= walkable_platform.platform_radius * walkable_platform.platform_radius
                end
            end
        end
        return false
    end
    return valid_tile, is_overhang
end

function CanDeployAtPointInWater(pt, inst, mouseover, data)
    local tile = self:GetTileAtPoint(pt.x, pt.y, pt.z)
    if tile == GROUND.IMPASSABLE or tile == GROUND.INVALID then
        return false
    end

    -- check if there's a boat in the way
    local min_distance_from_boat = (data and data.boat) or 0
    local radius = (data and data.radius) or 0
    local entities = TheSim:FindEntities(pt.x, 0, pt.z, TUNING.MAX_WALKABLE_PLATFORM_RADIUS + radius + min_distance_from_boat, WALKABLE_PLATFORM_TAGS)
    for i, v in ipairs(entities) do
        if v.components.walkableplatform and math.sqrt(v:GetDistanceSqToPoint(pt.x, 0, pt.z)) <= (v.components.walkableplatform.platform_radius + radius + min_distance_from_boat) then
            return false
        end
    end

    local min_distance_from_land = (data and data.land) or 0

    return (mouseover == nil or mouseover:HasTag("player"))
        and self:IsDeployPointClear(pt, nil, min_distance_from_boat + radius)
        and self:IsSurroundedByWater(pt.x, pt.y, pt.z, min_distance_from_land + radius)
end



!!!!!!!!!!!!!!!!!!!!IT"S IMPORTANT!!!!!!!!!!!!!!!!!!!!!!
-You also should increase TUNING.MAX_WALKABLE_PLATFORM_RADIUS

 


Steps to Reproduce

Try to create a boat with custom size
 

  • Like 5
  • Sad 1


User Feedback


A developer has marked this issue as fixed. This means that the issue has been addressed in the current development build and will likely be in the next update.


Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now