#AIRWING - make airwing fill airbase storage with aircraft types when adding a Squadron and if necessary, ie not unlimited storage and storage lower than squadron assets number

This commit is contained in:
Applevangelist
2025-12-28 17:53:49 +01:00
parent 1eb6dbc7f2
commit 29b244d843
+21
View File
@@ -326,6 +326,27 @@ function AIRWING:AddSquadron(Squadron)
if Squadron:IsStopped() then
Squadron:Start()
end
-- if storage is limited, add the amount of aircraft needed
local airbasename = self:GetAirbaseName()
if airbasename then
local group = GROUP:FindByName(Squadron.templategroup)
local Nunits = 1
local units
if group then units = group:GetUnits() end
if units then Nunits = #units end
local typename = Squadron.aircrafttype or "none"
local NAssets = Squadron.Ngroups * Nunits
local storage = STORAGE:New(airbasename)
--self:T(self.lid.."Adding "..typename.." #"..NAssets)
if storage and storage:IsLimitedAircraft() and typename ~= "none" then
local NInStore = storage:GetItemAmount(typename) or 0
if NAssets > NInStore then
storage:AddItem(typename,NAssets)
end
end
end
return self
end