mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
ARMYGROUP
Added parameter to delay init group
This commit is contained in:
parent
375a564446
commit
bd9022c010
@ -2043,7 +2043,11 @@ end
|
|||||||
-- @param #ARMYGROUP self
|
-- @param #ARMYGROUP self
|
||||||
-- @param #table Template Template used to init the group. Default is `self.template`.
|
-- @param #table Template Template used to init the group. Default is `self.template`.
|
||||||
-- @return #ARMYGROUP self
|
-- @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.
|
-- First check if group was already initialized.
|
||||||
if self.groupinitialized then
|
if self.groupinitialized then
|
||||||
@ -2051,6 +2055,8 @@ function ARMYGROUP:_InitGroup(Template)
|
|||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
self:I(self.lid.."FF Initializing Group")
|
||||||
|
|
||||||
-- Get template of group.
|
-- Get template of group.
|
||||||
local template=Template or self:_GetTemplate()
|
local template=Template or self:_GetTemplate()
|
||||||
|
|
||||||
@ -2103,10 +2109,11 @@ function ARMYGROUP:_InitGroup(Template)
|
|||||||
-- DCS group.
|
-- DCS group.
|
||||||
local dcsgroup=Group.getByName(self.groupname)
|
local dcsgroup=Group.getByName(self.groupname)
|
||||||
local size0=dcsgroup:getInitialSize()
|
local size0=dcsgroup:getInitialSize()
|
||||||
|
local u=dcsgroup:getUnits()
|
||||||
|
|
||||||
-- Quick check.
|
-- Quick check.
|
||||||
if #units~=size0 then
|
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
|
end
|
||||||
|
|
||||||
-- Add elemets.
|
-- Add elemets.
|
||||||
@ -2118,6 +2125,7 @@ function ARMYGROUP:_InitGroup(Template)
|
|||||||
|
|
||||||
-- Init done.
|
-- Init done.
|
||||||
self.groupinitialized=true
|
self.groupinitialized=true
|
||||||
|
end
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@ -1768,6 +1768,8 @@ function OPSGROUP:GetDCSUnit(UnitNumber)
|
|||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
local unit=DCSGroup:getUnit(UnitNumber or 1)
|
local unit=DCSGroup:getUnit(UnitNumber or 1)
|
||||||
return unit
|
return unit
|
||||||
|
else
|
||||||
|
self:E(self.lid..string.format("ERROR: DCS group does not exist! Cannot get unit"))
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
@ -3521,6 +3523,8 @@ function OPSGROUP:OnEventBirth(EventData)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T(self.lid..string.format("EVENT: Element %s born ==> spawned", unitname))
|
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.
|
-- Set element to spawned state.
|
||||||
self:ElementSpawned(element)
|
self:ElementSpawned(element)
|
||||||
|
|
||||||
|
|||||||
@ -305,6 +305,8 @@ function GROUP:GetDCSObject()
|
|||||||
|
|
||||||
if DCSGroup then
|
if DCSGroup then
|
||||||
return DCSGroup
|
return DCSGroup
|
||||||
|
else
|
||||||
|
env.error("ERROR: Could not get DCS group object!")
|
||||||
end
|
end
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user