mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Fixed bugs in MOOSE
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
--- A MISSION is the main owner of a Mission orchestration within MOOSE . The Mission framework orchestrates @{CLIENT}s, @{TASK}s, @{STAGE}s etc.
|
||||
-- A @{CLIENT} needs to be registered within the @{MISSION} through the function @{AddClient}. A @{TASK} needs to be registered within the @{MISSION} through the function @{AddTask}.
|
||||
-- @module MISSION
|
||||
-- @module Mission
|
||||
|
||||
Include.File( "Routines" )
|
||||
Include.File( "Base" )
|
||||
@@ -8,7 +8,10 @@ Include.File( "Client" )
|
||||
Include.File( "Task" )
|
||||
|
||||
--- The MISSION class
|
||||
-- @type
|
||||
-- @type MISSION
|
||||
-- @extends Base#BASE
|
||||
-- @field #MISSION.Clients _Clients
|
||||
-- @field #string MissionBriefing
|
||||
MISSION = {
|
||||
ClassName = "MISSION",
|
||||
Name = "",
|
||||
@@ -29,6 +32,8 @@ MISSION = {
|
||||
_GoalTasks = {}
|
||||
}
|
||||
|
||||
--- @type MISSION.Clients
|
||||
-- @list <Client#CLIENTS>
|
||||
|
||||
function MISSION:Meta()
|
||||
|
||||
@@ -236,10 +241,10 @@ end
|
||||
-- @return CLIENT
|
||||
-- @usage
|
||||
-- Add a number of Client objects to the Mission.
|
||||
-- Mission:AddClient( CLIENT:New( 'US UH-1H*HOT-Deploy Troops 1', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:New( 'US UH-1H*RAMP-Deploy Troops 3', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:New( 'US UH-1H*HOT-Deploy Troops 2', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:New( 'US UH-1H*RAMP-Deploy Troops 4', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:FindByName( 'US UH-1H*HOT-Deploy Troops 1', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:FindByName( 'US UH-1H*RAMP-Deploy Troops 3', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:FindByName( 'US UH-1H*HOT-Deploy Troops 2', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
-- Mission:AddClient( CLIENT:FindByName( 'US UH-1H*RAMP-Deploy Troops 4', 'Transport 3 groups of air defense engineers from our barracks "Gold" and "Titan" to each patriot battery control center to activate our air defenses.' ):Transport() )
|
||||
function MISSION:AddClient( Client )
|
||||
self:F( { Client } )
|
||||
|
||||
@@ -355,6 +360,7 @@ _TransportExecuteStage = {
|
||||
|
||||
--- The MISSIONSCHEDULER is an OBJECT and is the main scheduler of ALL active MISSIONs registered within this scheduler. It's workings are considered internal and is automatically created when the Mission.lua file is included.
|
||||
-- @type MISSIONSCHEDULER
|
||||
-- @field #MISSIONSCHEDULER.MISSIONS Missions
|
||||
MISSIONSCHEDULER = {
|
||||
Missions = {},
|
||||
MissionCount = 0,
|
||||
@@ -364,20 +370,28 @@ MISSIONSCHEDULER = {
|
||||
TimeShow = 5
|
||||
}
|
||||
|
||||
--- @type MISSIONSCHEDULER.MISSIONS
|
||||
-- @list <#MISSION> Mission
|
||||
|
||||
--- This is the main MISSIONSCHEDULER Scheduler function. It is considered internal and is automatically created when the Mission.lua file is included.
|
||||
function MISSIONSCHEDULER.Scheduler()
|
||||
|
||||
|
||||
-- loop through the missions in the TransportTasks
|
||||
for MissionName, Mission in pairs( MISSIONSCHEDULER.Missions ) do
|
||||
|
||||
for MissionName, MissionData in pairs( MISSIONSCHEDULER.Missions ) do
|
||||
|
||||
local Mission = MissionData -- #MISSION
|
||||
|
||||
if not Mission:IsCompleted() then
|
||||
|
||||
-- This flag will monitor if for this mission, there are clients alive. If this flag is still false at the end of the loop, the mission status will be set to Pending (if not Failed or Completed).
|
||||
local ClientsAlive = false
|
||||
|
||||
for ClientID, Client in pairs( Mission._Clients ) do
|
||||
for ClientID, ClientData in pairs( Mission._Clients ) do
|
||||
|
||||
local Client = ClientData -- Client#CLIENT
|
||||
|
||||
if Client:GetDCSGroup() then
|
||||
if Client:IsAlive() then
|
||||
|
||||
-- There is at least one Client that is alive... So the Mission status is set to Ongoing.
|
||||
ClientsAlive = true
|
||||
@@ -405,7 +419,7 @@ function MISSIONSCHEDULER.Scheduler()
|
||||
|
||||
-- For each Client, check for each Task the state and evolve the mission.
|
||||
-- This flag will indicate if the Task of the Client is Complete.
|
||||
TaskComplete = false
|
||||
local TaskComplete = false
|
||||
|
||||
for TaskNumber, Task in pairs( Client._Tasks ) do
|
||||
|
||||
@@ -554,7 +568,7 @@ function MISSIONSCHEDULER.AddMission( Mission )
|
||||
MISSIONSCHEDULER.Missions[Mission.Name] = Mission
|
||||
MISSIONSCHEDULER.MissionCount = MISSIONSCHEDULER.MissionCount + 1
|
||||
-- Add an overall AI Client for the AI tasks... This AI Client will facilitate the Events in the background for each Task.
|
||||
--MissionAdd:AddClient( CLIENT:New( 'AI' ) )
|
||||
--MissionAdd:AddClient( CLIENT:Register( 'AI' ) )
|
||||
|
||||
return Mission
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user