mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
First prototype of the scheduler dispatcher is ready... It works, but the code was very difficult...
So, when the Scheduler that is passed to the AddScheduler is nillified, the internal arrays that keep the Scheduler reference are also nillified. And it does what i need for further utilization in MOOSE classes. When the Scheduler is nillified, but, a schedule was planned for that Scheduler, once the scheduler fires off, it will ignore that call... cool. Sven
This commit is contained in:
@@ -1,6 +1,19 @@
|
||||
--- The EVENT class models an efficient event handling process between other classes and its units, weapons.
|
||||
--- This module contains the EVENT class.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- Takes care of EVENT dispatching between DCS events and event handling functions defined in MOOSE classes.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- The above menus classes **are derived** from 2 main **abstract** classes defined within the MOOSE framework (so don't use these):
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Contributions: -
|
||||
-- ### Authors: FlightControl : Design & Programming
|
||||
--
|
||||
-- @module Event
|
||||
-- @author FlightControl
|
||||
|
||||
--- The EVENT structure
|
||||
-- @type EVENT
|
||||
@@ -93,7 +106,7 @@ function EVENT:Init( EventID, EventClass )
|
||||
end
|
||||
|
||||
if not self.Events[EventID][EventClass] then
|
||||
self.Events[EventID][EventClass] = setmetatable( {}, { __mode = "v" } )
|
||||
self.Events[EventID][EventClass] = setmetatable( {}, { __mode = "k" } )
|
||||
end
|
||||
return self.Events[EventID][EventClass]
|
||||
end
|
||||
|
||||
@@ -58,26 +58,6 @@ function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArg
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
|
||||
|
||||
self:Schedule( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Schedule a new time event. Note that the schedule will only take place if the scheduler is *started*. Even for a single schedule event, the scheduler needs to be started also.
|
||||
-- @param #SCHEDULER self
|
||||
-- @param #table TimeEventObject Specified for which Moose object the timer is setup. If a value of nil is provided, a scheduler will be setup without an object reference.
|
||||
-- @param #function TimeEventFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in TimeEventFunctionArguments.
|
||||
-- @param #table TimeEventFunctionArguments Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||
-- @param #number StartSeconds Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
||||
-- @param #number RepeatSecondsInterval Specifies the interval in seconds when the scheduler will call the event function.
|
||||
-- @param #number RandomizationFactor Specifies a randomization factor between 0 and 1 to randomize the RepeatSecondsInterval.
|
||||
-- @param #number StopSeconds Specifies the amount of seconds when the scheduler will be stopped.
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Schedule( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
self:T3( { TimeEventFunctionArguments } )
|
||||
|
||||
self.TimeEventObject = TimeEventObject
|
||||
self.TimeEventFunction = TimeEventFunction
|
||||
self.TimeEventFunctionArguments = TimeEventFunctionArguments
|
||||
@@ -89,103 +69,11 @@ function SCHEDULER:Schedule( TimeEventObject, TimeEventFunction, TimeEventFuncti
|
||||
|
||||
self.StartTime = timer.getTime()
|
||||
|
||||
self:Start()
|
||||
_TIMERDISPATCHER:AddSchedule( self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Re-)Starts the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Start()
|
||||
self:F2()
|
||||
|
||||
if self.RepeatSecondsInterval ~= 0 then
|
||||
self.Repeat = true
|
||||
end
|
||||
|
||||
if self.StartSeconds then
|
||||
if self.ScheduleID then
|
||||
timer.removeFunction( self.ScheduleID )
|
||||
end
|
||||
self:T( { self.StartSeconds } )
|
||||
self.ScheduleID = timer.scheduleFunction( self._Scheduler, self, timer.getTime() + self.StartSeconds + .001 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stops the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Stop()
|
||||
self:F2( self.TimeEventObject )
|
||||
|
||||
self.Repeat = false
|
||||
if self.ScheduleID then
|
||||
self:E( "Stop Schedule" )
|
||||
timer.removeFunction( self.ScheduleID )
|
||||
end
|
||||
self.ScheduleID = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-- Private Functions
|
||||
|
||||
--- @param #SCHEDULER self
|
||||
function SCHEDULER:_Scheduler()
|
||||
self:F2( self.TimeEventFunctionArguments )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
|
||||
env.info( "Error in SCHEDULER function:" .. errmsg )
|
||||
if debug ~= nil then
|
||||
env.info( debug.traceback() )
|
||||
end
|
||||
|
||||
return errmsg
|
||||
end
|
||||
|
||||
local StartTime = self.StartTime
|
||||
local StopSeconds = self.StopSeconds
|
||||
local Repeat = self.Repeat
|
||||
local RandomizationFactor = self.RandomizationFactor
|
||||
local RepeatSecondsInterval = self.RepeatSecondsInterval
|
||||
local ScheduleID = self.ScheduleID
|
||||
|
||||
local Status, Result
|
||||
if self.TimeEventObject then
|
||||
Status, Result = xpcall( function() return self.TimeEventFunction( self.TimeEventObject, unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||
else
|
||||
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||
end
|
||||
|
||||
self:T( { "Timer Event2 .. " .. self.ScheduleID, Status, Result, StartTime, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
|
||||
if Status and ( ( Result == nil ) or ( Result and Result ~= false ) ) then
|
||||
if Repeat and ( not StopSeconds or ( StopSeconds and timer.getTime() <= StartTime + StopSeconds ) ) then
|
||||
local ScheduleTime =
|
||||
timer.getTime() +
|
||||
self.RepeatSecondsInterval +
|
||||
math.random(
|
||||
- ( RandomizationFactor * RepeatSecondsInterval / 2 ),
|
||||
( RandomizationFactor * RepeatSecondsInterval / 2 )
|
||||
) +
|
||||
0.01
|
||||
self:T( { self.TimeEventFunctionArguments, "Repeat:", timer.getTime(), ScheduleTime } )
|
||||
return ScheduleTime -- returns the next time the function needs to be called.
|
||||
else
|
||||
timer.removeFunction( ScheduleID )
|
||||
self.ScheduleID = nil
|
||||
end
|
||||
else
|
||||
timer.removeFunction( ScheduleID )
|
||||
self.ScheduleID = nil
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
214
Moose Development/Moose/Core/Scheduler2.lua
Normal file
214
Moose Development/Moose/Core/Scheduler2.lua
Normal file
@@ -0,0 +1,214 @@
|
||||
--- This module contains the SCHEDULER class.
|
||||
--
|
||||
-- 1) @{Core.Scheduler#SCHEDULER} class, extends @{Core.Base#BASE}
|
||||
-- =====================================================
|
||||
-- The @{Core.Scheduler#SCHEDULER} class models time events calling given event handling functions.
|
||||
--
|
||||
-- 1.1) SCHEDULER constructor
|
||||
-- --------------------------
|
||||
-- The SCHEDULER class is quite easy to use:
|
||||
--
|
||||
-- * @{Core.Scheduler#SCHEDULER.New}: Setup a new scheduler and start it with the specified parameters.
|
||||
--
|
||||
-- 1.2) SCHEDULER timer stop and start
|
||||
-- -----------------------------------
|
||||
-- The SCHEDULER can be stopped and restarted with the following methods:
|
||||
--
|
||||
-- * @{Core.Scheduler#SCHEDULER.Start}: (Re-)Start the scheduler.
|
||||
-- * @{Core.Scheduler#SCHEDULER.Stop}: Stop the scheduler.
|
||||
--
|
||||
-- 1.3) Reschedule new time event
|
||||
-- ------------------------------
|
||||
-- With @{Core.Scheduler#SCHEDULER.Schedule} a new time event can be scheduled.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Contributions:
|
||||
--
|
||||
-- * Mechanist : Concept & Testing
|
||||
--
|
||||
-- ### Authors:
|
||||
--
|
||||
-- * FlightControl : Design & Programming
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- @module Scheduler
|
||||
|
||||
|
||||
--- The SCHEDULER class
|
||||
-- @type SCHEDULER
|
||||
-- @field #number ScheduleID the ID of the scheduler.
|
||||
-- @extends Core.Base#BASE
|
||||
SCHEDULER = {
|
||||
ClassName = "SCHEDULER",
|
||||
}
|
||||
|
||||
--- SCHEDULER constructor.
|
||||
-- @param #SCHEDULER self
|
||||
-- @param #table TimeEventObject Specified for which Moose object the timer is setup. If a value of nil is provided, a scheduler will be setup without an object reference.
|
||||
-- @param #function TimeEventFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in TimeEventFunctionArguments.
|
||||
-- @param #table TimeEventFunctionArguments Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||
-- @param #number StartSeconds Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
||||
-- @param #number RepeatSecondsInterval Specifies the interval in seconds when the scheduler will call the event function.
|
||||
-- @param #number RandomizationFactor Specifies a randomization factor between 0 and 1 to randomize the RepeatSecondsInterval.
|
||||
-- @param #number StopSeconds Specifies the amount of seconds when the scheduler will be stopped.
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:New( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
|
||||
self.TimeEventObject = TimeEventObject
|
||||
self.TimeEventFunction = TimeEventFunction
|
||||
self.TimeEventFunctionArguments = TimeEventFunctionArguments
|
||||
self.StartSeconds = StartSeconds
|
||||
self.Repeat = false
|
||||
self.RepeatSecondsInterval = RepeatSecondsInterval or 0
|
||||
self.RandomizationFactor = RandomizationFactor or 0
|
||||
self.StopSeconds = StopSeconds
|
||||
|
||||
self.StartTime = timer.getTime()
|
||||
|
||||
_TIMERDISPATCHER:AddSchedule( self )
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Schedule a new time event. Note that the schedule will only take place if the scheduler is *started*. Even for a single schedule event, the scheduler needs to be started also.
|
||||
-- @param #SCHEDULER self
|
||||
-- @param #table TimeEventObject Specified for which Moose object the timer is setup. If a value of nil is provided, a scheduler will be setup without an object reference.
|
||||
-- @param #function TimeEventFunction The event function to be called when a timer event occurs. The event function needs to accept the parameters specified in TimeEventFunctionArguments.
|
||||
-- @param #table TimeEventFunctionArguments Optional arguments that can be given as part of scheduler. The arguments need to be given as a table { param1, param 2, ... }.
|
||||
-- @param #number StartSeconds Specifies the amount of seconds that will be waited before the scheduling is started, and the event function is called.
|
||||
-- @param #number RepeatSecondsInterval Specifies the interval in seconds when the scheduler will call the event function.
|
||||
-- @param #number RandomizationFactor Specifies a randomization factor between 0 and 1 to randomize the RepeatSecondsInterval.
|
||||
-- @param #number StopSeconds Specifies the amount of seconds when the scheduler will be stopped.
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Schedule( TimeEventObject, TimeEventFunction, TimeEventFunctionArguments, StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds )
|
||||
self:F2( { StartSeconds, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
self:T3( { TimeEventFunctionArguments } )
|
||||
|
||||
self.TimeEventObject = TimeEventObject
|
||||
self.TimeEventFunction = TimeEventFunction
|
||||
self.TimeEventFunctionArguments = TimeEventFunctionArguments
|
||||
self.StartSeconds = StartSeconds
|
||||
self.Repeat = false
|
||||
self.RepeatSecondsInterval = RepeatSecondsInterval or 0
|
||||
self.RandomizationFactor = RandomizationFactor or 0
|
||||
self.StopSeconds = StopSeconds
|
||||
|
||||
self.StartTime = timer.getTime()
|
||||
|
||||
self:Start()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- (Re-)Starts the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Start()
|
||||
self:F2()
|
||||
|
||||
if self.RepeatSecondsInterval ~= 0 then
|
||||
self.Repeat = true
|
||||
end
|
||||
|
||||
if self.StartSeconds then
|
||||
if self.ScheduleID then
|
||||
timer.removeFunction( self.ScheduleID )
|
||||
end
|
||||
self:T( { self.StartSeconds } )
|
||||
self.ScheduleID = timer.scheduleFunction( self._Scheduler, self, timer.getTime() + self.StartSeconds + .001 )
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Stops the scheduler.
|
||||
-- @param #SCHEDULER self
|
||||
-- @return #SCHEDULER self
|
||||
function SCHEDULER:Stop()
|
||||
self:F2( self.TimeEventObject )
|
||||
|
||||
self.Repeat = false
|
||||
if self.ScheduleID then
|
||||
self:E( "Stop Schedule" )
|
||||
timer.removeFunction( self.ScheduleID )
|
||||
end
|
||||
self.ScheduleID = nil
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
-- Private Functions
|
||||
|
||||
--- @param #SCHEDULER self
|
||||
function SCHEDULER:_Scheduler()
|
||||
self:F2( self.TimeEventFunctionArguments )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
|
||||
env.info( "Error in SCHEDULER function:" .. errmsg )
|
||||
if debug ~= nil then
|
||||
env.info( debug.traceback() )
|
||||
end
|
||||
|
||||
return errmsg
|
||||
end
|
||||
|
||||
local StartTime = self.StartTime
|
||||
local StopSeconds = self.StopSeconds
|
||||
local Repeat = self.Repeat
|
||||
local RandomizationFactor = self.RandomizationFactor
|
||||
local RepeatSecondsInterval = self.RepeatSecondsInterval
|
||||
local ScheduleID = self.ScheduleID
|
||||
|
||||
local Status, Result
|
||||
if self.TimeEventObject then
|
||||
Status, Result = xpcall( function() return self.TimeEventFunction( self.TimeEventObject, unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||
else
|
||||
Status, Result = xpcall( function() return self.TimeEventFunction( unpack( self.TimeEventFunctionArguments ) ) end, ErrorHandler )
|
||||
end
|
||||
|
||||
self:T( { "Timer Event2 .. " .. self.ScheduleID, Status, Result, StartTime, RepeatSecondsInterval, RandomizationFactor, StopSeconds } )
|
||||
|
||||
if Status and ( ( Result == nil ) or ( Result and Result ~= false ) ) then
|
||||
if Repeat and ( not StopSeconds or ( StopSeconds and timer.getTime() <= StartTime + StopSeconds ) ) then
|
||||
local ScheduleTime =
|
||||
timer.getTime() +
|
||||
self.RepeatSecondsInterval +
|
||||
math.random(
|
||||
- ( RandomizationFactor * RepeatSecondsInterval / 2 ),
|
||||
( RandomizationFactor * RepeatSecondsInterval / 2 )
|
||||
) +
|
||||
0.01
|
||||
self:T( { self.TimeEventFunctionArguments, "Repeat:", timer.getTime(), ScheduleTime } )
|
||||
return ScheduleTime -- returns the next time the function needs to be called.
|
||||
else
|
||||
timer.removeFunction( ScheduleID )
|
||||
self.ScheduleID = nil
|
||||
end
|
||||
else
|
||||
timer.removeFunction( ScheduleID )
|
||||
self.ScheduleID = nil
|
||||
end
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
104
Moose Development/Moose/Core/Timer.lua
Normal file
104
Moose Development/Moose/Core/Timer.lua
Normal file
@@ -0,0 +1,104 @@
|
||||
--- This module contains the TIMER class.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- Takes care of scheduled function dispatching for defined in MOOSE classes.
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ===
|
||||
--
|
||||
-- ### Contributions: -
|
||||
-- ### Authors: FlightControl : Design & Programming
|
||||
--
|
||||
-- @module Timer
|
||||
|
||||
--- The TIMER structure
|
||||
-- @type TIMER
|
||||
TIMER = {
|
||||
ClassName = "TIMER",
|
||||
CallID = 0,
|
||||
}
|
||||
|
||||
function TIMER:New()
|
||||
local self = BASE:Inherit( self, BASE:New() )
|
||||
self:F3()
|
||||
return self
|
||||
end
|
||||
|
||||
--- Add a Schedule to the ScheduleDispatcher.
|
||||
-- The development of this method was really tidy.
|
||||
-- It is constructed as such that a garbage collection is executed on the weak tables, when the Scheduler is nillified.
|
||||
-- Nothing of this code should be modified without testing it thoroughly.
|
||||
-- @param #TIMER self
|
||||
-- @param Core.Scheduler#SCHEDULER Scheduler
|
||||
function TIMER:AddSchedule( Scheduler )
|
||||
self:F3( { Scheduler = Scheduler } )
|
||||
|
||||
-- Initialize the Functions array, which is a weakly coupled table.
|
||||
-- If the object used as the key is nil, then the garbage collector will remove the item from the Functions array.
|
||||
self.Schedulers = self.Schedulers or setmetatable( {}, { __mode = "k" } )
|
||||
|
||||
self.CallID = self.CallID + 1
|
||||
self.Schedulers[Scheduler] = self.CallID
|
||||
|
||||
self:E(self.Schedulers)
|
||||
|
||||
self.Schedule = self.Schedule or setmetatable( {}, { __mode = "v" } )
|
||||
|
||||
|
||||
self.Schedule[self.CallID] = {}
|
||||
|
||||
self.Schedule[self.CallID].ScheduleFunction = Scheduler.TimeEventFunction
|
||||
self.Schedule[self.CallID].ScheduleArguments = Scheduler.TimeEventFunctionArguments
|
||||
self.Schedule[self.CallID].ScheduleObject = Scheduler.TimeEventObject
|
||||
self.Schedule[self.CallID].ScheduleStart = Scheduler.StartSeconds + .001
|
||||
|
||||
self:E( self.Schedule[self.CallID] )
|
||||
|
||||
local function ScheduleCallHandler( CallID )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
env.info( "Error in timer function: " .. errmsg )
|
||||
if debug ~= nil then
|
||||
env.info( debug.traceback() )
|
||||
end
|
||||
return errmsg
|
||||
end
|
||||
|
||||
BASE:E( { self } )
|
||||
|
||||
local ScheduleFunction = self.Schedule[CallID].ScheduleFunction
|
||||
local ScheduleArguments = self.Schedule[CallID].ScheduleArguments
|
||||
local ScheduleObject = self.Schedule[CallID].ScheduleObject
|
||||
|
||||
local Status, Result
|
||||
if ScheduleObject then
|
||||
local function Timer()
|
||||
return ScheduleFunction( ScheduleObject, unpack( ScheduleArguments ) )
|
||||
end
|
||||
Status, Result = xpcall( Timer, ErrorHandler )
|
||||
else
|
||||
local function Timer()
|
||||
return ScheduleFunction( unpack( ScheduleArguments ) )
|
||||
end
|
||||
Status, Result = xpcall( Timer, ErrorHandler )
|
||||
end
|
||||
end
|
||||
|
||||
timer.scheduleFunction(
|
||||
ScheduleCallHandler,
|
||||
self.CallID,
|
||||
timer.getTime() + 1
|
||||
)
|
||||
--[[
|
||||
|
||||
|
||||
self:T( Schedule.FunctionID )
|
||||
--]]
|
||||
|
||||
return self.CallID
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -7,6 +7,7 @@ Include.File( "Utilities/Utils" )
|
||||
--- Core Classes
|
||||
Include.File( "Core/Base" )
|
||||
Include.File( "Core/Scheduler" )
|
||||
Include.File( "Core/Timer")
|
||||
Include.File( "Core/Event" )
|
||||
Include.File( "Core/Menu" )
|
||||
Include.File( "Core/Zone" )
|
||||
@@ -66,3 +67,6 @@ _EVENTDISPATCHER = EVENT:New() -- Core.Event#EVENT
|
||||
--- Declare the main database object, which is used internally by the MOOSE classes.
|
||||
_DATABASE = DATABASE:New() -- Database#DATABASE
|
||||
|
||||
--- Declare the timer dispatcher based on the TIMER class
|
||||
_TIMERDISPATCHER = TIMER:New() -- Core.Timer#TIMER
|
||||
|
||||
|
||||
@@ -148,9 +148,7 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType )
|
||||
self:UnAssignFromUnit( TaskUnit )
|
||||
self:MessageToGroups( TaskUnit:GetPlayerName() .. " aborted Task " .. self:GetName() )
|
||||
end
|
||||
if self:HasAliveUnits() == false then
|
||||
self:__Abort( 1 )
|
||||
end
|
||||
self:__Abort( 1 )
|
||||
end
|
||||
end
|
||||
)
|
||||
@@ -793,6 +791,27 @@ function TASK_BASE:SetBriefing( TaskBriefing )
|
||||
return self
|
||||
end
|
||||
|
||||
--- StateMachine callback function for a TASK
|
||||
-- @param #TASK_BASE self
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
-- @param Core.Event#EVENTDATA Event
|
||||
function TASK_BASE:onbeforeAbort( Event, From, To )
|
||||
|
||||
self:E("Abort")
|
||||
|
||||
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
|
||||
if self:HasAliveUnits() then
|
||||
return false
|
||||
end
|
||||
end
|
||||
|
||||
self:MessageToGroups( "Task " .. self:GetName() .. " has been aborted! Task will be replanned." )
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- StateMachine callback function for a TASK
|
||||
|
||||
Reference in New Issue
Block a user