mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Squadron Grouping
This commit is contained in:
parent
56fad29df9
commit
b6bc22f991
@ -5799,19 +5799,12 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
|
||||
template.route.routeRelativeTOT=true
|
||||
template.route.points = {}
|
||||
|
||||
local N=asset.grouping or #template.units
|
||||
|
||||
-- Handle units.
|
||||
for i=1,N do
|
||||
for i=1,#template.units do
|
||||
|
||||
-- Unit template.
|
||||
local unit = template.units[i]
|
||||
|
||||
-- If more units are in the
|
||||
if i>#template.units then
|
||||
unit=UTILS.DeepCopy(template.units[1])
|
||||
end
|
||||
|
||||
-- Nillify the unit ID.
|
||||
unit.unitId=nil
|
||||
|
||||
|
||||
@ -1456,8 +1456,10 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
|
||||
if asset.assignment==assignment then
|
||||
|
||||
local nunits=#asset.template.units
|
||||
|
||||
-- Debug text.
|
||||
local text=string.format("Adding asset to squadron %s: assignment=%s, type=%s, attribute=%s", squad.name, assignment, asset.unittype, asset.attribute)
|
||||
local text=string.format("Adding asset to squadron %s: assignment=%s, type=%s, attribute=%s, nunits=%d %s", squad.name, assignment, asset.unittype, asset.attribute, nunits, tostring(squad.ngrouping))
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Create callsign and modex.
|
||||
@ -1476,12 +1478,13 @@ function AIRWING:onafterNewAsset(From, Event, To, asset, assignment)
|
||||
local unit = template.units[i]
|
||||
|
||||
-- If grouping is larger than units present, copy first unit.
|
||||
if i>#template.units then
|
||||
unit=UTILS.DeepCopy(template.units[1])
|
||||
if i>nunits then
|
||||
--unit=UTILS.DeepCopy(template.units[1])
|
||||
table.insert(template.units, UTILS.DeepCopy(template.units[1]))
|
||||
end
|
||||
|
||||
-- Remove units if original template contains more than in grouping.
|
||||
if squad.ngrouping<#template.units and i>#template.units then
|
||||
if squad.ngrouping<nunits and i>nunits then
|
||||
unit=nil
|
||||
end
|
||||
end
|
||||
|
||||
@ -245,6 +245,17 @@ function SQUADRON:SetRadio(Frequency, Modulation)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set number of units in groups.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #nunits Number of units. Must be >=1 and <=4. Default 2.
|
||||
-- @return #SQUADRON self
|
||||
function SQUADRON:SetGrouping(nunits)
|
||||
self.grouping=nunits or 2
|
||||
if self.grouping<1 then self.grouping=1 end
|
||||
if self.grouping>4 then self.grouping=4 end
|
||||
return self
|
||||
end
|
||||
|
||||
--- Set mission types this squadron is able to perform.
|
||||
-- @param #SQUADRON self
|
||||
-- @param #table MissionTypes Table of mission types. Can also be passed as a #string if only one type.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user