mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Update Warehouse.lua
- Added born check. Helps with delayed spawning on carriers.
This commit is contained in:
parent
717842b276
commit
a00c198bcc
@ -1552,7 +1552,7 @@
|
||||
WAREHOUSE = {
|
||||
ClassName = "WAREHOUSE",
|
||||
Debug = false,
|
||||
verbosity = 2,
|
||||
verbosity = 0,
|
||||
lid = nil,
|
||||
Report = true,
|
||||
warehouse = nil,
|
||||
@ -3473,6 +3473,8 @@ function WAREHOUSE:_JobDone()
|
||||
for _,request in pairs(self.pending) do
|
||||
local request=request --#WAREHOUSE.Pendingitem
|
||||
|
||||
if request.born then
|
||||
|
||||
-- Count number of cargo groups.
|
||||
local ncargo=0
|
||||
if request.cargogroupset then
|
||||
@ -3637,7 +3639,7 @@ function WAREHOUSE:_JobDone()
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end -- born check
|
||||
end -- loop over requests
|
||||
|
||||
-- Remove pending requests if done.
|
||||
@ -5158,7 +5160,7 @@ end
|
||||
-- @param #WAREHOUSE.Pendingitem request The request of the dead asset.
|
||||
function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
local text=string.format("Asset %s from request id=%d was spawned!", asset.spawngroupname, request.uid)
|
||||
self:I(self.lid..text)
|
||||
self:T(self.lid..text)
|
||||
|
||||
-- Sete asset state to spawned.
|
||||
asset.spawned=true
|
||||
@ -5169,22 +5171,23 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
||||
local assetitem=_asset --#WAREHOUSE.Assetitem
|
||||
|
||||
-- Debug info.
|
||||
self:I(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||
self:T(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||
|
||||
if assetitem.spawned then
|
||||
n=n+1
|
||||
else
|
||||
self:I(self.lid.."FF What?! This should not happen!")
|
||||
-- Now this can happend if multiple groups need to be spawned in one request.
|
||||
--self:I(self.lid.."FF What?! This should not happen!")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
-- Trigger event.
|
||||
if n==request.nasset+request.ntransport then
|
||||
self:I(self.lid..string.format("All assets %d (ncargo=%d + ntransport=%d) of request rid=%d spawned. Calling RequestSpawned", n, request.nasset, request.ntransport, request.uid))
|
||||
self:T(self.lid..string.format("All assets %d (ncargo=%d + ntransport=%d) of request rid=%d spawned. Calling RequestSpawned", n, request.nasset, request.ntransport, request.uid))
|
||||
self:RequestSpawned(request, request.cargogroupset, request.transportgroupset)
|
||||
else
|
||||
self:I(self.lid..string.format("Not all assets %d (ncargo=%d + ntransport=%d) of request rid=%d spawned YET", n, request.nasset, request.ntransport, request.uid))
|
||||
self:T(self.lid..string.format("Not all assets %d (ncargo=%d + ntransport=%d) of request rid=%d spawned YET", n, request.nasset, request.ntransport, request.uid))
|
||||
end
|
||||
|
||||
end
|
||||
@ -5795,7 +5798,7 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
|
||||
template.lateActivation=false
|
||||
|
||||
if asset.missionTask then
|
||||
self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
|
||||
self:T(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
|
||||
template.task=asset.missionTask
|
||||
end
|
||||
|
||||
@ -6122,9 +6125,11 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
||||
|
||||
if asset and request then
|
||||
|
||||
|
||||
-- Debug message.
|
||||
self:I(self.lid..string.format("Warehouse %s captured event birth of request ID=%d, asset ID=%d, unit %s spawned=%s", self.alias, request.uid, asset.uid, EventData.IniUnitName, tostring(asset.spawned)))
|
||||
self:T(self.lid..string.format("Warehouse %s captured event birth of request ID=%d, asset ID=%d, unit %s spawned=%s", self.alias, request.uid, asset.uid, EventData.IniUnitName, tostring(asset.spawned)))
|
||||
|
||||
-- Set born to true.
|
||||
request.born=true
|
||||
|
||||
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
||||
if not asset.spawned then
|
||||
@ -6150,7 +6155,7 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
||||
|
||||
-- Asset spawned FSM function.
|
||||
--self:__AssetSpawned(1, group, asset, request)
|
||||
env.info(string.format("FF asset spawned %s, %s", asset.spawngroupname, EventData.IniUnitName))
|
||||
--env.info(string.format("FF asset spawned %s, %s", asset.spawngroupname, EventData.IniUnitName))
|
||||
self:AssetSpawned(group, asset, request)
|
||||
|
||||
end
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user