Fixeds for tasking

- Fixed the hanging report (I think)
- Fixed the routing messages appearing every time again
- Fixed the Task menu
This commit is contained in:
FlightControl
2017-04-26 11:33:48 +02:00
parent 6e353cf893
commit 755343d02e
8 changed files with 138 additions and 125 deletions

View File

@@ -208,82 +208,91 @@ do -- TASK_A2G_DISPATCHER
local ChangeMsg = {}
local Mission = self.Mission
--- First we need to the detected targets.
for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do
local DetectedItem = DetectedItem -- Functional.Detection#DETECTION_BASE.DetectedItem
local DetectedSet = DetectedItem.Set -- Functional.Detection#DETECTION_BASE.DetectedSet
local DetectedZone = DetectedItem.Zone
self:E( { "Targets in DetectedItem", DetectedItem.ItemID, DetectedSet:Count(), tostring( DetectedItem ) } )
DetectedSet:Flush()
local ItemID = DetectedItem.ID
-- Evaluate SEAD Tasking
local SEADTask = Mission:GetTask( string.format( "SEAD.%03d", ItemID ) )
SEADTask = self:EvaluateRemoveTask( Mission, SEADTask, DetectedItem )
if not SEADTask then
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
SEADTask = Mission:AddTask( Task )
end
end
-- Evaluate CAS Tasking
local CASTask = Mission:GetTask( string.format( "CAS.%03d", ItemID ) )
CASTask = self:EvaluateRemoveTask( Mission, CASTask, DetectedItem )
if not CASTask then
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
CASTask = Mission:AddTask( Task )
end
end
-- Evaluate BAI Tasking
local BAITask = Mission:GetTask( string.format( "BAI.%03d", ItemID ) )
BAITask = self:EvaluateRemoveTask( Mission, BAITask, DetectedItem )
if not BAITask then
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.Mission:GetCommandCenter():GetPositionable():GetCoalition() ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
BAITask = Mission:AddTask( Task )
end
end
-- OK, so the tasking has been done, now delete the changes reported for the area.
Detection:AcceptChanges( DetectedItem )
end
if Mission:IsIDLE() or Mission:IsENGAGED() then
-- TODO set menus using the HQ coordinator
Mission:GetCommandCenter():SetMenu()
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
Mission:GetCommandCenter():MessageToGroup( string.format( "There are %d tasks remaining for mission *%s*. Subscribe to a task using the menu.", Mission:GetTasksRemaining(), Mission:GetName() ), TaskGroup )
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
-- Mission:GetCommandCenter():MessageToGroup(
-- string.format( "HQ Reporting - Planned tasks for mission '%s':\n\n%s\n",
-- self.Mission:GetName(),
-- string.format( "%s\n\n%s\n\n%s\n\n%s", ReportSEAD:Text(), ReportCAS:Text(), ReportBAI:Text(), ReportChanges:Text()
-- )
-- ), TaskGroup
-- )
local TaskReport = REPORT:New()
--- First we need to the detected targets.
for DetectedItemID, DetectedItem in pairs( Detection:GetDetectedItems() ) do
local DetectedItem = DetectedItem -- Functional.Detection#DETECTION_BASE.DetectedItem
local DetectedSet = DetectedItem.Set -- Functional.Detection#DETECTION_BASE.DetectedSet
local DetectedZone = DetectedItem.Zone
self:E( { "Targets in DetectedItem", DetectedItem.ItemID, DetectedSet:Count(), tostring( DetectedItem ) } )
DetectedSet:Flush()
local ItemID = DetectedItem.ID
-- Evaluate SEAD Tasking
local SEADTask = Mission:GetTask( string.format( "SEAD.%03d", ItemID ) )
SEADTask = self:EvaluateRemoveTask( Mission, SEADTask, DetectedItem )
if not SEADTask then
local TargetSetUnit = self:EvaluateSEAD( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_SEAD:New( Mission, self.SetGroup, string.format( "SEAD.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
SEADTask = Mission:AddTask( Task )
TaskReport:Add( Task:GetName() )
end
end
-- Evaluate CAS Tasking
local CASTask = Mission:GetTask( string.format( "CAS.%03d", ItemID ) )
CASTask = self:EvaluateRemoveTask( Mission, CASTask, DetectedItem )
if not CASTask then
local TargetSetUnit = self:EvaluateCAS( DetectedItem ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_CAS:New( Mission, self.SetGroup, string.format( "CAS.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
CASTask = Mission:AddTask( Task )
TaskReport:Add( Task:GetName() )
end
end
-- Evaluate BAI Tasking
local BAITask = Mission:GetTask( string.format( "BAI.%03d", ItemID ) )
BAITask = self:EvaluateRemoveTask( Mission, BAITask, DetectedItem )
if not BAITask then
local TargetSetUnit = self:EvaluateBAI( DetectedItem, self.Mission:GetCommandCenter():GetPositionable():GetCoalition() ) -- Returns a SetUnit if there are targets to be SEADed...
if TargetSetUnit then
local Task = TASK_BAI:New( Mission, self.SetGroup, string.format( "BAI.%03d", ItemID ), TargetSetUnit )
Task:SetTargetZone( DetectedZone )
Task:SetDispatcher( self )
Task:SetInfo( "Detection", Detection:DetectedItemReportSummary( DetectedItemID ) )
Task:SetInfo( "Changes", Detection:GetChangeText( DetectedItem ) )
BAITask = Mission:AddTask( Task )
TaskReport:Add( Task:GetName() )
end
end
-- OK, so the tasking has been done, now delete the changes reported for the area.
Detection:AcceptChanges( DetectedItem )
end
-- TODO set menus using the HQ coordinator
Mission:GetCommandCenter():SetMenu()
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
Mission:GetCommandCenter():MessageToGroup( string.format( "New task(s) %s for mission *%s*. Subscribe to a task using the Mission *Overlord* radio menu.", TaskReport:Text(", "), Mission:GetName() ), TaskGroup )
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
-- Mission:GetCommandCenter():MessageToGroup(
-- string.format( "HQ Reporting - Planned tasks for mission '%s':\n\n%s\n",
-- self.Mission:GetName(),
-- string.format( "%s\n\n%s\n\n%s\n\n%s", ReportSEAD:Text(), ReportCAS:Text(), ReportBAI:Text(), ReportChanges:Text()
-- )
-- ), TaskGroup
-- )
end
end
end
return true