mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
commit
96aa49d682
@ -1011,12 +1011,12 @@ do -- FSM_PROCESS
|
|||||||
-- Copy Processes
|
-- Copy Processes
|
||||||
for ProcessID, Process in pairs( self:GetProcesses() ) do
|
for ProcessID, Process in pairs( self:GetProcesses() ) do
|
||||||
self:E( { Process} )
|
self:E( { Process} )
|
||||||
Process.fsm:Remove()
|
if Process.fsm then
|
||||||
Process.fsm = nil
|
Process.fsm:Remove()
|
||||||
|
Process.fsm = nil
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self._Processes = nil
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1121,7 +1121,7 @@ end
|
|||||||
self:T( { ProcessUnit, From, Event, To, Dummy, self:IsTrace() } )
|
self:T( { ProcessUnit, From, Event, To, Dummy, self:IsTrace() } )
|
||||||
|
|
||||||
if self:IsTrace() then
|
if self:IsTrace() then
|
||||||
MESSAGE:New( "@ Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
|
--MESSAGE:New( "@ Process " .. self:GetClassNameAndID() .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T( { Scores = self._Scores, To = To } )
|
self:T( { Scores = self._Scores, To = To } )
|
||||||
|
|||||||
@ -82,7 +82,7 @@ do -- MENU_BASE
|
|||||||
-- @param #string MenuText The text of the child menu.
|
-- @param #string MenuText The text of the child menu.
|
||||||
-- @return #MENU_BASE
|
-- @return #MENU_BASE
|
||||||
function MENU_BASE:GetMenu( MenuText )
|
function MENU_BASE:GetMenu( MenuText )
|
||||||
self:F( { self.Menus, MenuText } )
|
self:F2( { Menu = self.Menus[MenuText] } )
|
||||||
return self.Menus[MenuText]
|
return self.Menus[MenuText]
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -810,9 +810,9 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #MENU_GROUP self
|
-- @return #MENU_GROUP self
|
||||||
function MENU_GROUP:RemoveSubMenus( MenuTime )
|
function MENU_GROUP:RemoveSubMenus( MenuTime )
|
||||||
self:F2( { self.MenuPath, MenuTime, self.MenuTime } )
|
--self:F2( { self.MenuPath, MenuTime, self.MenuTime } )
|
||||||
|
|
||||||
self:T( { "Removing Group SubMenus:", self.MenuGroup:GetName(), self.MenuPath } )
|
--self:T( { "Removing Group SubMenus:", self.MenuGroup:GetName(), self.MenuPath } )
|
||||||
for MenuText, Menu in pairs( self.Menus ) do
|
for MenuText, Menu in pairs( self.Menus ) do
|
||||||
Menu:Remove( MenuTime )
|
Menu:Remove( MenuTime )
|
||||||
end
|
end
|
||||||
@ -825,7 +825,7 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP:Remove( MenuTime )
|
function MENU_GROUP:Remove( MenuTime )
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
--self:F2( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||||
|
|
||||||
self:RemoveSubMenus( MenuTime )
|
self:RemoveSubMenus( MenuTime )
|
||||||
|
|
||||||
@ -844,7 +844,7 @@ do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
self:T( { "Removing Group Menu:", self.MenuGroup:GetName(), self.MenuGroup._Menus[self.Path].Path } )
|
self:T( { "Removing Group Menu:", MenuGroup = self.MenuGroup:GetName(), MenuPath = self.MenuGroup._Menus[self.Path].Path } )
|
||||||
self.MenuGroup._Menus[self.Path] = nil
|
self.MenuGroup._Menus[self.Path] = nil
|
||||||
self = nil
|
self = nil
|
||||||
end
|
end
|
||||||
@ -882,7 +882,7 @@ do
|
|||||||
local Path = ( ParentMenu and ( table.concat( ParentMenu.MenuPath or {}, "@" ) .. "@" .. MenuText ) ) or MenuText
|
local Path = ( ParentMenu and ( table.concat( ParentMenu.MenuPath or {}, "@" ) .. "@" .. MenuText ) ) or MenuText
|
||||||
if MenuGroup._Menus[Path] then
|
if MenuGroup._Menus[Path] then
|
||||||
self = MenuGroup._Menus[Path]
|
self = MenuGroup._Menus[Path]
|
||||||
self:T( { "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } )
|
self:F2( { "Re-using Group Command Menu:", MenuGroup:GetName(), MenuText } )
|
||||||
else
|
else
|
||||||
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
self = BASE:Inherit( self, MENU_COMMAND_BASE:New( MenuText, ParentMenu, CommandMenuFunction, arg ) )
|
||||||
|
|
||||||
@ -896,7 +896,7 @@ do
|
|||||||
self.MenuText = MenuText
|
self.MenuText = MenuText
|
||||||
self.ParentMenu = ParentMenu
|
self.ParentMenu = ParentMenu
|
||||||
|
|
||||||
self:T( { "Adding Group Command Menu:", MenuGroup:GetName(), MenuText, self.MenuParentPath } )
|
self:F( { "Adding Group Command Menu:", MenuGroup = MenuGroup:GetName(), MenuText = MenuText, MenuPath = self.MenuParentPath } )
|
||||||
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
self.MenuPath = missionCommands.addCommandForGroup( self.MenuGroupID, MenuText, self.MenuParentPath, self.MenuCallHandler, arg )
|
||||||
|
|
||||||
if self.ParentMenu and self.ParentMenu.Menus then
|
if self.ParentMenu and self.ParentMenu.Menus then
|
||||||
@ -914,14 +914,14 @@ do
|
|||||||
-- @param MenuTime
|
-- @param MenuTime
|
||||||
-- @return #nil
|
-- @return #nil
|
||||||
function MENU_GROUP_COMMAND:Remove( MenuTime )
|
function MENU_GROUP_COMMAND:Remove( MenuTime )
|
||||||
self:F( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
--self:F2( { self.MenuGroupID, self.MenuPath, MenuTime, self.MenuTime } )
|
||||||
|
|
||||||
if not MenuTime or self.MenuTime ~= MenuTime then
|
if not MenuTime or self.MenuTime ~= MenuTime then
|
||||||
if self.MenuGroup._Menus[self.Path] then
|
if self.MenuGroup._Menus[self.Path] then
|
||||||
self = self.MenuGroup._Menus[self.Path]
|
self = self.MenuGroup._Menus[self.Path]
|
||||||
|
|
||||||
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
missionCommands.removeItemForGroup( self.MenuGroupID, self.MenuPath )
|
||||||
self:T( { "Removing Group Command Menu:", self.MenuGroup:GetName(), self.MenuText, self.Path, self.MenuGroup._Menus[self.Path].Path } )
|
self:T( { "Removing Group Command Menu:", MenuGroup = self.MenuGroup:GetName(), MenuText = self.MenuText, MenuPath = self.Path } )
|
||||||
|
|
||||||
self.ParentMenu.Menus[self.MenuText] = nil
|
self.ParentMenu.Menus[self.MenuText] = nil
|
||||||
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
self.ParentMenu.MenuCount = self.ParentMenu.MenuCount - 1
|
||||||
|
|||||||
@ -165,11 +165,10 @@ end
|
|||||||
-- @param #SET_BASE self
|
-- @param #SET_BASE self
|
||||||
-- @param #string ObjectName
|
-- @param #string ObjectName
|
||||||
function SET_BASE:Remove( ObjectName )
|
function SET_BASE:Remove( ObjectName )
|
||||||
self:F( ObjectName )
|
|
||||||
|
|
||||||
local t = self.Set[ObjectName]
|
local t = self.Set[ObjectName]
|
||||||
|
|
||||||
self:E( { ObjectName, t } )
|
self:F3( { ObjectName, t } )
|
||||||
|
|
||||||
if t then
|
if t then
|
||||||
if t._next then
|
if t._next then
|
||||||
@ -1568,7 +1567,7 @@ end
|
|||||||
-- @return #string The name of the UNIT
|
-- @return #string The name of the UNIT
|
||||||
-- @return #table The UNIT
|
-- @return #table The UNIT
|
||||||
function SET_UNIT:FindInDatabase( Event )
|
function SET_UNIT:FindInDatabase( Event )
|
||||||
self:E( { Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName], Event } )
|
self:F2( { Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName], Event } )
|
||||||
|
|
||||||
|
|
||||||
return Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName]
|
return Event.IniDCSUnitName, self.Set[Event.IniDCSUnitName]
|
||||||
|
|||||||
@ -269,7 +269,6 @@ end
|
|||||||
-- @param #COMMANDCENTER self
|
-- @param #COMMANDCENTER self
|
||||||
-- @return Core.Menu#MENU_COALITION
|
-- @return Core.Menu#MENU_COALITION
|
||||||
function COMMANDCENTER:GetMenu()
|
function COMMANDCENTER:GetMenu()
|
||||||
self:F()
|
|
||||||
return self.CommandCenterMenu
|
return self.CommandCenterMenu
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@ -12,6 +12,7 @@ MISSION = {
|
|||||||
ClassName = "MISSION",
|
ClassName = "MISSION",
|
||||||
Name = "",
|
Name = "",
|
||||||
MissionStatus = "PENDING",
|
MissionStatus = "PENDING",
|
||||||
|
AssignedGroups = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc.
|
--- This is the main MISSION declaration method. Each Mission is like the master or a Mission orchestration between, Clients, Tasks, Stages etc.
|
||||||
@ -288,20 +289,17 @@ end
|
|||||||
-- If the Unit is part of a Task in the Mission, true is returned.
|
-- If the Unit is part of a Task in the Mission, true is returned.
|
||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player joining the Mission.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player joining the Mission.
|
||||||
-- @return #boolean true if Unit is part of a Task in the Mission.
|
-- @return #MISSION
|
||||||
function MISSION:AbortUnit( PlayerUnit )
|
function MISSION:AbortUnit( PlayerUnit )
|
||||||
self:F( { PlayerUnit = PlayerUnit } )
|
self:F( { PlayerUnit = PlayerUnit } )
|
||||||
|
|
||||||
local PlayerUnitRemoved = false
|
|
||||||
|
|
||||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||||
local Task = Task -- Tasking.Task#TASK
|
local Task = Task -- Tasking.Task#TASK
|
||||||
if Task:AbortUnit( PlayerUnit ) then
|
local PlayerGroup = PlayerUnit:GetGroup()
|
||||||
PlayerUnitRemoved = true
|
Task:AbortGroup( PlayerGroup )
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return PlayerUnitRemoved
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Handles a crash of a PlayerUnit from the Mission.
|
--- Handles a crash of a PlayerUnit from the Mission.
|
||||||
@ -366,7 +364,7 @@ end
|
|||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
function MISSION:SetMenu( MenuTime )
|
function MISSION:SetMenu( MenuTime )
|
||||||
self:F()
|
self:F( { self:GetName(), MenuTime } )
|
||||||
|
|
||||||
for _, TaskData in pairs( self:GetTasks() ) do
|
for _, TaskData in pairs( self:GetTasks() ) do
|
||||||
local Task = TaskData -- Tasking.Task#TASK
|
local Task = TaskData -- Tasking.Task#TASK
|
||||||
@ -378,7 +376,7 @@ end
|
|||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
function MISSION:RemoveMenu( MenuTime )
|
function MISSION:RemoveMenu( MenuTime )
|
||||||
self:F()
|
self:F( { self:GetName(), MenuTime } )
|
||||||
|
|
||||||
for _, Task in pairs( self:GetTasks() ) do
|
for _, Task in pairs( self:GetTasks() ) do
|
||||||
local Task = Task -- Tasking.Task#TASK
|
local Task = Task -- Tasking.Task#TASK
|
||||||
@ -387,6 +385,58 @@ function MISSION:RemoveMenu( MenuTime )
|
|||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
do -- Group Assignment
|
||||||
|
|
||||||
|
--- Returns if the @{Mission} is assigned to the Group.
|
||||||
|
-- @param #MISSION self
|
||||||
|
-- @param Wrapper.Group#GROUP MissionGroup
|
||||||
|
-- @return #boolean
|
||||||
|
function MISSION:IsGroupAssigned( MissionGroup )
|
||||||
|
|
||||||
|
local MissionGroupName = MissionGroup:GetName()
|
||||||
|
|
||||||
|
if self.AssignedGroups[MissionGroupName] == MissionGroup then
|
||||||
|
self:T( { "Mission is assigned to:", MissionGroup:GetName() } )
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
self:T( { "Mission is not assigned to:", MissionGroup:GetName() } )
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set @{Group} assigned to the @{Mission}.
|
||||||
|
-- @param #MISSION self
|
||||||
|
-- @param Wrapper.Group#GROUP MissionGroup
|
||||||
|
-- @return #MISSION
|
||||||
|
function MISSION:SetGroupAssigned( MissionGroup )
|
||||||
|
|
||||||
|
local MissionName = self:GetName()
|
||||||
|
local MissionGroupName = MissionGroup:GetName()
|
||||||
|
|
||||||
|
self.AssignedGroups[MissionGroupName] = MissionGroup
|
||||||
|
self:E( string.format( "Mission %s is assigned to %s", MissionName, MissionGroupName ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Clear the @{Group} assignment from the @{Mission}.
|
||||||
|
-- @param #MISSION self
|
||||||
|
-- @param Wrapper.Group#GROUP MissionGroup
|
||||||
|
-- @return #MISSION
|
||||||
|
function MISSION:ClearGroupAssignment( MissionGroup )
|
||||||
|
|
||||||
|
local MissionName = self:GetName()
|
||||||
|
local MissionGroupName = MissionGroup:GetName()
|
||||||
|
|
||||||
|
self.AssignedGroups[MissionGroupName] = nil
|
||||||
|
self:E( string.format( "Mission %s is unassigned to %s", MissionName, MissionGroupName ) )
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
--- Gets the COMMANDCENTER.
|
--- Gets the COMMANDCENTER.
|
||||||
-- @param #MISSION self
|
-- @param #MISSION self
|
||||||
-- @return Tasking.CommandCenter#COMMANDCENTER
|
-- @return Tasking.CommandCenter#COMMANDCENTER
|
||||||
@ -642,7 +692,6 @@ end
|
|||||||
-- Tasks = Mission:GetTasks()
|
-- Tasks = Mission:GetTasks()
|
||||||
-- env.info( "Task 2 Completion = " .. Tasks[2]:GetGoalPercentage() .. "%" )
|
-- env.info( "Task 2 Completion = " .. Tasks[2]:GetGoalPercentage() .. "%" )
|
||||||
function MISSION:GetTasks()
|
function MISSION:GetTasks()
|
||||||
self:F()
|
|
||||||
|
|
||||||
return self.Tasks
|
return self.Tasks
|
||||||
end
|
end
|
||||||
|
|||||||
@ -78,6 +78,7 @@ TASK = {
|
|||||||
Mission = nil,
|
Mission = nil,
|
||||||
CommandCenter = nil,
|
CommandCenter = nil,
|
||||||
TimeOut = 0,
|
TimeOut = 0,
|
||||||
|
AssignedGroups = {},
|
||||||
}
|
}
|
||||||
|
|
||||||
--- FSM PlayerAborted event handler prototype for TASK.
|
--- FSM PlayerAborted event handler prototype for TASK.
|
||||||
@ -164,6 +165,7 @@ function TASK:New( Mission, SetGroupAssign, TaskName, TaskType )
|
|||||||
self:AddTransition( "Planned", "Assign", "Assigned" )
|
self:AddTransition( "Planned", "Assign", "Assigned" )
|
||||||
self:AddTransition( "Assigned", "AssignUnit", "Assigned" )
|
self:AddTransition( "Assigned", "AssignUnit", "Assigned" )
|
||||||
self:AddTransition( "Assigned", "Success", "Success" )
|
self:AddTransition( "Assigned", "Success", "Success" )
|
||||||
|
self:AddTransition( "Assigned", "Hold", "Hold" )
|
||||||
self:AddTransition( "Assigned", "Fail", "Failed" )
|
self:AddTransition( "Assigned", "Fail", "Failed" )
|
||||||
self:AddTransition( "Assigned", "Abort", "Aborted" )
|
self:AddTransition( "Assigned", "Abort", "Aborted" )
|
||||||
self:AddTransition( "Assigned", "Cancel", "Cancelled" )
|
self:AddTransition( "Assigned", "Cancel", "Cancelled" )
|
||||||
@ -241,9 +243,9 @@ function TASK:JoinUnit( PlayerUnit, PlayerGroup )
|
|||||||
--self:MessageToGroups( PlayerUnit:GetPlayerName() .. " is planning to join Task " .. self:GetName() )
|
--self:MessageToGroups( PlayerUnit:GetPlayerName() .. " is planning to join Task " .. self:GetName() )
|
||||||
end
|
end
|
||||||
if self:IsStateAssigned() then
|
if self:IsStateAssigned() then
|
||||||
local IsAssignedToGroup = self:IsAssignedToGroup( PlayerGroup )
|
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
||||||
self:E( { IsAssignedToGroup = IsAssignedToGroup } )
|
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
||||||
if IsAssignedToGroup then
|
if IsGroupAssigned then
|
||||||
self:AssignToUnit( PlayerUnit )
|
self:AssignToUnit( PlayerUnit )
|
||||||
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " joined Task " .. self:GetName() )
|
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " joined Task " .. self:GetName() )
|
||||||
end
|
end
|
||||||
@ -259,13 +261,10 @@ end
|
|||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player aborting the Task.
|
||||||
-- @return #boolean true if Unit is part of the Task.
|
-- @return #boolean true if Unit is part of the Task.
|
||||||
function TASK:AbortUnit( PlayerUnit )
|
function TASK:AbortGroup( PlayerGroup )
|
||||||
self:F( { PlayerUnit = PlayerUnit } )
|
self:F( { PlayerGroup = PlayerGroup } )
|
||||||
|
|
||||||
local PlayerUnitAborted = false
|
|
||||||
|
|
||||||
local PlayerGroups = self:GetGroups()
|
local PlayerGroups = self:GetGroups()
|
||||||
local PlayerGroup = PlayerUnit:GetGroup()
|
|
||||||
|
|
||||||
-- Is the PlayerGroup part of the PlayerGroups?
|
-- Is the PlayerGroup part of the PlayerGroups?
|
||||||
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
if PlayerGroups:IsIncludeObject( PlayerGroup ) then
|
||||||
@ -273,24 +272,39 @@ function TASK:AbortUnit( PlayerUnit )
|
|||||||
-- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is aborted from the Task.
|
-- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is aborted from the Task.
|
||||||
-- If the PlayerUnit was the last unit of the PlayerGroup, the menu needs to be removed from the Group.
|
-- If the PlayerUnit was the last unit of the PlayerGroup, the menu needs to be removed from the Group.
|
||||||
if self:IsStateAssigned() then
|
if self:IsStateAssigned() then
|
||||||
local IsAssignedToGroup = self:IsAssignedToGroup( PlayerGroup )
|
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
||||||
self:E( { IsAssignedToGroup = IsAssignedToGroup } )
|
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
||||||
if IsAssignedToGroup then
|
if IsGroupAssigned then
|
||||||
local PlayerName = PlayerUnit:GetPlayerName()
|
local PlayerName = PlayerGroup:GetUnit(1):GetPlayerName()
|
||||||
self:UnAssignFromUnit( PlayerUnit )
|
|
||||||
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
|
self:MessageToGroups( PlayerName .. " aborted Task " .. self:GetName() )
|
||||||
self:E( { TaskGroup = PlayerGroup:GetName(), GetUnits = PlayerGroup:GetUnits() } )
|
self:UnAssignFromGroup( PlayerGroup )
|
||||||
if #PlayerGroup:GetUnits() == 1 then
|
--self:Abort()
|
||||||
self:UnAssignFromGroup( PlayerGroup )
|
|
||||||
PlayerGroup:SetState( PlayerGroup, "Assigned", nil )
|
-- Now check if the task needs to go to hold...
|
||||||
|
-- It will go to hold, if there are no players in the mission...
|
||||||
|
|
||||||
|
PlayerGroups:Flush()
|
||||||
|
local IsRemaining = false
|
||||||
|
for GroupName, AssignedGroup in pairs( PlayerGroups:GetSet() or {} ) do
|
||||||
|
if self:IsGroupAssigned( AssignedGroup ) == true then
|
||||||
|
IsRemaining = true
|
||||||
|
self:F( { Task = self:GetName(), IsRemaining = IsRemaining } )
|
||||||
|
break
|
||||||
|
end
|
||||||
end
|
end
|
||||||
self:Abort()
|
|
||||||
self:PlayerAborted( PlayerUnit )
|
self:F( { Task = self:GetName(), IsRemaining = IsRemaining } )
|
||||||
|
if IsRemaining == false then
|
||||||
|
self:Abort()
|
||||||
|
end
|
||||||
|
|
||||||
|
self:PlayerAborted( PlayerGroup:GetUnit(1) )
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return PlayerUnitAborted
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- A PlayerUnit crashed in a Task. Abort the Player.
|
--- A PlayerUnit crashed in a Task. Abort the Player.
|
||||||
@ -313,14 +327,14 @@ function TASK:CrashUnit( PlayerUnit )
|
|||||||
-- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is aborted from the Task.
|
-- Check if the PlayerGroup is already assigned to the Task. If yes, the PlayerGroup is aborted from the Task.
|
||||||
-- If the PlayerUnit was the last unit of the PlayerGroup, the menu needs to be removed from the Group.
|
-- If the PlayerUnit was the last unit of the PlayerGroup, the menu needs to be removed from the Group.
|
||||||
if self:IsStateAssigned() then
|
if self:IsStateAssigned() then
|
||||||
local IsAssignedToGroup = self:IsAssignedToGroup( PlayerGroup )
|
local IsGroupAssigned = self:IsGroupAssigned( PlayerGroup )
|
||||||
self:E( { IsAssignedToGroup = IsAssignedToGroup } )
|
self:E( { IsGroupAssigned = IsGroupAssigned } )
|
||||||
if IsAssignedToGroup then
|
if IsGroupAssigned then
|
||||||
self:UnAssignFromUnit( PlayerUnit )
|
self:UnAssignFromUnit( PlayerUnit )
|
||||||
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " crashed in Task " .. self:GetName() )
|
self:MessageToGroups( PlayerUnit:GetPlayerName() .. " crashed in Task " .. self:GetName() )
|
||||||
self:E( { TaskGroup = PlayerGroup:GetName(), GetUnits = PlayerGroup:GetUnits() } )
|
self:E( { TaskGroup = PlayerGroup:GetName(), GetUnits = PlayerGroup:GetUnits() } )
|
||||||
if #PlayerGroup:GetUnits() == 1 then
|
if #PlayerGroup:GetUnits() == 1 then
|
||||||
PlayerGroup:SetState( PlayerGroup, "Assigned", nil )
|
self:ClearGroupAssignment( PlayerGroup )
|
||||||
end
|
end
|
||||||
self:PlayerCrashed( PlayerUnit )
|
self:PlayerCrashed( PlayerUnit )
|
||||||
end
|
end
|
||||||
@ -348,40 +362,141 @@ function TASK:GetGroups()
|
|||||||
return self.SetGroup
|
return self.SetGroup
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do -- Group Assignment
|
||||||
|
|
||||||
|
--- Returns if the @{Task} is assigned to the Group.
|
||||||
--- Assign the @{Task} to a @{Group}.
|
-- @param #TASK self
|
||||||
-- @param #TASK self
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
-- @param Wrapper.Group#GROUP TaskGroup
|
-- @return #boolean
|
||||||
-- @return #TASK
|
function TASK:IsGroupAssigned( TaskGroup )
|
||||||
function TASK:AssignToGroup( TaskGroup )
|
|
||||||
self:F( TaskGroup:GetName() )
|
|
||||||
|
|
||||||
local TaskGroupName = TaskGroup:GetName()
|
local TaskGroupName = TaskGroup:GetName()
|
||||||
|
|
||||||
TaskGroup:SetState( TaskGroup, "Assigned", self )
|
if self.AssignedGroups[TaskGroupName] then
|
||||||
|
self:T( { "Task is assigned to:", TaskGroup:GetName() } )
|
||||||
self:E("Task is assigned to " .. TaskGroup:GetName() )
|
return true
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
|
||||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
|
||||||
MissionMenu:RemoveSubMenus()
|
|
||||||
|
|
||||||
self:SetAssignedMenuForGroup( TaskGroup )
|
|
||||||
|
|
||||||
local TaskUnits = TaskGroup:GetUnits()
|
|
||||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
|
||||||
local TaskUnit = UnitData -- Wrapper.Unit#UNIT
|
|
||||||
local PlayerName = TaskUnit:GetPlayerName()
|
|
||||||
self:E(PlayerName)
|
|
||||||
if PlayerName ~= nil or PlayerName ~= "" then
|
|
||||||
self:AssignToUnit( TaskUnit )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:T( { "Task is not assigned to:", TaskGroup:GetName() } )
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
--- Set @{Group} assigned to the @{Task}.
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
|
-- @return #TASK
|
||||||
|
function TASK:SetGroupAssigned( TaskGroup )
|
||||||
|
|
||||||
|
local TaskName = self:GetName()
|
||||||
|
local TaskGroupName = TaskGroup:GetName()
|
||||||
|
|
||||||
|
self.AssignedGroups[TaskGroupName] = TaskGroup
|
||||||
|
self:E( string.format( "Task %s is assigned to %s", TaskName, TaskGroupName ) )
|
||||||
|
|
||||||
|
-- Set the group to be assigned at mission level. This allows to decide the menu options on mission level for this group.
|
||||||
|
self:GetMission():SetGroupAssigned( TaskGroup )
|
||||||
|
|
||||||
|
local SetAssignedGroups = self:GetGroups()
|
||||||
|
|
||||||
|
SetAssignedGroups:ForEachGroup(
|
||||||
|
function( AssignedGroup )
|
||||||
|
if self:IsGroupAssigned(AssignedGroup) then
|
||||||
|
self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to group %s.", TaskName, TaskGroupName ), AssignedGroup )
|
||||||
|
else
|
||||||
|
self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is assigned to your group.", TaskName ), AssignedGroup )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Clear the @{Group} assignment from the @{Task}.
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
|
-- @return #TASK
|
||||||
|
function TASK:ClearGroupAssignment( TaskGroup )
|
||||||
|
|
||||||
|
local TaskName = self:GetName()
|
||||||
|
local TaskGroupName = TaskGroup:GetName()
|
||||||
|
|
||||||
|
self.AssignedGroups[TaskGroupName] = nil
|
||||||
|
self:E( string.format( "Task %s is unassigned to %s", TaskName, TaskGroupName ) )
|
||||||
|
|
||||||
|
-- Set the group to be assigned at mission level. This allows to decide the menu options on mission level for this group.
|
||||||
|
self:GetMission():ClearGroupAssignment( TaskGroup )
|
||||||
|
|
||||||
|
local SetAssignedGroups = self:GetGroups()
|
||||||
|
|
||||||
|
SetAssignedGroups:ForEachGroup(
|
||||||
|
function( AssignedGroup )
|
||||||
|
if self:IsGroupAssigned(AssignedGroup) then
|
||||||
|
self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is unassigned from group %s.", TaskName, TaskGroupName ), AssignedGroup )
|
||||||
|
else
|
||||||
|
self:GetMission():GetCommandCenter():MessageToGroup( string.format( "Task %s is unassigned from your group.", TaskName ), AssignedGroup )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
)
|
||||||
|
|
||||||
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
return self
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
do -- Group Assignment
|
||||||
|
|
||||||
|
--- Assign the @{Task} to a @{Group}.
|
||||||
|
-- @param #TASK self
|
||||||
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
|
-- @return #TASK
|
||||||
|
function TASK:AssignToGroup( TaskGroup )
|
||||||
|
self:F( TaskGroup:GetName() )
|
||||||
|
|
||||||
|
local TaskGroupName = TaskGroup:GetName()
|
||||||
|
|
||||||
|
self:SetGroupAssigned( TaskGroup )
|
||||||
|
|
||||||
|
local TaskUnits = TaskGroup:GetUnits()
|
||||||
|
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||||
|
local TaskUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
local PlayerName = TaskUnit:GetPlayerName()
|
||||||
|
self:E(PlayerName)
|
||||||
|
if PlayerName ~= nil or PlayerName ~= "" then
|
||||||
|
self:AssignToUnit( TaskUnit )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local Mission = self:GetMission()
|
||||||
|
local CommandCenter = Mission:GetCommandCenter()
|
||||||
|
CommandCenter:SetMenu()
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
--- UnAssign the @{Task} from a @{Group}.
|
||||||
|
-- @param #TASK self
|
||||||
|
function TASK:UnAssignFromGroup( TaskGroup )
|
||||||
|
self:F2( { TaskGroup } )
|
||||||
|
|
||||||
|
self:ClearGroupAssignment( TaskGroup )
|
||||||
|
|
||||||
|
local TaskUnits = TaskGroup:GetUnits()
|
||||||
|
for UnitID, UnitData in pairs( TaskUnits ) do
|
||||||
|
local TaskUnit = UnitData -- Wrapper.Unit#UNIT
|
||||||
|
local PlayerName = TaskUnit:GetPlayerName()
|
||||||
|
if PlayerName ~= nil or PlayerName ~= "" then
|
||||||
|
self:UnAssignFromUnit( TaskUnit )
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local Mission = self:GetMission()
|
||||||
|
local CommandCenter = Mission:GetCommandCenter()
|
||||||
|
CommandCenter:SetMenu()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
---
|
---
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
-- @param Wrapper.Group#GROUP FindGroup
|
-- @param Wrapper.Group#GROUP FindGroup
|
||||||
@ -457,7 +572,7 @@ function TASK:SendBriefingToAssignedGroups()
|
|||||||
|
|
||||||
for TaskGroupName, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupName, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
|
|
||||||
if self:IsAssignedToGroup( TaskGroup ) then
|
if self:IsGroupAssigned( TaskGroup ) then
|
||||||
TaskGroup:Message( self.TaskBriefing, 60 )
|
TaskGroup:Message( self.TaskBriefing, 60 )
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -474,47 +589,7 @@ function TASK:UnAssignFromGroups()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
--- UnAssign the @{Task} from a @{Group}.
|
|
||||||
-- @param #TASK self
|
|
||||||
function TASK:UnAssignFromGroup( TaskGroup )
|
|
||||||
self:F2( { TaskGroup } )
|
|
||||||
|
|
||||||
TaskGroup:SetState( TaskGroup, "Assigned", nil )
|
|
||||||
|
|
||||||
self:E("Task is unassigned from " .. TaskGroup:GetName() )
|
|
||||||
|
|
||||||
self:RemoveAssignedMenuForGroup( TaskGroup )
|
|
||||||
|
|
||||||
local TaskUnits = TaskGroup:GetUnits()
|
|
||||||
for UnitID, UnitData in pairs( TaskUnits ) do
|
|
||||||
local TaskUnit = UnitData -- Wrapper.Unit#UNIT
|
|
||||||
local PlayerName = TaskUnit:GetPlayerName()
|
|
||||||
if PlayerName ~= nil or PlayerName ~= "" then
|
|
||||||
self:UnAssignFromUnit( TaskUnit )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
--- Returns if the @{Task} is assigned to the Group.
|
|
||||||
-- @param #TASK self
|
|
||||||
-- @param Wrapper.Group#GROUP TaskGroup
|
|
||||||
-- @return #boolean
|
|
||||||
function TASK:IsAssignedToGroup( TaskGroup )
|
|
||||||
|
|
||||||
local TaskGroupName = TaskGroup:GetName()
|
|
||||||
|
|
||||||
if self:IsStateAssigned() then
|
|
||||||
if TaskGroup:GetState( TaskGroup, "Assigned" ) == self then
|
|
||||||
self:T( { "Task is assigned to:", TaskGroup:GetName() } )
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
self:T( { "Task is not assigned to:", TaskGroup:GetName() } )
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Returns if the @{Task} has still alive and assigned Units.
|
--- Returns if the @{Task} has still alive and assigned Units.
|
||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
@ -524,7 +599,7 @@ function TASK:HasAliveUnits()
|
|||||||
|
|
||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
if self:IsStateAssigned() then
|
if self:IsStateAssigned() then
|
||||||
if self:IsAssignedToGroup( TaskGroup ) then
|
if self:IsGroupAssigned( TaskGroup ) then
|
||||||
for TaskUnitID, TaskUnit in pairs( TaskGroup:GetUnits() ) do
|
for TaskUnitID, TaskUnit in pairs( TaskGroup:GetUnits() ) do
|
||||||
if TaskUnit:IsAlive() then
|
if TaskUnit:IsAlive() then
|
||||||
self:T( { HasAliveUnits = true } )
|
self:T( { HasAliveUnits = true } )
|
||||||
@ -544,9 +619,9 @@ end
|
|||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK
|
-- @return #TASK
|
||||||
function TASK:SetMenu( MenuTime ) --R2.1 Mission Reports and Task Reports added. Fixes issue #424.
|
function TASK:SetMenu( MenuTime ) --R2.1 Mission Reports and Task Reports added. Fixes issue #424.
|
||||||
self:F()
|
self:F( { self:GetName(), MenuTime } )
|
||||||
|
|
||||||
self.SetGroup:Flush()
|
--self.SetGroup:Flush()
|
||||||
for TaskGroupID, TaskGroupData in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroupData in pairs( self.SetGroup:GetSet() ) do
|
||||||
local TaskGroup = TaskGroupData -- Wrapper.Group#GROUP
|
local TaskGroup = TaskGroupData -- Wrapper.Group#GROUP
|
||||||
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
||||||
@ -565,9 +640,9 @@ function TASK:SetMenu( MenuTime ) --R2.1 Mission Reports and Task Reports added.
|
|||||||
MENU_GROUP_COMMAND:New( TaskGroup, "Report Held Tasks", TaskGroup.MenuReports, Mission.MenuReportOverview, Mission, TaskGroup, "Hold" )
|
MENU_GROUP_COMMAND:New( TaskGroup, "Report Held Tasks", TaskGroup.MenuReports, Mission.MenuReportOverview, Mission, TaskGroup, "Hold" )
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:IsStatePlanned() or self:IsStateReplanned() then
|
-- if self:IsStatePlanned() or self:IsStateReplanned() then
|
||||||
self:SetMenuForGroup( TaskGroup, MenuTime )
|
self:SetMenuForGroup( TaskGroup, MenuTime )
|
||||||
end
|
-- end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -580,12 +655,9 @@ end
|
|||||||
-- @return #TASK
|
-- @return #TASK
|
||||||
function TASK:SetMenuForGroup( TaskGroup, MenuTime )
|
function TASK:SetMenuForGroup( TaskGroup, MenuTime )
|
||||||
|
|
||||||
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
|
self:SetPlannedMenuForGroup( TaskGroup, MenuTime )
|
||||||
self:SetPlannedMenuForGroup( TaskGroup, self:GetTaskName(), MenuTime )
|
if self:IsGroupAssigned( TaskGroup ) then
|
||||||
else
|
self:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
||||||
if not self:IsAssignedToGroup( TaskGroup ) then
|
|
||||||
self:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -596,7 +668,7 @@ end
|
|||||||
-- @param #string MenuText The menu text.
|
-- @param #string MenuText The menu text.
|
||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK self
|
-- @return #TASK self
|
||||||
function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText, MenuTime )
|
function TASK:SetPlannedMenuForGroup( TaskGroup, MenuTime )
|
||||||
self:E( TaskGroup:GetName() )
|
self:E( TaskGroup:GetName() )
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
local Mission = self:GetMission()
|
||||||
@ -604,14 +676,21 @@ function TASK:SetPlannedMenuForGroup( TaskGroup, MenuText, MenuTime )
|
|||||||
local CommandCenter = Mission:GetCommandCenter()
|
local CommandCenter = Mission:GetCommandCenter()
|
||||||
local CommandCenterMenu = CommandCenter:GetMenu()
|
local CommandCenterMenu = CommandCenter:GetMenu()
|
||||||
|
|
||||||
|
local TaskType = self:GetType()
|
||||||
|
local TaskText = self:GetName()
|
||||||
|
|
||||||
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
|
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
|
||||||
|
|
||||||
|
|
||||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||||
|
|
||||||
local TaskType = self:GetType()
|
local TaskPlannedMenu = MENU_GROUP:New( TaskGroup, "Planned Tasks", MissionMenu ):SetTime( MenuTime )
|
||||||
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, MissionMenu ):SetTime( MenuTime )
|
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskType, TaskPlannedMenu ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, MenuText, TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } ):SetTime( MenuTime ):SetRemoveParent( true )
|
local TaskTypeMenu = MENU_GROUP:New( TaskGroup, TaskText, TaskTypeMenu ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
local ReportTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task %s Status", TaskText ), TaskTypeMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
|
||||||
|
if not Mission:IsGroupAssigned( TaskGroup ) then
|
||||||
|
local JoinTaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Join Task %s", TaskText ), TaskTypeMenu, self.MenuAssignToGroup, { self = self, TaskGroup = TaskGroup } ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -622,15 +701,23 @@ end
|
|||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK self
|
-- @return #TASK self
|
||||||
function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
function TASK:SetAssignedMenuForGroup( TaskGroup, MenuTime )
|
||||||
self:E( TaskGroup:GetName() )
|
self:F( { TaskGroup:GetName(), MenuTime } )
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
local Mission = self:GetMission()
|
||||||
|
local MissionName = Mission:GetName()
|
||||||
|
local CommandCenter = Mission:GetCommandCenter()
|
||||||
|
local CommandCenterMenu = CommandCenter:GetMenu()
|
||||||
|
|
||||||
|
local TaskType = self:GetType()
|
||||||
|
local TaskText = self:GetName()
|
||||||
|
|
||||||
|
local MissionMenu = MENU_GROUP:New( TaskGroup, MissionName, CommandCenterMenu ):SetTime( MenuTime )
|
||||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||||
|
|
||||||
self:E( { MissionMenu = MissionMenu } )
|
|
||||||
|
|
||||||
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Task Status", MissionMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime )
|
local TaskAssignedMenu = MENU_GROUP:New( TaskGroup, string.format( "Assigned Task %s", TaskText ), MissionMenu ):SetTime( MenuTime )
|
||||||
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, "Abort Task", MissionMenu, self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime )
|
local TaskTypeMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Report Task %s Status", TaskText ), TaskAssignedMenu, self.MenuTaskStatus, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
local TaskMenu = MENU_GROUP_COMMAND:New( TaskGroup, string.format( "Abort Group from Task %s", TaskText ), TaskAssignedMenu, self.MenuTaskAbort, self, TaskGroup ):SetTime( MenuTime ):SetRemoveParent( true )
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
@ -640,14 +727,12 @@ end
|
|||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK
|
-- @return #TASK
|
||||||
function TASK:RemoveMenu( MenuTime )
|
function TASK:RemoveMenu( MenuTime )
|
||||||
self:F()
|
self:F( { self:GetName(), MenuTime } )
|
||||||
|
|
||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
local TaskGroup = TaskGroup -- Wrapper.Group#GROUP
|
local TaskGroup = TaskGroup -- Wrapper.Group#GROUP
|
||||||
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
if TaskGroup:IsAlive() and TaskGroup:GetPlayerNames() then
|
||||||
if not self:IsAssignedToGroup( TaskGroup ) then
|
self:RefreshMenus( TaskGroup, MenuTime )
|
||||||
self:RemovePlannedMenuForGroup( TaskGroup, MenuTime )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -658,24 +743,26 @@ end
|
|||||||
-- @param Wrapper.Group#GROUP TaskGroup
|
-- @param Wrapper.Group#GROUP TaskGroup
|
||||||
-- @param #number MenuTime
|
-- @param #number MenuTime
|
||||||
-- @return #TASK self
|
-- @return #TASK self
|
||||||
function TASK:RemovePlannedMenuForGroup( TaskGroup, MenuTime )
|
function TASK:RefreshMenus( TaskGroup, MenuTime )
|
||||||
self:F()
|
self:F( { TaskGroup:GetName(), MenuTime } )
|
||||||
|
|
||||||
local Mission = self:GetMission()
|
local Mission = self:GetMission()
|
||||||
local MissionName = Mission:GetName()
|
local MissionName = Mission:GetName()
|
||||||
|
local CommandCenter = Mission:GetCommandCenter()
|
||||||
|
local CommandCenterMenu = CommandCenter:GetMenu()
|
||||||
|
|
||||||
local MissionMenu = Mission:GetMenu( TaskGroup )
|
local MissionMenu = Mission:GetMenu( TaskGroup )
|
||||||
|
|
||||||
|
local TaskText = self:GetName()
|
||||||
|
local PlannedMenu = MissionMenu:GetMenu( "Planned Tasks" )
|
||||||
|
local AssignedMenu = MissionMenu:GetMenu( string.format( "Assigned Task %s", TaskText ) )
|
||||||
|
|
||||||
if MissionMenu then
|
if PlannedMenu then
|
||||||
local TaskType = self:GetType()
|
PlannedMenu:Remove( MenuTime )
|
||||||
local TypeMenu = MissionMenu:GetMenu( TaskType )
|
end
|
||||||
|
|
||||||
if TypeMenu then
|
if AssignedMenu then
|
||||||
local TaskMenu = TypeMenu:GetMenu( self:GetTaskName() )
|
AssignedMenu:Remove( MenuTime )
|
||||||
if TaskMenu then
|
|
||||||
TaskMenu:Remove( MenuTime )
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
@ -724,12 +811,7 @@ end
|
|||||||
-- @param #TASK self
|
-- @param #TASK self
|
||||||
function TASK:MenuTaskAbort( TaskGroup )
|
function TASK:MenuTaskAbort( TaskGroup )
|
||||||
|
|
||||||
for PlayerUnitName, PlayerUnit in pairs( TaskGroup:GetUnits() ) do
|
self:AbortGroup( TaskGroup )
|
||||||
self:AbortUnit( PlayerUnit )
|
|
||||||
end
|
|
||||||
|
|
||||||
self:GetMission():GetCommandCenter():GetPositionable():MessageToSetGroup( "Abort", 15, self.SetGroup )
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -800,13 +882,14 @@ end
|
|||||||
function TASK:RemoveStateMachine( TaskUnit )
|
function TASK:RemoveStateMachine( TaskUnit )
|
||||||
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
|
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
|
||||||
|
|
||||||
self:E( self.Fsm )
|
--self:E( self.Fsm )
|
||||||
for TaskUnitT, Fsm in pairs( self.Fsm ) do
|
--for TaskUnitT, Fsm in pairs( self.Fsm ) do
|
||||||
local Fsm = Fsm -- Core.Fsm#FSM_PROCESS
|
--local Fsm = Fsm -- Core.Fsm#FSM_PROCESS
|
||||||
self:E( TaskUnitT )
|
--self:E( TaskUnitT )
|
||||||
Fsm:Remove()
|
--self.Fsm[TaskUnit] = nil
|
||||||
end
|
--end
|
||||||
|
|
||||||
|
self.Fsm[TaskUnit]:Remove()
|
||||||
self.Fsm[TaskUnit] = nil
|
self.Fsm[TaskUnit] = nil
|
||||||
|
|
||||||
collectgarbage()
|
collectgarbage()
|
||||||
@ -1025,14 +1108,17 @@ function TASK:onenterAssigned( From, Event, To, PlayerUnit, PlayerName )
|
|||||||
|
|
||||||
self:E( { "Task Assigned", self.Dispatcher } )
|
self:E( { "Task Assigned", self.Dispatcher } )
|
||||||
|
|
||||||
self:MessageToGroups( "Task " .. self:GetName() .. " has been assigned to your group." )
|
if From ~= "Assigned" then
|
||||||
|
self:GetMission():GetCommandCenter():MessageToCoalition( "Task " .. self:GetName() .. " is assigned." )
|
||||||
if self.Dispatcher then
|
if self.Dispatcher then
|
||||||
self:E( "Firing Assign event " )
|
self:E( "Firing Assign event " )
|
||||||
self.Dispatcher:Assign( self, PlayerUnit, PlayerName )
|
self.Dispatcher:Assign( self, PlayerUnit, PlayerName )
|
||||||
|
end
|
||||||
|
|
||||||
|
self:GetMission():__Start( 1 )
|
||||||
|
|
||||||
|
self:SetMenu()
|
||||||
end
|
end
|
||||||
|
|
||||||
self:GetMission():__Start( 1 )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@ -1061,12 +1147,13 @@ end
|
|||||||
function TASK:onenterAborted( From, Event, To )
|
function TASK:onenterAborted( From, Event, To )
|
||||||
|
|
||||||
self:E( "Task Aborted" )
|
self:E( "Task Aborted" )
|
||||||
|
|
||||||
self:GetMission():GetCommandCenter():MessageToCoalition( "Task " .. self:GetName() .. " has been aborted! Task may be replanned." )
|
|
||||||
|
|
||||||
self:UnAssignFromGroups()
|
if From ~= "Aborted" then
|
||||||
|
self:GetMission():GetCommandCenter():MessageToCoalition( "Task " .. self:GetName() .. " has been aborted! Task may be replanned." )
|
||||||
|
self:__Replan( 5 )
|
||||||
|
self:SetMenu()
|
||||||
|
end
|
||||||
|
|
||||||
self:__Replan( 5 )
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- FSM function for a TASK
|
--- FSM function for a TASK
|
||||||
@ -1106,7 +1193,7 @@ end
|
|||||||
function TASK:onstatechange( From, Event, To )
|
function TASK:onstatechange( From, Event, To )
|
||||||
|
|
||||||
if self:IsTrace() then
|
if self:IsTrace() then
|
||||||
MESSAGE:New( "@ Task " .. self.TaskName .. " : " .. Event .. " changed to state " .. To, 2 ):ToAll()
|
--MESSAGE:New( "@ Task " .. self.TaskName .. " : " .. From .. " changed to " .. To .. " by " .. Event, 2 ):ToAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
if self.Scores[To] then
|
if self.Scores[To] then
|
||||||
|
|||||||
@ -277,9 +277,7 @@ do -- TASK_A2G_DISPATCHER
|
|||||||
Mission:GetCommandCenter():SetMenu()
|
Mission:GetCommandCenter():SetMenu()
|
||||||
|
|
||||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||||
if not TaskGroup:GetState( TaskGroup, "Assigned" ) then
|
Mission:GetCommandCenter():MessageToGroup( string.format( "Mission *%s* has tasks %s. Subscribe to a task using the Mission *Overlord* radio menu.", Mission:GetName(), TaskReport:Text(", ") ), TaskGroup )
|
||||||
Mission:GetCommandCenter():MessageToGroup( string.format( "Mission *%s* has tasks %s. Subscribe to a task using the Mission *Overlord* radio menu.", Mission:GetName(), TaskReport:Text(", ") ), TaskGroup )
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1141,7 +1141,7 @@ do -- Players
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self:F( PlayerNames )
|
self:F2( PlayerNames )
|
||||||
return PlayerNames
|
return PlayerNames
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user