mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Sync
This commit is contained in:
parent
68e3472c49
commit
2d3ee93d9e
@ -205,8 +205,11 @@ function STATEMACHINE._handler( self, EventName, ... )
|
||||
end
|
||||
|
||||
if execute then
|
||||
self:T3( { onenter = "onenter" .. to, callback = self["onenter" .. to] } )
|
||||
self:_call_handler("onenter" .. to, params)
|
||||
-- only execute the call if the From state is not equal to the To state! Otherwise this function should never execute!
|
||||
if from ~= to then
|
||||
self:T3( { onenter = "onenter" .. to, callback = self["onenter" .. to] } )
|
||||
self:_call_handler("onenter" .. to, params)
|
||||
end
|
||||
|
||||
self:T3( { On = "OnBefore" .. to, callback = self["OnBefore" .. to] } )
|
||||
if ( self:_call_handler("OnBefore" .. to, params ) ~= false ) then
|
||||
@ -434,6 +437,8 @@ function STATEMACHINE_PROCESS:Assign( Task, ProcessUnit )
|
||||
self:SetTask( Task )
|
||||
|
||||
self.ProcessGroup = ProcessUnit:GetGroup()
|
||||
--Task:RemoveMenuForGroup( self.ProcessGroup )
|
||||
--Task:SetAssignedMenuForGroup( self.ProcessGroup )
|
||||
|
||||
--self:Activate()
|
||||
|
||||
|
||||
@ -2,15 +2,7 @@
|
||||
-- A COMMANDCENTER governs multiple missions, the tasking and the reporting.
|
||||
-- @module CommandCenter
|
||||
|
||||
--- The COMMANDCENTER class
|
||||
-- @type COMMANDCENTER
|
||||
-- @field Wrapper.Group#GROUP HQ
|
||||
-- @list<Tasking.Mission#MISSION> Missions
|
||||
-- @extends Core.Base#BASE
|
||||
COMMANDCENTER = {
|
||||
ClassName = "COMMANDCENTER",
|
||||
Name = "",
|
||||
}
|
||||
|
||||
|
||||
--- The REPORT class
|
||||
-- @type REPORT
|
||||
@ -46,19 +38,31 @@ function REPORT:Text()
|
||||
return table.concat( self.Report, "\n" )
|
||||
end
|
||||
|
||||
|
||||
--- The COMMANDCENTER class
|
||||
-- @type COMMANDCENTER
|
||||
-- @field Wrapper.Group#GROUP HQ
|
||||
-- @field Dcs.DCSCoalitionObject#coalition CommandCenterCoalition
|
||||
-- @list<Tasking.Mission#MISSION> Missions
|
||||
-- @extends Core.Base#BASE
|
||||
COMMANDCENTER = {
|
||||
ClassName = "COMMANDCENTER",
|
||||
CommandCenterName = "",
|
||||
CommandCenterCoalition = nil,
|
||||
CommandCenterPositionable = nil,
|
||||
Name = "",
|
||||
}
|
||||
--- The constructor takes an IDENTIFIABLE as the HQ command center.
|
||||
-- @param #COMMANDCENTER self
|
||||
-- @param Wrapper.Positionable#POSITIONABLE HQ
|
||||
-- @param #string HQName
|
||||
-- @param Wrapper.Positionable#POSITIONABLE CommandCenterPositionable
|
||||
-- @param #string CommandCenterName
|
||||
-- @return #COMMANDCENTER
|
||||
function COMMANDCENTER:New( HQ, HQName )
|
||||
function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName )
|
||||
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
|
||||
self.HQ = HQ
|
||||
self.HQName = HQName or HQ:GetName()
|
||||
self.HQCoalition = HQ:GetCoalition()
|
||||
self.CommandCenterPositionable = CommandCenterPositionable
|
||||
self.CommandCenterName = CommandCenterName or CommandCenterPositionable:GetName()
|
||||
self.CommandCenterCoalition = CommandCenterPositionable:GetCoalition()
|
||||
|
||||
self.Missions = {}
|
||||
setmetatable( self.Missions, { __mode = "v" } )
|
||||
@ -69,8 +73,7 @@ function COMMANDCENTER:New( HQ, HQName )
|
||||
self:E( { EventData } )
|
||||
local EventGroup = GROUP:Find( EventData.IniDCSGroup )
|
||||
if EventGroup and HQ:HasGroup( EventGroup ) then
|
||||
local MenuHQ = MENU_GROUP:New( EventGroup, "HQ" )
|
||||
local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", MenuHQ )
|
||||
local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu )
|
||||
local MenuMissions = MENU_GROUP_COMMAND:New( EventGroup, "Missions", MenuReporting, HQ.ReportMissions, HQ, EventGroup )
|
||||
end
|
||||
end
|
||||
@ -115,6 +118,8 @@ end
|
||||
-- @param #COMMANDCENTER self
|
||||
function COMMANDCENTER:SetMenu()
|
||||
|
||||
self.CommandCenterMenu = MENU_COALITION:New( self.CommandCenterCoalition, "HQ" )
|
||||
|
||||
for MissionID, Mission in pairs( self.Missions ) do
|
||||
local Mission = Mission -- Tasking.Mission#MISSION
|
||||
Mission:SetMenu()
|
||||
|
||||
@ -41,19 +41,21 @@ end
|
||||
|
||||
--- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc.
|
||||
-- @param #MISSION self
|
||||
-- @param Tasking.CommandCenter#COMMANDCENTER CommandCenter
|
||||
-- @param #string MissionName is the name of the mission. This name will be used to reference the status of each mission by the players.
|
||||
-- @param #string MissionPriority is a string indicating the "priority" of the Mission. f.e. "Primary", "Secondary" or "First", "Second". It is free format and up to the Mission designer to choose. There are no rules behind this field.
|
||||
-- @param #string MissionBriefing is a string indicating the mission briefing to be shown when a player joins a @{CLIENT}.
|
||||
-- @param DCSCoalitionObject#coalition MissionCoalition is a string indicating the coalition or party to which this mission belongs to. It is free format and can be chosen freely by the mission designer. Note that this field is not to be confused with the coalition concept of the ME. Examples of a Mission Coalition could be "NATO", "CCCP", "Intruders", "Terrorists"...
|
||||
-- @return #MISSION self
|
||||
function MISSION:New( HQ, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
||||
function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefing, MissionCoalition )
|
||||
|
||||
local self = BASE:Inherit( self, STATEMACHINE:New() ) -- Core.StateMachine#STATEMACHINE
|
||||
|
||||
self:T( { MissionName, MissionPriority, MissionBriefing, MissionCoalition } )
|
||||
|
||||
self.HQ = HQ
|
||||
HQ:AddMission( self )
|
||||
self.CommandCenter = CommandCenter
|
||||
CommandCenter:AddMission( self )
|
||||
|
||||
self.Name = MissionName
|
||||
self.MissionPriority = MissionPriority
|
||||
self.MissionBriefing = MissionBriefing
|
||||
@ -118,15 +120,19 @@ end
|
||||
|
||||
--- Sets the Planned Task menu.
|
||||
-- @param #MISSION self
|
||||
-- @param Core.Menu#MENU_COALITION CommandCenterMenu
|
||||
function MISSION:SetMenu()
|
||||
|
||||
for _, Task in pairs( self.Tasks ) do
|
||||
local Task = Task -- Tasking.Task#TASK_BASE
|
||||
Task:RemoveMenu()
|
||||
Task:SetMenu()
|
||||
end
|
||||
end
|
||||
|
||||
function MISSION:GetCommandCenter()
|
||||
return self.CommandCenter
|
||||
end
|
||||
|
||||
--- Sets the Assigned Task menu.
|
||||
-- @param #MISSION self
|
||||
-- @param Task#TASK_BASE Task
|
||||
|
||||
@ -106,6 +106,11 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType, TaskCategor
|
||||
return self
|
||||
end
|
||||
|
||||
function TASK_BASE:GetMission()
|
||||
|
||||
return self.Mission
|
||||
end
|
||||
|
||||
--- Gets the SET_GROUP assigned to the TASK.
|
||||
-- @param #TASK_BASE self
|
||||
-- @return Core.Set#SET_GROUP
|
||||
@ -142,6 +147,7 @@ function TASK_BASE:AssignToGroup( TaskGroup )
|
||||
|
||||
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
||||
|
||||
self:RemoveMenuForGroup( TaskGroup )
|
||||
self:SetAssignedMenuForGroup( TaskGroup )
|
||||
|
||||
local TaskUnits = TaskGroup:GetUnits()
|
||||
@ -291,8 +297,7 @@ function TASK_BASE:SetMenu()
|
||||
|
||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||
if not self:IsAssignedToGroup( TaskGroup ) then
|
||||
local MenuText = self:GetPlannedMenuText()
|
||||
self:SetPlannedMenuForGroup( TaskGroup, MenuText )
|
||||
self:SetPlannedMenuForGroup( TaskGroup, self:GetTaskName() )
|
||||
else
|
||||
self:SetAssignedMenuForGroup( TaskGroup )
|
||||
end
|
||||
@ -319,38 +324,17 @@ end
|
||||
function TASK_BASE:SetPlannedMenuForGroup( TaskGroup, MenuText )
|
||||
self:E( TaskGroup:GetName() )
|
||||
|
||||
local TaskMission = self.Mission:GetName()
|
||||
local TaskCategory = self:GetCategory()
|
||||
local Mission = self:GetMission()
|
||||
local CommandCenter = Mission:GetCommandCenter()
|
||||
local CommandCenterMenu = CommandCenter.CommandCenterMenu
|
||||
|
||||
local MissionName = Mission:GetName()
|
||||
local TaskType = self:GetType()
|
||||
|
||||
local Mission = self.Mission
|
||||
|
||||
Mission.MenuMission = Mission.MenuMission or {}
|
||||
local MenuMission = Mission.MenuMission
|
||||
|
||||
Mission.MenuCategory = Mission.MenuCategory or {}
|
||||
local MenuCategory = Mission.MenuCategory
|
||||
|
||||
Mission.MenuType = Mission.MenuType or {}
|
||||
local MenuType = Mission.MenuType
|
||||
|
||||
self.Menu = self.Menu or {}
|
||||
local Menu = self.Menu
|
||||
|
||||
local TaskGroupName = TaskGroup:GetName()
|
||||
MenuMission[TaskGroupName] = MenuMission[TaskGroupName] or MENU_GROUP:New( TaskGroup, TaskMission, nil )
|
||||
|
||||
MenuCategory[TaskGroupName] = MenuCategory[TaskGroupName] or {}
|
||||
MenuCategory[TaskGroupName][TaskCategory] = MenuCategory[TaskGroupName][TaskCategory] or MENU_GROUP:New( TaskGroup, TaskCategory, MenuMission[TaskGroupName] )
|
||||
|
||||
MenuType[TaskGroupName] = MenuType[TaskGroupName] or {}
|
||||
MenuType[TaskGroupName][TaskType] = MenuType[TaskGroupName][TaskType] or MENU_GROUP:New( TaskGroup, TaskType, MenuCategory[TaskGroupName][TaskCategory] )
|
||||
|
||||
if Menu[TaskGroupName] then
|
||||
Menu[TaskGroupName]:Remove()
|
||||
end
|
||||
Menu[TaskGroupName] = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, MenuType[TaskGroupName][TaskType], self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } )
|
||||
|
||||
|
||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu )
|
||||
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, MissionMenu )
|
||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -361,24 +345,17 @@ end
|
||||
function TASK_BASE:SetAssignedMenuForGroup( TaskGroup )
|
||||
self:E( TaskGroup:GetName() )
|
||||
|
||||
local TaskMission = self.Mission:GetName()
|
||||
|
||||
local Mission = self.Mission
|
||||
local Mission = self:GetMission()
|
||||
local CommandCenter = Mission:GetCommandCenter()
|
||||
local CommandCenterMenu = CommandCenter.CommandCenterMenu
|
||||
|
||||
Mission.MenuMission = Mission.MenuMission or {}
|
||||
local MenuMission = Mission.MenuMission
|
||||
|
||||
self.MenuStatus = self.MenuStatus or {}
|
||||
local MenuStatus = self.MenuStatus
|
||||
|
||||
|
||||
self.MenuAbort = self.MenuAbort or {}
|
||||
local MenuAbort = self.MenuAbort
|
||||
local MissionName = Mission:GetName()
|
||||
|
||||
local TaskGroupName = TaskGroup:GetName()
|
||||
MenuMission[TaskGroupName] = MenuMission[TaskGroupName] or MENU_GROUP:New( TaskGroup, TaskMission, nil )
|
||||
MenuStatus[TaskGroupName] = MENU_GROUP_COMMAND:New( TaskGroup, "Task Status", MenuMission[TaskGroupName], self.MenuTaskStatus, { self = self, TaskGroup = TaskGroup } )
|
||||
MenuAbort[TaskGroupName] = MENU_GROUP_COMMAND:New( TaskGroup, "Abort Task", MenuMission[TaskGroupName], self.MenuTaskAbort, { self = self, TaskGroup = TaskGroup } )
|
||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu )
|
||||
self:E( { MissionMenu = MissionMenu } )
|
||||
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Task Status", MissionMenu, self.MenuTaskStatus, { self = self, TaskGroup = TaskGroup } )
|
||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Abort Task", MissionMenu, self.MenuTaskAbort, { self = self, TaskGroup = TaskGroup } )
|
||||
|
||||
return self
|
||||
end
|
||||
@ -389,50 +366,11 @@ end
|
||||
-- @return #TASK_BASE self
|
||||
function TASK_BASE:RemoveMenuForGroup( TaskGroup )
|
||||
|
||||
local TaskGroupName = TaskGroup:GetName()
|
||||
|
||||
local Mission = self.Mission
|
||||
local MenuMission = Mission.MenuMission
|
||||
local MenuCategory = Mission.MenuCategory
|
||||
local MenuType = Mission.MenuType
|
||||
local MenuStatus = self.MenuStatus
|
||||
local MenuAbort = self.MenuAbort
|
||||
local Menu = self.Menu
|
||||
|
||||
Menu = Menu or {}
|
||||
if Menu[TaskGroupName] then
|
||||
Menu[TaskGroupName]:Remove()
|
||||
Menu[TaskGroupName] = nil
|
||||
end
|
||||
|
||||
MenuType = MenuType or {}
|
||||
if MenuType[TaskGroupName] then
|
||||
for _, Menu in pairs( MenuType[TaskGroupName] ) do
|
||||
Menu:Remove()
|
||||
end
|
||||
MenuType[TaskGroupName] = nil
|
||||
end
|
||||
|
||||
MenuCategory = MenuCategory or {}
|
||||
if MenuCategory[TaskGroupName] then
|
||||
for _, Menu in pairs( MenuCategory[TaskGroupName] ) do
|
||||
Menu:Remove()
|
||||
end
|
||||
MenuCategory[TaskGroupName] = nil
|
||||
end
|
||||
|
||||
MenuStatus = MenuStatus or {}
|
||||
if MenuStatus[TaskGroupName] then
|
||||
MenuStatus[TaskGroupName]:Remove()
|
||||
MenuStatus[TaskGroupName] = nil
|
||||
end
|
||||
|
||||
MenuAbort = MenuAbort or {}
|
||||
if MenuAbort[TaskGroupName] then
|
||||
MenuAbort[TaskGroupName]:Remove()
|
||||
MenuAbort[TaskGroupName] = nil
|
||||
end
|
||||
local Mission = self:GetMission()
|
||||
local MissionName = Mission:GetName()
|
||||
|
||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName )
|
||||
MissionMenu:Remove()
|
||||
end
|
||||
|
||||
function TASK_BASE.MenuAssignToGroup( MenuParam )
|
||||
@ -829,6 +767,7 @@ end
|
||||
function TASK_BASE:onenterAssigned( Event, From, To )
|
||||
|
||||
self:E("Assigned")
|
||||
|
||||
|
||||
end
|
||||
|
||||
|
||||
@ -46,3 +46,5 @@ function FsmSEAD:onenterUpdated( TaskUnit )
|
||||
end
|
||||
|
||||
Mission:AddTask( TaskSEAD )
|
||||
|
||||
HQ:SetMenu()
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user