mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
-- Fixed Designate menus for UNITS and TYPES.
-- Fixed error in Detection Units and Types, when the last unit is destroyed in teh collection, it would crash the logic. -- In the event processing, no error to be generated if the target static is not found.
This commit is contained in:
@@ -1517,7 +1517,8 @@ do -- DETECTION_BASE
|
||||
end
|
||||
|
||||
|
||||
--- Get the detected @{Set#SET_BASE}s.
|
||||
--- Get the DetectedItems by Key.
|
||||
-- This will return the DetectedItems collection, indexed by the Key, which can be any object that acts as the key of the detection.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #DETECTION_BASE.DetectedItems
|
||||
function DETECTION_BASE:GetDetectedItems()
|
||||
@@ -1525,6 +1526,15 @@ do -- DETECTION_BASE
|
||||
return self.DetectedItems
|
||||
end
|
||||
|
||||
--- Get the DetectedItems by Index.
|
||||
-- This will return the DetectedItems collection, indexed by an internal numerical Index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #DETECTION_BASE.DetectedItems
|
||||
function DETECTION_BASE:GetDetectedItemsByIndex()
|
||||
|
||||
return self.DetectedItemsByIndex
|
||||
end
|
||||
|
||||
--- Get the amount of SETs with detected objects.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @return #number The amount of detected items. Note that the amount of detected items can differ with the reality, because detections are not real-time but doen in intervals!
|
||||
@@ -1880,7 +1890,7 @@ do -- DETECTION_UNITS
|
||||
|
||||
-- Loop the current detected items, and check if each object still exists and is detected.
|
||||
|
||||
for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do
|
||||
for DetectedItemKey, DetectedItem in pairs( self.DetectedItems ) do
|
||||
|
||||
local DetectedItemSet = DetectedItem.Set -- Core.Set#SET_UNIT
|
||||
|
||||
@@ -1915,6 +1925,11 @@ do -- DETECTION_UNITS
|
||||
DetectedItemSet:Remove( DetectedUnitName )
|
||||
end
|
||||
end
|
||||
if DetectedItemSet:Count() == 0 then
|
||||
-- Now the Set is empty, meaning that a detected item has no units anymore.
|
||||
-- Delete the DetectedItem from the detections
|
||||
self:RemoveDetectedItem( DetectedItemKey )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -2126,7 +2141,7 @@ do -- DETECTION_TYPES
|
||||
|
||||
-- Loop the current detected items, and check if each object still exists and is detected.
|
||||
|
||||
for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do
|
||||
for DetectedItemKey, DetectedItem in pairs( self.DetectedItems ) do
|
||||
|
||||
local DetectedItemSet = DetectedItem.Set -- Core.Set#SET_UNIT
|
||||
local DetectedTypeName = DetectedItem.TypeName
|
||||
@@ -2149,6 +2164,11 @@ do -- DETECTION_TYPES
|
||||
DetectedItemSet:Remove( DetectedUnitName )
|
||||
end
|
||||
end
|
||||
if DetectedItemSet:Count() == 0 then
|
||||
-- Now the Set is empty, meaning that a detected item has no units anymore.
|
||||
-- Delete the DetectedItem from the detections
|
||||
self:RemoveDetectedItem( DetectedItemKey )
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user