FSM restructuring

This commit is contained in:
FlightControl
2016-12-06 10:30:05 +01:00
parent 0a4630bde6
commit e46d7be91b
11 changed files with 210 additions and 210 deletions

View File

@@ -2,23 +2,23 @@
--
-- ===
--
-- # @{#PROCESS_SMOKE} FSM class, extends @{Process#PROCESS}
-- # @{#FSMT_SMOKE} FSM class, extends @{Process#PROCESS}
--
-- ## PROCESS_SMOKE state machine:
-- ## FSMT_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.
--
-- ### PROCESS_SMOKE **Events**:
-- ### FSMT_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.
--
-- ### PROCESS_SMOKE **Event methods**:
-- ### FSMT_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.
--
-- ### PROCESS_SMOKE **States**:
-- ### FSMT_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.
--
-- ### PROCESS_SMOKE state transition methods:
-- ### FSMT_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) @{#PROCESS_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#PROCESS_SMOKE}
-- # 1) @{#FSMT_SMOKE_TARGETS_ZONE} class, extends @{Fsm.Route#FSMT_SMOKE}
--
-- The PROCESS_SMOKE_TARGETS_ZONE class implements the core functions to smoke targets in a @{Zone}.
-- The FSMT_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) PROCESS_SMOKE_TARGETS_ZONE constructor:
-- # 1.1) FSMT_SMOKE_TARGETS_ZONE constructor:
--
-- * @{#PROCESS_SMOKE_TARGETS_ZONE.New}(): Creates a new PROCESS_SMOKE_TARGETS_ZONE object.
-- * @{#FSMT_SMOKE_TARGETS_ZONE.New}(): Creates a new FSMT_SMOKE_TARGETS_ZONE object.
--
-- ===
--
-- @module Smoke
do -- PROCESS_SMOKE
do -- FSMT_SMOKE
--- PROCESS_SMOKE class
-- @type PROCESS_SMOKE
--- FSMT_SMOKE class
-- @type FSMT_SMOKE
-- @extends Core.StateMachine#FSM_TEMPLATE
PROCESS_SMOKE = {
ClassName = "PROCESS_SMOKE",
FSMT_SMOKE = {
ClassName = "FSMT_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 #PROCESS_SMOKE self
-- @return #PROCESS_SMOKE
function PROCESS_SMOKE:New()
-- @param #FSMT_SMOKE self
-- @return #FSMT_SMOKE
function FSMT_SMOKE:New()
-- Inherits from BASE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "PROCESS_SMOKE" ) ) -- Core.StateMachine#FSM_TEMPLATE
local self = BASE:Inherit( self, FSM_TEMPLATE:New( "FSMT_SMOKE" ) ) -- Core.StateMachine#FSM_TEMPLATE
self:AddTransition( "None", "Start", "AwaitSmoke" )
self:AddTransition( "AwaitSmoke", "Next", "Smoking" )
@@ -100,12 +100,12 @@ do -- PROCESS_SMOKE
--- Task Events
--- StateMachine callback function
-- @param #PROCESS_SMOKE self
-- @param #FSMT_SMOKE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function PROCESS_SMOKE:onafterStart( ProcessUnit, Event, From, To )
function FSMT_SMOKE:onafterStart( ProcessUnit, Event, From, To )
local ProcessGroup = ProcessUnit:GetGroup()
local MissionMenu = self:GetMission():GetMissionMenu( ProcessGroup )
@@ -128,18 +128,18 @@ do -- PROCESS_SMOKE
end
do -- PROCESS_SMOKE_TARGETS_ZONE
do -- FSMT_SMOKE_TARGETS_ZONE
--- PROCESS_SMOKE_TARGETS_ZONE class
-- @type PROCESS_SMOKE_TARGETS_ZONE
--- FSMT_SMOKE_TARGETS_ZONE class
-- @type FSMT_SMOKE_TARGETS_ZONE
-- @field Set#SET_UNIT TargetSetUnit
-- @field Zone#ZONE_BASE TargetZone
-- @extends #PROCESS_SMOKE
PROCESS_SMOKE_TARGETS_ZONE = {
ClassName = "PROCESS_SMOKE_TARGETS_ZONE",
-- @extends #FSMT_SMOKE
FSMT_SMOKE_TARGETS_ZONE = {
ClassName = "FSMT_SMOKE_TARGETS_ZONE",
}
-- function PROCESS_SMOKE_TARGETS_ZONE:_Destructor()
-- function FSMT_SMOKE_TARGETS_ZONE:_Destructor()
-- self:E("_Destructor")
--
-- self.Menu:Remove()
@@ -147,11 +147,11 @@ do -- PROCESS_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 #PROCESS_SMOKE_TARGETS_ZONE self
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Zone#ZONE_BASE TargetZone
function PROCESS_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, PROCESS_SMOKE:New() ) -- #PROCESS_SMOKE
function FSMT_SMOKE_TARGETS_ZONE:New( TargetSetUnit, TargetZone )
local self = BASE:Inherit( self, FSMT_SMOKE:New() ) -- #FSMT_SMOKE
self:SetParameters( { TargetSetUnit, TargetZone } )
@@ -159,11 +159,11 @@ do -- PROCESS_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 #PROCESS_SMOKE_TARGETS_ZONE self
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param Set#SET_UNIT TargetSetUnit
-- @param Zone#ZONE_BASE TargetZone
-- @return #PROCESS_SMOKE_TARGETS_ZONE self
function PROCESS_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
-- @return #FSMT_SMOKE_TARGETS_ZONE self
function FSMT_SMOKE_TARGETS_ZONE:Init( TargetSetUnit, TargetZone )
self.TargetSetUnit = TargetSetUnit
self.TargetZone = TargetZone
@@ -172,12 +172,12 @@ do -- PROCESS_SMOKE_TARGETS_ZONE
end
--- StateMachine callback function
-- @param #PROCESS_SMOKE_TARGETS_ZONE self
-- @param #FSMT_SMOKE_TARGETS_ZONE self
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
-- @param #string Event
-- @param #string From
-- @param #string To
function PROCESS_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
function FSMT_SMOKE_TARGETS_ZONE:onenterSmoking( ProcessUnit, Event, From, To )
self.TargetSetUnit:ForEachUnit(
--- @param Wrapper.Unit#UNIT SmokeUnit