mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Got mission dispatching working again with SEAD_Task and A2G_Task ...
Next is debugging all, and ensuring the scoring and Failed / Abort is working.
This commit is contained in:
@@ -381,6 +381,7 @@ do -- DETECTION_DISPATCHER
|
||||
|
||||
if Task then
|
||||
if Task:IsStatePlanned() and DetectedArea.Changed == true then
|
||||
self:E( "Removing Tasking: " .. Task:GetTaskName() )
|
||||
Mission:RemoveTaskMenu( Task )
|
||||
Task = Mission:RemoveTask( Task )
|
||||
end
|
||||
@@ -420,10 +421,11 @@ do -- DETECTION_DISPATCHER
|
||||
if not SEADTask then
|
||||
local TargetSetUnit = self:EvaluateSEAD( DetectedArea ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
SEADTask = Mission:AddTask( TASK_SEAD:New( Mission, self.SetGroup, "SEAD." .. AreaID, TargetSetUnit , DetectedZone ) ):StatePlanned()
|
||||
SEADTask = Mission:AddTask( TASK_SEAD:New( Mission, self.SetGroup, "SEAD." .. AreaID, TargetSetUnit , DetectedZone ) )
|
||||
end
|
||||
end
|
||||
if SEADTask and SEADTask:IsStatePlanned() then
|
||||
self:E( "Planned" )
|
||||
SEADTask:SetPlannedMenu()
|
||||
TaskMsg[#TaskMsg+1] = " - " .. SEADTask:GetStateString() .. " SEAD " .. AreaID .. " - " .. SEADTask.TargetSetUnit:GetUnitTypesText()
|
||||
end
|
||||
@@ -434,7 +436,7 @@ do -- DETECTION_DISPATCHER
|
||||
if not CASTask then
|
||||
local TargetSetUnit = self:EvaluateCAS( DetectedArea ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
CASTask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "CAS." .. AreaID, "CAS", TargetSetUnit , DetectedZone, DetectedArea.NearestFAC ) ):StatePlanned()
|
||||
CASTask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "CAS." .. AreaID, "CAS", TargetSetUnit , DetectedZone, DetectedArea.NearestFAC ) )
|
||||
end
|
||||
end
|
||||
if CASTask and CASTask:IsStatePlanned() then
|
||||
@@ -448,7 +450,7 @@ do -- DETECTION_DISPATCHER
|
||||
if not BAITask then
|
||||
local TargetSetUnit = self:EvaluateBAI( DetectedArea, self.CommandCenter:GetCoalition() ) -- Returns a SetUnit if there are targets to be SEADed...
|
||||
if TargetSetUnit then
|
||||
BAITask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "BAI." .. AreaID, "BAI", TargetSetUnit , DetectedZone, DetectedArea.NearestFAC ) ):StatePlanned()
|
||||
BAITask = Mission:AddTask( TASK_A2G:New( Mission, self.SetGroup, "BAI." .. AreaID, "BAI", TargetSetUnit , DetectedZone, DetectedArea.NearestFAC ) )
|
||||
end
|
||||
end
|
||||
if BAITask and BAITask:IsStatePlanned() then
|
||||
|
||||
@@ -13,7 +13,6 @@ MISSION = {
|
||||
Name = "",
|
||||
MissionStatus = "PENDING",
|
||||
_Clients = {},
|
||||
Tasks = {},
|
||||
TaskMenus = {},
|
||||
TaskCategoryMenus = {},
|
||||
TaskTypeMenus = {},
|
||||
@@ -57,6 +56,9 @@ function MISSION:New( MissionName, MissionPriority, MissionBriefing, MissionCoal
|
||||
self.MissionPriority = MissionPriority
|
||||
self.MissionBriefing = MissionBriefing
|
||||
self.MissionCoalition = MissionCoalition
|
||||
|
||||
self.Tasks = {}
|
||||
setmetatable( self.Tasks, { __mode = "v" } )
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -141,8 +143,7 @@ function MISSION:ClearMissionMenu()
|
||||
end
|
||||
|
||||
--- Get the TASK identified by the TaskNumber from the Mission. This function is useful in GoalFunctions.
|
||||
-- @param #string TaskIndex is the Index of the @{Task} within the @{Mission}.
|
||||
-- @param #number TaskID is the ID of the @{Task} within the @{Mission}.
|
||||
-- @param #string TaskName The Name of the @{Task} within the @{Mission}.
|
||||
-- @return Task#TASK_BASE The Task
|
||||
-- @return #nil Returns nil if no task was found.
|
||||
function MISSION:GetTask( TaskName )
|
||||
@@ -178,6 +179,7 @@ end
|
||||
function MISSION:RemoveTask( Task )
|
||||
|
||||
local TaskName = Task:GetTaskName()
|
||||
|
||||
self:F( TaskName )
|
||||
self.Tasks[TaskName] = self.Tasks[TaskName] or { n = 0 }
|
||||
|
||||
@@ -187,6 +189,8 @@ function MISSION:RemoveTask( Task )
|
||||
self.Tasks[TaskName] = nil
|
||||
Task = nil
|
||||
|
||||
collectgarbage()
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
@@ -406,7 +410,7 @@ end
|
||||
function MISSION:GetTasks()
|
||||
self:F()
|
||||
|
||||
return self._Tasks
|
||||
return self.Tasks
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType, TaskCategor
|
||||
self:SetName( TaskName )
|
||||
self:SetID( Mission:GetNextTaskID( self ) ) -- The Mission orchestrates the task sequences ..
|
||||
|
||||
self.TaskBriefing = "You are assigned to the task: " .. self.TaskName .. "."
|
||||
self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "."
|
||||
|
||||
self.FsmTemplate = self.FsmTemplate or STATEMACHINE_PROCESS:New( {} )
|
||||
self.FsmTemplate:SetTask( self )
|
||||
@@ -432,6 +432,8 @@ function TASK_BASE.MenuAssignToGroup( MenuParam )
|
||||
local self = MenuParam.self
|
||||
local TaskGroup = MenuParam.TaskGroup
|
||||
|
||||
self:E( "Assigned menu selected")
|
||||
|
||||
self:AssignToGroup( TaskGroup )
|
||||
end
|
||||
|
||||
@@ -691,7 +693,7 @@ end
|
||||
--- Is the @{Task} status **Success**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStateSuccess()
|
||||
return self:GetStateString() == "Success"
|
||||
return self:Is( "Success" )
|
||||
end
|
||||
|
||||
--- Sets a @{Task} to status **Failed**.
|
||||
@@ -704,7 +706,7 @@ end
|
||||
--- Is the @{Task} status **Failed**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStateFailed()
|
||||
return self:GetStateString() == "Failed"
|
||||
return self:Is( "Failed" )
|
||||
end
|
||||
|
||||
--- Sets a @{Task} to status **Planned**.
|
||||
@@ -717,7 +719,7 @@ end
|
||||
--- Is the @{Task} status **Planned**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStatePlanned()
|
||||
return self:GetStateString() == "Planned"
|
||||
return self:Is( "Planned" )
|
||||
end
|
||||
|
||||
--- Sets a @{Task} to status **Assigned**.
|
||||
@@ -730,7 +732,7 @@ end
|
||||
--- Is the @{Task} status **Assigned**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStateAssigned()
|
||||
return self:GetStateString() == "Assigned"
|
||||
return self:Is( "Assigned" )
|
||||
end
|
||||
|
||||
--- Sets a @{Task} to status **Hold**.
|
||||
@@ -743,7 +745,7 @@ end
|
||||
--- Is the @{Task} status **Hold**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStateHold()
|
||||
return self:GetStateString() == "Hold"
|
||||
return self:Is( "Hold" )
|
||||
end
|
||||
|
||||
--- Sets a @{Task} to status **Replanned**.
|
||||
@@ -756,7 +758,7 @@ end
|
||||
--- Is the @{Task} status **Replanned**.
|
||||
-- @param #TASK_BASE self
|
||||
function TASK_BASE:IsStateReplanned()
|
||||
return self:GetStateString() == "Replanned"
|
||||
return self:Is( "Replanned" )
|
||||
end
|
||||
|
||||
--- Gets the @{Task} status.
|
||||
@@ -812,28 +814,27 @@ end
|
||||
|
||||
--- StateMachine callback function for a TASK
|
||||
-- @param #TASK_BASE self
|
||||
-- @param StateMachine#STATEMACHINE_TASK Fsm
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Event#EVENTDATA Event
|
||||
function TASK_BASE:onenterAssigned( Fsm, Event, From, To )
|
||||
function TASK_BASE:onenterAssigned( Event, From, To )
|
||||
|
||||
self:E("Assigned")
|
||||
|
||||
end
|
||||
|
||||
|
||||
--- StateMachine callback function for a TASK
|
||||
-- @param #TASK_BASE self
|
||||
-- @param Unit#UNIT TaskUnit
|
||||
-- @param StateMachine#STATEMACHINE_TASK Fsm
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Event#EVENTDATA Event
|
||||
function TASK_BASE:onenterSuccess( TaskUnit, Fsm, Event, From, To )
|
||||
function TASK_BASE:onenterSuccess( Event, From, To )
|
||||
|
||||
self:E("Success")
|
||||
|
||||
end
|
||||
|
||||
--- StateMachine callback function for a TASK
|
||||
|
||||
@@ -47,12 +47,12 @@ do -- TASK_SEAD
|
||||
|
||||
local Fsm = self:GetFsmTemplate()
|
||||
|
||||
Fsm:AddProcess( "Planned", "Accept", "Planned", PROCESS_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
|
||||
Fsm:AddProcess( "Planned", "Accept", PROCESS_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
|
||||
Fsm:AddProcess( "Assigned", "Route", PROCESS_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
|
||||
Fsm:AddAction ( "Rejected", "Eject", "Planned" )
|
||||
Fsm:AddAction ( "Arrived", "Update", "Updated" )
|
||||
Fsm:AddProcess( "Updated", "Account", PROCESS_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
|
||||
Fsm:AddProcess( "Updated", "Smoke", PROCESS_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
|
||||
Fsm:AddProcess( "*", "Account", PROCESS_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
|
||||
Fsm:AddProcess( "*", "Smoke", PROCESS_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
|
||||
Fsm:AddAction ( "Accounted", "Success", "Success" )
|
||||
Fsm:AddAction ( "Failed", "Fail", "Failed" )
|
||||
|
||||
|
||||
Reference in New Issue
Block a user