Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
Applevangelist
2024-07-09 11:32:28 +02:00
6 changed files with 102 additions and 3 deletions

View File

@@ -577,7 +577,7 @@ function COHORT:AddAsset(Asset)
return self
end
--- Remove asset from chort.
--- Remove specific asset from chort.
-- @param #COHORT self
-- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset.
-- @return #COHORT self
@@ -609,6 +609,40 @@ function COHORT:DelGroup(GroupName)
return self
end
--- Remove assets from pool. Not that assets must not be spawned or already reserved or requested.
-- @param #COHORT self
-- @param #number N Number of assets to be removed. Default 1.
-- @return #COHORT self
function COHORT:RemoveAssets(N)
self:T2(self.lid..string.format("Remove %d assets of Cohort", N))
N=N or 1
local n=0
for i=#self.assets,1,-1 do
local asset=self.assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
self:T2(self.lid..string.format("Checking removing asset %s", asset.spawngroupname))
if not (asset.requested or asset.spawned or asset.isReserved) then
self:T2(self.lid..string.format("Removing asset %s", asset.spawngroupname))
table.remove(self.assets, i)
n=n+1
else
self:T2(self.lid..string.format("Could NOT Remove asset %s", asset.spawngroupname))
end
if n>=N then
break
end
end
self:T(self.lid..string.format("Removed %d/%d assets. New asset count=%d", n, N, #self.assets))
return self
end
--- Get name of the cohort.
-- @param #COHORT self
-- @return #string Name of the cohort.