mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-28 09:35:30 +00:00
Merge pull request #2630 from shaji-Dev/master-ng
[ADDED] OnBeforeSpawnGroup hook function option to be called before spawning a group for extra template tweaks.
This commit is contained in:
@@ -1880,6 +1880,11 @@ function SPAWN:SpawnWithIndex( SpawnIndex, NoBirth )
|
|||||||
-- SpawnTemplate.uncontrolled = self.SpawnUnControlled
|
-- SpawnTemplate.uncontrolled = self.SpawnUnControlled
|
||||||
-- end
|
-- end
|
||||||
-- end
|
-- end
|
||||||
|
|
||||||
|
|
||||||
|
if self.BeforeTemplateSpawnFunc then
|
||||||
|
self:BeforeTemplateSpawnFunc(SpawnTemplate, SpawnIndex)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if not NoBirth then
|
if not NoBirth then
|
||||||
@@ -1995,6 +2000,31 @@ function SPAWN:SpawnScheduleStop()
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Allows to place a CallFunction hook just before spawning the group to tweak the template.
|
||||||
|
-- The provided method will be called just before a new group is spawned, including its given parameters.
|
||||||
|
-- The first parameter of the BeforeTemplateSpawnFunc is the raw Template used to spawn the group, the second is the SpawnIndex.
|
||||||
|
-- @param #SPAWN self
|
||||||
|
-- @param #function BeforeTemplateSpawnFunc The function to be called before the group spawns.
|
||||||
|
-- @return #SPAWN
|
||||||
|
-- @usage
|
||||||
|
--
|
||||||
|
-- -- Declare SpawnObject and call a function when a new Group is spawned.
|
||||||
|
-- local SpawnObject = SPAWN:New( "SpawnObject" )
|
||||||
|
-- :InitLimit( 2, 10 )
|
||||||
|
-- :OnBeforeSpawnGroup( function( SpawnTemplate )
|
||||||
|
-- Tweaking the template units
|
||||||
|
-- end
|
||||||
|
-- )
|
||||||
|
-- :SpawnScheduled( 300, 0.3 )
|
||||||
|
--
|
||||||
|
function SPAWN:OnBeforeTemplateSpawnGroup( BeforeTemplateSpawnFunc )
|
||||||
|
--self:F( "OnBeforeSpawnGroup" )
|
||||||
|
|
||||||
|
self.BeforeTemplateSpawnFunc = BeforeTemplateSpawnFunc
|
||||||
|
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
--- Allows to place a CallFunction hook when a new group spawns.
|
--- Allows to place a CallFunction hook when a new group spawns.
|
||||||
-- The provided method will be called when a new group is spawned, including its given parameters.
|
-- The provided method will be called when a new group is spawned, including its given parameters.
|
||||||
-- The first parameter of the SpawnFunction is the @{Wrapper.Group#GROUP} that was spawned.
|
-- The first parameter of the SpawnFunction is the @{Wrapper.Group#GROUP} that was spawned.
|
||||||
|
|||||||
Reference in New Issue
Block a user