mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-19 05:36:02 +00:00
Assets
- remove assets from warehouse if they are removed from cohort
This commit is contained in:
@@ -79,6 +79,7 @@
|
|||||||
|
|
||||||
do -- FSM
|
do -- FSM
|
||||||
|
|
||||||
|
--- FSM class
|
||||||
-- @type FSM
|
-- @type FSM
|
||||||
-- @field #string ClassName Name of the class.
|
-- @field #string ClassName Name of the class.
|
||||||
-- @field Core.Scheduler#SCHEDULER CallScheduler Call scheduler.
|
-- @field Core.Scheduler#SCHEDULER CallScheduler Call scheduler.
|
||||||
|
|||||||
@@ -8596,6 +8596,8 @@ function WAREHOUSE:_DeleteStockItem(stockitem)
|
|||||||
local item=self.stock[i] --#WAREHOUSE.Assetitem
|
local item=self.stock[i] --#WAREHOUSE.Assetitem
|
||||||
if item.uid==stockitem.uid then
|
if item.uid==stockitem.uid then
|
||||||
table.remove(self.stock,i)
|
table.remove(self.stock,i)
|
||||||
|
-- remove also from warehouse DB
|
||||||
|
_WAREHOUSEDB.Assets[stockitem.uid]=nil
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -629,32 +629,42 @@ end
|
|||||||
--- Remove assets from pool. Not that assets must not be spawned or already reserved or requested.
|
--- Remove assets from pool. Not that assets must not be spawned or already reserved or requested.
|
||||||
-- @param #COHORT self
|
-- @param #COHORT self
|
||||||
-- @param #number N Number of assets to be removed. Default 1.
|
-- @param #number N Number of assets to be removed. Default 1.
|
||||||
|
-- @param #number Delay Delay in seconds before assets are removed.
|
||||||
-- @return #COHORT self
|
-- @return #COHORT self
|
||||||
function COHORT:RemoveAssets(N)
|
function COHORT:RemoveAssets(N, Delay)
|
||||||
self:T2(self.lid..string.format("Remove %d assets of Cohort", N))
|
self:T2(self.lid..string.format("Remove %d assets of Cohort", N))
|
||||||
|
|
||||||
N=N or 1
|
|
||||||
|
|
||||||
local n=0
|
if Delay and Delay>0 then
|
||||||
for i=#self.assets,1,-1 do
|
-- Delayed call
|
||||||
local asset=self.assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
self:ScheduleOnce(Delay, COHORT.RemoveAssets, self, N, 0)
|
||||||
|
else
|
||||||
|
|
||||||
self:T2(self.lid..string.format("Checking removing asset %s", asset.spawngroupname))
|
N=N or 1
|
||||||
if not (asset.requested or asset.spawned or asset.isReserved) then
|
|
||||||
self:T2(self.lid..string.format("Removing asset %s", asset.spawngroupname))
|
local n=0
|
||||||
table.remove(self.assets, i)
|
for i=#self.assets,1,-1 do
|
||||||
n=n+1
|
local asset=self.assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem
|
||||||
else
|
|
||||||
self:T2(self.lid..string.format("Could NOT Remove asset %s", asset.spawngroupname))
|
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))
|
||||||
|
-- Remove from warehouse and warehouse DB
|
||||||
|
asset.legion:_DeleteStockItem(asset)
|
||||||
|
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
|
end
|
||||||
|
|
||||||
if n>=N then
|
self:T(self.lid..string.format("Removed %d/%d assets. New asset count=%d", n, N, #self.assets))
|
||||||
break
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
self:T(self.lid..string.format("Removed %d/%d assets. New asset count=%d", n, N, #self.assets))
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13466,10 +13466,10 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
local ammotable=unit:GetAmmo()
|
local ammotable=unit:GetAmmo()
|
||||||
|
|
||||||
if ammotable then
|
if ammotable then
|
||||||
|
|
||||||
local weapons=#ammotable
|
local weapons=#ammotable
|
||||||
|
|
||||||
--self:I(ammotable)
|
--self:I(ammotable)
|
||||||
|
--UTILS.PrintTableToLog(ammotable)
|
||||||
|
|
||||||
-- Loop over all weapons.
|
-- Loop over all weapons.
|
||||||
for w=1,weapons do
|
for w=1,weapons do
|
||||||
@@ -13477,9 +13477,9 @@ function OPSGROUP:GetAmmoUnit(unit, display)
|
|||||||
-- Number of current weapon.
|
-- Number of current weapon.
|
||||||
local Nammo=ammotable[w]["count"]
|
local Nammo=ammotable[w]["count"]
|
||||||
|
|
||||||
-- Range in meters. Seems only to exist for missiles (not shells).
|
-- Range in meters. Seems only to exist for missiles (not shells).
|
||||||
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
|
local rmin=ammotable[w]["desc"]["rangeMin"] or 0
|
||||||
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
|
local rmax=ammotable[w]["desc"]["rangeMaxAltMin"] or 0
|
||||||
|
|
||||||
-- Type name of current weapon.
|
-- Type name of current weapon.
|
||||||
local Tammo=ammotable[w]["desc"]["typeName"]
|
local Tammo=ammotable[w]["desc"]["typeName"]
|
||||||
|
|||||||
Reference in New Issue
Block a user