Updated SET_GROUP and SET

This commit is contained in:
FlightControl 2016-06-08 17:53:06 +02:00
parent b925339f24
commit f7eef96c94
22 changed files with 630 additions and 174 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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()

View File

@ -275,6 +275,12 @@ These tracing levels were defined to avoid bulks of tracing to be generated by l
<td class="name" nowrap="nowrap"><a href="##(BASE).T3">BASE:T3(Arguments)</a></td>
<td class="summary">
<p>Trace a function logic level 3.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(BASE).TraceAll">BASE:TraceAll(TraceAll)</a></td>
<td class="summary">
<p>Trace all methods in MOOSE</p>
</td>
</tr>
<tr>
@ -896,6 +902,28 @@ A #table or any field.</p>
<dl class="function">
<dt>
<a id="#(BASE).TraceAll" >
<strong>BASE:TraceAll(TraceAll)</strong>
</a>
</dt>
<dd>
<p>Trace all methods in MOOSE</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#boolean TraceAll </em></code>:
true = trace all methods in MOOSE.</p>
</li>
</ul>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(BASE).TraceClass" >
<strong>BASE:TraceClass(Class)</strong>
</a>

View File

@ -77,12 +77,23 @@
<hr/>
<h1>1) <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> class, extending <a href="Base.html##(BASE)">Base#BASE</a></h1>
<p>The <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> class defines the core functions that define a collection of objects.</p>
<h1>1) <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> class, extends <a href="Base.html##(BASE)">Base#BASE</a></h1>
<p>The <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> class defines the core functions that define a collection of objects.
A SET provides iterators to iterate the SET, but will <strong>temporarily</strong> yield the ForEach interator loop at defined <strong>"intervals"</strong> to the mail simulator loop.
In this way, large loops can be done while not blocking the simulator main processing loop.
The default <strong>"yield interval"</strong> is after 10 objects processed.
The default <strong>"time interval"</strong> is after 0.001 seconds.</p>
<h2>1.1) Add or remove objects from the SET</h2>
<p>Some key core functions are <a href="Set.html##(SET_BASE).Add">Set#SET_BASE.Add</a> and <a href="Set.html##(SET_BASE).Remove">Set#SET_BASE.Remove</a> to add or remove objects from the SET in your logic.</p>
<h2>1.2) Define the SET iterator <strong>"yield interval"</strong> and the <strong>"time interval"</strong>.</h2>
<p>Modify the iterator intervals with the <a href="Set.html##(SET_BASE).SetInteratorIntervals">Set#SET_BASE.SetInteratorIntervals</a> method.
You can set the <strong>"yield interval"</strong>, and the <strong>"time interval"</strong>. (See above).</p>
<hr/>
<h1>2) <a href="Set.html##(SET_GROUP)">Set#SET_GROUP</a> class, extending <a href="Set.html##(SET_BASE)">Set#SET_BASE</a></h1>
<h1>2) <a href="Set.html##(SET_GROUP)">Set#SET_GROUP</a> class, extends <a href="Set.html##(SET_BASE)">Set#SET_BASE</a></h1>
<p>Mission designers can use the <a href="Set.html##(SET_GROUP)">Set#SET_GROUP</a> class to build sets of groups belonging to certain:</p>
<ul>
@ -92,14 +103,18 @@
<li>Starting with certain prefix strings.</li>
</ul>
<h2>2.1) SET_GROUP construction methods:</h2>
<h2>2.1) SET_GROUP construction method:</h2>
<p>Create a new SET_GROUP object with the <a href="##(SET_GROUP).New">SET_GROUP.New</a> method:</p>
<ul>
<li><a href="##(SET_GROUP).New">SET_GROUP.New</a>: Creates a new SET_GROUP object.</li>
</ul>
<h2>2.2) SET_GROUP filter criteria: </h2>
<h2>2.2) Add or Remove GROUP(s) from SET_GROUP: </h2>
<p>GROUPS can be added and removed using the <a href="Set.html##(SET_GROUP).AddGroupsByName">Set#SET_GROUP.AddGroupsByName</a> and <a href="Set.html##(SET_GROUPS).RemoveGroupsByName">Set#SET_GROUPS.RemoveGroupsByName</a> respectively.
These methods take a single GROUP name or an array of GROUP names to be added or removed from SET_GROUP.</p>
<h2>2.3) SET_GROUP filter criteria: </h2>
<p>You can set filter criteria to define the set of groups within the SET_GROUP.
Filter criteria are defined by:</p>
@ -113,7 +128,7 @@ Filter criteria are defined by:</p>
<p>Once the filter criteria have been set for the SET_GROUP, you can start filtering using:</p>
<ul>
<li><a href="##(SET_GROUP).FilterStart">SET_GROUP.FilterStart</a>: Starts the filtering of the groups within the SET_GROUP.</li>
<li><a href="##(SET_GROUP).FilterStart">SET_GROUP.FilterStart</a>: Starts the filtering of the groups within the SET_GROUP and add or remove GROUP objects <strong>dynamically</strong>.</li>
</ul>
<p>Planned filter criteria within development are (so these are not yet available):</p>
@ -122,19 +137,21 @@ Filter criteria are defined by:</p>
<li><a href="##(SET_GROUP).FilterZones">SET_GROUP.FilterZones</a>: Builds the SET_GROUP with the groups within a <a href="Zone.html##(ZONE)">Zone#ZONE</a>.</li>
</ul>
<h2>2.3) SET_GROUP iterators:</h2>
<h2>2.4) SET_GROUP iterators:</h2>
<p>Once the filters have been defined and the SET<em>GROUP has been built, you can iterate the SET</em>GROUP with the available iterator methods.
The iterator methods will walk the SET<em>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</em>GROUP:</p>
<ul>
<li><a href="##(SET_GROUP).ForEachGroup">SET_GROUP.ForEachGroup</a>: Calls a function for each alive group it finds within the SET_GROUP.</li>
<li><a href="##(SET_GROUP).ForEachGroupCompletelyInZone">SET_GROUP.ForEachGroupCompletelyInZone</a>: Iterate the SET_GROUP and call an iterator function for each <strong>alive</strong> GROUP presence completely in a <a href="Zone.html">Zone</a>, providing the GROUP and optional parameters to the called function.</li>
<li><a href="##(SET_GROUP).ForEachGroupPartlyInZone">SET_GROUP.ForEachGroupPartlyInZone</a>: Iterate the SET_GROUP and call an iterator function for each <strong>alive</strong> GROUP presence partly in a <a href="Zone.html">Zone</a>, providing the GROUP and optional parameters to the called function.</li>
<li><a href="##(SET_GROUP).ForEachGroupNotInZone">SET_GROUP.ForEachGroupNotInZone</a>: Iterate the SET_GROUP and call an iterator function for each <strong>alive</strong> GROUP presence not in a <a href="Zone.html">Zone</a>, providing the GROUP and optional parameters to the called function.</li>
</ul>
<hr/>
<h1>3) <a href="Set.html##(SET_UNIT)">Set#SET_UNIT</a> class, extending <a href="Set.html##(SET_BASE)">Set#SET_BASE</a></h1>
<h1>3) <a href="Set.html##(SET_UNIT)">Set#SET_UNIT</a> class, extends <a href="Set.html##(SET_BASE)">Set#SET_BASE</a></h1>
<p>Mission designers can use the <a href="Set.html##(SET_UNIT)">Set#SET_UNIT</a> class to build sets of units belonging to certain:</p>
<ul>
@ -145,7 +162,7 @@ The following iterator methods are currently available within the SET</em>GROUP:
<li>Starting with certain prefix strings.</li>
</ul>
<h2>3.1) SET_UNIT construction methods:</h2>
<h2>3.1) SET_UNIT construction method:</h2>
<p>Create a new SET_UNIT object with the <a href="##(SET_UNIT).New">SET_UNIT.New</a> method:</p>
<ul>
@ -221,6 +238,12 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<h2><a id="#(SET_BASE)">Type <code>SET_BASE</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).Add">SET_BASE:Add(ObjectName, Object)</a></td>
<td class="summary">
<p>Adds a <a href="Base.html##(BASE)">Base#BASE</a> object in the <a href="Set.html##(SET_BASE)">Set#SET_BASE</a>, using the Object Name as the index.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).ClassName">SET_BASE.ClassName</a></td>
<td class="summary">
@ -241,7 +264,7 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).ForEach">SET_BASE:ForEach(IteratorFunction, arg, Set, Function, FunctionArguments)</a></td>
<td class="summary">
<p>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.</p>
<p>Iterate the SET<em>BASE and derived classes and call an iterator function for the given SET</em>BASE, providing the Object for each element within the set and optional parameters.</p>
</td>
</tr>
<tr>
@ -254,6 +277,12 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).New">SET_BASE:New(Database)</a></td>
<td class="summary">
<p>Creates a new SET_BASE object, building a set of units belonging to a coalitions, categories, countries, types or with defined prefix names.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).Remove">SET_BASE:Remove(ObjectName)</a></td>
<td class="summary">
<p>Removes a <a href="Base.html##(BASE)">Base#BASE</a> object from the <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> and derived classes, based on the Object Name.</p>
</td>
</tr>
<tr>
@ -263,9 +292,21 @@ The following iterator methods are currently available within the SET</em>UNIT:<
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE)._Add">SET_BASE:_Add(ObjectName, Object)</a></td>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).SetIteratorIntervals">SET_BASE:SetIteratorIntervals(YieldInterval, TimeInterval)</a></td>
<td class="summary">
<p>Adds a Object based on the Object Name.</p>
<p>Define the SET iterator <strong>"yield interval"</strong> and the <strong>"time interval"</strong>.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).TimeInterval">SET_BASE.TimeInterval</a></td>
<td class="summary">
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE).YieldInterval">SET_BASE.YieldInterval</a></td>
<td class="summary">
</td>
</tr>
<tr>
@ -289,7 +330,7 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_BASE)._Find">SET_BASE:_Find(ObjectName)</a></td>
<td class="summary">
<p>Finds an Object based on the Object Name.</p>
<p>Finds an <a href="Base.html##(BASE)">Base#BASE</a> object based on the object Name.</p>
</td>
</tr>
</table>
@ -297,6 +338,12 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<h2><a id="#(SET_GROUP)">Type <code>SET_GROUP</code></a></h2>
<table class="function_list">
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_GROUP).AddGroupsByName">SET_GROUP:AddGroupsByName(AddGroupNames)</a></td>
<td class="summary">
<p>Add GROUP(s) to SET_GROUP.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_GROUP).AddInDatabase">SET_GROUP:AddInDatabase(Event)</a></td>
<td class="summary">
<p>Handles the Database to check on an event (birth) that the Object was added in the Database.</p>
@ -396,6 +443,12 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<td class="name" nowrap="nowrap"><a href="##(SET_GROUP).New">SET_GROUP:New()</a></td>
<td class="summary">
<p>Creates a new SET_GROUP object, building a set of groups belonging to a coalitions, categories, countries, types or with defined prefix names.</p>
</td>
</tr>
<tr>
<td class="name" nowrap="nowrap"><a href="##(SET_GROUP).RemoveGroupsByName">SET_GROUP:RemoveGroupsByName(RemoveGroupNames)</a></td>
<td class="summary">
<p>Remove GROUP(s) to SET_GROUP.</p>
</td>
</tr>
</table>
@ -553,6 +606,37 @@ The following iterator methods are currently available within the SET</em>UNIT:<
<dl class="function">
<dt>
<a id="#(SET_BASE).Add" >
<strong>SET_BASE:Add(ObjectName, Object)</strong>
</a>
</dt>
<dd>
<p>Adds a <a href="Base.html##(BASE)">Base#BASE</a> object in the <a href="Set.html##(SET_BASE)">Set#SET_BASE</a>, using the Object Name as the index.</p>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em>#string ObjectName </em></code>: </p>
</li>
<li>
<p><code><em><a href="Base.html##(BASE)">Base#BASE</a> Object </em></code>: </p>
</li>
</ul>
<h3>Return value</h3>
<p><em><a href="Base.html##(BASE)">Base#BASE</a>:</em>
The added BASE Object.</p>
</dd>
</dl>
<dl class="function">
<dt>
<em>#string</em>
<a id="#(SET_BASE).ClassName" >
<strong>SET_BASE.ClassName</strong>
@ -608,14 +692,14 @@ A string with the names of the objects.</p>
</dt>
<dd>
<p>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.</p>
<p>Iterate the SET<em>BASE and derived classes and call an iterator function for the given SET</em>BASE, providing the Object for each element within the set and optional parameters.</p>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em>#function IteratorFunction </em></code>:
The function that will be called when there is an alive player in the SET_BASE.</p>
The function that will be called.</p>
</li>
<li>
@ -700,6 +784,27 @@ self</p>
<pre class="example"><code>-- Define a new SET_BASE Object. This DBObject will contain a reference to all Group and Unit Templates defined within the ME and the DCSRTE.
DBObject = SET_BASE:New()</code></pre>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(SET_BASE).Remove" >
<strong>SET_BASE:Remove(ObjectName)</strong>
</a>
</dt>
<dd>
<p>Removes a <a href="Base.html##(BASE)">Base#BASE</a> object from the <a href="Set.html##(SET_BASE)">Set#SET_BASE</a> and derived classes, based on the Object Name.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string ObjectName </em></code>: </p>
</li>
</ul>
</dd>
</dl>
<dl class="function">
@ -719,31 +824,61 @@ DBObject = SET_BASE:New()</code></pre>
<dl class="function">
<dt>
<a id="#(SET_BASE)._Add" >
<strong>SET_BASE:_Add(ObjectName, Object)</strong>
<a id="#(SET_BASE).SetIteratorIntervals" >
<strong>SET_BASE:SetIteratorIntervals(YieldInterval, TimeInterval)</strong>
</a>
</dt>
<dd>
<p>Adds a Object based on the Object Name.</p>
<p>Define the SET iterator <strong>"yield interval"</strong> and the <strong>"time interval"</strong>.</p>
<h3>Parameters</h3>
<ul>
<li>
<p><code><em>#string ObjectName </em></code>: </p>
<p><code><em>#number YieldInterval </em></code>:
Sets the frequency when the iterator loop will yield after the number of objects processed. The default frequency is 10 objects processed.</p>
</li>
<li>
<p><code><em>#table Object </em></code>: </p>
<p><code><em>#number TimeInterval </em></code>:
Sets the time in seconds when the main logic will resume the iterator loop. The default time is 0.001 seconds.</p>
</li>
</ul>
<h3>Return value</h3>
<p><em>#table:</em>
The added Object.</p>
<p><em><a href="##(SET_BASE)">#SET_BASE</a>:</em>
self</p>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(SET_BASE).TimeInterval" >
<strong>SET_BASE.TimeInterval</strong>
</a>
</dt>
<dd>
</dd>
</dl>
<dl class="function">
<dt>
<em></em>
<a id="#(SET_BASE).YieldInterval" >
<strong>SET_BASE.YieldInterval</strong>
</a>
</dt>
<dd>
</dd>
</dl>
@ -816,7 +951,7 @@ self</p>
</dt>
<dd>
<p>Finds an Object based on the Object Name.</p>
<p>Finds an <a href="Base.html##(BASE)">Base#BASE</a> object based on the object Name.</p>
<h3>Parameter</h3>
<ul>
@ -828,7 +963,7 @@ self</p>
</ul>
<h3>Return value</h3>
<p><em>#table:</em>
<p><em><a href="Base.html##(BASE)">Base#BASE</a>:</em>
The Object found.</p>
</dd>
@ -842,6 +977,33 @@ The Object found.</p>
<dl class="function">
<dt>
<a id="#(SET_GROUP).AddGroupsByName" >
<strong>SET_GROUP:AddGroupsByName(AddGroupNames)</strong>
</a>
</dt>
<dd>
<p>Add GROUP(s) to SET_GROUP.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em>#string AddGroupNames </em></code>:
A single name or an array of GROUP names.</p>
</li>
</ul>
<h3>Return value</h3>
<p>self</p>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(SET_GROUP).AddInDatabase" >
<strong>SET_GROUP:AddInDatabase(Event)</strong>
</a>
@ -1315,6 +1477,33 @@ self</p>
<pre class="example"><code>-- Define a new SET_GROUP Object. This DBObject will contain a reference to all alive GROUPS.
DBObject = SET_GROUP:New()</code></pre>
</dd>
</dl>
<dl class="function">
<dt>
<a id="#(SET_GROUP).RemoveGroupsByName" >
<strong>SET_GROUP:RemoveGroupsByName(RemoveGroupNames)</strong>
</a>
</dt>
<dd>
<p>Remove GROUP(s) to SET_GROUP.</p>
<h3>Parameter</h3>
<ul>
<li>
<p><code><em><a href="Group.html##(GROUP)">Group#GROUP</a> RemoveGroupNames </em></code>:
A single name or an array of GROUP names.</p>
</li>
</ul>
<h3>Return value</h3>
<p>self</p>
</dd>
</dl>