ARMYGROUP

Added parameter to delay init group
This commit is contained in:
Frank 2023-10-31 10:45:56 +01:00
parent 375a564446
commit bd9022c010
3 changed files with 83 additions and 69 deletions

View File

@ -2043,7 +2043,11 @@ end
-- @param #ARMYGROUP self
-- @param #table Template Template used to init the group. Default is `self.template`.
-- @return #ARMYGROUP self
function ARMYGROUP:_InitGroup(Template)
function ARMYGROUP:_InitGroup(Template, Delay)
if Delay and Delay>0 then
self:ScheduleOnce(Delay, ARMYGROUP._InitGroup, self, Template, 0)
else
-- First check if group was already initialized.
if self.groupinitialized then
@ -2051,6 +2055,8 @@ function ARMYGROUP:_InitGroup(Template)
return
end
self:I(self.lid.."FF Initializing Group")
-- Get template of group.
local template=Template or self:_GetTemplate()
@ -2103,10 +2109,11 @@ function ARMYGROUP:_InitGroup(Template)
-- DCS group.
local dcsgroup=Group.getByName(self.groupname)
local size0=dcsgroup:getInitialSize()
local u=dcsgroup:getUnits()
-- Quick check.
if #units~=size0 then
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units!", #units, size0))
self:T(self.lid..string.format("ERROR: Got #units=%d but group consists of %d units! u=%d", #units, size0, #u))
end
-- Add elemets.
@ -2118,6 +2125,7 @@ function ARMYGROUP:_InitGroup(Template)
-- Init done.
self.groupinitialized=true
end
return self
end

View File

@ -1768,6 +1768,8 @@ function OPSGROUP:GetDCSUnit(UnitNumber)
if DCSGroup then
local unit=DCSGroup:getUnit(UnitNumber or 1)
return unit
else
self:E(self.lid..string.format("ERROR: DCS group does not exist! Cannot get unit"))
end
return nil
@ -3521,6 +3523,8 @@ function OPSGROUP:OnEventBirth(EventData)
-- Debug info.
self:T(self.lid..string.format("EVENT: Element %s born ==> spawned", unitname))
self:T2(self.lid..string.format("DCS unit=%s isExist=%s", tostring(EventData.IniDCSUnit:getName()), tostring(EventData.IniDCSUnit:isExist()) ))
-- Set element to spawned state.
self:ElementSpawned(element)

View File

@ -305,6 +305,8 @@ function GROUP:GetDCSObject()
if DCSGroup then
return DCSGroup
else
env.error("ERROR: Could not get DCS group object!")
end
return nil