This commit is contained in:
FlightControl
2016-12-16 12:07:11 +01:00
parent d62acf421e
commit 995e21e200
4 changed files with 222 additions and 48 deletions

View File

@@ -32,17 +32,6 @@ do -- FSM
-- Inherits from BASE
local self = BASE:Inherit( self, BASE:New() )
--local self = routines.utils.deepCopy( self ) -- Create a new self instance
--assert(options.events)
--local MT = {}
--setmetatable( self, MT )
--self.__index = self
self.options = options or {}
self.options.subs = self.options.subs or {}
self.current = self.options.initial or 'none'
@@ -95,8 +84,6 @@ do -- FSM
return self._Transitions or {}
end
--- Set the default @{Process} template with key ProcessName providing the ProcessClass and the process object when it is assigned to a @{Controllable} by the task.
-- @return Fsm.Fsm#FSM_PROCESS
function FSM:AddProcess( From, Event, Process, ReturnEvents )
@@ -391,27 +378,7 @@ do -- FSM
function FSM:cannot(e)
return not self:can(e)
end
function FSM:CopyCallHandlers( FsmT )
local Parent = BASE:GetParent( FsmT )
if Parent then
self:CopyCallHandlers( Parent )
end
for ElementID, Element in pairs( FsmT ) do
self:E( { ElementID = ElementID } )
if type( Element ) == "function" then
if ElementID.find( ElementID, "^onbefore" ) or
ElementID.find( ElementID, "^onafter" ) or
ElementID.find( ElementID, "^onenter" ) or
ElementID.find( ElementID, "^onleave" ) or
ElementID.find( ElementID, "^onfunc" ) then
self[ ElementID ] = Element
end
end
end
end
end
do -- FSM_CONTROLLABLE
@@ -551,7 +518,7 @@ do -- FSM_PROCESS
--- Sets the task of the process.
-- @param #FSM_PROCESS self
-- @param Tasking.Task#TASK_BASE Task
-- @return #PROCESS
-- @return #FSM_PROCESS
function FSM_PROCESS:SetTask( Task )
self.Task = Task

View File

@@ -158,9 +158,6 @@ do -- FSM_ASSIGN_ACCEPT
function FSM_ASSIGN_ACCEPT:onafterStart( ProcessUnit, Event, From, To )
self:E( { ProcessUnit, Event, From, To } )
local ProcessGroup = ProcessUnit:GetGroup()
MESSAGE:New( self.TaskBriefing, 30, ProcessUnit:GetPlayerName() .. " Task Acceptance" ):ToGroup( ProcessGroup )
self:__Assign( 1 )
end
@@ -175,8 +172,8 @@ do -- FSM_ASSIGN_ACCEPT
self:E( { ProcessUnit, Event, From, To } )
local ProcessGroup = ProcessUnit:GetGroup()
MESSAGE:New( "You are assigned to the task " .. self.Task:GetName(), 30, ProcessUnit:GetPlayerName() .. ": Task Assignment" ):ToGroup( ProcessGroup )
self:Message( "You are assigned to the task " .. self.Task:GetName() )
self.Task:Assign()
end
@@ -240,8 +237,8 @@ do -- FSM_ASSIGN_MENU_ACCEPT
-- @param #string 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() )
self:Message( "Access the radio menu to accept the task. You have 30 seconds or the assignment will be cancelled." )
local ProcessGroup = ProcessUnit:GetGroup()

View File

@@ -201,7 +201,6 @@ do -- FSM_ROUTE_ZONE
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
@@ -213,7 +212,6 @@ do -- FSM_ROUTE_ZONE
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.
@@ -223,8 +221,8 @@ do -- FSM_ROUTE_ZONE
function FSM_ROUTE_ZONE:onfuncHasArrived( 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() )
local RouteText = "You have arrived within the zone."
self:Message( RouteText )
end
return ProcessUnit:IsInZone( self.TargetZone )
@@ -244,8 +242,8 @@ do -- FSM_ROUTE_ZONE
local ZonePointVec2 = POINT_VEC2:New( ZoneVec2.x, ZoneVec2.y )
local TaskUnitVec2 = ProcessUnit:GetVec2()
local TaskUnitPointVec2 = POINT_VEC2:New( TaskUnitVec2.x, TaskUnitVec2.y )
local RouteText = ProcessUnit:GetCallsign() .. ": Route to " .. TaskUnitPointVec2:GetBRText( ZonePointVec2 ) .. " km to target."
MESSAGE:New( RouteText, self.DisplayTime, self.DisplayCategory ):ToGroup( ProcessUnit:GetGroup() )
local RouteText = "Route to " .. TaskUnitPointVec2:GetBRText( ZonePointVec2 ) .. " km to target."
self:Message( RouteText )
end
end -- FSM_ROUTE_ZONE