mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Jippie! Finally got the Sub Statemachine declaration understandable for end-users.
Reworked the hierarchical state machine processing in terms of sub processing. Now, the declaration and usage of subs is completely understandable and easy to implement. I am excited to see how end-users will see the possibilities.
This commit is contained in:
@@ -124,8 +124,11 @@ do -- PROCESS_ACCOUNT
|
||||
-- @param #string To
|
||||
function PROCESS_ACCOUNT:onafterStart( ProcessUnit, Event, From, To )
|
||||
|
||||
self:EventOnDead( self.EventDead )
|
||||
|
||||
self:__Wait( 1 )
|
||||
end
|
||||
|
||||
|
||||
--- StateMachine callback function
|
||||
-- @param #PROCESS_ACCOUNT self
|
||||
@@ -169,6 +172,15 @@ do -- PROCESS_ACCOUNT_DEADS
|
||||
TargetSetUnit = nil,
|
||||
}
|
||||
|
||||
|
||||
--- Creates a new DESTROY process.
|
||||
-- @param #PROCESS_ACCOUNT_DEADS self
|
||||
-- @param Set#SET_UNIT TargetSetUnit
|
||||
-- @param #string TaskName
|
||||
function PROCESS_ACCOUNT_DEADS:Template( TargetSetUnit, TaskName )
|
||||
return { self, arg }
|
||||
end
|
||||
|
||||
|
||||
--- Creates a new DESTROY process.
|
||||
-- @param #PROCESS_ACCOUNT_DEADS self
|
||||
@@ -182,12 +194,15 @@ do -- PROCESS_ACCOUNT_DEADS
|
||||
|
||||
self.TargetSetUnit = TargetSetUnit
|
||||
self.TaskName = TaskName
|
||||
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function PROCESS_ACCOUNT_DEADS:_Destructor()
|
||||
self:E("_Destructor")
|
||||
|
||||
self:RemoveEventsAll()
|
||||
|
||||
function PROCESS_ACCOUNT_DEADS:ProcessStart()
|
||||
self:EventOnDead( self.EventDead )
|
||||
end
|
||||
|
||||
--- Process Events
|
||||
|
||||
@@ -134,6 +134,14 @@ do -- PROCESS_ASSIGN_ACCEPT
|
||||
}
|
||||
|
||||
|
||||
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
|
||||
-- @param #PROCESS_ASSIGN_ACCEPT self
|
||||
-- @param #string TaskBriefing
|
||||
function PROCESS_ASSIGN_ACCEPT:Template( TaskBriefing )
|
||||
return { self, { TaskBriefing } }
|
||||
end
|
||||
|
||||
|
||||
--- Creates a new task assignment state machine. The process will accept the task by default, no player intervention accepted.
|
||||
-- @param #PROCESS_ASSIGN_ACCEPT self
|
||||
-- @param #string TaskBriefing
|
||||
|
||||
@@ -107,7 +107,7 @@ do -- PROCESS_ROUTE
|
||||
{ name = 'Fail', from = '*', to = 'Failed' },
|
||||
},
|
||||
endstates = {
|
||||
'Arrived', 'Failed', 'Success'
|
||||
'Arrived', 'Failed'
|
||||
},
|
||||
}
|
||||
|
||||
@@ -150,10 +150,10 @@ do -- PROCESS_ROUTE
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function PROCESS_ROUTE:onafterRoute( ProcessUnit, Event, From, To )
|
||||
function PROCESS_ROUTE:onbeforeRoute( ProcessUnit, Event, From, To )
|
||||
|
||||
if ProcessUnit:IsAlive() then
|
||||
local HasArrived = self:HasArrived( ProcessUnit )
|
||||
local HasArrived = self:HasArrived( ProcessUnit ) -- Polymorphic
|
||||
if self.DisplayCount >= self.DisplayInterval then
|
||||
self:T( { HasArrived = HasArrived } )
|
||||
if not HasArrived then
|
||||
@@ -165,7 +165,12 @@ do -- PROCESS_ROUTE
|
||||
end
|
||||
|
||||
self:T( { DisplayCount = self.DisplayCount } )
|
||||
self:__Route( 1 )
|
||||
|
||||
if HasArrived then
|
||||
self:__Arrive( 1 )
|
||||
else
|
||||
self:__Route( 1 )
|
||||
end
|
||||
|
||||
return HasArrived -- if false, then the event will not be executed...
|
||||
end
|
||||
@@ -189,6 +194,14 @@ do -- PROCESS_ROUTE_ZONE
|
||||
PROCESS_ROUTE_ZONE = {
|
||||
ClassName = "PROCESS_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 #PROCESS_ROUTE_ZONE self
|
||||
-- @param Zone#ZONE_BASE TargetZone
|
||||
function PROCESS_ROUTE_ZONE:Template( TargetZone )
|
||||
return { self, arg }
|
||||
end
|
||||
|
||||
|
||||
--- Creates a new routing state machine. The task will route a controllable to a ZONE until the controllable is within that ZONE.
|
||||
@@ -206,9 +219,15 @@ do -- PROCESS_ROUTE_ZONE
|
||||
|
||||
--- Method override to check if the controllable has arrived.
|
||||
-- @param #PROCESS_ROUTE self
|
||||
-- @param Controllable#CONTROLLABLE ProcessUnit
|
||||
-- @param Wrapper.Controllable#CONTROLLABLE ProcessUnit
|
||||
-- @return #boolean
|
||||
function PROCESS_ROUTE_ZONE:HasArrived( ProcessUnit )
|
||||
|
||||
if ProcessUnit:IsInZone( self.TargetZone ) then
|
||||
local RouteText = ProcessUnit:GetCallsign() .. ": You have arrived within the zone!"
|
||||
MESSAGE:New( RouteText, self.DisplayTime, self.DisplayCategory ):ToGroup( ProcessUnit:GetGroup() )
|
||||
end
|
||||
|
||||
return ProcessUnit:IsInZone( self.TargetZone )
|
||||
end
|
||||
|
||||
|
||||
@@ -144,13 +144,20 @@ do -- PROCESS_SMOKE_TARGETS_ZONE
|
||||
ClassName = "PROCESS_SMOKE_TARGETS_ZONE",
|
||||
}
|
||||
|
||||
function PROCESS_SMOKE_TARGETS_ZONE:ProcessStop()
|
||||
self:E("ProcessStop Detailed")
|
||||
function PROCESS_SMOKE_TARGETS_ZONE:_Destructor()
|
||||
self:E("_Destructor")
|
||||
|
||||
self.Menu:Remove()
|
||||
|
||||
self:EventRemoveAll()
|
||||
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 Set#SET_UNIT TargetSetUnit
|
||||
-- @param Zone#ZONE_BASE TargetZone
|
||||
function PROCESS_SMOKE_TARGETS_ZONE:Template( TargetSetUnit, TargetZone )
|
||||
return { self, arg }
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user