mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Clean up the detection code. It is complicated
This commit is contained in:
parent
0f18b29144
commit
9be9277a08
@ -784,7 +784,7 @@ do -- DETECTION_BASE
|
||||
local DetectedItems = self:GetDetectedItems()
|
||||
|
||||
for DetectedItemIndex, DetectedItem in pairs( DetectedItems ) do
|
||||
local DetectedSet = self:GetDetectedSet( DetectedItemIndex )
|
||||
local DetectedSet = self:GetDetectedSet( DetectedItem )
|
||||
if DetectedSet then
|
||||
DetectedSet:RemoveUnitsByName( UnitName )
|
||||
end
|
||||
@ -1458,23 +1458,26 @@ do -- DETECTION_BASE
|
||||
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param ItemPrefix
|
||||
-- @param #string DetectedItemIndex The index of the DetectedItem.
|
||||
-- @param DetectedItemKey The key of the DetectedItem.
|
||||
-- @param Core.Set#SET_UNIT Set (optional) The Set of Units to be added.
|
||||
-- @return #DETECTION_BASE.DetectedItem
|
||||
function DETECTION_BASE:AddDetectedItem( ItemPrefix, DetectedItemIndex, Set )
|
||||
function DETECTION_BASE:AddDetectedItem( ItemPrefix, DetectedItemKey, Set )
|
||||
|
||||
local DetectedItem = {}
|
||||
self.DetectedItemCount = self.DetectedItemCount + 1
|
||||
self.DetectedItemMax = self.DetectedItemMax + 1
|
||||
|
||||
if DetectedItemIndex then
|
||||
self.DetectedItems[DetectedItemIndex] = DetectedItem
|
||||
if DetectedItemKey then
|
||||
self.DetectedItems[DetectedItemKey] = DetectedItem
|
||||
else
|
||||
self.DetectedItems[self.DetectedItemMax] = DetectedItem
|
||||
self.DetectedItemsByIndex[self.DetectedItemMax] = DetectedItem
|
||||
end
|
||||
|
||||
self.DetectedItemsByIndex[self.DetectedItemMax] = DetectedItem
|
||||
|
||||
|
||||
DetectedItem.Set = Set or SET_UNIT:New():FilterDeads():FilterCrashes()
|
||||
DetectedItem.Index = DetectedItemIndex or self.DetectedItemMax
|
||||
DetectedItem.Index = DetectedItemKey or self.DetectedItemMax
|
||||
DetectedItem.ItemID = ItemPrefix .. "." .. self.DetectedItemMax
|
||||
DetectedItem.ID = self.DetectedItemMax
|
||||
DetectedItem.Removed = false
|
||||
@ -1485,13 +1488,13 @@ do -- DETECTION_BASE
|
||||
--- Adds a new DetectedItem to the DetectedItems list.
|
||||
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #string DetectedItemIndex The index of the DetectedItem.
|
||||
-- @param DetectedItemKey The key of the DetectedItem.
|
||||
-- @param Core.Set#SET_UNIT Set (optional) The Set of Units to be added.
|
||||
-- @param Core.Zone#ZONE_UNIT Zone (optional) The Zone to be added where the Units are located.
|
||||
-- @return #DETECTION_BASE.DetectedItem
|
||||
function DETECTION_BASE:AddDetectedItemZone( DetectedItemIndex, Set, Zone )
|
||||
function DETECTION_BASE:AddDetectedItemZone( DetectedItemKey, Set, Zone )
|
||||
|
||||
local DetectedItem = self:AddDetectedItem( "AREA", DetectedItemIndex, Set )
|
||||
local DetectedItem = self:AddDetectedItem( "AREA", DetectedItemKey, Set )
|
||||
|
||||
DetectedItem.Zone = Zone
|
||||
|
||||
@ -1501,12 +1504,16 @@ do -- DETECTION_BASE
|
||||
--- Removes an existing DetectedItem from the DetectedItems list.
|
||||
-- The DetectedItem is a table and contains a SET_UNIT in the field Set.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number DetectedItemIndex The index or position in the DetectedItems list where the item needs to be removed.
|
||||
function DETECTION_BASE:RemoveDetectedItem( DetectedItemIndex )
|
||||
-- @param DetectedItemKey The key in the DetectedItems list where the item needs to be removed.
|
||||
function DETECTION_BASE:RemoveDetectedItem( DetectedItemKey )
|
||||
|
||||
if self.DetectedItems[DetectedItemIndex] then
|
||||
local DetectedItem = self.DetectedItems[DetectedItemKey]
|
||||
|
||||
if DetectedItem then
|
||||
self.DetectedItemCount = self.DetectedItemCount - 1
|
||||
self.DetectedItems[DetectedItemIndex] = nil
|
||||
local DetectedItemIndex = DetectedItem.Index
|
||||
self.DetectedItemsByIndex[DetectedItemIndex] = nil
|
||||
self.DetectedItems[DetectedItemKey] = nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -1528,14 +1535,31 @@ do -- DETECTION_BASE
|
||||
return DetectedCount
|
||||
end
|
||||
|
||||
--- Get a detected item using a given Key.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param Key
|
||||
-- @return #DETECTION_BASE.DetectedItem
|
||||
function DETECTION_BASE:GetDetectedItemByKey( Key )
|
||||
|
||||
self:F( { DetectedItems = self.DetectedItems } )
|
||||
|
||||
local DetectedItem = self.DetectedItems[Key]
|
||||
if DetectedItem then
|
||||
return DetectedItem
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Get a detected item using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @return #DETECTION_BASE.DetectedItem
|
||||
function DETECTION_BASE:GetDetectedItem( Index )
|
||||
function DETECTION_BASE:GetDetectedItemByIndex( Index )
|
||||
|
||||
self:F( { DetectedItems = self.DetectedItems } )
|
||||
local DetectedItem = self.DetectedItems[Index]
|
||||
self:F( { DetectedItemsByIndex = self.DetectedItemsByIndex } )
|
||||
|
||||
local DetectedItem = self.DetectedItemsByIndex[Index]
|
||||
if DetectedItem then
|
||||
return DetectedItem
|
||||
end
|
||||
@ -1545,16 +1569,11 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Get a detected ItemID using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @return #string DetectedItemID
|
||||
function DETECTION_BASE:GetDetectedItemID( Index ) --R2.1
|
||||
function DETECTION_BASE:GetDetectedItemID( DetectedItem ) --R2.1
|
||||
|
||||
local DetectedItem = self.DetectedItems[Index]
|
||||
if DetectedItem then
|
||||
return DetectedItem.ItemID
|
||||
end
|
||||
|
||||
return ""
|
||||
return DetectedItem and DetectedItem.ItemID or ""
|
||||
end
|
||||
|
||||
--- Get a detected ID using a given numeric index.
|
||||
@ -1563,7 +1582,7 @@ do -- DETECTION_BASE
|
||||
-- @return #string DetectedItemID
|
||||
function DETECTION_BASE:GetDetectedID( Index ) --R2.1
|
||||
|
||||
local DetectedItem = self.DetectedItems[Index]
|
||||
local DetectedItem = self.DetectedItemsByIndex[Index]
|
||||
if DetectedItem then
|
||||
return DetectedItem.ID
|
||||
end
|
||||
@ -1573,12 +1592,11 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Get the @{Set#SET_UNIT} of a detecttion area using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem
|
||||
-- @return Core.Set#SET_UNIT DetectedSet
|
||||
function DETECTION_BASE:GetDetectedSet( Index )
|
||||
function DETECTION_BASE:GetDetectedSet( DetectedItem )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
local DetectedSetUnit = DetectedItem.Set
|
||||
local DetectedSetUnit = DetectedItem and DetectedItem.Set
|
||||
if DetectedSetUnit then
|
||||
return DetectedSetUnit
|
||||
end
|
||||
@ -1623,11 +1641,11 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Get the @{Zone#ZONE_UNIT} of a detection area using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @return Core.Zone#ZONE_UNIT DetectedZone
|
||||
function DETECTION_BASE:GetDetectedItemZone( Index )
|
||||
function DETECTION_BASE:GetDetectedItemZone( DetectedItem )
|
||||
|
||||
local DetectedZone = self.DetectedItems[Index].Zone
|
||||
local DetectedZone = DetectedItem and DetectedItem.Zone
|
||||
if DetectedZone then
|
||||
return DetectedZone
|
||||
end
|
||||
@ -1642,7 +1660,7 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Set the detected item coordinate.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #DETECTION_BASE.DetectedItem The DetectedItem to set the coordinate at.
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem to set the coordinate at.
|
||||
-- @param Core.Point#COORDINATE Coordinate The coordinate to set the last know detected position at.
|
||||
-- @param Wrapper.Unit#UNIT DetectedItemUnit The unit to set the heading and altitude from.
|
||||
-- @return #DETECTION_BASE
|
||||
@ -1662,12 +1680,10 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Get the detected item coordinate.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem to set the coordinate at.
|
||||
-- @return Core.Point#COORDINATE
|
||||
function DETECTION_BASE:GetDetectedItemCoordinate( Index )
|
||||
self:F( { Index = Index } )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
function DETECTION_BASE:GetDetectedItemCoordinate( DetectedItem )
|
||||
self:F( { DetectedItem = DetectedItem } )
|
||||
|
||||
if DetectedItem then
|
||||
return DetectedItem.Coordinate
|
||||
@ -1693,12 +1709,10 @@ do -- DETECTION_BASE
|
||||
|
||||
--- Get the detected item coordinate.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param #number Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @return #number ThreatLevel
|
||||
function DETECTION_BASE:GetDetectedItemThreatLevel( Index )
|
||||
self:F( { Index = Index } )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
function DETECTION_BASE:GetDetectedItemThreatLevel( DetectedItem )
|
||||
self:F( { DetectedItem = DetectedItem } )
|
||||
|
||||
if DetectedItem then
|
||||
self:F( { ThreatLevel = DetectedItem.ThreatLevel, ThreatText = DetectedItem.ThreatText } )
|
||||
@ -1709,27 +1723,13 @@ do -- DETECTION_BASE
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
--- Menu of a detected item using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param Index
|
||||
-- @return #string
|
||||
function DETECTION_BASE:DetectedItemMenu( Index, AttackGroup )
|
||||
self:F( Index )
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
--- Report summary of a detected item using a given numeric index.
|
||||
-- @param #DETECTION_BASE self
|
||||
-- @param Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @param Wrapper.Group#GROUP AttackGroup The group to generate the report for.
|
||||
-- @param Core.Settings#SETTINGS Settings Message formatting settings to use.
|
||||
-- @return Core.Report#REPORT
|
||||
function DETECTION_BASE:DetectedItemReportSummary( Index, AttackGroup, Settings )
|
||||
function DETECTION_BASE:DetectedItemReportSummary( DetectedItem, AttackGroup, Settings )
|
||||
self:F( Index )
|
||||
return nil
|
||||
end
|
||||
@ -1766,7 +1766,7 @@ do -- DETECTION_BASE
|
||||
for RecceUnit, RecceUnit in pairs( RecceGroup:GetUnits() ) do
|
||||
if RecceUnit:IsActive() then
|
||||
local RecceUnitCoord = RecceUnit:GetCoordinate()
|
||||
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem.Index ) )
|
||||
local Distance = RecceUnitCoord:Get2DDistance( self:GetDetectedItemCoordinate( DetectedItem ) )
|
||||
if Distance < DistanceRecce then
|
||||
DistanceRecce = Distance
|
||||
NearestRecce = RecceUnit
|
||||
@ -1930,10 +1930,10 @@ do -- DETECTION_UNITS
|
||||
|
||||
if DetectedUnit then
|
||||
local DetectedTypeName = DetectedUnit:GetTypeName()
|
||||
local DetectedItem = self:GetDetectedItem( DetectedUnitName )
|
||||
local DetectedItem = self:GetDetectedItemByKey( DetectedUnitName )
|
||||
if not DetectedItem then
|
||||
self:T( "Added new DetectedItem" )
|
||||
DetectedItem = self:AddDetectedItem( "UNIT" )
|
||||
DetectedItem = self:AddDetectedItem( "UNIT", DetectedUnitName )
|
||||
DetectedItem.TypeName = DetectedUnit:GetTypeName()
|
||||
DetectedItem.Name = DetectedObject.Name
|
||||
DetectedItem.IsVisible = DetectedObject.IsVisible
|
||||
@ -1969,48 +1969,17 @@ do -- DETECTION_UNITS
|
||||
|
||||
end
|
||||
|
||||
--- Menu of a DetectedItem using a given numeric index.
|
||||
-- @param #DETECTION_UNITS self
|
||||
-- @param Index
|
||||
-- @return #string
|
||||
function DETECTION_UNITS:DetectedItemMenu( Index, AttackGroup )
|
||||
self:F( Index )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
local DetectedSet = self:GetDetectedSet( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( Index )
|
||||
|
||||
self:T( DetectedSet )
|
||||
if DetectedSet then
|
||||
local ReportSummary = ""
|
||||
local UnitDistanceText = ""
|
||||
local UnitCategoryText = ""
|
||||
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index )
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
||||
|
||||
ReportSummary = string.format(
|
||||
"%s - %s",
|
||||
DetectedItemID,
|
||||
DetectedItemCoordText
|
||||
)
|
||||
self:T( ReportSummary )
|
||||
|
||||
return ReportSummary
|
||||
end
|
||||
end
|
||||
|
||||
--- Report summary of a DetectedItem using a given numeric index.
|
||||
-- @param #DETECTION_UNITS self
|
||||
-- @param Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @param Wrapper.Group#GROUP AttackGroup The group to generate the report for.
|
||||
-- @param Core.Settings#SETTINGS Settings Message formatting settings to use.
|
||||
-- @return Core.Report#REPORT The report of the detection items.
|
||||
function DETECTION_UNITS:DetectedItemReportSummary( Index, AttackGroup, Settings )
|
||||
self:F( { Index, self.DetectedItems } )
|
||||
function DETECTION_UNITS:DetectedItemReportSummary( DetectedItem, AttackGroup, Settings )
|
||||
self:F( { DetectedItem = DetectedItem } )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( DetectedItem )
|
||||
|
||||
if DetectedItem then
|
||||
local ReportSummary = ""
|
||||
@ -2040,10 +2009,10 @@ do -- DETECTION_UNITS
|
||||
end
|
||||
|
||||
--TODO: solve Index reference
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( Index )
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedItem )
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( Index )
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedItem )
|
||||
|
||||
local Report = REPORT:New()
|
||||
Report:Add(DetectedItemID .. ", " .. DetectedItemCoordText)
|
||||
@ -2063,9 +2032,9 @@ do -- DETECTION_UNITS
|
||||
self:F()
|
||||
|
||||
local Report = REPORT:New()
|
||||
for DetectedItemID, DetectedItem in pairs( self.DetectedItems ) do
|
||||
for DetectedItemIndex, DetectedItem in pairs( self.DetectedItems ) do
|
||||
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItemID, AttackGroup )
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItem, AttackGroup )
|
||||
Report:SetTitle( "Detected units:" )
|
||||
Report:Add( ReportSummary:Text() )
|
||||
end
|
||||
@ -2195,10 +2164,10 @@ do -- DETECTION_TYPES
|
||||
|
||||
if DetectedUnit then
|
||||
local DetectedTypeName = DetectedUnit:GetTypeName()
|
||||
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
||||
local DetectedItem = self:GetDetectedItemByKey( DetectedTypeName )
|
||||
if not DetectedItem then
|
||||
DetectedItem = self:AddDetectedItem( "TYPE" )
|
||||
DetectedItem.TypeName = DetectedUnit:GetTypeName()
|
||||
DetectedItem = self:AddDetectedItem( "TYPE", DetectedTypeName )
|
||||
DetectedItem.TypeName = DetectedTypeName
|
||||
end
|
||||
|
||||
DetectedItem.Set:AddUnit( DetectedUnit )
|
||||
@ -2229,53 +2198,26 @@ do -- DETECTION_TYPES
|
||||
|
||||
end
|
||||
|
||||
--- Menu of a DetectedItem using a given numeric index.
|
||||
-- @param #DETECTION_TYPES self
|
||||
-- @param Index
|
||||
-- @return #string
|
||||
function DETECTION_TYPES:DetectedItemMenu( DetectedTypeName, AttackGroup )
|
||||
self:F( DetectedTypeName )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
||||
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
|
||||
|
||||
if DetectedItem then
|
||||
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedTypeName )
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
||||
|
||||
local ReportSummary = string.format(
|
||||
"%s - %s",
|
||||
DetectedItemID,
|
||||
DetectedItemCoordText
|
||||
)
|
||||
self:T( ReportSummary )
|
||||
|
||||
return ReportSummary
|
||||
end
|
||||
end
|
||||
|
||||
--- Report summary of a DetectedItem using a given numeric index.
|
||||
-- @param #DETECTION_TYPES self
|
||||
-- @param Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @param Wrapper.Group#GROUP AttackGroup The group to generate the report for.
|
||||
-- @param Core.Settings#SETTINGS Settings Message formatting settings to use.
|
||||
-- @return Core.Report#REPORT The report of the detection items.
|
||||
function DETECTION_TYPES:DetectedItemReportSummary( DetectedTypeName, AttackGroup, Settings )
|
||||
self:F( DetectedTypeName )
|
||||
function DETECTION_TYPES:DetectedItemReportSummary( DetectedItem, AttackGroup, Settings )
|
||||
self:F( { DetectedItem = DetectedItem } )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( DetectedTypeName )
|
||||
local DetectedSet = self:GetDetectedSet( DetectedTypeName )
|
||||
local DetectedItemID = self:GetDetectedItemID( DetectedTypeName )
|
||||
local DetectedSet = self:GetDetectedSet( DetectedItem )
|
||||
local DetectedItemID = self:GetDetectedItemID( DetectedItem )
|
||||
|
||||
self:T( DetectedItem )
|
||||
if DetectedItem then
|
||||
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedTypeName )
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedItem )
|
||||
local DetectedItemsCount = DetectedSet:Count()
|
||||
local DetectedItemType = DetectedItem.TypeName
|
||||
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedTypeName )
|
||||
local DetectedItemCoordinate = self:GetDetectedItemCoordinate( DetectedItem )
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||
|
||||
local Report = REPORT:New()
|
||||
@ -2294,9 +2236,9 @@ do -- DETECTION_TYPES
|
||||
self:F()
|
||||
|
||||
local Report = REPORT:New()
|
||||
for DetectedItemTypeName, DetectedItem in pairs( self.DetectedItems ) do
|
||||
for DetectedItemIndex, DetectedItem in pairs( self.DetectedItems ) do
|
||||
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItemTypeName, AttackGroup )
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItem, AttackGroup )
|
||||
Report:SetTitle( "Detected types:" )
|
||||
Report:Add( ReportSummary:Text() )
|
||||
end
|
||||
@ -2375,57 +2317,26 @@ do -- DETECTION_AREAS
|
||||
end
|
||||
|
||||
|
||||
--- Menu of a detected item using a given numeric index.
|
||||
-- @param #DETECTION_AREAS self
|
||||
-- @param Index
|
||||
-- @return #string
|
||||
function DETECTION_AREAS:DetectedItemMenu( Index, AttackGroup )
|
||||
self:F( Index )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( Index )
|
||||
|
||||
if DetectedItem then
|
||||
local DetectedSet = self:GetDetectedSet( Index )
|
||||
local ReportSummaryItem
|
||||
|
||||
local DetectedZone = self:GetDetectedItemZone( Index )
|
||||
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup )
|
||||
|
||||
local ReportSummary = string.format(
|
||||
"%s - %s",
|
||||
DetectedItemID,
|
||||
DetectedItemCoordText
|
||||
)
|
||||
|
||||
return ReportSummary
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Report summary of a detected item using a given numeric index.
|
||||
-- @param #DETECTION_AREAS self
|
||||
-- @param Index
|
||||
-- @param #DETECTION_BASE.DetectedItem DetectedItem The DetectedItem.
|
||||
-- @param Wrapper.Group#GROUP AttackGroup The group to get the settings for.
|
||||
-- @param Core.Settings#SETTINGS Settings (Optional) Message formatting settings to use.
|
||||
-- @return Core.Report#REPORT The report of the detection items.
|
||||
function DETECTION_AREAS:DetectedItemReportSummary( Index, AttackGroup, Settings )
|
||||
self:F( Index )
|
||||
function DETECTION_AREAS:DetectedItemReportSummary( DetectedItem, AttackGroup, Settings )
|
||||
self:F( { DetectedItem = DetectedItem } )
|
||||
|
||||
local DetectedItem = self:GetDetectedItem( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( Index )
|
||||
local DetectedItemID = self:GetDetectedItemID( DetectedItem )
|
||||
|
||||
if DetectedItem then
|
||||
local DetectedSet = self:GetDetectedSet( Index )
|
||||
local DetectedSet = self:GetDetectedSet( DetectedItem )
|
||||
local ReportSummaryItem
|
||||
|
||||
local DetectedZone = self:GetDetectedItemZone( Index )
|
||||
local DetectedZone = self:GetDetectedItemZone( DetectedItem )
|
||||
local DetectedItemCoordinate = DetectedZone:GetCoordinate()
|
||||
local DetectedItemCoordText = DetectedItemCoordinate:ToString( AttackGroup, Settings )
|
||||
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( Index )
|
||||
local ThreatLevelA2G = self:GetDetectedItemThreatLevel( DetectedItem )
|
||||
local DetectedItemsCount = DetectedSet:Count()
|
||||
local DetectedItemsTypes = DetectedSet:GetTypeNames()
|
||||
|
||||
@ -2450,7 +2361,7 @@ do -- DETECTION_AREAS
|
||||
local Report = REPORT:New()
|
||||
for DetectedItemIndex, DetectedItem in pairs( self.DetectedItems ) do
|
||||
local DetectedItem = DetectedItem -- #DETECTION_BASE.DetectedItem
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItemIndex, AttackGroup )
|
||||
local ReportSummary = self:DetectedItemReportSummary( DetectedItem, AttackGroup )
|
||||
Report:SetTitle( "Detected areas:" )
|
||||
Report:Add( ReportSummary:Text() )
|
||||
end
|
||||
|
||||
@ -846,8 +846,8 @@ function _Resume( EscortGroup )
|
||||
end
|
||||
|
||||
--- @param #ESCORT self
|
||||
-- @param #number DetectedItemID
|
||||
function ESCORT:_AttackTarget( DetectedItemID )
|
||||
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
|
||||
function ESCORT:_AttackTarget( DetectedItem )
|
||||
|
||||
local EscortGroup = self.EscortGroup -- Wrapper.Group#GROUP
|
||||
self:E( EscortGroup )
|
||||
@ -861,7 +861,7 @@ function ESCORT:_AttackTarget( DetectedItemID )
|
||||
EscortGroup:OptionROTPassiveDefense()
|
||||
EscortGroup:SetState( EscortGroup, "Escort", self )
|
||||
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItemID )
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItem )
|
||||
|
||||
local Tasks = {}
|
||||
|
||||
@ -884,7 +884,7 @@ function ESCORT:_AttackTarget( DetectedItemID )
|
||||
|
||||
else
|
||||
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItemID )
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItem )
|
||||
|
||||
local Tasks = {}
|
||||
|
||||
@ -910,8 +910,9 @@ function ESCORT:_AttackTarget( DetectedItemID )
|
||||
end
|
||||
|
||||
---
|
||||
-- @param #number DetectedItemID
|
||||
function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItemID )
|
||||
--- @param #ESCORT self
|
||||
-- @param Functional.Detection#DETECTION_BASE.DetectedItem DetectedItem
|
||||
function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItem )
|
||||
|
||||
local EscortGroup = self.EscortGroup
|
||||
local EscortClient = self.EscortClient
|
||||
@ -922,7 +923,7 @@ function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItemID )
|
||||
EscortGroupAttack:OptionROEOpenFire()
|
||||
EscortGroupAttack:OptionROTVertical()
|
||||
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItemID )
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItem )
|
||||
|
||||
local Tasks = {}
|
||||
|
||||
@ -944,7 +945,7 @@ function ESCORT:_AssistTarget( EscortGroupAttack, DetectedItemID )
|
||||
)
|
||||
|
||||
else
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItemID )
|
||||
local DetectedSet = self.Detection:GetDetectedSet( DetectedItem )
|
||||
|
||||
local Tasks = {}
|
||||
|
||||
@ -1162,11 +1163,11 @@ function ESCORT:_ReportTargetsScheduler()
|
||||
local ClientEscortTargets = EscortGroupData.Detection
|
||||
--local EscortUnit = EscortGroupData:GetUnit( 1 )
|
||||
|
||||
for DetectedItemID, DetectedItem in pairs( DetectedItems ) do
|
||||
self:E( { DetectedItemID, DetectedItem } )
|
||||
for DetectedItemIndex, DetectedItem in pairs( DetectedItems ) do
|
||||
self:E( { DetectedItemIndex, DetectedItem } )
|
||||
-- Remove the sub menus of the Attack menu of the Escort for the EscortGroup.
|
||||
|
||||
local DetectedItemReportSummary = self.Detection:DetectedItemReportSummary( DetectedItemID, EscortGroupData.EscortGroup, _DATABASE:GetPlayerSettings( self.EscortClient:GetPlayerName() ) )
|
||||
local DetectedItemReportSummary = self.Detection:DetectedItemReportSummary( DetectedItem, EscortGroupData.EscortGroup, _DATABASE:GetPlayerSettings( self.EscortClient:GetPlayerName() ) )
|
||||
|
||||
if ClientEscortGroupName == EscortGroupName then
|
||||
|
||||
@ -1180,7 +1181,7 @@ function ESCORT:_ReportTargetsScheduler()
|
||||
self.EscortMenuAttackNearbyTargets,
|
||||
ESCORT._AttackTarget,
|
||||
self,
|
||||
DetectedItemID
|
||||
DetectedItem
|
||||
)
|
||||
else
|
||||
if self.EscortMenuTargetAssistance then
|
||||
@ -1195,7 +1196,7 @@ function ESCORT:_ReportTargetsScheduler()
|
||||
ESCORT._AssistTarget,
|
||||
self,
|
||||
EscortGroupData.EscortGroup,
|
||||
DetectedItemID
|
||||
DetectedItem
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
@ -875,7 +875,7 @@ end
|
||||
function TASK:MenuMarkToGroup( TaskGroup )
|
||||
self:F()
|
||||
|
||||
self:UpdateTaskInfo()
|
||||
self:UpdateTaskInfo( self.DetectedItem )
|
||||
|
||||
local Report = REPORT:New():SetIndent( 0 )
|
||||
|
||||
@ -1380,14 +1380,14 @@ do -- Links
|
||||
--- Set detection of a task
|
||||
-- @param #TASK self
|
||||
-- @param Function.Detection#DETECTION_BASE Detection
|
||||
-- @param #number DetectedItemIndex
|
||||
-- @param DetectedItem
|
||||
-- @return #TASK
|
||||
function TASK:SetDetection( Detection, DetectedItemIndex )
|
||||
function TASK:SetDetection( Detection, DetectedItem )
|
||||
|
||||
self:E({DetectedItemIndex,Detection})
|
||||
self:E( { DetectedItem, Detection } )
|
||||
|
||||
self.Detection = Detection
|
||||
self.DetectedItemIndex = DetectedItemIndex
|
||||
self.DetectedItem = DetectedItem
|
||||
end
|
||||
|
||||
end
|
||||
@ -1420,7 +1420,7 @@ end
|
||||
-- @return #string
|
||||
function TASK:ReportOverview( ReportGroup )
|
||||
|
||||
self:UpdateTaskInfo()
|
||||
self:UpdateTaskInfo( self.DetectedItem )
|
||||
|
||||
-- List the name of the Task.
|
||||
local TaskName = self:GetName()
|
||||
@ -1480,7 +1480,7 @@ end
|
||||
-- @return #string
|
||||
function TASK:ReportDetails( ReportGroup )
|
||||
|
||||
self:UpdateTaskInfo()
|
||||
self:UpdateTaskInfo( self.DetectedItem )
|
||||
|
||||
local Report = REPORT:New():SetIndent( 3 )
|
||||
|
||||
|
||||
@ -308,16 +308,16 @@ do -- TASK_A2A
|
||||
|
||||
|
||||
--- @param #TASK_A2A self
|
||||
function TASK_A2A:UpdateTaskInfo()
|
||||
function TASK_A2A:UpdateTaskInfo( DetectedItem )
|
||||
|
||||
if self:IsStatePlanned() or self:IsStateAssigned() then
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
local TargetCoordinate = DetectedItem and self.Detection:GetDetectedItemCoordinate( DetectedItem ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self.TaskInfo:AddTaskName( 0, "MSOD" )
|
||||
self.TaskInfo:AddCoordinate( TargetCoordinate, 1, "SOD" )
|
||||
|
||||
local ThreatLevel, ThreatText
|
||||
if self.Detection then
|
||||
ThreatLevel, ThreatText = self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex )
|
||||
if DetectedItem then
|
||||
ThreatLevel, ThreatText = self.Detection:GetDetectedItemThreatLevel( DetectedItem )
|
||||
else
|
||||
ThreatLevel, ThreatText = self.TargetSetUnit:CalculateThreatLevelA2G()
|
||||
end
|
||||
|
||||
@ -307,16 +307,16 @@ do -- TASK_A2G
|
||||
end
|
||||
|
||||
--- @param #TASK_A2G self
|
||||
function TASK_A2G:UpdateTaskInfo()
|
||||
function TASK_A2G:UpdateTaskInfo( DetectedItem )
|
||||
|
||||
if self:IsStatePlanned() or self:IsStateAssigned() then
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
local TargetCoordinate = DetectedItem and self.Detection:GetDetectedItemCoordinate( self.DetectedItem ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self.TaskInfo:AddTaskName( 0, "MSOD" )
|
||||
self.TaskInfo:AddCoordinate( TargetCoordinate, 1, "SOD" )
|
||||
|
||||
local ThreatLevel, ThreatText
|
||||
if self.Detection then
|
||||
ThreatLevel, ThreatText = self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex )
|
||||
if DetectedItem then
|
||||
ThreatLevel, ThreatText = self.Detection:GetDetectedItemThreatLevel( self.DetectedItem )
|
||||
else
|
||||
ThreatLevel, ThreatText = self.TargetSetUnit:CalculateThreatLevelA2G()
|
||||
end
|
||||
|
||||
@ -612,7 +612,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if TargetSetUnit then
|
||||
if Task:IsInstanceOf( TASK_A2G_SEAD ) then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||
else
|
||||
Task:Cancel()
|
||||
@ -623,7 +623,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||
else
|
||||
Task:Cancel()
|
||||
@ -635,7 +635,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||
else
|
||||
Task:Cancel()
|
||||
@ -663,7 +663,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
@ -674,7 +674,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
@ -685,7 +685,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
@ -730,7 +730,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
self.Tasks[TaskIndex] = Task
|
||||
Task:SetTargetZone( DetectedZone )
|
||||
Task:SetDispatcher( self )
|
||||
Task:UpdateTaskInfo()
|
||||
Task:UpdateTaskInfo( DetectedItem )
|
||||
Mission:AddTask( Task )
|
||||
|
||||
TaskReport:Add( Task:GetName() )
|
||||
|
||||
@ -810,7 +810,7 @@ do -- TASK_CARGO
|
||||
end
|
||||
|
||||
--- @param #TASK_CARGO self
|
||||
function TASK_CARGO:UpdateTaskInfo()
|
||||
function TASK_CARGO:UpdateTaskInfo( DetectedItem )
|
||||
|
||||
if self:IsStatePlanned() or self:IsStateAssigned() then
|
||||
self.TaskInfo:AddTaskName( 0, "MSOD" )
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user