mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Updates
This commit is contained in:
@@ -530,10 +530,20 @@ do -- FSM
|
||||
|
||||
|
||||
function FSM:_call_handler( handler, params, EventName )
|
||||
|
||||
local ErrorHandler = function( errmsg )
|
||||
|
||||
env.info( "Error in SCHEDULER function:" .. errmsg )
|
||||
if debug ~= nil then
|
||||
env.info( debug.traceback() )
|
||||
end
|
||||
|
||||
return errmsg
|
||||
end
|
||||
if self[handler] then
|
||||
self:T( "Calling " .. handler )
|
||||
self._EventSchedules[EventName] = nil
|
||||
local Value = self[handler]( self, unpack(params) )
|
||||
local Result, Value = xpcall( function() return self[handler]( self, unpack( params ) ) end, ErrorHandler )
|
||||
return Value
|
||||
end
|
||||
end
|
||||
|
||||
@@ -181,11 +181,15 @@ function SCHEDULEDISPATCHER:Start( Scheduler, CallID )
|
||||
|
||||
if CallID then
|
||||
local Schedule = self.Schedule[Scheduler]
|
||||
Schedule[CallID].ScheduleID = timer.scheduleFunction(
|
||||
Schedule[CallID].CallHandler,
|
||||
CallID,
|
||||
timer.getTime() + Schedule[CallID].Start
|
||||
)
|
||||
-- Only start when there is no ScheduleID defined!
|
||||
-- This prevents to "Start" the scheduler twice with the same CallID...
|
||||
if not Schedule[CallID].ScheduleID then
|
||||
Schedule[CallID].ScheduleID = timer.scheduleFunction(
|
||||
Schedule[CallID].CallHandler,
|
||||
CallID,
|
||||
timer.getTime() + Schedule[CallID].Start
|
||||
)
|
||||
end
|
||||
else
|
||||
for CallID, Schedule in pairs( self.Schedule[Scheduler] ) do
|
||||
self:Start( Scheduler, CallID ) -- Recursive
|
||||
@@ -198,7 +202,12 @@ function SCHEDULEDISPATCHER:Stop( Scheduler, CallID )
|
||||
|
||||
if CallID then
|
||||
local Schedule = self.Schedule[Scheduler]
|
||||
timer.removeFunction( Schedule[CallID].ScheduleID )
|
||||
-- Only stop when there is a ScheduleID defined for the CallID.
|
||||
-- So, when the scheduler was stopped before, do nothing.
|
||||
if Schedule[CallID].ScheduleID then
|
||||
timer.removeFunction( Schedule[CallID].ScheduleID )
|
||||
Schedule[CallID].ScheduleID = nil
|
||||
end
|
||||
else
|
||||
for CallID, Schedule in pairs( self.Schedule[Scheduler] ) do
|
||||
self:Stop( Scheduler, CallID ) -- Recursive
|
||||
|
||||
@@ -384,6 +384,29 @@ function SET_BASE:Get( ObjectName )
|
||||
|
||||
end
|
||||
|
||||
--- Gets the first object from the @{Set#SET_BASE} and derived classes.
|
||||
-- @param #SET_BASE self
|
||||
-- @return Core.Base#BASE
|
||||
function SET_BASE:GetFirst()
|
||||
self:F()
|
||||
|
||||
local t = self.List.first._
|
||||
self:T3( { t } )
|
||||
return t
|
||||
end
|
||||
|
||||
--- Gets the last object from the @{Set#SET_BASE} and derived classes.
|
||||
-- @param #SET_BASE self
|
||||
-- @return Core.Base#BASE
|
||||
function SET_BASE:GetLast()
|
||||
self:F()
|
||||
|
||||
local t = self.List.last._
|
||||
self:T3( { t } )
|
||||
return t
|
||||
end
|
||||
|
||||
|
||||
--- Retrieves the amount of objects in the @{Set#SET_BASE} and derived classes.
|
||||
-- @param #SET_BASE self
|
||||
-- @return #number Count
|
||||
@@ -652,7 +675,8 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen
|
||||
return false
|
||||
end
|
||||
|
||||
self.CallScheduler:Schedule( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 )
|
||||
--self.CallScheduler:Schedule( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 )
|
||||
Schedule()
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -725,7 +749,7 @@ end
|
||||
|
||||
--- SET_GROUP class
|
||||
-- @type SET_GROUP
|
||||
-- @extends #SET_BASE
|
||||
-- @extends Core.Set#SET_BASE
|
||||
SET_GROUP = {
|
||||
ClassName = "SET_GROUP",
|
||||
Filter = {
|
||||
|
||||
@@ -212,6 +212,60 @@ function ZONE_BASE:GetVec2()
|
||||
|
||||
return nil
|
||||
end
|
||||
|
||||
--- Returns a @{Point#POINT_VEC2} of the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located.
|
||||
-- @return Core.Point#POINT_VEC2 The PointVec2 of the zone.
|
||||
function ZONE_BASE:GetPointVec2()
|
||||
self:F2( self.ZoneName )
|
||||
|
||||
local Vec2 = self:GetVec2()
|
||||
|
||||
local PointVec2 = POINT_VEC2:NewFromVec2( Vec2 )
|
||||
|
||||
self:T2( { PointVec2 } )
|
||||
|
||||
return PointVec2
|
||||
end
|
||||
|
||||
|
||||
--- Returns the @{DCSTypes#Vec3} of the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located.
|
||||
-- @return Dcs.DCSTypes#Vec3 The Vec3 of the zone.
|
||||
function ZONE_BASE:GetVec3( Height )
|
||||
self:F2( self.ZoneName )
|
||||
|
||||
Height = Height or 0
|
||||
|
||||
local Vec2 = self:GetVec2()
|
||||
|
||||
local Vec3 = { x = Vec2.x, y = land.getHeight( self:GetVec2() ) + Height, z = Vec2.y }
|
||||
|
||||
self:T2( { Vec3 } )
|
||||
|
||||
return Vec3
|
||||
end
|
||||
|
||||
--- Returns a @{Point#POINT_VEC3} of the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @param Dcs.DCSTypes#Distance Height The height to add to the land height where the center of the zone is located.
|
||||
-- @return Core.Point#POINT_VEC3 The PointVec3 of the zone.
|
||||
function ZONE_BASE:GetPointVec3( Height )
|
||||
self:F2( self.ZoneName )
|
||||
|
||||
local Vec3 = self:GetVec3( Height )
|
||||
|
||||
local PointVec3 = POINT_VEC3:NewFromVec3( Vec3 )
|
||||
|
||||
self:T2( { PointVec3 } )
|
||||
|
||||
return PointVec3
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Define a random @{DCSTypes#Vec2} within the zone.
|
||||
-- @param #ZONE_BASE self
|
||||
-- @return Dcs.DCSTypes#Vec2 The Vec2 coordinates.
|
||||
|
||||
Reference in New Issue
Block a user