mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Progress
This commit is contained in:
@@ -46,7 +46,8 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi
|
||||
|
||||
self:AddTransition( "Idle", "Start", "Ongoing" )
|
||||
self:AddTransition( "Ongoing", "Stop", "Idle" )
|
||||
self:AddTransition( "Ongoing", "Finish", "Finished" )
|
||||
self:AddTransition( "Ongoing", "Complete", "Completed" )
|
||||
self:AddTransition( "*", "Fail", "Failed" )
|
||||
|
||||
self:T( { MissionName, MissionPriority, MissionBriefing, MissionCoalition } )
|
||||
|
||||
@@ -60,12 +61,35 @@ function MISSION:New( CommandCenter, MissionName, MissionPriority, MissionBriefi
|
||||
|
||||
self.Tasks = {}
|
||||
|
||||
-- Build the Fsm for the mission.
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- FSM function for a MISSION
|
||||
-- @param #MISSION self
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function MISSION:onbeforeComplete( Event, From, To )
|
||||
|
||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||
local Task = Task -- Tasking.Task#TASK_BASE
|
||||
if not Task:IsStateSuccess() and not Task:IsStateFailed() and not Task:IsStateAborted() and not Task:IsStateCancelled() then
|
||||
return false -- Mission cannot be completed. Other Tasks are still active.
|
||||
end
|
||||
end
|
||||
return true -- Allow Mission completion.
|
||||
end
|
||||
|
||||
--- FSM function for a MISSION
|
||||
-- @param #MISSION self
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function MISSION:onenterCompleted( Event, From, To )
|
||||
|
||||
self:GetCommandCenter():MessageToCoalition( "Mission " .. self:GetName() .. " has been completed! Good job guys!" )
|
||||
end
|
||||
|
||||
--- Gets the mission name.
|
||||
-- @param #MISSION self
|
||||
-- @return #MISSION self
|
||||
@@ -114,6 +138,28 @@ function MISSION:AbortUnit( PlayerUnit )
|
||||
|
||||
return PlayerUnitRemoved
|
||||
end
|
||||
|
||||
--- Handles a crash of a PlayerUnit from the Mission.
|
||||
-- For each Task within the Mission, the PlayerUnit is removed from Task where it is assigned.
|
||||
-- If the Unit was not part of a Task in the Mission, false is returned.
|
||||
-- If the Unit is part of a Task in the Mission, true is returned.
|
||||
-- @param #MISSION self
|
||||
-- @param Wrapper.Unit#UNIT PlayerUnit The CLIENT or UNIT of the Player crashing.
|
||||
-- @return #boolean true if Unit is part of a Task in the Mission.
|
||||
function MISSION:CrashUnit( PlayerUnit )
|
||||
self:F( { PlayerUnit = PlayerUnit } )
|
||||
|
||||
local PlayerUnitRemoved = false
|
||||
|
||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||
if Task:CrashUnit( PlayerUnit ) then
|
||||
PlayerUnitRemoved = true
|
||||
end
|
||||
end
|
||||
|
||||
return PlayerUnitRemoved
|
||||
end
|
||||
|
||||
--- Add a scoring to the mission.
|
||||
-- @param #MISSION self
|
||||
-- @return #MISSION self
|
||||
@@ -371,10 +417,12 @@ function MISSION:HasGroup( TaskGroup )
|
||||
return Has
|
||||
end
|
||||
|
||||
--- Create a summary report of the mission (one line).
|
||||
--- Create a summary report of the Mission (one line).
|
||||
-- @param #MISSION self
|
||||
-- @return #string
|
||||
function MISSION:ReportStatus()
|
||||
function MISSION:ReportSummary()
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
-- List the name of the mission.
|
||||
local Name = self:GetName()
|
||||
@@ -392,7 +440,59 @@ function MISSION:ReportStatus()
|
||||
end
|
||||
end
|
||||
|
||||
return "Mission " .. Name .. " - " .. Status .. " - " .. TasksRemaining .. " tasks remaining."
|
||||
Report:Add( "Mission " .. Name .. " - " .. Status .. " - " .. TasksRemaining .. " tasks remaining." )
|
||||
|
||||
return Report:Text()
|
||||
end
|
||||
|
||||
--- Create a overview report of the Mission (multiple lines).
|
||||
-- @param #MISSION self
|
||||
-- @return #string
|
||||
function MISSION:ReportOverview()
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
-- List the name of the mission.
|
||||
local Name = self:GetName()
|
||||
|
||||
-- Determine the status of the mission.
|
||||
local Status = self:GetState()
|
||||
|
||||
Report:Add( "Mission " .. Name .. " - State '" .. Status .. "'" )
|
||||
|
||||
-- Determine how many tasks are remaining.
|
||||
local TasksRemaining = 0
|
||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||
local Task = Task -- Tasking.Task#TASK_BASE
|
||||
Report:Add( "- " .. Task:ReportSummary() )
|
||||
end
|
||||
|
||||
return Report:Text()
|
||||
end
|
||||
|
||||
--- Create a detailed report of the Mission, listing all the details of the Task.
|
||||
-- @param #MISSION self
|
||||
-- @return #string
|
||||
function MISSION:ReportDetails()
|
||||
|
||||
local Report = REPORT:New()
|
||||
|
||||
-- List the name of the mission.
|
||||
local Name = self:GetName()
|
||||
|
||||
-- Determine the status of the mission.
|
||||
local Status = self:GetState()
|
||||
|
||||
Report:Add( "Mission " .. Name .. " - State '" .. Status .. "'" )
|
||||
|
||||
-- Determine how many tasks are remaining.
|
||||
local TasksRemaining = 0
|
||||
for TaskID, Task in pairs( self:GetTasks() ) do
|
||||
local Task = Task -- Tasking.Task#TASK_BASE
|
||||
Report:Add( Task:ReportDetails() )
|
||||
end
|
||||
|
||||
return Report:Text()
|
||||
end
|
||||
|
||||
--- Report the status of all MISSIONs to all active Clients.
|
||||
|
||||
Reference in New Issue
Block a user