Undone the Templating crap. It is much better now. Users will understand ...

This commit is contained in:
FlightControl 2016-12-09 12:34:28 +01:00
parent 618fdb8405
commit 50e69e07fb
20 changed files with 1064 additions and 54148 deletions

File diff suppressed because it is too large Load Diff

View File

@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSMT_ACCOUNT} FSM class, extends @{Fsm.Fsm#FSM_TEMPLATE}
-- # @{#FSM_ACCOUNT} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
--
-- ## FSMT_ACCOUNT state machine:
-- ## FSM_ACCOUNT state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSMT_ACCOUNT **Events**:
-- ### FSM_ACCOUNT **Events**:
--
-- These are the events defined in this class:
--
@ -21,7 +21,7 @@
-- * **More**: There are more DCS events that need to be accounted for. The process will go back into the Report state.
-- * **NoMore**: There are no more DCS events that need to be accounted for. The process will go into the Success state.
--
-- ### FSMT_ACCOUNT **Event methods**:
-- ### FSM_ACCOUNT **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@ -29,7 +29,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSMT_ACCOUNT **States**:
-- ### FSM_ACCOUNT **States**:
--
-- * **Assigned**: The player is assigned to the task. This is the initialization state for the process.
-- * **Waiting**: the process is waiting for a DCS event to occur within the simulator. This state is set automatically.
@ -40,7 +40,7 @@
--
-- (*) End states of the process.
--
-- ### FSMT_ACCOUNT state transition methods:
-- ### FSM_ACCOUNT state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@ -55,41 +55,41 @@
-- The state transition method needs to start with the name **OnAfter + the name of the state**.
-- These state transition methods need to provide a return value, which is specified at the function description.
--
-- # 1) @{#FSMT_ACCOUNT_DEADS} FSM class, extends @{Fsm.Account#FSMT_ACCOUNT}
-- # 1) @{#FSM_ACCOUNT_DEADS} FSM class, extends @{Fsm.Account#FSM_ACCOUNT}
--
-- The FSMT_ACCOUNT_DEADS class accounts (detects, counts and reports) successful kills of DCS units.
-- The FSM_ACCOUNT_DEADS class accounts (detects, counts and reports) successful kills of DCS units.
-- The process is given a @{Set} of units that will be tracked upon successful destruction.
-- The process will end after each target has been successfully destroyed.
-- Each successful dead will trigger an Account state transition that can be scored, modified or administered.
--
--
-- ## FSMT_ACCOUNT_DEADS constructor:
-- ## FSM_ACCOUNT_DEADS constructor:
--
-- * @{#FSMT_ACCOUNT_DEADS.New}(): Creates a new FSMT_ACCOUNT_DEADS object.
-- * @{#FSM_ACCOUNT_DEADS.New}(): Creates a new FSM_ACCOUNT_DEADS object.
--
-- ===
--
-- @module Account
do -- FSMT_ACCOUNT
do -- FSM_ACCOUNT
--- FSMT_ACCOUNT class
-- @type FSMT_ACCOUNT
--- FSM_ACCOUNT class
-- @type FSM_ACCOUNT
-- @field Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_TEMPLATE
FSMT_ACCOUNT = {
ClassName = "FSMT_ACCOUNT",
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ACCOUNT = {
ClassName = "FSM_ACCOUNT",
TargetSetUnit = nil,
}
--- Creates a new DESTROY process.
-- @param #FSMT_ACCOUNT self
-- @return #FSMT_ACCOUNT
function FSMT_ACCOUNT:New()
-- @param #FSM_ACCOUNT self
-- @return #FSM_ACCOUNT
function FSM_ACCOUNT:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "FSMT_ACCOUNT" ) ) -- Fsm.Fsm#FSM_TEMPLATE
local self = BASE:Inherit( self, FSM_PROCESS:New() ) -- Fsm.Fsm#FSM_PROCESS
self:AddTransition( "Assigned", "Start", "Waiting")
self:AddTransition( "*", "Wait", "Waiting")
@ -110,12 +110,12 @@ do -- FSMT_ACCOUNT
--- Process Events
--- StateMachine callback function
-- @param #FSMT_ACCOUNT self
-- @param #FSM_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT:onafterStart( ProcessUnit, Event, From, To )
function FSM_ACCOUNT:onafterStart( ProcessUnit, Event, From, To )
self:EventOnDead( self.onfuncEventDead )
@ -124,12 +124,12 @@ do -- FSMT_ACCOUNT
--- StateMachine callback function
-- @param #FSMT_ACCOUNT self
-- @param #FSM_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT:onenterWaiting( ProcessUnit, Event, From, To )
function FSM_ACCOUNT:onenterWaiting( ProcessUnit, Event, From, To )
if self.DisplayCount >= self.DisplayInterval then
self:Report()
@ -142,53 +142,59 @@ do -- FSMT_ACCOUNT
end
--- StateMachine callback function
-- @param #FSMT_ACCOUNT self
-- @param #FSM_ACCOUNT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT:onafterEvent( ProcessUnit, Event, From, To, Event )
function FSM_ACCOUNT:onafterEvent( ProcessUnit, Event, From, To, Event )
self:__NoMore( 1 )
end
end -- FSMT_ACCOUNT
end -- FSM_ACCOUNT
do -- FSMT_ACCOUNT_DEADS
do -- FSM_ACCOUNT_DEADS
--- FSMT_ACCOUNT_DEADS class
-- @type FSMT_ACCOUNT_DEADS
--- FSM_ACCOUNT_DEADS class
-- @type FSM_ACCOUNT_DEADS
-- @field Set#SET_UNIT TargetSetUnit
-- @extends #FSMT_ACCOUNT
FSMT_ACCOUNT_DEADS = {
ClassName = "FSMT_ACCOUNT_DEADS",
-- @extends #FSM_ACCOUNT
FSM_ACCOUNT_DEADS = {
ClassName = "FSM_ACCOUNT_DEADS",
TargetSetUnit = nil,
}
--- Creates a new DESTROY process.
-- @param #FSMT_ACCOUNT_DEADS self
-- @param #FSM_ACCOUNT_DEADS self
-- @param Set#SET_UNIT TargetSetUnit
-- @param #string TaskName
function FSMT_ACCOUNT_DEADS:New( TargetSetUnit, TaskName )
function FSM_ACCOUNT_DEADS:New( TargetSetUnit, TaskName )
-- Inherits from BASE
local self = BASE:Inherit( self, FSMT_ACCOUNT:New() ) -- #FSMT_ACCOUNT_DEADS
self:SetParameters( {
TargetSetUnit = TargetSetUnit,
TaskName = TaskName,
DisplayInterval = 30,
DisplayCount = 30,
DisplayMessage = true,
DisplayTime = 10, -- 10 seconds is the default
DisplayCategory = "HQ", -- Targets is the default display category
} )
local self = BASE:Inherit( self, FSM_ACCOUNT:New() ) -- #FSM_ACCOUNT_DEADS
self.TargetSetUnit = TargetSetUnit
self.TaskName = TaskName
self.DisplayInterval = 30
self.DisplayCount = 30
self.DisplayMessage = true
self.DisplayTime = 10 -- 10 seconds is the default
self.DisplayCategory = "HQ" -- Targets is the default display category
return self
end
function FSM_ACCOUNT_DEADS:Init( FsmAccount )
self.TargetSetUnit = FsmAccount.TargetSetUnit
self.TaskName = FsmAccount.TaskName
end
function FSMT_ACCOUNT_DEADS:_Destructor()
function FSM_ACCOUNT_DEADS:_Destructor()
self:E("_Destructor")
self:EventRemoveAll()
@ -198,12 +204,12 @@ do -- FSMT_ACCOUNT_DEADS
--- Process Events
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT_DEADS:onenterReport( ProcessUnit, Event, From, To )
function FSM_ACCOUNT_DEADS:onenterReport( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
local TaskGroup = ProcessUnit:GetGroup()
@ -212,12 +218,12 @@ do -- FSMT_ACCOUNT_DEADS
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT_DEADS:onenterAccount( ProcessUnit, Event, From, To, EventData )
function FSM_ACCOUNT_DEADS:onenterAccount( ProcessUnit, Event, From, To, EventData )
self:T( { ProcessUnit, EventData, Event, From, To } )
self:T({self.Controllable})
@ -232,12 +238,12 @@ do -- FSMT_ACCOUNT_DEADS
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ACCOUNT_DEADS:onafterEvent( ProcessUnit, Event, From, To, EventData )
function FSM_ACCOUNT_DEADS:onafterEvent( ProcessUnit, Event, From, To, EventData )
if self.TargetSetUnit:Count() > 0 then
self:__More( 1 )
@ -248,9 +254,9 @@ do -- FSMT_ACCOUNT_DEADS
--- DCS Events
--- @param #FSMT_ACCOUNT_DEADS self
--- @param #FSM_ACCOUNT_DEADS self
-- @param Event#EVENTDATA EventData
function FSMT_ACCOUNT_DEADS:onfuncEventDead( EventData )
function FSM_ACCOUNT_DEADS:onfuncEventDead( EventData )
self:T( { "EventDead", EventData } )
if EventData.IniDCSUnit then
@ -258,4 +264,4 @@ do -- FSMT_ACCOUNT_DEADS
end
end
end -- FSMT_ACCOUNT DEADS
end -- FSM_ACCOUNT DEADS

View File

@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSMT_ASSIGN} FSM template class, extends @{Fsm.Fsm#FSM_TEMPLATE}
-- # @{#FSM_ASSIGN} FSM template class, extends @{Fsm.Fsm#FSM_PROCESS}
--
-- ## FSMT_ASSIGN state machine:
-- ## FSM_ASSIGN state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSMT_ASSIGN **Events**:
-- ### FSM_ASSIGN **Events**:
--
-- These are the events defined in this class:
--
@ -19,7 +19,7 @@
-- * **Assign**: Assign the task.
-- * **Reject**: Reject the task..
--
-- ### FSMT_ASSIGN **Event methods**:
-- ### FSM_ASSIGN **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@ -27,7 +27,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSMT_ASSIGN **States**:
-- ### FSM_ASSIGN **States**:
--
-- * **UnAssigned**: The player has not accepted the task.
-- * **Assigned (*)**: The player has accepted the task.
@ -37,7 +37,7 @@
--
-- (*) End states of the process.
--
-- ### FSMT_ASSIGN state transition methods:
-- ### FSM_ASSIGN state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@ -54,52 +54,52 @@
--
-- ===
--
-- # 1) @{#FSMT_ASSIGN_ACCEPT} class, extends @{Fsm.Assign#FSMT_ASSIGN}
-- # 1) @{#FSM_ASSIGN_ACCEPT} class, extends @{Fsm.Assign#FSM_ASSIGN}
--
-- The FSMT_ASSIGN_ACCEPT class accepts by default a task for a player. No player intervention is allowed to reject the task.
-- The FSM_ASSIGN_ACCEPT class accepts by default a task for a player. No player intervention is allowed to reject the task.
--
-- ## 1.1) FSMT_ASSIGN_ACCEPT constructor:
-- ## 1.1) FSM_ASSIGN_ACCEPT constructor:
--
-- * @{#FSMT_ASSIGN_ACCEPT.New}(): Creates a new FSMT_ASSIGN_ACCEPT object.
-- * @{#FSM_ASSIGN_ACCEPT.New}(): Creates a new FSM_ASSIGN_ACCEPT object.
--
-- ===
--
-- # 2) @{#FSMT_ASSIGN_MENU_ACCEPT} class, extends @{Fsm.Assign#FSMT_ASSIGN}
-- # 2) @{#FSM_ASSIGN_MENU_ACCEPT} class, extends @{Fsm.Assign#FSM_ASSIGN}
--
-- The FSMT_ASSIGN_MENU_ACCEPT class accepts a task when the player accepts the task through an added menu option.
-- The FSM_ASSIGN_MENU_ACCEPT class accepts a task when the player accepts the task through an added menu option.
-- This assignment type is useful to conditionally allow the player to choose whether or not he would accept the task.
-- The assignment type also allows to reject the task.
--
-- ## 2.1) FSMT_ASSIGN_MENU_ACCEPT constructor:
-- ## 2.1) FSM_ASSIGN_MENU_ACCEPT constructor:
-- -----------------------------------------
--
-- * @{#FSMT_ASSIGN_MENU_ACCEPT.New}(): Creates a new FSMT_ASSIGN_MENU_ACCEPT object.
-- * @{#FSM_ASSIGN_MENU_ACCEPT.New}(): Creates a new FSM_ASSIGN_MENU_ACCEPT object.
--
-- ===
--
-- @module Assign
do -- FSMT_ASSIGN
do -- FSM_ASSIGN
--- FSMT_ASSIGN class
-- @type FSMT_ASSIGN
--- FSM_ASSIGN class
-- @type FSM_ASSIGN
-- @field Tasking.Task#TASK_BASE Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends Fsm.Fsm#FSM_TEMPLATE
FSMT_ASSIGN = {
ClassName = "FSMT_ASSIGN",
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ASSIGN = {
ClassName = "FSM_ASSIGN",
}
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
-- @param #FSMT_ASSIGN self
-- @return #FSMT_ASSIGN The task acceptance process.
function FSMT_ASSIGN:New()
-- @param #FSM_ASSIGN self
-- @return #FSM_ASSIGN The task acceptance process.
function FSM_ASSIGN:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "FSMT_ASSIGN" ) ) -- Fsm.Fsm#FSM_TEMPLATE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_ASSIGN" ) ) -- Fsm.Fsm#FSM_PROCESS
self:AddTransition( "UnAssigned", "Start", "Waiting" )
self:AddTransition( "Waiting", "Assign", "Assigned" )
@ -115,42 +115,47 @@ do -- FSMT_ASSIGN
return self
end
end -- FSMT_ASSIGN
end -- FSM_ASSIGN
do -- FSMT_ASSIGN_ACCEPT
do -- FSM_ASSIGN_ACCEPT
--- FSMT_ASSIGN_ACCEPT class
-- @type FSMT_ASSIGN_ACCEPT
--- FSM_ASSIGN_ACCEPT class
-- @type FSM_ASSIGN_ACCEPT
-- @field Tasking.Task#TASK_BASE Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSMT_ASSIGN
FSMT_ASSIGN_ACCEPT = {
ClassName = "FSMT_ASSIGN_ACCEPT",
-- @extends #FSM_ASSIGN
FSM_ASSIGN_ACCEPT = {
ClassName = "FSM_ASSIGN_ACCEPT",
}
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
-- @param #FSMT_ASSIGN_ACCEPT self
-- @param #FSM_ASSIGN_ACCEPT self
-- @param #string TaskBriefing
function FSMT_ASSIGN_ACCEPT:New( TaskBriefing )
function FSM_ASSIGN_ACCEPT:New( TaskBriefing )
local self = BASE:Inherit( self, FSMT_ASSIGN:New() ) -- #FSMT_ASSIGN_ACCEPT
local self = BASE:Inherit( self, FSM_ASSIGN:New() ) -- #FSM_ASSIGN_ACCEPT
self:SetParameters( { TaskBriefing = TaskBriefing } )
self.TaskBriefing = TaskBriefing
return self
end
function FSM_ASSIGN_ACCEPT:Init( FsmAssign )
self.TaskBriefing = FsmAssign.TaskBriefing
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_ACCEPT self
-- @param #FSM_ASSIGN_ACCEPT self
-- @param Wrapper.Unit#UNIT ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ASSIGN_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
function FSM_ASSIGN_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
local ProcessGroup = ProcessUnit:GetGroup()
@ -160,12 +165,12 @@ do -- FSMT_ASSIGN_ACCEPT
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_ACCEPT self
-- @param #FSM_ASSIGN_ACCEPT self
-- @param Wrapper.Unit#UNIT ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ASSIGN_ACCEPT:onenterAssigned( ProcessUnit, Event, From, To )
function FSM_ASSIGN_ACCEPT:onenterAssigned( ProcessUnit, Event, From, To )
env.info( "in here" )
self:E( { ProcessUnit, Event, From, To } )
@ -176,43 +181,50 @@ do -- FSMT_ASSIGN_ACCEPT
self.Task:Assign()
end
end -- FSMT_ASSIGN_ACCEPT
end -- FSM_ASSIGN_ACCEPT
do -- FSMT_ASSIGN_MENU_ACCEPT
do -- FSM_ASSIGN_MENU_ACCEPT
--- FSMT_ASSIGN_MENU_ACCEPT class
-- @type FSMT_ASSIGN_MENU_ACCEPT
--- FSM_ASSIGN_MENU_ACCEPT class
-- @type FSM_ASSIGN_MENU_ACCEPT
-- @field Tasking.Task#TASK_BASE Task
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSMT_ASSIGN
FSMT_ASSIGN_MENU_ACCEPT = {
ClassName = "FSMT_ASSIGN_MENU_ACCEPT",
-- @extends #FSM_ASSIGN
FSM_ASSIGN_MENU_ACCEPT = {
ClassName = "FSM_ASSIGN_MENU_ACCEPT",
}
--- Init.
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #string TaskName
-- @param #string TaskBriefing
-- @return #FSMT_ASSIGN_MENU_ACCEPT self
function FSMT_ASSIGN_MENU_ACCEPT:New( TaskName, TaskBriefing )
-- @return #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:New( TaskName, TaskBriefing )
-- Inherits from BASE
local self = BASE:Inherit( self, FSMT_ASSIGN:New() ) -- #FSMT_ASSIGN_MENU_ACCEPT
local self = BASE:Inherit( self, FSM_ASSIGN:New() ) -- #FSM_ASSIGN_MENU_ACCEPT
self:SetParameters( { TaskName = TaskName, TaskBriefing = TaskBriefing } )
self.TaskName = TaskName
self.TaskBriefing = TaskBriefing
return self
end
function FSM_ASSIGN_MENU_ACCEPT:Init( FsmAssign )
self.TaskName = FsmAssign.TaskName
self.TaskBriefing = FsmAssign.TaskBriefing
end
--- Creates a new task assignment state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param #string TaskName
-- @param #string TaskBriefing
-- @return #FSMT_ASSIGN_MENU_ACCEPT self
function FSMT_ASSIGN_MENU_ACCEPT:Init( TaskName, TaskBriefing )
-- @return #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:Init( TaskName, TaskBriefing )
self.TaskBriefing = TaskBriefing
self.TaskName = TaskName
@ -221,12 +233,12 @@ do -- FSMT_ASSIGN_MENU_ACCEPT
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ASSIGN_MENU_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
function FSM_ASSIGN_MENU_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
MESSAGE:New( self.TaskBriefing .. "\nAccess the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled.", 30, "Task Assignment" ):ToGroup( ProcessUnit:GetGroup() )
@ -239,40 +251,40 @@ do -- FSMT_ASSIGN_MENU_ACCEPT
end
--- Menu function.
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
function FSMT_ASSIGN_MENU_ACCEPT:MenuAssign()
-- @param #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:MenuAssign()
self:E( )
self:__Assign( 1 )
end
--- Menu function.
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
function FSMT_ASSIGN_MENU_ACCEPT:MenuReject()
-- @param #FSM_ASSIGN_MENU_ACCEPT self
function FSM_ASSIGN_MENU_ACCEPT:MenuReject()
self:E( )
self:__Reject( 1 )
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ASSIGN_MENU_ACCEPT:onafterAssign( ProcessUnit, Event, From, To )
function FSM_ASSIGN_MENU_ACCEPT:onafterAssign( ProcessUnit, Event, From, To )
self:E( { ProcessUnit.UnitNameEvent, From, To } )
self.Menu:Remove()
end
--- StateMachine callback function
-- @param #FSMT_ASSIGN_MENU_ACCEPT self
-- @param #FSM_ASSIGN_MENU_ACCEPT self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ASSIGN_MENU_ACCEPT:onafterReject( ProcessUnit, Event, From, To )
function FSM_ASSIGN_MENU_ACCEPT:onafterReject( ProcessUnit, Event, From, To )
self:E( { ProcessUnit.UnitName, Event, From, To } )
self.Menu:Remove()
@ -281,4 +293,4 @@ do -- FSMT_ASSIGN_MENU_ACCEPT
ProcessUnit:Destroy()
end
end -- FSMT_ASSIGN_MENU_ACCEPT
end -- FSM_ASSIGN_MENU_ACCEPT

View File

@ -2,16 +2,16 @@
--
-- ===
--
-- # @{#FSMT_ROUTE} FSM class, extends @{Fsm.Fsm#FSM_TEMPLATE}
-- # @{#FSM_ROUTE} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
--
-- ## FSMT_ROUTE state machine:
-- ## FSM_ROUTE state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSMT_ROUTE **Events**:
-- ### FSM_ROUTE **Events**:
--
-- These are the events defined in this class:
--
@ -23,7 +23,7 @@
-- * **More**: There are more route points that need to be followed. The process will go back into the Report state.
-- * **NoMore**: There are no more route points that need to be followed. The process will go into the Success state.
--
-- ### FSMT_ROUTE **Event methods**:
-- ### FSM_ROUTE **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@ -31,7 +31,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSMT_ROUTE **States**:
-- ### FSM_ROUTE **States**:
--
-- * **None**: The controllable did not receive route commands.
-- * **Arrived (*)**: The controllable has arrived at a route point.
@ -43,7 +43,7 @@
--
-- (*) End states of the process.
--
-- ### FSMT_ROUTE state transition methods:
-- ### FSM_ROUTE state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@ -60,41 +60,41 @@
--
-- ===
--
-- # 1) @{#FSMT_ROUTE_ZONE} class, extends @{Fsm.Route#FSMT_ROUTE}
-- # 1) @{#FSM_ROUTE_ZONE} class, extends @{Fsm.Route#FSM_ROUTE}
--
-- The FSMT_ROUTE_ZONE class implements the core functions to route an AIR @{Controllable} player @{Unit} to a @{Zone}.
-- The FSM_ROUTE_ZONE class implements the core functions to route an AIR @{Controllable} player @{Unit} to a @{Zone}.
-- The player receives on perioding times messages with the coordinates of the route to follow.
-- Upon arrival at the zone, a confirmation of arrival is sent, and the process will be ended.
--
-- # 1.1) FSMT_ROUTE_ZONE constructor:
-- # 1.1) FSM_ROUTE_ZONE constructor:
--
-- * @{#FSMT_ROUTE_ZONE.New}(): Creates a new FSMT_ROUTE_ZONE object.
-- * @{#FSM_ROUTE_ZONE.New}(): Creates a new FSM_ROUTE_ZONE object.
--
-- ===
--
-- @module Route
do -- FSMT_ROUTE
do -- FSM_ROUTE
--- FSMT_ROUTE class
-- @type FSMT_ROUTE
--- FSM_ROUTE class
-- @type FSM_ROUTE
-- @field Tasking.Task#TASK TASK
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends Fsm.Fsm#FSM_TEMPLATE
FSMT_ROUTE = {
ClassName = "FSMT_ROUTE",
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_ROUTE = {
ClassName = "FSM_ROUTE",
}
--- Creates a new routing state machine. The process will route a CLIENT to a ZONE until the CLIENT is within that ZONE.
-- @param #FSMT_ROUTE self
-- @return #FSMT_ROUTE self
function FSMT_ROUTE:New()
-- @param #FSM_ROUTE self
-- @return #FSM_ROUTE self
function FSM_ROUTE:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "FSMT_ROUTE" ) ) -- Fsm.Fsm#FSM_TEMPLATE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_ROUTE" ) ) -- Fsm.Fsm#FSM_PROCESS
self:AddTransition( "None", "Start", "Routing" )
self:AddTransition( "*", "Report", "Reporting" )
@ -118,32 +118,32 @@ do -- FSMT_ROUTE
--- Task Events
--- StateMachine callback function
-- @param #FSMT_ROUTE self
-- @param #FSM_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ROUTE:onafterStart( ProcessUnit, Event, From, To )
function FSM_ROUTE:onafterStart( ProcessUnit, Event, From, To )
self:__Route( 1 )
end
--- Check if the controllable has arrived.
-- @param #FSMT_ROUTE self
-- @param #FSM_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @return #boolean
function FSMT_ROUTE:onfuncHasArrived( ProcessUnit )
function FSM_ROUTE:onfuncHasArrived( ProcessUnit )
return false
end
--- StateMachine callback function
-- @param #FSMT_ROUTE self
-- @param #FSM_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ROUTE:onbeforeRoute( ProcessUnit, Event, From, To )
function FSM_ROUTE:onbeforeRoute( ProcessUnit, Event, From, To )
if ProcessUnit:IsAlive() then
local HasArrived = self:onfuncHasArrived( ProcessUnit ) -- Polymorphic
@ -172,46 +172,55 @@ do -- FSMT_ROUTE
end
end -- FSMT_ROUTE
end -- FSM_ROUTE
do -- FSMT_ROUTE_ZONE
do -- FSM_ROUTE_ZONE
--- FSMT_ROUTE_ZONE class
-- @type FSMT_ROUTE_ZONE
--- FSM_ROUTE_ZONE class
-- @type FSM_ROUTE_ZONE
-- @field Tasking.Task#TASK TASK
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSMT_ROUTE
FSMT_ROUTE_ZONE = {
ClassName = "FSMT_ROUTE_ZONE",
-- @extends #FSM_ROUTE
FSM_ROUTE_ZONE = {
ClassName = "FSM_ROUTE_ZONE",
}
--- Creates a new routing state machine. The task will route a controllable to a ZONE until the controllable is within that ZONE.
-- @param #FSMT_ROUTE_ZONE self
-- @param #FSM_ROUTE_ZONE self
-- @param Core.Zone#ZONE_BASE TargetZone
function FSMT_ROUTE_ZONE:New( TargetZone )
local self = BASE:Inherit( self, FSMT_ROUTE:New() ) -- #FSMT_ROUTE_ZONE
function FSM_ROUTE_ZONE:New( TargetZone )
local self = BASE:Inherit( self, FSM_ROUTE:New() ) -- #FSM_ROUTE_ZONE
self:SetParameters( {
TargetZone = TargetZone,
DisplayInterval = 30,
DisplayCount = 30,
DisplayMessage = true,
DisplayTime = 10, -- 10 seconds is the default
DisplayCategory = "HQ", -- Route is the default display category
} )
self.TargetZone = TargetZone
self.DisplayInterval = 30
self.DisplayCount = 30
self.DisplayMessage = true
self.DisplayTime = 10 -- 10 seconds is the default
self.DisplayCategory = "HQ" -- Route is the default display category
return self
end
function FSM_ROUTE_ZONE:Init( FsmRoute )
self.TargetZone = FsmRoute.TargetZone
self.DisplayInterval = 30
self.DisplayCount = 30
self.DisplayMessage = true
self.DisplayTime = 10 -- 10 seconds is the default
self.DisplayCategory = "HQ" -- Route is the default display category
end
--- Method override to check if the controllable has arrived.
-- @param #FSMT_ROUTE self
-- @param #FSM_ROUTE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @return #boolean
function FSMT_ROUTE_ZONE:onfuncHasArrived( ProcessUnit )
function FSM_ROUTE_ZONE:onfuncHasArrived( ProcessUnit )
if ProcessUnit:IsInZone( self.TargetZone ) then
local RouteText = ProcessUnit:GetCallsign() .. ": You have arrived within the zone!"
@ -224,12 +233,12 @@ do -- FSMT_ROUTE_ZONE
--- Task Events
--- StateMachine callback function
-- @param #FSMT_ROUTE_ZONE self
-- @param #FSM_ROUTE_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_ROUTE_ZONE:onenterReporting( ProcessUnit, Event, From, To )
function FSM_ROUTE_ZONE:onenterReporting( ProcessUnit, Event, From, To )
local ZoneVec2 = self.TargetZone:GetVec2()
local ZonePointVec2 = POINT_VEC2:New( ZoneVec2.x, ZoneVec2.y )
@ -239,4 +248,4 @@ do -- FSMT_ROUTE_ZONE
MESSAGE:New( RouteText, self.DisplayTime, self.DisplayCategory ):ToGroup( ProcessUnit:GetGroup() )
end
end -- FSMT_ROUTE_ZONE
end -- FSM_ROUTE_ZONE

View File

@ -2,23 +2,23 @@
--
-- ===
--
-- # @{#FSMT_SMOKE} FSM class, extends @{Fsm.Fsm#FSM_TEMPLATE}
-- # @{#FSM_SMOKE} FSM class, extends @{Fsm.Fsm#FSM_PROCESS}
--
-- ## FSMT_SMOKE state machine:
-- ## FSM_SMOKE state machine:
--
-- This class is a state machine: it manages a process that is triggered by events causing state transitions to occur.
-- All derived classes from this class will start with the class name, followed by a \_. See the relevant derived class descriptions below.
-- Each derived class follows exactly the same process, using the same events and following the same state transitions,
-- but will have **different implementation behaviour** upon each event or state transition.
--
-- ### FSMT_SMOKE **Events**:
-- ### FSM_SMOKE **Events**:
--
-- These are the events defined in this class:
--
-- * **Start**: The process is started.
-- * **Next**: The process is smoking the targets in the given zone.
--
-- ### FSMT_SMOKE **Event methods**:
-- ### FSM_SMOKE **Event methods**:
--
-- Event methods are available (dynamically allocated by the state machine), that accomodate for state transitions occurring in the process.
-- There are two types of event methods, which you can use to influence the normal mechanisms in the state machine:
@ -26,7 +26,7 @@
-- * **Immediate**: The event method has exactly the name of the event.
-- * **Delayed**: The event method starts with a __ + the name of the event. The first parameter of the event method is a number value, expressing the delay in seconds when the event will be executed.
--
-- ### FSMT_SMOKE **States**:
-- ### FSM_SMOKE **States**:
--
-- * **None**: The controllable did not receive route commands.
-- * **AwaitSmoke (*)**: The process is awaiting to smoke the targets in the zone.
@ -35,7 +35,7 @@
--
-- (*) End states of the process.
--
-- ### FSMT_SMOKE state transition methods:
-- ### FSM_SMOKE state transition methods:
--
-- State transition functions can be set **by the mission designer** customizing or improving the behaviour of the state.
-- There are 2 moments when state transition methods will be called by the state machine:
@ -52,36 +52,36 @@
--
-- ===
--
-- # 1) @{#FSMT_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#FSMT_SMOKE}
-- # 1) @{#FSM_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#FSM_SMOKE}
--
-- The FSMT_SMOKE_TARGETS_ZONE class implements the core functions to smoke targets in a @{Zone}.
-- The FSM_SMOKE_TARGETS_ZONE class implements the core functions to smoke targets in a @{Zone}.
-- The targets are smoked within a certain range around each target, simulating a realistic smoking behaviour.
-- At random intervals, a new target is smoked.
--
-- # 1.1) FSMT_SMOKE_TARGETS_ZONE constructor:
-- # 1.1) FSM_SMOKE_TARGETS_ZONE constructor:
--
-- * @{#FSMT_SMOKE_TARGETS_ZONE.New}(): Creates a new FSMT_SMOKE_TARGETS_ZONE object.
-- * @{#FSM_SMOKE_TARGETS_ZONE.New}(): Creates a new FSM_SMOKE_TARGETS_ZONE object.
--
-- ===
--
-- @module Smoke
do -- FSMT_SMOKE
do -- FSM_SMOKE
--- FSMT_SMOKE class
-- @type FSMT_SMOKE
-- @extends Fsm.Fsm#FSM_TEMPLATE
FSMT_SMOKE = {
ClassName = "FSMT_SMOKE",
--- FSM_SMOKE class
-- @type FSM_SMOKE
-- @extends Fsm.Fsm#FSM_PROCESS
FSM_SMOKE = {
ClassName = "FSM_SMOKE",
}
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSMT_SMOKE self
-- @return #FSMT_SMOKE
function FSMT_SMOKE:New()
-- @param #FSM_SMOKE self
-- @return #FSM_SMOKE
function FSM_SMOKE:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "FSMT_SMOKE" ) ) -- Fsm.Fsm#FSM_TEMPLATE
local self = BASE:Inherit( self, FSM_PROCESS:New( "FSM_SMOKE" ) ) -- Fsm.Fsm#FSM_PROCESS
self:AddTransition( "None", "Start", "AwaitSmoke" )
self:AddTransition( "AwaitSmoke", "Next", "Smoking" )
@ -100,12 +100,12 @@ do -- FSMT_SMOKE
--- Task Events
--- StateMachine callback function
-- @param #FSMT_SMOKE self
-- @param #FSM_SMOKE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_SMOKE:onafterStart( ProcessUnit, Event, From, To )
function FSM_SMOKE:onafterStart( ProcessUnit, Event, From, To )
local ProcessGroup = ProcessUnit:GetGroup()
local MissionMenu = self:GetMission():GetMissionMenu( ProcessGroup )
@ -128,18 +128,18 @@ do -- FSMT_SMOKE
end
do -- FSMT_SMOKE_TARGETS_ZONE
do -- FSM_SMOKE_TARGETS_ZONE
--- FSMT_SMOKE_TARGETS_ZONE class
-- @type FSMT_SMOKE_TARGETS_ZONE
--- FSM_SMOKE_TARGETS_ZONE class
-- @type FSM_SMOKE_TARGETS_ZONE
-- @field Set#SET_UNIT TargetSetUnit
-- @field Core.Zone#ZONE_BASE TargetZone
-- @extends #FSMT_SMOKE
FSMT_SMOKE_TARGETS_ZONE = {
ClassName = "FSMT_SMOKE_TARGETS_ZONE",
-- @extends #FSM_SMOKE
FSM_SMOKE_TARGETS_ZONE = {
ClassName = "FSM_SMOKE_TARGETS_ZONE",
}
-- function FSMT_SMOKE_TARGETS_ZONE:_Destructor()
-- function FSM_SMOKE_TARGETS_ZONE:_Destructor()
-- self:E("_Destructor")
--
-- self.Menu:Remove()
@ -147,23 +147,30 @@ do -- FSMT_SMOKE_TARGETS_ZONE
-- end
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Core.Zone#ZONE_BASE TargetZone
function FSMT_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, FSMT_SMOKE:New() ) -- #FSMT_SMOKE
function FSM_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, FSM_SMOKE:New() ) -- #FSM_SMOKE
self:SetParameters( { TargetSetUnit, TargetZone } )
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
return self
end
function FSM_SMOKE_TARGETS_ZONE:Init( FsmSmoke )
self.TargetSetUnit = FsmSmoke.TargetSetUnit
self.TargetZone = FsmSmoke.TargetZone
end
--- Creates a new target smoking state machine. The process will request from the menu if it accepts the task, if not, the unit is removed from the simulator.
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Core.Zone#ZONE_BASE TargetZone
-- @return #FSMT_SMOKE_TARGETS_ZONE self
function FSMT_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
-- @return #FSM_SMOKE_TARGETS_ZONE self
function FSM_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
@ -172,12 +179,12 @@ do -- FSMT_SMOKE_TARGETS_ZONE
end
--- StateMachine callback function
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param #FSM_SMOKE_TARGETS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function FSMT_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
function FSM_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
self.TargetSetUnit:ForEachUnit(
--- @param Wrapper.Unit#UNIT SmokeUnit

View File

@ -345,7 +345,7 @@ function PATROLZONE:onenterRoute()
self.Controllable:SetState( self.Controllable, "PatrolZone", self )
self.Controllable:WayPointFunction( #PatrolRoute, 1, "_NewPatrolRoute" )
--- NOW FSMT_ROUTE THE GROUP!
--- NOW FSM_ROUTE THE GROUP!
self.Controllable:WayPointExecute( 1 )
self:__Patrol( 30 )

View File

@ -4,7 +4,7 @@
-- @type PROCESS_JTAC
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_TEMPLATE
-- @extends Fsm.Fsm#FSM_PROCESS
PROCESS_JTAC = {
ClassName = "PROCESS_JTAC",
Fsm = {},

View File

@ -4,7 +4,7 @@
-- @type PROCESS_PICKUP
-- @field Wrapper.Unit#UNIT ProcessUnit
-- @field Core.Set#SET_UNIT TargetSetUnit
-- @extends Fsm.Fsm#FSM_TEMPLATE
-- @extends Fsm.Fsm#FSM_PROCESS
PROCESS_PICKUP = {
ClassName = "PROCESS_PICKUP",
Fsm = {},

View File

@ -44,10 +44,10 @@ Include.File( "Fsm/Process" )
Include.File( "Fsm/Process_JTAC" )
Include.File( "Fsm/Patrol" )
Include.File( "Fsm/Cargo" )
Include.File( "Fsm/FsmTAssign" )
Include.File( "Fsm/FsmTRoute" )
Include.File( "Fsm/FsmTAccount" )
Include.File( "Fsm/FsmTSmoke" )
Include.File( "Fsm/FsmAssign" )
Include.File( "Fsm/FsmRoute" )
Include.File( "Fsm/FsmAccount" )
Include.File( "Fsm/FsmSmoke" )
--- Task Handling Classes
Include.File( "Tasking/CommandCenter" )

View File

@ -54,7 +54,7 @@
-- @field Core.Scheduler#SCHEDULER TaskScheduler
-- @field Tasking.Mission#MISSION Mission
-- @field Core.Set#SET_GROUP SetGroup The Set of Groups assigned to the Task
-- @field Fsm.Fsm#FSM_TEMPLATE FsmTemplate
-- @field Fsm.Fsm#FSM_PROCESS FsmTemplate
-- @extends Fsm.Fsm#FSM_TASK
TASK_BASE = {
ClassName = "TASK_BASE",
@ -82,7 +82,10 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType )
self:SetStartState( "Planned" )
self:AddTransition( "Planned", "Assign", "Assigned" )
self:AddTransition( "Assigned", "Success", "Success" )
self:AddTransition( "*", "Fail", "Failed" )
self:AddTransition( "Assigned", "Fail", "Failed" )
self:AddTransition( "Assigned", "Abort", "Aborted" )
self:AddTransition( "Assigned", "Cancel", "Cancelled" )
self:AddTransition( { "Failed", "Aborted", "Cancelled" }, "Replan", "Planned" )
self:E( "New TASK " .. TaskName )
@ -98,7 +101,7 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType )
self.TaskBriefing = "You are invited for the task: " .. self.TaskName .. "."
self.FsmTemplate = self.FsmTemplate or FSM_TEMPLATE:New( "MAIN" )
self.FsmTemplate = self.FsmTemplate or FSM_PROCESS:New()
-- Handle the birth of new planes within the assigned set.
self:EventOnPlayerEnterUnit(
@ -117,6 +120,46 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType )
end
end
)
-- Handle when a player leaves a slot and goes back to spectators ...
-- The Task is UnAssigned from the Unit.
-- When there is no Unit left running the Task, the Task goes into Abort...
self:EventOnPlayerLeaveUnit(
--- @param #TASK_BASE self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
self:E( "In LeaveUnit" )
self:E( { "State", self:GetState() } )
if self:IsStateAssigned() then
local TaskUnit = EventData.IniUnit
local TaskGroup = EventData.IniUnit:GetGroup()
self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
if self.SetGroup:IsIncludeObject( TaskGroup ) then
self:UnAssignFromUnit( TaskUnit )
end
end
end
)
-- Handle when a player crashes ...
-- The Task is UnAssigned from the Unit.
-- When there is no Unit left running the Task, and all of the Players crashed, the Task goes into Failed ...
self:EventOnCrash(
--- @param #TASK_BASE self
-- @param Core.Event#EVENTDATA EventData
function( self, EventData )
self:E( "In LeaveUnit" )
self:E( { "State", self:GetState() } )
if self:IsStateAssigned() then
local TaskUnit = EventData.IniUnit
local TaskGroup = EventData.IniUnit:GetGroup()
self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
if self.SetGroup:IsIncludeObject( TaskGroup ) then
self:UnAssignFromUnit( TaskUnit )
end
end
end
)
return self
end
@ -184,8 +227,10 @@ end
function TASK_BASE:AssignToUnit( TaskUnit )
self:F( TaskUnit:GetName() )
local FsmTemplate = self:GetFsmTemplate()
-- Assign a new FsmUnit to TaskUnit.
local FsmUnit = self:SetStateMachine( TaskUnit, FSM_PROCESS:New( self:GetFsmTemplate(), TaskUnit, self ) ) -- Fsm.Fsm#FSM_PROCESS
local FsmUnit = self:SetStateMachine( TaskUnit, FsmTemplate:Copy( TaskUnit, self ) ) -- Fsm.Fsm#FSM_PROCESS
self:E({"Address FsmUnit", tostring( FsmUnit ) } )
-- Set the events
@ -206,13 +251,10 @@ end
-- @param #TASK_BASE self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return #TASK_BASE self
function TASK_BASE:UnAssignFromUnit( TaskUnitName )
self:F( TaskUnitName )
function TASK_BASE:UnAssignFromUnit( TaskUnit )
self:F( TaskUnit )
if self:HasStateMachine( TaskUnitName ) == true then
self:E("RemoveStateMachines")
self:RemoveStateMachine( TaskUnitName )
end
self:RemoveStateMachine( TaskUnit )
return self
end
@ -246,7 +288,7 @@ function TASK_BASE:UnAssignFromGroups()
local TaskUnit = UnitData -- Wrapper.Unit#UNIT
local PlayerName = TaskUnit:GetPlayerName()
if PlayerName ~= nil or PlayerName ~= "" then
self:UnAssignFromUnit( TaskUnit:GetName() )
self:UnAssignFromUnit( TaskUnit )
end
end
end
@ -392,7 +434,7 @@ end
--- Get the default or currently assigned @{Process} template with key ProcessName.
-- @param #TASK_BASE self
-- @param #string ProcessName
-- @return Fsm.Fsm#FSM_TEMPLATE
-- @return Fsm.Fsm#FSM_PROCESS
function TASK_BASE:GetProcessTemplate( ProcessName )
local ProcessTemplate = self.ProcessClasses[ProcessName]
@ -415,35 +457,37 @@ function TASK_BASE:FailProcesses( TaskUnitName )
end
end
--- Add a FiniteStateMachine to @{Task} with key @{Unit}
--- Add a FiniteStateMachine to @{Task} with key Task@{Unit}
-- @param #TASK_BASE self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return #TASK_BASE self
function TASK_BASE:SetStateMachine( TaskUnit, Fsm )
local TaskUnitName = TaskUnit:GetName()
self.Fsm[TaskUnitName] = Fsm
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
self.Fsm[TaskUnit] = Fsm
return Fsm
end
--- Remove FiniteStateMachines from @{Task} with key @{Unit}
--- Remove FiniteStateMachines from @{Task} with key Task@{Unit}
-- @param #TASK_BASE self
-- @param #string TaskUnitName
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return #TASK_BASE self
function TASK_BASE:RemoveStateMachine( TaskUnitName )
function TASK_BASE:RemoveStateMachine( TaskUnit )
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
self.Fsm[TaskUnitName] = nil
self.Fsm[TaskUnit] = nil
collectgarbage()
end
--- Checks if there is a FiniteStateMachine assigned to @{Unit} for @{Task}
--- Checks if there is a FiniteStateMachine assigned to Task@{Unit} for @{Task}
-- @param #TASK_BASE self
-- @param #string TaskUnitName
-- @param Wrapper.Unit#UNIT TaskUnit
-- @return #TASK_BASE self
function TASK_BASE:HasStateMachine( TaskUnitName )
function TASK_BASE:HasStateMachine( TaskUnit )
self:F( { TaskUnit, self.Fsm[TaskUnit] ~= nil } )
self:F( { TaskUnitName, self.Fsm[TaskUnitName] ~= nil } )
return ( self.Fsm[TaskUnitName] ~= nil )
return ( self.Fsm[TaskUnit] ~= nil )
end
@ -694,7 +738,7 @@ end
-- @param #string ScoreText is a text describing the score that is given according the status.
-- @param #number Score is a number providing the score of the status.
-- @return #FSM_TEMPLATE self
function FSM_TEMPLATE:AddScoreTask( TaskStatus, ScoreText, Score )
function TASK_BASE:AddScoreTask( TaskStatus, ScoreText, Score )
self:F2( { TaskStatus, ScoreText, Score } )
self.Scores[TaskStatus] = self.Scores[TaskStatus] or {}
@ -729,17 +773,19 @@ function TASK_BASE:onenterSuccess( Event, From, To )
self:E("Success")
self:UnAssignFromGroups()
self:SetMenu()
end
--- StateMachine callback function for a TASK
-- @param #TASK_BASE self
-- @param Wrapper.Unit#UNIT TaskUnit
-- @param Fsm.Fsm#FSM_TASK Fsm
-- @param #string Event
-- @param #string From
-- @param #string To
-- @param Core.Event#EVENTDATA Event
function TASK_BASE:OnFailed( TaskUnit, Fsm, Event, From, To )
function TASK_BASE:onenterFailed( TaskUnit, Event, From, To )
self:E( { "Failed for unit ", TaskUnit:GetName(), TaskUnit:GetPlayerName() } )
@ -747,8 +793,7 @@ function TASK_BASE:OnFailed( TaskUnit, Fsm, Event, From, To )
-- When the player leaves its unit, we will need to check whether he was on the ground or not at an airbase.
-- When the player crashes, we will need to check whether in the group there are other players still active. It not, we reset the task from Assigned to Planned, otherwise, we just leave as Assigned.
self:UnAssignFromGroups()
self:StatePlanned()
self:UnAssignFromUnit()
end

View File

@ -7,8 +7,8 @@
-- The TASK_A2G is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSMT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSMT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@ -47,12 +47,12 @@ do -- TASK_A2G
local Fsm = self:GetFsmTemplate()
Fsm:AddProcess( "Planned", "Accept", FSMT_ASSIGN_ACCEPT:New( "Attack the Area" ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSMT_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddProcess( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( "Attack the Area" ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSM_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddAction ( "Rejected", "Eject", "Planned" )
Fsm:AddAction ( "Arrived", "Update", "Updated" )
Fsm:AddProcess( "Updated", "Account", FSMT_ACCOUNT_DEADS:New( self.TargetSetUnit, "Attack" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSMT_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddProcess( "Updated", "Account", FSM_ACCOUNT_DEADS:New( self.TargetSetUnit, "Attack" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
--Fsm:AddProcess( "Updated", "JTAC", PROCESS_JTAC:New( self, TaskUnit, self.TargetSetUnit, self.FACUnit ) )
Fsm:AddAction ( "Accounted", "Success", "Success" )
Fsm:AddAction ( "Failed", "Fail", "Failed" )

View File

@ -7,8 +7,8 @@
-- The TASK_PICKUP is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSMT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSMT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@ -67,7 +67,7 @@ do -- TASK_PICKUP
function TASK_PICKUP:AssignToUnit( TaskUnit )
self:F( TaskUnit:GetName() )
local ProcessAssign = self:AddProcess( TaskUnit, FSMT_ASSIGN_ACCEPT:New( self, TaskUnit, self.TaskBriefing ) )
local ProcessAssign = self:AddProcess( TaskUnit, FSM_ASSIGN_ACCEPT:New( self, TaskUnit, self.TaskBriefing ) )
local ProcessPickup = self:AddProcess( TaskUnit, PROCESS_PICKUP:New( self, self.TaskType, TaskUnit ) )
local Process = self:AddStateMachine( TaskUnit, FSM_TASK:New( self, TaskUnit, {

View File

@ -7,8 +7,8 @@
-- The TASK_SEAD is implemented using a @{Statemachine#FSM_TASK}, and has the following statuses:
--
-- * **None**: Start of the process
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSMT_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSMT_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Planned**: The SEAD task is planned. Upon Planned, the sub-process @{Process_Fsm.Assign#FSM_ASSIGN_ACCEPT} is started to accept the task.
-- * **Assigned**: The SEAD task is assigned to a @{Wrapper.Group#GROUP}. Upon Assigned, the sub-process @{Process_Fsm.Route#FSM_ROUTE} is started to route the active Units in the Group to the attack zone.
-- * **Success**: The SEAD task is successfully completed. Upon Success, the sub-process @{Process_SEAD#PROCESS_SEAD} is started to follow-up successful SEADing of the targets assigned in the task.
-- * **Failed**: The SEAD task has failed. This will happen if the player exists the task early, without communicating a possible cancellation to HQ.
--
@ -47,12 +47,12 @@ do -- TASK_SEAD
local Fsm = self:GetFsmTemplate()
Fsm:AddProcess( "Planned", "Accept", FSMT_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSMT_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddProcess( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( self.TaskBriefing ), { Assigned = "Route", Rejected = "Eject" } )
Fsm:AddProcess( "Assigned", "Route", FSM_ROUTE_ZONE:New( self.TargetZone ), { Arrived = "Update" } )
Fsm:AddAction ( "Rejected", "Eject", "Planned" )
Fsm:AddAction ( "Arrived", "Update", "Updated" )
Fsm:AddProcess( "Updated", "Account", FSMT_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSMT_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddProcess( "Updated", "Account", FSM_ACCOUNT_DEADS:New( self.TargetSetUnit, "SEAD" ), { Accounted = "Success" } )
Fsm:AddProcess( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( self.TargetSetUnit, self.TargetZone ) )
Fsm:AddAction ( "Accounted", "Success", "Success" )
Fsm:AddAction ( "Failed", "Fail", "Failed" )

View File

@ -970,7 +970,7 @@ function CONTROLLABLE:TaskFAC_AttackGroup( AttackGroup, WeaponType, Designation,
return DCSTask
end
-- EN-FSMT_ROUTE TASKS FOR AIRBORNE CONTROLLABLES
-- EN-FSM_ROUTE TASKS FOR AIRBORNE CONTROLLABLES
--- (AIR) Engaging targets of defined types.
-- @param #CONTROLLABLE self

View File

@ -915,7 +915,7 @@ end
_TransportStage: Defines the different stages of which of transport missions can be in. This table is internal and is used to control the sequence of messages, actions and flow.
- _TransportStage.START
- _TransportStage.FSMT_ROUTE
- _TransportStage.FSM_ROUTE
- _TransportStage.LAND
- _TransportStage.EXECUTE
- _TransportStage.DONE
@ -924,7 +924,7 @@ end
_TransportStage = {
HOLD = "HOLD",
START = "START",
FSMT_ROUTE = "FSMT_ROUTE",
FSM_ROUTE = "FSM_ROUTE",
LANDING = "LANDING",
LANDED = "LANDED",
EXECUTING = "EXECUTING",
@ -937,7 +937,7 @@ _TransportStage = {
_TransportStageMsgTime = {
HOLD = 10,
START = 60,
FSMT_ROUTE = 5,
FSM_ROUTE = 5,
LANDING = 10,
LANDED = 30,
EXECUTING = 30,
@ -950,7 +950,7 @@ _TransportStageMsgTime = {
_TransportStageTime = {
HOLD = 10,
START = 5,
FSMT_ROUTE = 5,
FSM_ROUTE = 5,
LANDING = 1,
LANDED = 1,
EXECUTING = 5,

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -66,19 +66,19 @@ local FsmSEADTemplate = TaskSEAD:GetFsmTemplate()
-- Adding a new sub-process to the Task Template.
-- At first, the task needs to be accepted by a pilot.
-- We use for this the SUB-PROCESS FSMT_ASSIGN_ACCEPT.
-- We use for this the SUB-PROCESS FSM_ASSIGN_ACCEPT.
-- The method on the FsmSEAD AddProcess accepts the following parameters:
-- 1. State From "Planned". When the Fsm is in state "Planned", allow the event "Accept".
-- 2. Event "Accept". This event can be triggered through FsmSEAD:Accept() or FsmSEAD:__Accept( 1 ). See documentation on state machines.
-- 3. The PROCESS derived class. In this case, we use the FSMT_ASSIGN_ACCEPT to accept the task and provide a briefing. So, when the event "Accept" is fired, this process is executed.
-- 4. A table with the "return" states of the FSMT_ASSIGN_ACCEPT process. This table indicates that for a certain return state, a further event needs to be called.
-- 3. The PROCESS derived class. In this case, we use the FSM_ASSIGN_ACCEPT to accept the task and provide a briefing. So, when the event "Accept" is fired, this process is executed.
-- 4. A table with the "return" states of the FSM_ASSIGN_ACCEPT process. This table indicates that for a certain return state, a further event needs to be called.
-- 4.1 When the return state is Assigned, fire the event in the Task FsmSEAD:Route()
-- 4.2 When the return state is Rejected, fire the event in the Task FsmSEAD:Eject()
-- All other AddProcess calls are working in a similar manner.
FsmSEADTemplate:AddProcess ( "Planned", "Accept", FSMT_ASSIGN_ACCEPT:New( "SEAD the Area" ), { Assigned = "Route", Rejected = "Eject" } )
FsmSEADTemplate:AddProcess ( "Planned", "Accept", FSM_ASSIGN_ACCEPT:New( "SEAD the Area" ), { Assigned = "Route", Rejected = "Eject" } )
-- Same, adding a process.
FsmSEADTemplate:AddProcess ( "Assigned", "Route", FSMT_ROUTE_ZONE:New( TargetZone ), { Arrived = "Update" } )
FsmSEADTemplate:AddProcess ( "Assigned", "Route", FSM_ROUTE_ZONE:New( TargetZone ), { Arrived = "Update" } )
-- Adding a new Action...
-- Actions define also the flow of the Task, but the actions will need to be programmed within your script.
@ -89,8 +89,8 @@ FsmSEADTemplate:AddProcess ( "Assigned", "Route", FSMT_ROUTE_ZONE:New( T
-- 3. State To "Planned". After the event has been fired, the FsmSEAD will transition to Planned.
FsmSEADTemplate:AddTransition ( "Rejected", "Eject", "Planned" )
FsmSEADTemplate:AddTransition ( "Arrived", "Update", "Updated" )
FsmSEADTemplate:AddProcess ( "Updated", "Account", FSMT_ACCOUNT_DEADS:New( TargetSet, "SEAD" ), { Accounted = "Success" } )
FsmSEADTemplate:AddProcess ( "Updated", "Smoke", FSMT_SMOKE_TARGETS_ZONE:New( TargetSet, TargetZone ) )
FsmSEADTemplate:AddProcess ( "Updated", "Account", FSM_ACCOUNT_DEADS:New( TargetSet, "SEAD" ), { Accounted = "Success" } )
FsmSEADTemplate:AddProcess ( "Updated", "Smoke", FSM_SMOKE_TARGETS_ZONE:New( TargetSet, TargetZone ) )
FsmSEADTemplate:AddTransition ( "Accounted", "Success", "Success" )
FsmSEADTemplate:AddTransition ( "*", "Fail", "Failed" )