- FSM pseudo function cleanup
- Fixed bug when mission is cancelled
This commit is contained in:
Frank
2021-08-27 11:31:12 +02:00
parent a8a8dcff3f
commit f0167b3e88
10 changed files with 244 additions and 111 deletions

View File

@@ -410,7 +410,7 @@ do -- FSM
Transition.To = To
-- Debug message.
self:T3( Transition )
--self:T3( Transition )
self._Transitions[Transition] = Transition
self:_eventmap( self.Events, Transition )
@@ -432,7 +432,7 @@ do -- FSM
-- @param #table ReturnEvents A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
-- @return Core.Fsm#FSM_PROCESS The SubFSM.
function FSM:AddProcess( From, Event, Process, ReturnEvents )
self:T3( { From, Event } )
--self:T3( { From, Event } )
local Sub = {}
Sub.From = From
@@ -533,7 +533,7 @@ do -- FSM
Process._Scores[State].ScoreText = ScoreText
Process._Scores[State].Score = Score
self:T3( Process._Scores )
--self:T3( Process._Scores )
return Process
end
@@ -576,7 +576,7 @@ do -- FSM
self[__Event] = self[__Event] or self:_delayed_transition(Event)
-- Debug message.
self:T3( "Added methods: " .. Event .. ", " .. __Event )
--self:T3( "Added methods: " .. Event .. ", " .. __Event )
Events[Event] = self.Events[Event] or { map = {} }
self:_add_to_map( Events[Event].map, EventStructure )
@@ -791,7 +791,7 @@ do -- FSM
return function( self, DelaySeconds, ... )
-- Debug.
self:T2( "Delayed Event: " .. EventName )
self:T3( "Delayed Event: " .. EventName )
local CallID = 0
if DelaySeconds ~= nil then
@@ -809,23 +809,23 @@ do -- FSM
self._EventSchedules[EventName] = CallID
-- Debug output.
self:T2(string.format("NEGATIVE Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
else
self:T2(string.format("NEGATIVE Event %s delayed by %.1f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds))
self:T2(string.format("NEGATIVE Event %s delayed by %.3f sec CANCELLED as we already have such an event in the queue.", EventName, DelaySeconds))
-- reschedule
end
else
CallID = self.CallScheduler:Schedule( self, self._handler, { EventName, ... }, DelaySeconds or 1, nil, nil, nil, 4, true )
self:T2(string.format("Event %s delayed by %.1f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
self:T2(string.format("Event %s delayed by %.3f sec SCHEDULED with CallID=%s", EventName, DelaySeconds, tostring(CallID)))
end
else
error( "FSM: An asynchronous event trigger requires a DelaySeconds parameter!!! This can be positive or negative! Sorry, but will not process this." )
end
-- Debug.
self:T3( { CallID = CallID } )
--self:T3( { CallID = CallID } )
end
end
@@ -846,7 +846,7 @@ do -- FSM
function FSM:_gosub( ParentFrom, ParentEvent )
local fsmtable = {}
if self.subs[ParentFrom] and self.subs[ParentFrom][ParentEvent] then
self:T3( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
--self:T3( { ParentFrom, ParentEvent, self.subs[ParentFrom], self.subs[ParentFrom][ParentEvent] } )
return self.subs[ParentFrom][ParentEvent]
else
return {}
@@ -893,7 +893,7 @@ do -- FSM
end
end
self:T3( { Map, Event } )
--self:T3( { Map, Event } )
end
--- Get current state.
@@ -1150,7 +1150,7 @@ do -- FSM_PROCESS
-- @param #FSM_PROCESS self
-- @return #FSM_PROCESS
function FSM_PROCESS:Copy( Controllable, Task )
self:T3( { self:GetClassNameAndID() } )
--self:T3( { self:GetClassNameAndID() } )
local NewFsm = self:New( Controllable, Task ) -- Core.Fsm#FSM_PROCESS
@@ -1176,13 +1176,13 @@ do -- FSM_PROCESS
-- Copy End States
for EndStateID, EndState in pairs( self:GetEndStates() ) do
self:T3( EndState )
--self:T3( EndState )
NewFsm:AddEndState( EndState )
end
-- Copy the score tables
for ScoreID, Score in pairs( self:GetScores() ) do
self:T3( Score )
--self:T3( Score )
NewFsm:AddScore( ScoreID, Score.ScoreText, Score.Score )
end