diff --git a/Moose Development/Moose/Base.lua b/Moose Development/Moose/Base.lua index 10f5cf4dc..47045deed 100644 --- a/Moose Development/Moose/Base.lua +++ b/Moose Development/Moose/Base.lua @@ -57,27 +57,8 @@ Include.File( "Routines" ) local _TraceOn = true local _TraceLevel = 1 -local _TraceClass = { - --DATABASE = true, - --SEAD = true, - --DESTROYBASETASK = true, - --MOVEMENT = true, - --SPAWN = true, - --STAGE = true, - --ZONE = true, - --GROUP = true, - --UNIT = true, - --CLIENT = true, - --CARGO = true, - --CARGO_GROUP = true, - --CARGO_PACKAGE = true, - --CARGO_SLINGLOAD = true, - --CARGO_ZONE = true, - --CLEANUP = true, - --MENU_CLIENT = true, - --MENU_CLIENT_COMMAND = true, - --ESCORT = true, - } +local _TraceAll = false +local _TraceClass = {} local _TraceClassMethod = {} --- The BASE Class @@ -355,6 +336,20 @@ function BASE:TraceLevel( Level ) self:E( "Tracing level " .. Level ) end +--- Trace all methods in MOOSE +-- @param #BASE self +-- @param #boolean TraceAll true = trace all methods in MOOSE. +function BASE:TraceAll( TraceAll ) + + _TraceAll = TraceAll + + if _TraceAll then + self:E( "Tracing all methods in MOOSE " ) + else + self:E( "Switched off tracing all methods in MOOSE" ) + end +end + --- Set tracing for a class -- @param #BASE self -- @param #string Class @@ -382,7 +377,7 @@ end -- @param Arguments A #table or any field. function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -392,7 +387,7 @@ function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then @@ -436,7 +431,7 @@ end -- @param Arguments A #table or any field. function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -446,7 +441,7 @@ function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then diff --git a/Moose Development/Moose/Set.lua b/Moose Development/Moose/Set.lua index 25fef0064..da27604ce 100644 --- a/Moose Development/Moose/Set.lua +++ b/Moose Development/Moose/Set.lua @@ -2,13 +2,26 @@ -- -- === -- --- 1) @{Set#SET_BASE} class, extending @{Base#BASE} +-- 1) @{Set#SET_BASE} class, extends @{Base#BASE} -- ================================================ -- The @{Set#SET_BASE} class defines the core functions that define a collection of objects. +-- A SET provides iterators to iterate the SET, but will **temporarily** yield the ForEach interator loop at defined **"intervals"** to the mail simulator loop. +-- In this way, large loops can be done while not blocking the simulator main processing loop. +-- The default **"yield interval"** is after 10 objects processed. +-- The default **"time interval"** is after 0.001 seconds. +-- +-- 1.1) Add or remove objects from the SET +-- --------------------------------------- +-- Some key core functions are @{Set#SET_BASE.Add} and @{Set#SET_BASE.Remove} to add or remove objects from the SET in your logic. +-- +-- 1.2) Define the SET iterator **"yield interval"** and the **"time interval"**. +-- ------------------------------------------------------------------------------------- +-- Modify the iterator intervals with the @{Set#SET_BASE.SetInteratorIntervals} method. +-- You can set the **"yield interval"**, and the **"time interval"**. (See above). -- -- === -- --- 2) @{Set#SET_GROUP} class, extending @{Set#SET_BASE} +-- 2) @{Set#SET_GROUP} class, extends @{Set#SET_BASE} -- ==================================================== -- Mission designers can use the @{Set#SET_GROUP} class to build sets of groups belonging to certain: -- @@ -17,13 +30,18 @@ -- * Countries -- * Starting with certain prefix strings. -- --- 2.1) SET_GROUP construction methods: --- ------------------------------------ +-- 2.1) SET_GROUP construction method: +-- ----------------------------------- -- Create a new SET_GROUP object with the @{#SET_GROUP.New} method: -- -- * @{#SET_GROUP.New}: Creates a new SET_GROUP object. -- --- 2.2) SET_GROUP filter criteria: +-- 2.2) Add or Remove GROUP(s) from SET_GROUP: +-- ------------------------------------------- +-- GROUPS can be added and removed using the @{Set#SET_GROUP.AddGroupsByName} and @{Set#SET_GROUPS.RemoveGroupsByName} respectively. +-- These methods take a single GROUP name or an array of GROUP names to be added or removed from SET_GROUP. +-- +-- 2.3) SET_GROUP filter criteria: -- ------------------------------- -- You can set filter criteria to define the set of groups within the SET_GROUP. -- Filter criteria are defined by: @@ -35,24 +53,26 @@ -- -- Once the filter criteria have been set for the SET_GROUP, you can start filtering using: -- --- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP. +-- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP and add or remove GROUP objects **dynamically**. -- -- Planned filter criteria within development are (so these are not yet available): -- -- * @{#SET_GROUP.FilterZones}: Builds the SET_GROUP with the groups within a @{Zone#ZONE}. -- --- --- 2.3) SET_GROUP iterators: +-- 2.4) SET_GROUP iterators: -- ------------------------- -- Once the filters have been defined and the SET_GROUP has been built, you can iterate the SET_GROUP with the available iterator methods. -- The iterator methods will walk the SET_GROUP set, and call for each element within the set a function that you provide. -- The following iterator methods are currently available within the SET_GROUP: -- -- * @{#SET_GROUP.ForEachGroup}: Calls a function for each alive group it finds within the SET_GROUP. +-- * @{#SET_GROUP.ForEachGroupCompletelyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupPartlyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence partly in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupNotInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence not in a @{Zone}, providing the GROUP and optional parameters to the called function. -- -- ==== -- --- 3) @{Set#SET_UNIT} class, extending @{Set#SET_BASE} +-- 3) @{Set#SET_UNIT} class, extends @{Set#SET_BASE} -- =================================================== -- Mission designers can use the @{Set#SET_UNIT} class to build sets of units belonging to certain: -- @@ -62,8 +82,8 @@ -- * Unit types -- * Starting with certain prefix strings. -- --- 3.1) SET_UNIT construction methods: --- ----------------------------------- +-- 3.1) SET_UNIT construction method: +-- ---------------------------------- -- Create a new SET_UNIT object with the @{#SET_UNIT.New} method: -- -- * @{#SET_UNIT.New}: Creates a new SET_UNIT object. @@ -136,30 +156,57 @@ function SET_BASE:New( Database ) local self = BASE:Inherit( self, BASE:New() ) self.Database = Database + + self.YieldInterval = 10 + self.TimeInterval = 0.001 return self end ---- Finds an Object based on the Object Name. +--- Finds an @{Base#BASE} object based on the object Name. -- @param #SET_BASE self -- @param #string ObjectName --- @return #table The Object found. +-- @return Base#BASE The Object found. function SET_BASE:_Find( ObjectName ) local ObjectFound = self.Set[ObjectName] return ObjectFound end ---- Adds a Object based on the Object Name. + +--- Adds a @{Base#BASE} object in the @{Set#SET_BASE}, using the Object Name as the index. -- @param #SET_BASE self -- @param #string ObjectName --- @param #table Object --- @return #table The added Object. -function SET_BASE:_Add( ObjectName, Object ) +-- @param Base#BASE Object +-- @return Base#BASE The added BASE Object. +function SET_BASE:Add( ObjectName, Object ) self.Set[ObjectName] = Object end +--- Removes a @{Base#BASE} object from the @{Set#SET_BASE} and derived classes, based on the Object Name. +-- @param #SET_BASE self +-- @param #string ObjectName +function SET_BASE:Remove( ObjectName ) + + self.Set[ObjectName] = nil +end + +--- Define the SET iterator **"yield interval"** and the **"time interval"**. +-- @param #SET_BASE self +-- @param #number YieldInterval Sets the frequency when the iterator loop will yield after the number of objects processed. The default frequency is 10 objects processed. +-- @param #number TimeInterval Sets the time in seconds when the main logic will resume the iterator loop. The default time is 0.001 seconds. +-- @return #SET_BASE self +function SET_BASE:SetIteratorIntervals( YieldInterval, TimeInterval ) + + self.YieldInterval = YieldInterval + self.TimeInterval = TimeInterval + + return self +end + + + --- Starts the filtering for the defined collection. -- @param #SET_BASE self -- @return #SET_BASE self @@ -169,7 +216,7 @@ function SET_BASE:_FilterStart() if self:IsIncludeObject( Object ) then self:E( { "Adding Object:", ObjectName } ) - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) end end @@ -221,7 +268,7 @@ function SET_BASE:_EventOnBirth( Event ) local ObjectName, Object = self:AddInDatabase( Event ) self:T3( ObjectName, Object ) if self:IsIncludeObject( Object ) then - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) --self:_EventOnPlayerEnterUnit( Event ) end end @@ -236,7 +283,7 @@ function SET_BASE:_EventOnDeadOrCrash( Event ) if Event.IniDCSUnit then local ObjectName, Object = self:FindInDatabase( Event ) if ObjectName and Object then - self:_Delete( ObjectName ) + self:Remove( ObjectName ) end end end @@ -277,9 +324,9 @@ end -- Iterators ---- Interate the SET_BASE and call an interator function for the given set, providing the Object for each element within the set and optional parameters. +--- Iterate the SET_BASE and derived classes and call an iterator function for the given SET_BASE, providing the Object for each element within the set and optional parameters. -- @param #SET_BASE self --- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_BASE. +-- @param #function IteratorFunction The function that will be called. -- @return #SET_BASE self function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArguments ) self:F3( arg ) @@ -296,7 +343,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen IteratorFunction( Object, unpack( arg ) ) end Count = Count + 1 - if Count % 10 == 0 then + if Count % self.YieldInterval == 0 then coroutine.yield( false ) end end @@ -320,7 +367,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen return false end - local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 ) + local Scheduler = SCHEDULER:New( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 ) return self end @@ -433,6 +480,38 @@ function SET_GROUP:New() return self end +--- Add GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param #string AddGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:AddGroupsByName( AddGroupNames ) + + local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames } + + for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do + self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) ) + end + + return self +end + +--- Remove GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param Group#GROUP RemoveGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:RemoveGroupsByName( RemoveGroupNames ) + + local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames } + + for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do + self:Remove( RemoveGroupName.GroupName ) + end + + return self +end + + + --- Finds a Group based on the Group Name. -- @param #SET_GROUP self diff --git a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua index eb9424fc5..0f7292e6f 100644 --- a/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua +++ b/Moose Mission Setup/Moose Mission Update/l10n/DEFAULT/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160607_1320' ) +env.info( 'Moose Generation Timestamp: 20160608_1752' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) @@ -2607,27 +2607,8 @@ Include.File( "Routines" ) local _TraceOn = true local _TraceLevel = 1 -local _TraceClass = { - --DATABASE = true, - --SEAD = true, - --DESTROYBASETASK = true, - --MOVEMENT = true, - --SPAWN = true, - --STAGE = true, - --ZONE = true, - --GROUP = true, - --UNIT = true, - --CLIENT = true, - --CARGO = true, - --CARGO_GROUP = true, - --CARGO_PACKAGE = true, - --CARGO_SLINGLOAD = true, - --CARGO_ZONE = true, - --CLEANUP = true, - --MENU_CLIENT = true, - --MENU_CLIENT_COMMAND = true, - --ESCORT = true, - } +local _TraceAll = false +local _TraceClass = {} local _TraceClassMethod = {} --- The BASE Class @@ -2905,6 +2886,20 @@ function BASE:TraceLevel( Level ) self:E( "Tracing level " .. Level ) end +--- Trace all methods in MOOSE +-- @param #BASE self +-- @param #boolean TraceAll true = trace all methods in MOOSE. +function BASE:TraceAll( TraceAll ) + + _TraceAll = TraceAll + + if _TraceAll then + self:E( "Tracing all methods in MOOSE " ) + else + self:E( "Switched off tracing all methods in MOOSE" ) + end +end + --- Set tracing for a class -- @param #BASE self -- @param #string Class @@ -2932,7 +2927,7 @@ end -- @param Arguments A #table or any field. function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -2942,7 +2937,7 @@ function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then @@ -2986,7 +2981,7 @@ end -- @param Arguments A #table or any field. function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -2996,7 +2991,7 @@ function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then @@ -9342,13 +9337,26 @@ end -- -- === -- --- 1) @{Set#SET_BASE} class, extending @{Base#BASE} +-- 1) @{Set#SET_BASE} class, extends @{Base#BASE} -- ================================================ -- The @{Set#SET_BASE} class defines the core functions that define a collection of objects. +-- A SET provides iterators to iterate the SET, but will **temporarily** yield the ForEach interator loop at defined **"intervals"** to the mail simulator loop. +-- In this way, large loops can be done while not blocking the simulator main processing loop. +-- The default **"yield interval"** is after 10 objects processed. +-- The default **"time interval"** is after 0.001 seconds. +-- +-- 1.1) Add or remove objects from the SET +-- --------------------------------------- +-- Some key core functions are @{Set#SET_BASE.Add} and @{Set#SET_BASE.Remove} to add or remove objects from the SET in your logic. +-- +-- 1.2) Define the SET iterator **"yield interval"** and the **"time interval"**. +-- ------------------------------------------------------------------------------------- +-- Modify the iterator intervals with the @{Set#SET_BASE.SetInteratorIntervals} method. +-- You can set the **"yield interval"**, and the **"time interval"**. (See above). -- -- === -- --- 2) @{Set#SET_GROUP} class, extending @{Set#SET_BASE} +-- 2) @{Set#SET_GROUP} class, extends @{Set#SET_BASE} -- ==================================================== -- Mission designers can use the @{Set#SET_GROUP} class to build sets of groups belonging to certain: -- @@ -9357,13 +9365,18 @@ end -- * Countries -- * Starting with certain prefix strings. -- --- 2.1) SET_GROUP construction methods: --- ------------------------------------ +-- 2.1) SET_GROUP construction method: +-- ----------------------------------- -- Create a new SET_GROUP object with the @{#SET_GROUP.New} method: -- -- * @{#SET_GROUP.New}: Creates a new SET_GROUP object. -- --- 2.2) SET_GROUP filter criteria: +-- 2.2) Add or Remove GROUP(s) from SET_GROUP: +-- ------------------------------------------- +-- GROUPS can be added and removed using the @{Set#SET_GROUP.AddGroupsByName} and @{Set#SET_GROUPS.RemoveGroupsByName} respectively. +-- These methods take a single GROUP name or an array of GROUP names to be added or removed from SET_GROUP. +-- +-- 2.3) SET_GROUP filter criteria: -- ------------------------------- -- You can set filter criteria to define the set of groups within the SET_GROUP. -- Filter criteria are defined by: @@ -9375,24 +9388,26 @@ end -- -- Once the filter criteria have been set for the SET_GROUP, you can start filtering using: -- --- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP. +-- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP and add or remove GROUP objects **dynamically**. -- -- Planned filter criteria within development are (so these are not yet available): -- -- * @{#SET_GROUP.FilterZones}: Builds the SET_GROUP with the groups within a @{Zone#ZONE}. -- --- --- 2.3) SET_GROUP iterators: +-- 2.4) SET_GROUP iterators: -- ------------------------- -- Once the filters have been defined and the SET_GROUP has been built, you can iterate the SET_GROUP with the available iterator methods. -- The iterator methods will walk the SET_GROUP set, and call for each element within the set a function that you provide. -- The following iterator methods are currently available within the SET_GROUP: -- -- * @{#SET_GROUP.ForEachGroup}: Calls a function for each alive group it finds within the SET_GROUP. +-- * @{#SET_GROUP.ForEachGroupCompletelyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupPartlyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence partly in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupNotInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence not in a @{Zone}, providing the GROUP and optional parameters to the called function. -- -- ==== -- --- 3) @{Set#SET_UNIT} class, extending @{Set#SET_BASE} +-- 3) @{Set#SET_UNIT} class, extends @{Set#SET_BASE} -- =================================================== -- Mission designers can use the @{Set#SET_UNIT} class to build sets of units belonging to certain: -- @@ -9402,8 +9417,8 @@ end -- * Unit types -- * Starting with certain prefix strings. -- --- 3.1) SET_UNIT construction methods: --- ----------------------------------- +-- 3.1) SET_UNIT construction method: +-- ---------------------------------- -- Create a new SET_UNIT object with the @{#SET_UNIT.New} method: -- -- * @{#SET_UNIT.New}: Creates a new SET_UNIT object. @@ -9476,30 +9491,57 @@ function SET_BASE:New( Database ) local self = BASE:Inherit( self, BASE:New() ) self.Database = Database + + self.YieldInterval = 10 + self.TimeInterval = 0.001 return self end ---- Finds an Object based on the Object Name. +--- Finds an @{Base#BASE} object based on the object Name. -- @param #SET_BASE self -- @param #string ObjectName --- @return #table The Object found. +-- @return Base#BASE The Object found. function SET_BASE:_Find( ObjectName ) local ObjectFound = self.Set[ObjectName] return ObjectFound end ---- Adds a Object based on the Object Name. + +--- Adds a @{Base#BASE} object in the @{Set#SET_BASE}, using the Object Name as the index. -- @param #SET_BASE self -- @param #string ObjectName --- @param #table Object --- @return #table The added Object. -function SET_BASE:_Add( ObjectName, Object ) +-- @param Base#BASE Object +-- @return Base#BASE The added BASE Object. +function SET_BASE:Add( ObjectName, Object ) self.Set[ObjectName] = Object end +--- Removes a @{Base#BASE} object from the @{Set#SET_BASE} and derived classes, based on the Object Name. +-- @param #SET_BASE self +-- @param #string ObjectName +function SET_BASE:Remove( ObjectName ) + + self.Set[ObjectName] = nil +end + +--- Define the SET iterator **"yield interval"** and the **"time interval"**. +-- @param #SET_BASE self +-- @param #number YieldInterval Sets the frequency when the iterator loop will yield after the number of objects processed. The default frequency is 10 objects processed. +-- @param #number TimeInterval Sets the time in seconds when the main logic will resume the iterator loop. The default time is 0.001 seconds. +-- @return #SET_BASE self +function SET_BASE:SetIteratorIntervals( YieldInterval, TimeInterval ) + + self.YieldInterval = YieldInterval + self.TimeInterval = TimeInterval + + return self +end + + + --- Starts the filtering for the defined collection. -- @param #SET_BASE self -- @return #SET_BASE self @@ -9509,7 +9551,7 @@ function SET_BASE:_FilterStart() if self:IsIncludeObject( Object ) then self:E( { "Adding Object:", ObjectName } ) - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) end end @@ -9561,7 +9603,7 @@ function SET_BASE:_EventOnBirth( Event ) local ObjectName, Object = self:AddInDatabase( Event ) self:T3( ObjectName, Object ) if self:IsIncludeObject( Object ) then - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) --self:_EventOnPlayerEnterUnit( Event ) end end @@ -9576,7 +9618,7 @@ function SET_BASE:_EventOnDeadOrCrash( Event ) if Event.IniDCSUnit then local ObjectName, Object = self:FindInDatabase( Event ) if ObjectName and Object then - self:_Delete( ObjectName ) + self:Remove( ObjectName ) end end end @@ -9617,9 +9659,9 @@ end -- Iterators ---- Interate the SET_BASE and call an interator function for the given set, providing the Object for each element within the set and optional parameters. +--- Iterate the SET_BASE and derived classes and call an iterator function for the given SET_BASE, providing the Object for each element within the set and optional parameters. -- @param #SET_BASE self --- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_BASE. +-- @param #function IteratorFunction The function that will be called. -- @return #SET_BASE self function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArguments ) self:F3( arg ) @@ -9636,7 +9678,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen IteratorFunction( Object, unpack( arg ) ) end Count = Count + 1 - if Count % 10 == 0 then + if Count % self.YieldInterval == 0 then coroutine.yield( false ) end end @@ -9660,7 +9702,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen return false end - local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 ) + local Scheduler = SCHEDULER:New( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 ) return self end @@ -9773,6 +9815,38 @@ function SET_GROUP:New() return self end +--- Add GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param #string AddGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:AddGroupsByName( AddGroupNames ) + + local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames } + + for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do + self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) ) + end + + return self +end + +--- Remove GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param Group#GROUP RemoveGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:RemoveGroupsByName( RemoveGroupNames ) + + local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames } + + for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do + self:Remove( RemoveGroupName.GroupName ) + end + + return self +end + + + --- Finds a Group based on the Group Name. -- @param #SET_GROUP self diff --git a/Moose Mission Setup/Moose.lua b/Moose Mission Setup/Moose.lua index eb9424fc5..0f7292e6f 100644 --- a/Moose Mission Setup/Moose.lua +++ b/Moose Mission Setup/Moose.lua @@ -1,5 +1,5 @@ env.info( '*** MOOSE STATIC INCLUDE START *** ' ) -env.info( 'Moose Generation Timestamp: 20160607_1320' ) +env.info( 'Moose Generation Timestamp: 20160608_1752' ) local base = _G env.info("Loading MOOSE " .. base.timer.getAbsTime() ) @@ -2607,27 +2607,8 @@ Include.File( "Routines" ) local _TraceOn = true local _TraceLevel = 1 -local _TraceClass = { - --DATABASE = true, - --SEAD = true, - --DESTROYBASETASK = true, - --MOVEMENT = true, - --SPAWN = true, - --STAGE = true, - --ZONE = true, - --GROUP = true, - --UNIT = true, - --CLIENT = true, - --CARGO = true, - --CARGO_GROUP = true, - --CARGO_PACKAGE = true, - --CARGO_SLINGLOAD = true, - --CARGO_ZONE = true, - --CLEANUP = true, - --MENU_CLIENT = true, - --MENU_CLIENT_COMMAND = true, - --ESCORT = true, - } +local _TraceAll = false +local _TraceClass = {} local _TraceClassMethod = {} --- The BASE Class @@ -2905,6 +2886,20 @@ function BASE:TraceLevel( Level ) self:E( "Tracing level " .. Level ) end +--- Trace all methods in MOOSE +-- @param #BASE self +-- @param #boolean TraceAll true = trace all methods in MOOSE. +function BASE:TraceAll( TraceAll ) + + _TraceAll = TraceAll + + if _TraceAll then + self:E( "Tracing all methods in MOOSE " ) + else + self:E( "Switched off tracing all methods in MOOSE" ) + end +end + --- Set tracing for a class -- @param #BASE self -- @param #string Class @@ -2932,7 +2927,7 @@ end -- @param Arguments A #table or any field. function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -2942,7 +2937,7 @@ function BASE:F( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then @@ -2986,7 +2981,7 @@ end -- @param Arguments A #table or any field. function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) - if _TraceOn and ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) then + if _TraceOn and ( ( _TraceAll == true ) or ( _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName] ) ) then local DebugInfoCurrent = DebugInfoCurrentParam and DebugInfoCurrentParam or debug.getinfo( 2, "nl" ) local DebugInfoFrom = DebugInfoFromParam and DebugInfoFromParam or debug.getinfo( 3, "l" ) @@ -2996,7 +2991,7 @@ function BASE:T( Arguments, DebugInfoCurrentParam, DebugInfoFromParam ) Function = DebugInfoCurrent.name end - if _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then + if _TraceAll == true or _TraceClass[self.ClassName] or _TraceClassMethod[self.ClassName].Method[Function] then local LineCurrent = DebugInfoCurrent.currentline local LineFrom = 0 if DebugInfoFrom then @@ -9342,13 +9337,26 @@ end -- -- === -- --- 1) @{Set#SET_BASE} class, extending @{Base#BASE} +-- 1) @{Set#SET_BASE} class, extends @{Base#BASE} -- ================================================ -- The @{Set#SET_BASE} class defines the core functions that define a collection of objects. +-- A SET provides iterators to iterate the SET, but will **temporarily** yield the ForEach interator loop at defined **"intervals"** to the mail simulator loop. +-- In this way, large loops can be done while not blocking the simulator main processing loop. +-- The default **"yield interval"** is after 10 objects processed. +-- The default **"time interval"** is after 0.001 seconds. +-- +-- 1.1) Add or remove objects from the SET +-- --------------------------------------- +-- Some key core functions are @{Set#SET_BASE.Add} and @{Set#SET_BASE.Remove} to add or remove objects from the SET in your logic. +-- +-- 1.2) Define the SET iterator **"yield interval"** and the **"time interval"**. +-- ------------------------------------------------------------------------------------- +-- Modify the iterator intervals with the @{Set#SET_BASE.SetInteratorIntervals} method. +-- You can set the **"yield interval"**, and the **"time interval"**. (See above). -- -- === -- --- 2) @{Set#SET_GROUP} class, extending @{Set#SET_BASE} +-- 2) @{Set#SET_GROUP} class, extends @{Set#SET_BASE} -- ==================================================== -- Mission designers can use the @{Set#SET_GROUP} class to build sets of groups belonging to certain: -- @@ -9357,13 +9365,18 @@ end -- * Countries -- * Starting with certain prefix strings. -- --- 2.1) SET_GROUP construction methods: --- ------------------------------------ +-- 2.1) SET_GROUP construction method: +-- ----------------------------------- -- Create a new SET_GROUP object with the @{#SET_GROUP.New} method: -- -- * @{#SET_GROUP.New}: Creates a new SET_GROUP object. -- --- 2.2) SET_GROUP filter criteria: +-- 2.2) Add or Remove GROUP(s) from SET_GROUP: +-- ------------------------------------------- +-- GROUPS can be added and removed using the @{Set#SET_GROUP.AddGroupsByName} and @{Set#SET_GROUPS.RemoveGroupsByName} respectively. +-- These methods take a single GROUP name or an array of GROUP names to be added or removed from SET_GROUP. +-- +-- 2.3) SET_GROUP filter criteria: -- ------------------------------- -- You can set filter criteria to define the set of groups within the SET_GROUP. -- Filter criteria are defined by: @@ -9375,24 +9388,26 @@ end -- -- Once the filter criteria have been set for the SET_GROUP, you can start filtering using: -- --- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP. +-- * @{#SET_GROUP.FilterStart}: Starts the filtering of the groups within the SET_GROUP and add or remove GROUP objects **dynamically**. -- -- Planned filter criteria within development are (so these are not yet available): -- -- * @{#SET_GROUP.FilterZones}: Builds the SET_GROUP with the groups within a @{Zone#ZONE}. -- --- --- 2.3) SET_GROUP iterators: +-- 2.4) SET_GROUP iterators: -- ------------------------- -- Once the filters have been defined and the SET_GROUP has been built, you can iterate the SET_GROUP with the available iterator methods. -- The iterator methods will walk the SET_GROUP set, and call for each element within the set a function that you provide. -- The following iterator methods are currently available within the SET_GROUP: -- -- * @{#SET_GROUP.ForEachGroup}: Calls a function for each alive group it finds within the SET_GROUP. +-- * @{#SET_GROUP.ForEachGroupCompletelyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence completely in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupPartlyInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence partly in a @{Zone}, providing the GROUP and optional parameters to the called function. +-- * @{#SET_GROUP.ForEachGroupNotInZone}: Iterate the SET_GROUP and call an iterator function for each **alive** GROUP presence not in a @{Zone}, providing the GROUP and optional parameters to the called function. -- -- ==== -- --- 3) @{Set#SET_UNIT} class, extending @{Set#SET_BASE} +-- 3) @{Set#SET_UNIT} class, extends @{Set#SET_BASE} -- =================================================== -- Mission designers can use the @{Set#SET_UNIT} class to build sets of units belonging to certain: -- @@ -9402,8 +9417,8 @@ end -- * Unit types -- * Starting with certain prefix strings. -- --- 3.1) SET_UNIT construction methods: --- ----------------------------------- +-- 3.1) SET_UNIT construction method: +-- ---------------------------------- -- Create a new SET_UNIT object with the @{#SET_UNIT.New} method: -- -- * @{#SET_UNIT.New}: Creates a new SET_UNIT object. @@ -9476,30 +9491,57 @@ function SET_BASE:New( Database ) local self = BASE:Inherit( self, BASE:New() ) self.Database = Database + + self.YieldInterval = 10 + self.TimeInterval = 0.001 return self end ---- Finds an Object based on the Object Name. +--- Finds an @{Base#BASE} object based on the object Name. -- @param #SET_BASE self -- @param #string ObjectName --- @return #table The Object found. +-- @return Base#BASE The Object found. function SET_BASE:_Find( ObjectName ) local ObjectFound = self.Set[ObjectName] return ObjectFound end ---- Adds a Object based on the Object Name. + +--- Adds a @{Base#BASE} object in the @{Set#SET_BASE}, using the Object Name as the index. -- @param #SET_BASE self -- @param #string ObjectName --- @param #table Object --- @return #table The added Object. -function SET_BASE:_Add( ObjectName, Object ) +-- @param Base#BASE Object +-- @return Base#BASE The added BASE Object. +function SET_BASE:Add( ObjectName, Object ) self.Set[ObjectName] = Object end +--- Removes a @{Base#BASE} object from the @{Set#SET_BASE} and derived classes, based on the Object Name. +-- @param #SET_BASE self +-- @param #string ObjectName +function SET_BASE:Remove( ObjectName ) + + self.Set[ObjectName] = nil +end + +--- Define the SET iterator **"yield interval"** and the **"time interval"**. +-- @param #SET_BASE self +-- @param #number YieldInterval Sets the frequency when the iterator loop will yield after the number of objects processed. The default frequency is 10 objects processed. +-- @param #number TimeInterval Sets the time in seconds when the main logic will resume the iterator loop. The default time is 0.001 seconds. +-- @return #SET_BASE self +function SET_BASE:SetIteratorIntervals( YieldInterval, TimeInterval ) + + self.YieldInterval = YieldInterval + self.TimeInterval = TimeInterval + + return self +end + + + --- Starts the filtering for the defined collection. -- @param #SET_BASE self -- @return #SET_BASE self @@ -9509,7 +9551,7 @@ function SET_BASE:_FilterStart() if self:IsIncludeObject( Object ) then self:E( { "Adding Object:", ObjectName } ) - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) end end @@ -9561,7 +9603,7 @@ function SET_BASE:_EventOnBirth( Event ) local ObjectName, Object = self:AddInDatabase( Event ) self:T3( ObjectName, Object ) if self:IsIncludeObject( Object ) then - self:_Add( ObjectName, Object ) + self:Add( ObjectName, Object ) --self:_EventOnPlayerEnterUnit( Event ) end end @@ -9576,7 +9618,7 @@ function SET_BASE:_EventOnDeadOrCrash( Event ) if Event.IniDCSUnit then local ObjectName, Object = self:FindInDatabase( Event ) if ObjectName and Object then - self:_Delete( ObjectName ) + self:Remove( ObjectName ) end end end @@ -9617,9 +9659,9 @@ end -- Iterators ---- Interate the SET_BASE and call an interator function for the given set, providing the Object for each element within the set and optional parameters. +--- Iterate the SET_BASE and derived classes and call an iterator function for the given SET_BASE, providing the Object for each element within the set and optional parameters. -- @param #SET_BASE self --- @param #function IteratorFunction The function that will be called when there is an alive player in the SET_BASE. +-- @param #function IteratorFunction The function that will be called. -- @return #SET_BASE self function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArguments ) self:F3( arg ) @@ -9636,7 +9678,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen IteratorFunction( Object, unpack( arg ) ) end Count = Count + 1 - if Count % 10 == 0 then + if Count % self.YieldInterval == 0 then coroutine.yield( false ) end end @@ -9660,7 +9702,7 @@ function SET_BASE:ForEach( IteratorFunction, arg, Set, Function, FunctionArgumen return false end - local Scheduler = SCHEDULER:New( self, Schedule, {}, 0.001, 0.001, 0 ) + local Scheduler = SCHEDULER:New( self, Schedule, {}, self.TimeInterval, self.TimeInterval, 0 ) return self end @@ -9773,6 +9815,38 @@ function SET_GROUP:New() return self end +--- Add GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param #string AddGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:AddGroupsByName( AddGroupNames ) + + local AddGroupNamesArray = ( type( AddGroupNames ) == "table" ) and AddGroupNames or { AddGroupNames } + + for AddGroupID, AddGroupName in pairs( AddGroupNamesArray ) do + self:Add( AddGroupName, GROUP:FindByName( AddGroupName ) ) + end + + return self +end + +--- Remove GROUP(s) to SET_GROUP. +-- @param Set#SET_GROUP self +-- @param Group#GROUP RemoveGroupNames A single name or an array of GROUP names. +-- @return self +function SET_GROUP:RemoveGroupsByName( RemoveGroupNames ) + + local RemoveGroupNamesArray = ( type( RemoveGroupNames ) == "table" ) and RemoveGroupNames or { RemoveGroupNames } + + for RemoveGroupID, RemoveGroupName in pairs( RemoveGroupNamesArray ) do + self:Remove( RemoveGroupName.GroupName ) + end + + return self +end + + + --- Finds a Group based on the Group Name. -- @param #SET_GROUP self diff --git a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz index 83d5b535e..7dbf52cac 100644 Binary files a/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz and b/Moose Test Missions/Moose_Test_CLEANUP/Moose_Test_CLEANUP.miz differ diff --git a/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz b/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz index e331e78a5..0ec5118d7 100644 Binary files a/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz and b/Moose Test Missions/Moose_Test_DATABASE/Moose_Test_DATABASE.miz differ diff --git a/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz b/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz index c04779b86..adef34e4c 100644 Binary files a/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz and b/Moose Test Missions/Moose_Test_DESTROY/MOOSE_Test_DESTROY.miz differ diff --git a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz index 02a654199..17306c194 100644 Binary files a/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz and b/Moose Test Missions/Moose_Test_ESCORT/MOOSE_Test_ESCORT.miz differ diff --git a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz index 6ec1ffb61..018d968c3 100644 Binary files a/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz and b/Moose Test Missions/Moose_Test_MISSILETRAINER/Moose_Test_MISSILETRAINER.miz differ diff --git a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz index f7b87cb5e..b154eabb3 100644 Binary files a/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz and b/Moose Test Missions/Moose_Test_SEAD/MOOSE_Test_SEAD.miz differ diff --git a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua index 46f65e112..d5ed824df 100644 --- a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua +++ b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.lua @@ -2,6 +2,22 @@ Include.File( 'Set' ) Include.File( 'Spawn' ) +SetVehicles = SET_GROUP:New() + +SetVehicles:AddGroupsByName( { "Vehicle A", "Vehicle B", "Vehicle C" } ) + +SetVehicles:ForEachGroup( + --- @param Group#GROUP MooseGroup + function( MooseGroup ) + for UnitId, UnitData in pairs( MooseGroup:GetUnits() ) do + local UnitAction = UnitData -- Unit#UNIT + UnitAction:SmokeGreen() + end + end +) + + + SetBluePlanesGroup = SET_GROUP:New() :FilterCoalitions( "blue" ) :FilterCategories( "plane" ) @@ -14,6 +30,7 @@ SetNorthKoreaGroup = SET_GROUP:New() SetSAMGroup = SET_GROUP:New() :FilterPrefixes( "SAM" ) :FilterStart() + :SetIteratorIntervals( 5, 10 ) SpawnUS_Plane = SPAWN:New( 'Spawn Test USA Plane') GroupUS_Plane = SpawnUS_Plane:Spawn() diff --git a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz index 200630171..d479a16e0 100644 Binary files a/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz and b/Moose Test Missions/Moose_Test_SET_GROUP/Moose_Test_SET_GROUP.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz index 3f470750f..f29ec7778 100644 Binary files a/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz and b/Moose Test Missions/Moose_Test_SPAWN/MOOSE_Test_SPAWN.miz differ diff --git a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz b/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz index 8b3a56f05..42de42467 100644 Binary files a/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz and b/Moose Test Missions/Moose_Test_SPAWN_Repeat/MOOSE_Test_SPAWN_Repeat.miz differ diff --git a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz index eb8945702..0ac932082 100644 Binary files a/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz and b/Moose Test Missions/Moose_Test_TASK_Pickup_and_Deploy/MOOSE_Test_TASK_Pickup_and_Deploy.miz differ diff --git a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz index 01bb09502..8957c9541 100644 Binary files a/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz and b/Moose Test Missions/Moose_Test_WRAPPER/Moose_Test_WRAPPER.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz index f1101328e..b080d8a4c 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz and b/Moose Test Missions/Moose_Test_ZONE/Moose_Test_ZONE.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz index 697855fed..3d83bba99 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz and b/Moose Test Missions/Moose_Test_ZONE_POLYGON/Moose_Test_ZONE_POLYGON.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz index fc5159108..0ebf5cfa9 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz and b/Moose Test Missions/Moose_Test_ZONE_RADIUS/Moose_Test_ZONE_RADIUS.miz differ diff --git a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz index 1b2b09119..ec99c5cac 100644 Binary files a/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz and b/Moose Test Missions/Moose_Test_ZONE_UNIT/Moose_Test_ZONE_UNIT.miz differ diff --git a/Moose Training/Documentation/Base.html b/Moose Training/Documentation/Base.html index fb63c1547..5ba88ac2a 100644 --- a/Moose Training/Documentation/Base.html +++ b/Moose Training/Documentation/Base.html @@ -275,6 +275,12 @@ These tracing levels were defined to avoid bulks of tracing to be generated by l BASE:T3(Arguments)

Trace a function logic level 3.

+ + + + BASE:TraceAll(TraceAll) + +

Trace all methods in MOOSE

@@ -896,6 +902,28 @@ A #table or any field.

+ +BASE:TraceAll(TraceAll) + +
+
+ +

Trace all methods in MOOSE

+ +

Parameter

+ +
+
+
+
+ BASE:TraceClass(Class) diff --git a/Moose Training/Documentation/Set.html b/Moose Training/Documentation/Set.html index 5fb1409fc..684113b13 100644 --- a/Moose Training/Documentation/Set.html +++ b/Moose Training/Documentation/Set.html @@ -77,12 +77,23 @@
-

1) Set#SET_BASE class, extending Base#BASE

-

The Set#SET_BASE class defines the core functions that define a collection of objects.

+

1) Set#SET_BASE class, extends Base#BASE

+

The Set#SET_BASE class defines the core functions that define a collection of objects. +A SET provides iterators to iterate the SET, but will temporarily yield the ForEach interator loop at defined "intervals" to the mail simulator loop. +In this way, large loops can be done while not blocking the simulator main processing loop. +The default "yield interval" is after 10 objects processed. +The default "time interval" is after 0.001 seconds.

+ +

1.1) Add or remove objects from the SET

+

Some key core functions are Set#SET_BASE.Add and Set#SET_BASE.Remove to add or remove objects from the SET in your logic.

+ +

1.2) Define the SET iterator "yield interval" and the "time interval".

+

Modify the iterator intervals with the Set#SET_BASE.SetInteratorIntervals method. +You can set the "yield interval", and the "time interval". (See above).


-

2) Set#SET_GROUP class, extending Set#SET_BASE

+

2) Set#SET_GROUP class, extends Set#SET_BASE

Mission designers can use the Set#SET_GROUP class to build sets of groups belonging to certain:

-

2.1) SET_GROUP construction methods:

+

2.1) SET_GROUP construction method:

Create a new SET_GROUP object with the SET_GROUP.New method:

-

2.2) SET_GROUP filter criteria:

+

2.2) Add or Remove GROUP(s) from SET_GROUP:

+

GROUPS can be added and removed using the Set#SET_GROUP.AddGroupsByName and Set#SET_GROUPS.RemoveGroupsByName respectively. +These methods take a single GROUP name or an array of GROUP names to be added or removed from SET_GROUP.

+ +

2.3) SET_GROUP filter criteria:

You can set filter criteria to define the set of groups within the SET_GROUP. Filter criteria are defined by:

@@ -113,7 +128,7 @@ Filter criteria are defined by:

Once the filter criteria have been set for the SET_GROUP, you can start filtering using:

Planned filter criteria within development are (so these are not yet available):

@@ -122,19 +137,21 @@ Filter criteria are defined by:

  • SET_GROUP.FilterZones: Builds the SET_GROUP with the groups within a Zone#ZONE.
  • - -

    2.3) SET_GROUP iterators:

    +

    2.4) SET_GROUP iterators:

    Once the filters have been defined and the SETGROUP has been built, you can iterate the SETGROUP with the available iterator methods. The iterator methods will walk the SETGROUP set, and call for each element within the set a function that you provide. The following iterator methods are currently available within the SETGROUP:


    -

    3) Set#SET_UNIT class, extending Set#SET_BASE

    +

    3) Set#SET_UNIT class, extends Set#SET_BASE

    Mission designers can use the Set#SET_UNIT class to build sets of units belonging to certain:

    -

    3.1) SET_UNIT construction methods:

    +

    3.1) SET_UNIT construction method:

    Create a new SET_UNIT object with the SET_UNIT.New method:

    -

    Finds an Object based on the Object Name.

    +

    Finds an Base#BASE object based on the object Name.

    Parameter

    Return value

    -

    #table: +

    Base#BASE: The Object found.

    @@ -842,6 +977,33 @@ The Object found.

    + +SET_GROUP:AddGroupsByName(AddGroupNames) + +
    +
    + +

    Add GROUP(s) to SET_GROUP.

    + +

    Parameter

    +
      +
    • + +

      #string AddGroupNames : +A single name or an array of GROUP names.

      + +
    • +
    +

    Return value

    + + +

    self

    + +
    +
    +
    +
    + SET_GROUP:AddInDatabase(Event) @@ -1315,6 +1477,33 @@ self

    -- Define a new SET_GROUP Object. This DBObject will contain a reference to all alive GROUPS.
     DBObject = SET_GROUP:New()
    + +
    +
    +
    + + +SET_GROUP:RemoveGroupsByName(RemoveGroupNames) + +
    +
    + +

    Remove GROUP(s) to SET_GROUP.

    + +

    Parameter

    +
      +
    • + +

      Group#GROUP RemoveGroupNames : +A single name or an array of GROUP names.

      + +
    • +
    +

    Return value

    + + +

    self

    +