mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Finish Detection_error_with_units_and_types
This commit is contained in:
commit
08cc4e3530
@ -826,7 +826,7 @@ function EVENT:onEvent( Event )
|
||||
Event.TgtDCSUnit = Event.target
|
||||
Event.TgtDCSUnitName = Event.TgtDCSUnit:getName()
|
||||
Event.TgtUnitName = Event.TgtDCSUnitName
|
||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName )
|
||||
Event.TgtUnit = STATIC:FindByName( Event.TgtDCSUnitName, false )
|
||||
Event.TgtCoalition = Event.TgtDCSUnit:getCoalition()
|
||||
Event.TgtCategory = Event.TgtDCSUnit:getDesc().category
|
||||
Event.TgtTypeName = Event.TgtDCSUnit:getTypeName()
|
||||
|
||||
@ -793,16 +793,16 @@ do -- DESIGNATE
|
||||
-- @return #DESIGNATE
|
||||
function DESIGNATE:DesignationScope()
|
||||
|
||||
local DetectedItems = self.Detection:GetDetectedItems()
|
||||
local DetectedItems = self.Detection:GetDetectedItemsByIndex()
|
||||
|
||||
local DetectedItemCount = 0
|
||||
|
||||
for DesignateIndex, Designating in pairs( self.Designating ) do
|
||||
local DetectedItem = DetectedItems[DesignateIndex]
|
||||
local DetectedItem = self.Detection:GetDetectedItemByIndex( DesignateIndex )
|
||||
if DetectedItem then
|
||||
-- Check LOS...
|
||||
local IsDetected = self.Detection:IsDetectedItemDetected( DetectedItem )
|
||||
self:F({IsDetected = IsDetected, DetectedItem })
|
||||
self:F({IsDetected = IsDetected })
|
||||
if IsDetected == false then
|
||||
self:F("Removing")
|
||||
-- This Detection is obsolete, remove from the designate scope
|
||||
@ -861,7 +861,7 @@ do -- DESIGNATE
|
||||
-- @return #DESIGNATE
|
||||
function DESIGNATE:CoordinateLase()
|
||||
|
||||
local DetectedItems = self.Detection:GetDetectedItems()
|
||||
local DetectedItems = self.Detection:GetDetectedItemsByIndex()
|
||||
|
||||
for DesignateIndex, Designating in pairs( self.Designating ) do
|
||||
local DetectedItem = DetectedItems[DesignateIndex]
|
||||
@ -891,7 +891,7 @@ do -- DESIGNATE
|
||||
if self.FlashStatusMenu[AttackGroup] or ( MenuAttackGroup and ( AttackGroup:GetName() == MenuAttackGroup:GetName() ) ) then
|
||||
|
||||
local DetectedReport = REPORT:New( "Targets ready for Designation:" )
|
||||
local DetectedItems = self.Detection:GetDetectedItems()
|
||||
local DetectedItems = self.Detection:GetDetectedItemsByIndex()
|
||||
|
||||
for DesignateIndex, Designating in pairs( self.Designating ) do
|
||||
local DetectedItem = DetectedItems[DesignateIndex]
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user