mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
First version
This commit is contained in:
@@ -860,8 +860,9 @@ end
|
||||
|
||||
--- Create a summary report of the Mission (one line).
|
||||
-- @param #MISSION self
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
-- @return #string
|
||||
function MISSION:ReportSummary()
|
||||
function MISSION:ReportSummary( ReportGroup )
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
@@ -874,9 +875,9 @@ function MISSION:ReportSummary()
|
||||
Report:Add( string.format( '%s - %s - Task Overview Report', Name, Status ) )
|
||||
|
||||
-- Determine how many tasks are remaining.
|
||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||
for TaskID, Task in UTILS.spairs( self:GetTasks(), function( t, a, b ) return t[a]:ReportOrder( ReportGroup ) < t[b]:ReportOrder( ReportGroup ) end ) do
|
||||
local Task = Task -- Tasking.Task#TASK
|
||||
Report:Add( "- " .. Task:ReportSummary() )
|
||||
Report:Add( "- " .. Task:ReportSummary( ReportGroup ) )
|
||||
end
|
||||
|
||||
return Report:Text()
|
||||
@@ -898,13 +899,17 @@ function MISSION:ReportOverview( ReportGroup, TaskStatus )
|
||||
Report:Add( string.format( '%s - %s - %s Tasks Report', Name, Status, TaskStatus ) )
|
||||
|
||||
-- Determine how many tasks are remaining.
|
||||
local TasksRemaining = 0
|
||||
local Tasks = 0
|
||||
for TaskID, Task in UTILS.spairs( self:GetTasks(), function( t, a, b ) return t[a]:ReportOrder( ReportGroup ) < t[b]:ReportOrder( ReportGroup ) end ) do
|
||||
local Task = Task -- Tasking.Task#TASK
|
||||
if Task:Is( TaskStatus ) then
|
||||
Report:Add( string.rep( "-", 140 ) )
|
||||
Report:Add( " - " .. Task:ReportOverview( ReportGroup ) )
|
||||
end
|
||||
Tasks = Tasks + 1
|
||||
if Tasks >= 8 then
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
return Report:Text()
|
||||
@@ -963,7 +968,7 @@ end
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
function MISSION:MenuReportTasksSummary( ReportGroup )
|
||||
|
||||
local Report = self:ReportSummary()
|
||||
local Report = self:ReportSummary( ReportGroup )
|
||||
|
||||
self:GetCommandCenter():MessageToGroup( Report, ReportGroup )
|
||||
end
|
||||
|
||||
@@ -1343,7 +1343,7 @@ function TASK:onbeforeTimeOut( From, Event, To )
|
||||
return false
|
||||
end
|
||||
|
||||
do -- Dispatcher
|
||||
do -- Links
|
||||
|
||||
--- Set dispatcher of a task
|
||||
-- @param #TASK self
|
||||
@@ -1353,6 +1353,19 @@ do -- Dispatcher
|
||||
self.Dispatcher = Dispatcher
|
||||
end
|
||||
|
||||
--- Set detection of a task
|
||||
-- @param #TASK self
|
||||
-- @param Function.Detection#DETECTION_BASE Detection
|
||||
-- @param #number DetectedItemIndex
|
||||
-- @return #TASK
|
||||
function TASK:SetDetection( Detection, DetectedItemIndex )
|
||||
|
||||
self:E({DetectedItemIndex,Detection})
|
||||
|
||||
self.Detection = Detection
|
||||
self.DetectedItemIndex = DetectedItemIndex
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
do -- Reporting
|
||||
@@ -1360,36 +1373,38 @@ do -- Reporting
|
||||
--- Create a summary report of the Task.
|
||||
-- List the Task Name and Status
|
||||
-- @param #TASK self
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
-- @return #string
|
||||
function TASK:ReportSummary() --R2.1 fixed report. Now nicely formatted and contains the info required.
|
||||
function TASK:ReportSummary( ReportGroup )
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
-- List the name of the Task.
|
||||
local Name = self:GetName()
|
||||
Report:Add( self:GetName() )
|
||||
|
||||
-- Determine the status of the Task.
|
||||
local Status = "<" .. self:GetState() .. ">"
|
||||
Report:Add( "State: <" .. self:GetState() .. ">" )
|
||||
|
||||
Report:Add( 'Task ' .. Name .. ' - State ' .. Status )
|
||||
|
||||
return Report:Text()
|
||||
if self.TaskInfo["Coordinates"] then
|
||||
local TaskInfoIDText = string.format( "%s: ", "Coordinate" )
|
||||
local TaskCoord = self.TaskInfo["Coordinates"].TaskInfoText -- Core.Point#COORDINATE
|
||||
Report:Add( TaskInfoIDText .. TaskCoord:ToString( ReportGroup, nil, self ) )
|
||||
end
|
||||
|
||||
return Report:Text( ', ' )
|
||||
end
|
||||
|
||||
--- Create an overiew report of the Task.
|
||||
-- List the Task Name and Status
|
||||
-- @param #TASK self
|
||||
-- @return #string
|
||||
function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely formatted and contains the info required.
|
||||
function TASK:ReportOverview( ReportGroup )
|
||||
|
||||
self:UpdateTaskInfo()
|
||||
|
||||
-- List the name of the Task.
|
||||
local TaskName = self:GetName()
|
||||
local Report = REPORT:New()
|
||||
|
||||
-- Determine the status of the Task.
|
||||
local Status = "<" .. self:GetState() .. ">"
|
||||
|
||||
local Line = 0
|
||||
local LineReport = REPORT:New()
|
||||
@@ -1402,7 +1417,7 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
||||
if Line ~= 0 then
|
||||
Report:AddIndent( LineReport:Text( ", " ) )
|
||||
else
|
||||
Report:Add( TaskName .. " - " .. LineReport:Text( ", " ) )
|
||||
Report:Add( TaskName .. ", " .. LineReport:Text( ", " ) )
|
||||
end
|
||||
LineReport = REPORT:New()
|
||||
Line = math.floor( TaskInfo.TaskInfoOrder / 10 )
|
||||
@@ -1414,7 +1429,6 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
||||
LineReport:Add( TaskInfoIDText .. TaskInfo.TaskInfoText )
|
||||
elseif type(TaskInfo) == "table" then
|
||||
if TaskInfoID == "Coordinates" then
|
||||
local FromCoordinate = ReportGroup:GetUnit(1):GetCoordinate()
|
||||
local ToCoordinate = TaskInfo.TaskInfoText -- Core.Point#COORDINATE
|
||||
--Report:Add( TaskInfoIDText )
|
||||
LineReport:Add( TaskInfoIDText .. ToCoordinate:ToString( ReportGroup, nil, self ) )
|
||||
@@ -1422,8 +1436,6 @@ function TASK:ReportOverview( ReportGroup ) --R2.1 fixed report. Now nicely form
|
||||
else
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
end
|
||||
|
||||
Report:AddIndent( LineReport:Text( ", " ) )
|
||||
|
||||
@@ -328,17 +328,39 @@ do -- TASK_A2A_INTERCEPT
|
||||
"Intercept incoming intruders.\n"
|
||||
)
|
||||
|
||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
||||
self:UpdateTaskInfo()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function TASK_A2A_INTERCEPT:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- @param #TASK_A2A_INTERCEPT self
|
||||
-- @param Wrapper.Group#GROUP ReportGroup
|
||||
function TASK_A2A_INTERCEPT:ReportOrder( ReportGroup )
|
||||
@@ -461,17 +483,40 @@ do -- TASK_A2A_SWEEP
|
||||
"Perform a fighter sweep. Incoming intruders were detected and could be hiding at the location.\n"
|
||||
)
|
||||
|
||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
||||
|
||||
self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
||||
|
||||
self:UpdateTaskInfo()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function TASK_A2A_SWEEP:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Assumed Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Lost Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
function TASK_A2A_SWEEP:ReportOrder( ReportGroup )
|
||||
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
||||
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
||||
@@ -587,17 +632,39 @@ do -- TASK_A2A_ENGAGE
|
||||
"Bogeys are nearby! Players close by are ordered to ENGAGE the intruders!\n"
|
||||
)
|
||||
|
||||
local TargetCoordinate = TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 10 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 0 )
|
||||
self:UpdateTaskInfo()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
|
||||
function TASK_A2A_ENGAGE:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
function TASK_A2A_ENGAGE:ReportOrder( ReportGroup )
|
||||
local Coordinate = self.TaskInfo.Coordinates.TaskInfoText
|
||||
local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate )
|
||||
|
||||
@@ -382,9 +382,7 @@ do -- TASK_A2A_DISPATCHER
|
||||
end
|
||||
|
||||
if DetectedItemChanged == true or Remove then
|
||||
--self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
||||
Mission:RemoveTask( Task )
|
||||
self.Tasks[DetectedItemIndex] = nil
|
||||
Task = self:RemoveTask( DetectedItemIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -482,6 +480,11 @@ do -- TASK_A2A_DISPATCHER
|
||||
return PlayersCount, PlayerTypesReport
|
||||
end
|
||||
|
||||
function TASK_A2A_DISPATCHER:RemoveTask( TaskIndex )
|
||||
self.Mission:RemoveTask( self.Tasks[TaskIndex] )
|
||||
self.Tasks[TaskIndex] = nil
|
||||
end
|
||||
|
||||
|
||||
--- Assigns tasks in relation to the detected items to the @{Set#SET_GROUP}.
|
||||
-- @param #TASK_A2A_DISPATCHER self
|
||||
@@ -510,8 +513,7 @@ do -- TASK_A2A_DISPATCHER
|
||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2A task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
||||
end
|
||||
Mission:RemoveTask( Task )
|
||||
self.Tasks[TaskIndex] = nil
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -538,21 +540,24 @@ do -- TASK_A2A_DISPATCHER
|
||||
local TargetSetUnit = self:EvaluateENGAGE( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2A_ENGAGE:New( Mission, self.SetGroup, string.format( "ENGAGE.%03d", DetectedID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
else
|
||||
local TargetSetUnit = self:EvaluateINTERCEPT( DetectedItem ) -- Returns a SetUnit if there are targets to be INTERCEPTed...
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2A_INTERCEPT:New( Mission, self.SetGroup, string.format( "INTERCEPT.%03d", DetectedID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
else
|
||||
local TargetSetUnit = self:EvaluateSWEEP( DetectedItem ) -- Returns a SetUnit
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2A_SWEEP:New( Mission, self.SetGroup, string.format( "SWEEP.%03d", DetectedID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if Task then
|
||||
self.Tasks[TaskIndex] = Task
|
||||
Task:SetTargetZone( DetectedZone, DetectedSet:GetFirst():GetAltitude(), DetectedSet:GetFirst():GetHeading() )
|
||||
Task:SetTargetZone( DetectedZone, DetectedItem.Coordinate.y, DetectedItem.Coordinate.Heading )
|
||||
Task:SetDispatcher( self )
|
||||
Mission:AddTask( Task )
|
||||
|
||||
|
||||
@@ -317,7 +317,7 @@ do -- TASK_A2G_SEAD
|
||||
-- @param Core.Set#SET_UNIT TargetSetUnit
|
||||
-- @param #string TaskBriefing The briefing of the task.
|
||||
-- @return #TASK_A2G_SEAD self
|
||||
function TASK_A2G_SEAD:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing )
|
||||
function TASK_A2G_SEAD:New( Mission, SetGroup, TaskName, TargetSetUnit, TaskBriefing)
|
||||
local self = BASE:Inherit( self, TASK_A2G:New( Mission, SetGroup, TaskName, TargetSetUnit, "SEAD", TaskBriefing ) ) -- #TASK_A2G_SEAD
|
||||
self:F()
|
||||
|
||||
@@ -335,13 +335,29 @@ do -- TASK_A2G_SEAD
|
||||
|
||||
function TASK_A2G_SEAD:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -462,13 +478,30 @@ do -- TASK_A2G_BAI
|
||||
|
||||
function TASK_A2G_BAI:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:E({self.Detection, self.DetectedItemIndex})
|
||||
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -590,13 +623,28 @@ do -- TASK_A2G_CAS
|
||||
|
||||
function TASK_A2G_CAS:UpdateTaskInfo()
|
||||
|
||||
local TargetCoordinate = self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
local TargetCoordinate = self.Detection and self.Detection:GetDetectedItemCoordinate( self.DetectedItemIndex ) or self.TargetSetUnit:GetFirst():GetCoordinate()
|
||||
self:SetInfo( "Coordinates", TargetCoordinate, 0 )
|
||||
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
self:SetInfo( "Threat", "[" .. string.rep( "■", self.Detection and self.Detection:GetDetectedItemThreatLevel( self.DetectedItemIndex ) or self.TargetSetUnit:CalculateThreatLevelA2G() ) .. "]", 11 )
|
||||
|
||||
if self.Detection then
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local ReportTypes = REPORT:New()
|
||||
local TargetTypes = {}
|
||||
for TargetUnitName, TargetUnit in pairs( self.TargetSetUnit:GetSet() ) do
|
||||
local TargetType = self.Detection:GetDetectedUnitTypeName( TargetUnit )
|
||||
if not TargetTypes[TargetType] then
|
||||
TargetTypes[TargetType] = TargetType
|
||||
ReportTypes:Add( TargetType )
|
||||
end
|
||||
end
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, ReportTypes:Text( ", " ) ), 10 )
|
||||
else
|
||||
local DetectedItemsCount = self.TargetSetUnit:Count()
|
||||
local DetectedItemsTypes = self.TargetSetUnit:GetTypeNames()
|
||||
self:SetInfo( "Targets", string.format( "%d of %s", DetectedItemsCount, DetectedItemsTypes ), 10 )
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
|
||||
@@ -121,8 +121,9 @@ do -- TASK_A2G_DISPATCHER
|
||||
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
||||
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
||||
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
||||
local RadarCount = DetectedSet:HasSEAD()
|
||||
|
||||
if GroundUnitCount > 0 and FriendliesNearBy == true then
|
||||
if RadarCount == 0 and GroundUnitCount > 0 and FriendliesNearBy == true then
|
||||
|
||||
-- Copy the Set
|
||||
local TargetSetUnit = SET_UNIT:New()
|
||||
@@ -150,8 +151,9 @@ do -- TASK_A2G_DISPATCHER
|
||||
-- Determine if the set has radar targets. If it does, construct a SEAD task.
|
||||
local GroundUnitCount = DetectedSet:HasGroundUnits()
|
||||
local FriendliesNearBy = self.Detection:IsFriendliesNearBy( DetectedItem )
|
||||
local RadarCount = DetectedSet:HasSEAD()
|
||||
|
||||
if GroundUnitCount > 0 and FriendliesNearBy == false then
|
||||
if RadarCount == 0 and GroundUnitCount > 0 and FriendliesNearBy == false then
|
||||
|
||||
-- Copy the Set
|
||||
local TargetSetUnit = SET_UNIT:New()
|
||||
@@ -164,6 +166,12 @@ do -- TASK_A2G_DISPATCHER
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
function TASK_A2G_DISPATCHER:RemoveTask( TaskIndex )
|
||||
self.Mission:RemoveTask( self.Tasks[TaskIndex] )
|
||||
self.Tasks[TaskIndex] = nil
|
||||
end
|
||||
|
||||
--- Evaluates the removal of the Task from the Mission.
|
||||
-- Can only occur when the DetectedItem is Changed AND the state of the Task is "Planned".
|
||||
-- @param #TASK_A2G_DISPATCHER self
|
||||
@@ -177,8 +185,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
if Task then
|
||||
if ( Task:IsStatePlanned() and DetectedItemChanged == true ) or Task:IsStateCancelled() then
|
||||
--self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
||||
Mission:RemoveTask( Task )
|
||||
self.Tasks[TaskIndex] = nil
|
||||
self:RemoveTask( TaskIndex )
|
||||
end
|
||||
end
|
||||
|
||||
@@ -213,6 +220,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||
Mission:GetCommandCenter():MessageToGroup( string.format( "Obsolete A2G task %s for %s removed.", TaskText, Mission:GetName() ), TaskGroup )
|
||||
end
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
Mission:RemoveTask( Task )
|
||||
self.Tasks[TaskIndex] = nil
|
||||
end
|
||||
@@ -232,10 +240,11 @@ do -- TASK_A2G_DISPATCHER
|
||||
local TaskIndex = DetectedItem.Index
|
||||
local DetectedItemChanged = DetectedItem.Changed
|
||||
|
||||
self:E( { DetectedItemChanged = DetectedItemChanged, DetectedItemID = DetectedItemID, TaskIndex = TaskIndex } )
|
||||
|
||||
local Task = self.Tasks[TaskIndex] -- Tasking.Task_A2G#TASK_A2G
|
||||
|
||||
if Task then
|
||||
|
||||
-- If there is a Task and the task was assigned, then we check if the task was changed ... If it was, we need to reevaluate the targets.
|
||||
if Task:IsStateAssigned() then
|
||||
if DetectedItemChanged == true then -- The detection has changed, thus a new TargetSet is to be evaluated and set
|
||||
@@ -254,24 +263,24 @@ do -- TASK_A2G_DISPATCHER
|
||||
if TargetSetUnit then
|
||||
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = nil
|
||||
self.Tasks[TaskIndex] = nil
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
else
|
||||
local TargetSetUnit = self:EvaluateBAI( DetectedItem ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||
if TargetSetUnit then
|
||||
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
TargetsReport:Add( Detection:GetChangeText( DetectedItem ) )
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = nil
|
||||
self.Tasks[TaskIndex] = nil
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -288,14 +297,56 @@ do -- TASK_A2G_DISPATCHER
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Task = self:EvaluateRemoveTask( Mission, Task, TaskIndex, DetectedItemChanged ) -- Task will be removed if it is planned and changed.
|
||||
if Task then
|
||||
if Task:IsStatePlanned() then
|
||||
if DetectedItemChanged == true then -- The detection has changed, thus a new TargetSet is to be evaluated and set
|
||||
if Task:IsInstanceOf( TASK_A2G_SEAD ) then
|
||||
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:UpdateTaskInfo()
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
else
|
||||
if Task:IsInstanceOf( TASK_A2G_CAS ) then
|
||||
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be CASed...
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
else
|
||||
if Task:IsInstanceOf( TASK_A2G_BAI ) then
|
||||
local TargetSetUnit = self:EvaluateBAI( DetectedItem ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||
if TargetSetUnit then
|
||||
Task:SetTargetSetUnit( TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
Task:UpdateTaskInfo()
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
else
|
||||
Task:Cancel()
|
||||
Task = self:RemoveTask( TaskIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
-- Evaluate SEAD
|
||||
if not Task then
|
||||
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2G_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", DetectedItemID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
end
|
||||
|
||||
-- Evaluate CAS
|
||||
@@ -303,6 +354,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be CASed...
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2G_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", DetectedItemID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
end
|
||||
|
||||
-- Evaluate BAI
|
||||
@@ -310,6 +362,7 @@ do -- TASK_A2G_DISPATCHER
|
||||
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.Mission:GetCommandCenter():GetPositionable():GetCoalition() ) -- Returns a SetUnit if there are targets to be BAIed...
|
||||
if TargetSetUnit then
|
||||
Task = TASK_A2G_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", DetectedItemID ), TargetSetUnit )
|
||||
Task:SetDetection( Detection, TaskIndex )
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user