mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Check if RecceGroup is alive before iterating...
This commit is contained in:
parent
6959f50777
commit
f628e720a9
@ -2453,13 +2453,15 @@ do -- DETECTION_AREAS
|
||||
local DistanceRecce = 1000000000 -- Units are not further than 1000000 km away from an area :-)
|
||||
|
||||
for RecceGroupName, RecceGroup in pairs( self.DetectionSetGroup:GetSet() ) do
|
||||
for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
|
||||
if RecceUnit:IsActive() then
|
||||
local RecceUnitCoord = RecceUnit:GetCoordinate()
|
||||
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
|
||||
if Distance < DistanceRecce then
|
||||
DistanceRecce = Distance
|
||||
NearestRecce = RecceUnit
|
||||
if RecceGroup and RecceGroup:IsAlive() then
|
||||
for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
|
||||
if RecceUnit:IsActive() then
|
||||
local RecceUnitCoord = RecceUnit:GetCoordinate()
|
||||
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
|
||||
if Distance < DistanceRecce then
|
||||
DistanceRecce = Distance
|
||||
NearestRecce = RecceUnit
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user