findParkingSpots
Definition
-- @/lua/ge/extensions/gameplay/parking.lua:167
local function findParkingSpots(pos, minRadius, maxRadius) -- finds and returns a sorted array of parking spot objects and distances
if not sites then return {} end
pos = pos or core_camera.getPosition()
minRadius = minRadius or 0
maxRadius = maxRadius or areaRadius
local psList = sites:getRadialParkingSpots(pos, minRadius, maxRadius)
-- each entry in psList contains: v.ps (parking spot object), v.squaredDistance (squared distance to parking spot)
if M.debugLevel > 0 then
log("I", logTag, string.format("Found and validated %d parking spots in area", #psList))
end
table.sort(psList, function(a, b) return a.squaredDistance < b.squaredDistance end) -- sorts from closest to farthest
return psList
end
Callers
@/lua/ge/extensions/gameplay/parking.lua
maxDist = maxDist or 10000
psList = psList or findParkingSpots(focus and focus.pos, minDist, maxDist)
repeat -- find enough parking spots in the area
psList = findParkingSpots(originPos or core_camera.getPosition(), minDist, radius)
if psList[1] then
local psList = findParkingSpots(obj:getPosition(), 0, 15)
if psList[1] and psList[1].ps:vehicleFits(vehId) and psList[1].ps:checkParking(vehId, vars.precision) then
if vehData.focusPos:squaredDistance(vehData.aheadPos) >= square(maxDist * 0.5) then -- focus pos and nearby parking spots low frequency update
vehData.psList = findParkingSpots(vehData.aheadPos, 0, maxDist)
vehData.psList = filterParkingSpots(vehData.psList, emptyFilters)
currParkingSpots = findParkingSpots(aheadPos, 0, areaRadius)
currParkingSpots = filterParkingSpots(currParkingSpots)