mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
[Fixed] Disposition.getSimpleZones
This commit is contained in:
parent
03763e16d6
commit
a462c5a493
@ -3803,15 +3803,18 @@ do -- COORDINATE
|
|||||||
-- @param #number SearchRadius Radius of the search area.
|
-- @param #number SearchRadius Radius of the search area.
|
||||||
-- @param #number PosRadius Required clear radius around each position.
|
-- @param #number PosRadius Required clear radius around each position.
|
||||||
-- @param #number NumPositions Number of positions to find.
|
-- @param #number NumPositions Number of positions to find.
|
||||||
-- @return #table A table of Core.Point#COORDINATE that are clear of map objects within the given PosRadius.
|
-- @return #table A table of Core.Point#COORDINATE that are clear of map objects within the given PosRadius. nil if no positions are found.
|
||||||
function COORDINATE:GetSimpleZones(SearchRadius, PosRadius, NumPositions)
|
function COORDINATE:GetSimpleZones(SearchRadius, PosRadius, NumPositions)
|
||||||
local clearPositions = UTILS.GetSimpleZones(self:GetVec3(), SearchRadius, PosRadius, NumPositions)
|
local clearPositions = UTILS.GetSimpleZones(self:GetVec3(), SearchRadius, PosRadius, NumPositions)
|
||||||
local coords = {}
|
if clearPositions and #clearPositions > 0 then
|
||||||
for _, pos in ipairs(clearPositions) do
|
local coords = {}
|
||||||
local coord = COORDINATE:NewFromVec2(pos)
|
for _, pos in pairs(clearPositions) do
|
||||||
table.insert(coords, coord)
|
local coord = COORDINATE:NewFromVec2(pos)
|
||||||
|
table.insert(coords, coord)
|
||||||
|
end
|
||||||
|
return coords
|
||||||
end
|
end
|
||||||
return coords
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1515,7 +1515,7 @@ end
|
|||||||
-- @return #table A table of DCS#Vec2 positions that are clear of map objects within the given PosRadius. nil if no clear positions are found.
|
-- @return #table A table of DCS#Vec2 positions that are clear of map objects within the given PosRadius. nil if no clear positions are found.
|
||||||
function ZONE_RADIUS:GetClearZonePositions(PosRadius, NumPositions)
|
function ZONE_RADIUS:GetClearZonePositions(PosRadius, NumPositions)
|
||||||
local clearPositions = UTILS.GetSimpleZones(self:GetVec3(), self:GetRadius(), PosRadius, NumPositions)
|
local clearPositions = UTILS.GetSimpleZones(self:GetVec3(), self:GetRadius(), PosRadius, NumPositions)
|
||||||
if clearPositions or #clearPositions > 0 then
|
if clearPositions and #clearPositions > 0 then
|
||||||
local validZones = {}
|
local validZones = {}
|
||||||
for _, vec2 in pairs(clearPositions) do
|
for _, vec2 in pairs(clearPositions) do
|
||||||
if self:IsVec2InZone(vec2) then
|
if self:IsVec2InZone(vec2) then
|
||||||
@ -1538,7 +1538,7 @@ end
|
|||||||
function ZONE_RADIUS:GetRandomClearZoneCoordinate(PosRadius, NumPositions)
|
function ZONE_RADIUS:GetRandomClearZoneCoordinate(PosRadius, NumPositions)
|
||||||
local radius = PosRadius or math.min(self.Radius/10, 200)
|
local radius = PosRadius or math.min(self.Radius/10, 200)
|
||||||
local clearPositions = self:GetClearZonePositions(radius, NumPositions or 50)
|
local clearPositions = self:GetClearZonePositions(radius, NumPositions or 50)
|
||||||
if clearPositions or #clearPositions > 0 then
|
if clearPositions and #clearPositions > 0 then
|
||||||
local randomPosition = clearPositions[math.random(1, #clearPositions)]
|
local randomPosition = clearPositions[math.random(1, #clearPositions)]
|
||||||
return COORDINATE:NewFromVec2(randomPosition), radius
|
return COORDINATE:NewFromVec2(randomPosition), radius
|
||||||
end
|
end
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user