mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-23 11:40:57 +00:00
Merge branch 'develop' into FF/Fox2
This commit is contained in:
@@ -284,7 +284,7 @@
|
|||||||
--
|
--
|
||||||
-- Assets of the warehouse can be requested by other MOOSE warehouses. A request will first be scrutinized to check if can be fulfilled at all. If the request is valid, it is
|
-- Assets of the warehouse can be requested by other MOOSE warehouses. A request will first be scrutinized to check if can be fulfilled at all. If the request is valid, it is
|
||||||
-- put into the warehouse queue and processed as soon as possible.
|
-- put into the warehouse queue and processed as soon as possible.
|
||||||
--
|
--
|
||||||
-- Requested assets spawn in various "Rule of Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function.
|
-- Requested assets spawn in various "Rule of Engagement Rules" (ROE) and Alerts modes. If your assets will cross into dangerous areas, be sure to change these states. You can do this in @{#WAREHOUSE:OnAfterAssetSpawned}(*From, *Event, *To, *group, *asset, *request)) function.
|
||||||
--
|
--
|
||||||
-- Initial Spawn states is as follows:
|
-- Initial Spawn states is as follows:
|
||||||
@@ -1882,7 +1882,7 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
-- Define warehouse and default spawn zone.
|
-- Define warehouse and default spawn zone.
|
||||||
self.zone=ZONE_RADIUS:New(string.format("Warehouse zone %s", self.warehouse:GetName()), warehouse:GetVec2(), 500)
|
self.zone=ZONE_RADIUS:New(string.format("Warehouse zone %s", self.warehouse:GetName()), warehouse:GetVec2(), 500)
|
||||||
self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
|
self.spawnzone=ZONE_RADIUS:New(string.format("Warehouse %s spawn zone", self.warehouse:GetName()), warehouse:GetVec2(), 250)
|
||||||
|
|
||||||
-- Defaults
|
-- Defaults
|
||||||
self:SetMarker(true)
|
self:SetMarker(true)
|
||||||
|
|
||||||
@@ -1900,26 +1900,26 @@ function WAREHOUSE:New(warehouse, alias)
|
|||||||
-- From State --> Event --> To State
|
-- From State --> Event --> To State
|
||||||
self:AddTransition("NotReadyYet", "Load", "Loaded") -- Load the warehouse state from scatch.
|
self:AddTransition("NotReadyYet", "Load", "Loaded") -- Load the warehouse state from scatch.
|
||||||
self:AddTransition("Stopped", "Load", "Loaded") -- Load the warehouse state stopped state.
|
self:AddTransition("Stopped", "Load", "Loaded") -- Load the warehouse state stopped state.
|
||||||
|
|
||||||
self:AddTransition("NotReadyYet", "Start", "Running") -- Start the warehouse from scratch.
|
self:AddTransition("NotReadyYet", "Start", "Running") -- Start the warehouse from scratch.
|
||||||
self:AddTransition("Loaded", "Start", "Running") -- Start the warehouse when loaded from disk.
|
self:AddTransition("Loaded", "Start", "Running") -- Start the warehouse when loaded from disk.
|
||||||
|
|
||||||
self:AddTransition("*", "Status", "*") -- Status update.
|
self:AddTransition("*", "Status", "*") -- Status update.
|
||||||
|
|
||||||
self:AddTransition("*", "AddAsset", "*") -- Add asset to warehouse stock.
|
self:AddTransition("*", "AddAsset", "*") -- Add asset to warehouse stock.
|
||||||
self:AddTransition("*", "NewAsset", "*") -- New asset was added to warehouse stock.
|
self:AddTransition("*", "NewAsset", "*") -- New asset was added to warehouse stock.
|
||||||
|
|
||||||
self:AddTransition("*", "AddRequest", "*") -- New request from other warehouse.
|
self:AddTransition("*", "AddRequest", "*") -- New request from other warehouse.
|
||||||
self:AddTransition("Running", "Request", "*") -- Process a request. Only in running mode.
|
self:AddTransition("Running", "Request", "*") -- Process a request. Only in running mode.
|
||||||
self:AddTransition("Running", "RequestSpawned", "*") -- Assets of request were spawned.
|
self:AddTransition("Running", "RequestSpawned", "*") -- Assets of request were spawned.
|
||||||
self:AddTransition("Attacked", "Request", "*") -- Process a request. Only in running mode.
|
self:AddTransition("Attacked", "Request", "*") -- Process a request. Only in running mode.
|
||||||
|
|
||||||
self:AddTransition("*", "Unloaded", "*") -- Cargo has been unloaded from the carrier (unused ==> unnecessary?).
|
self:AddTransition("*", "Unloaded", "*") -- Cargo has been unloaded from the carrier (unused ==> unnecessary?).
|
||||||
self:AddTransition("*", "AssetSpawned", "*") -- Asset has been spawned into the world.
|
self:AddTransition("*", "AssetSpawned", "*") -- Asset has been spawned into the world.
|
||||||
self:AddTransition("*", "AssetLowFuel", "*") -- Asset is low on fuel.
|
self:AddTransition("*", "AssetLowFuel", "*") -- Asset is low on fuel.
|
||||||
|
|
||||||
self:AddTransition("*", "Arrived", "*") -- Cargo or transport group has arrived.
|
self:AddTransition("*", "Arrived", "*") -- Cargo or transport group has arrived.
|
||||||
|
|
||||||
self:AddTransition("*", "Delivered", "*") -- All cargo groups of a request have been delivered to the requesting warehouse.
|
self:AddTransition("*", "Delivered", "*") -- All cargo groups of a request have been delivered to the requesting warehouse.
|
||||||
self:AddTransition("Running", "SelfRequest", "*") -- Request to warehouse itself. Requested assets are only spawned but not delivered anywhere.
|
self:AddTransition("Running", "SelfRequest", "*") -- Request to warehouse itself. Requested assets are only spawned but not delivered anywhere.
|
||||||
self:AddTransition("Attacked", "SelfRequest", "*") -- Request to warehouse itself. Also possible when warehouse is under attack!
|
self:AddTransition("Attacked", "SelfRequest", "*") -- Request to warehouse itself. Also possible when warehouse is under attack!
|
||||||
@@ -3752,7 +3752,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
||||||
|
|
||||||
if wid and aid and rid then
|
if wid and aid and rid then
|
||||||
|
|
||||||
---------------------------
|
---------------------------
|
||||||
-- This is a KNOWN asset --
|
-- This is a KNOWN asset --
|
||||||
---------------------------
|
---------------------------
|
||||||
@@ -3768,7 +3768,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
|
|
||||||
-- Increase number of cargo delivered and transports home.
|
-- Increase number of cargo delivered and transports home.
|
||||||
local istransport=warehouse:_GroupIsTransport(group,request)
|
local istransport=warehouse:_GroupIsTransport(group,request)
|
||||||
|
|
||||||
if istransport==true then
|
if istransport==true then
|
||||||
request.ntransporthome=request.ntransporthome+1
|
request.ntransporthome=request.ntransporthome+1
|
||||||
request.transportgroupset:Remove(group:GetName(), true)
|
request.transportgroupset:Remove(group:GetName(), true)
|
||||||
@@ -3778,7 +3778,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
request.ndelivered=request.ndelivered+1
|
request.ndelivered=request.ndelivered+1
|
||||||
local namewo=self:_GetNameWithOut(group)
|
local namewo=self:_GetNameWithOut(group)
|
||||||
request.cargogroupset:Remove(namewo, true)
|
request.cargogroupset:Remove(namewo, true)
|
||||||
local ncargo=request.cargogroupset:Count()
|
local ncargo=request.cargogroupset:Count()
|
||||||
self:T2(warehouse.lid..string.format("Cargo %s: %d of %s delivered. CargoSet=%d", namewo, request.ndelivered, tostring(request.nasset), ncargo))
|
self:T2(warehouse.lid..string.format("Cargo %s: %d of %s delivered. CargoSet=%d", namewo, request.ndelivered, tostring(request.nasset), ncargo))
|
||||||
else
|
else
|
||||||
self:E(warehouse.lid..string.format("WARNING: Group %s is neither cargo nor transport! Need to investigate...", group:GetName()))
|
self:E(warehouse.lid..string.format("WARNING: Group %s is neither cargo nor transport! Need to investigate...", group:GetName()))
|
||||||
@@ -3808,10 +3808,10 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
asset.livery=liveries
|
asset.livery=liveries
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Set skill.
|
-- Set skill.
|
||||||
asset.skill=skill or asset.skill
|
asset.skill=skill or asset.skill
|
||||||
|
|
||||||
-- Asset now belongs to this warehouse. Set warehouse ID.
|
-- Asset now belongs to this warehouse. Set warehouse ID.
|
||||||
asset.wid=self.uid
|
asset.wid=self.uid
|
||||||
|
|
||||||
@@ -3833,7 +3833,7 @@ function WAREHOUSE:onafterAddAsset(From, Event, To, group, ngroups, forceattribu
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
-------------------------
|
-------------------------
|
||||||
-- This is a NEW asset --
|
-- This is a NEW asset --
|
||||||
-------------------------
|
-------------------------
|
||||||
@@ -4116,7 +4116,7 @@ function WAREHOUSE:onbeforeAddRequest(From, Event, To, warehouse, AssetDescripto
|
|||||||
self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
|
self:_ErrorMessage("ERROR: Invalid request. Asset assignment type must be passed as a string!", 5)
|
||||||
okay=false
|
okay=false
|
||||||
end
|
end
|
||||||
|
|
||||||
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
elseif AssetDescriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
||||||
|
|
||||||
if type(AssetDescriptorValue)~="table" then
|
if type(AssetDescriptorValue)~="table" then
|
||||||
@@ -4318,7 +4318,7 @@ function WAREHOUSE:onafterRequest(From, Event, To, Request)
|
|||||||
_assetitem.arrived=false
|
_assetitem.arrived=false
|
||||||
|
|
||||||
local spawngroup=nil --Wrapper.Group#GROUP
|
local spawngroup=nil --Wrapper.Group#GROUP
|
||||||
|
|
||||||
-- Add asset by id to all assets table.
|
-- Add asset by id to all assets table.
|
||||||
Request.assets[_assetitem.uid]=_assetitem
|
Request.assets[_assetitem.uid]=_assetitem
|
||||||
|
|
||||||
@@ -4738,7 +4738,7 @@ end
|
|||||||
function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||||
|
|
||||||
local asset=self:FindAssetInDB(group)
|
local asset=self:FindAssetInDB(group)
|
||||||
|
|
||||||
if asset then
|
if asset then
|
||||||
if asset.arrived==true then
|
if asset.arrived==true then
|
||||||
-- Asset already arrived (e.g. if multiple units trigger the event via landing).
|
-- Asset already arrived (e.g. if multiple units trigger the event via landing).
|
||||||
@@ -4748,7 +4748,29 @@ function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- On before "Arrived" event. Triggered when a group has arrived at its destination warehouse.
|
||||||
|
-- @param #WAREHOUSE self
|
||||||
|
-- @param #string From From state.
|
||||||
|
-- @param #string Event Event.
|
||||||
|
-- @param #string To To state.
|
||||||
|
-- @param Wrapper.Group#GROUP group The group that was delivered.
|
||||||
|
function WAREHOUSE:onbeforeArrived(From, Event, To, group)
|
||||||
|
|
||||||
|
local asset=self:FindAssetInDB(group)
|
||||||
|
|
||||||
|
if asset then
|
||||||
|
if asset.arrived==true then
|
||||||
|
-- Asset already arrived (e.g. if multiple units trigger the event via landing).
|
||||||
|
return false
|
||||||
|
else
|
||||||
|
asset.arrived=true --ensure this is not called again from the same asset group.
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On after "Arrived" event. Triggered when a group has arrived at its destination warehouse.
|
--- On after "Arrived" event. Triggered when a group has arrived at its destination warehouse.
|
||||||
@@ -4792,7 +4814,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group)
|
|||||||
if group:IsGround() and group:GetSpeedMax()>1 then
|
if group:IsGround() and group:GetSpeedMax()>1 then
|
||||||
group:RouteGroundTo(warehouse:GetCoordinate(), group:GetSpeedMax()*0.3, "Off Road")
|
group:RouteGroundTo(warehouse:GetCoordinate(), group:GetSpeedMax()*0.3, "Off Road")
|
||||||
end
|
end
|
||||||
|
|
||||||
-- NOTE: This is done in the AddAsset() function. Dont know, why we do it also here.
|
-- NOTE: This is done in the AddAsset() function. Dont know, why we do it also here.
|
||||||
--[[
|
--[[
|
||||||
if istransport==true then
|
if istransport==true then
|
||||||
@@ -4807,7 +4829,7 @@ function WAREHOUSE:onafterArrived(From, Event, To, group)
|
|||||||
self:E(warehouse.lid..string.format("ERROR: Group %s is neither cargo nor transport!", group:GetName()))
|
self:E(warehouse.lid..string.format("ERROR: Group %s is neither cargo nor transport!", group:GetName()))
|
||||||
end
|
end
|
||||||
]]
|
]]
|
||||||
|
|
||||||
-- Move asset from pending queue into new warehouse.
|
-- Move asset from pending queue into new warehouse.
|
||||||
warehouse:__AddAsset(60, group)
|
warehouse:__AddAsset(60, group)
|
||||||
end
|
end
|
||||||
@@ -5022,9 +5044,9 @@ function WAREHOUSE:onafterChangeCountry(From, Event, To, Country)
|
|||||||
local airbasecoaltion
|
local airbasecoaltion
|
||||||
if self.airbase ~= nil then
|
if self.airbase ~= nil then
|
||||||
local airbase=AIRBASE:FindByName(self.airbasename)
|
local airbase=AIRBASE:FindByName(self.airbasename)
|
||||||
airbasecoaltion=airbase:GetCoalition()
|
airbasecoaltion=airbase:GetCoalition()
|
||||||
else -- Warehouse has no airbase attached so just keep whatever, self.airbase will still be nil since CoalitionNew will not be nil if Warehouse have a airbse attacjed.
|
else -- Warehouse has no airbase attached so just keep whatever, self.airbase will still be nil since CoalitionNew will not be nil if Warehouse have a airbse attacjed.
|
||||||
airbasecoaltion = nil
|
airbasecoaltion = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
if CoalitionNew==airbasecoaltion then
|
if CoalitionNew==airbasecoaltion then
|
||||||
@@ -5115,7 +5137,7 @@ function WAREHOUSE:onafterAirbaseRecaptured(From, Event, To, Coalition)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- On before "AssetSpawned" event. Checks whether the asset was already set to "spawned" for groups with multiple units.
|
--- On before "AssetSpawned" event. Checks whether the asset was already set to "spawned" for groups with multiple units.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #string From From state.
|
-- @param #string From From state.
|
||||||
-- @param #string Event Event.
|
-- @param #string Event Event.
|
||||||
@@ -5129,7 +5151,7 @@ function WAREHOUSE:onbeforeAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
else
|
else
|
||||||
--return true
|
--return true
|
||||||
end
|
end
|
||||||
|
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5155,7 +5177,7 @@ function WAREHOUSE:onafterAssetSpawned(From, Event, To, group, asset, request)
|
|||||||
|
|
||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
self:T2(self.lid..string.format("Asset %s spawned %s as %s", assetitem.templatename, tostring(assetitem.spawned), tostring(assetitem.spawngroupname)))
|
||||||
|
|
||||||
if assetitem.spawned then
|
if assetitem.spawned then
|
||||||
n=n+1
|
n=n+1
|
||||||
else
|
else
|
||||||
@@ -5214,11 +5236,11 @@ function WAREHOUSE:onafterDestroyed(From, Event, To)
|
|||||||
for k,_ in pairs(self.queue) do
|
for k,_ in pairs(self.queue) do
|
||||||
self.queue[k]=nil
|
self.queue[k]=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
for k,_ in pairs(self.stock) do
|
for k,_ in pairs(self.stock) do
|
||||||
--self.stock[k]=nil
|
--self.stock[k]=nil
|
||||||
end
|
end
|
||||||
|
|
||||||
for k=#self.stock,1,-1 do
|
for k=#self.stock,1,-1 do
|
||||||
--local asset=self.stock[k] --#WAREHOUSE.Assetitem
|
--local asset=self.stock[k] --#WAREHOUSE.Assetitem
|
||||||
--self:AssetDead(asset, nil)
|
--self:AssetDead(asset, nil)
|
||||||
@@ -5481,15 +5503,15 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
|||||||
-- Set asset status to not spawned until we capture its birth event.
|
-- Set asset status to not spawned until we capture its birth event.
|
||||||
asset.spawned=false
|
asset.spawned=false
|
||||||
asset.iscargo=true
|
asset.iscargo=true
|
||||||
|
|
||||||
-- Set request ID.
|
-- Set request ID.
|
||||||
asset.rid=Request.uid
|
asset.rid=Request.uid
|
||||||
|
|
||||||
-- Spawn group name.
|
-- Spawn group name.
|
||||||
local _alias=asset.spawngroupname
|
local _alias=asset.spawngroupname
|
||||||
|
|
||||||
--Request add asset by id.
|
--Request add asset by id.
|
||||||
Request.assets[asset.uid]=asset
|
Request.assets[asset.uid]=asset
|
||||||
|
|
||||||
-- Spawn an asset group.
|
-- Spawn an asset group.
|
||||||
local _group=nil --Wrapper.Group#GROUP
|
local _group=nil --Wrapper.Group#GROUP
|
||||||
@@ -5581,7 +5603,7 @@ function WAREHOUSE:_SpawnAssetGroundNaval(alias, asset, request, spawnzone, aiof
|
|||||||
end
|
end
|
||||||
if asset.skill then
|
if asset.skill then
|
||||||
unit.skill= asset.skill
|
unit.skill= asset.skill
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5717,15 +5739,15 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
|||||||
end
|
end
|
||||||
|
|
||||||
if asset.payload then
|
if asset.payload then
|
||||||
unit.payload=asset.payload.pylons
|
unit.payload=asset.payload.pylons
|
||||||
end
|
end
|
||||||
|
|
||||||
if asset.modex then
|
if asset.modex then
|
||||||
unit.onboard_num=asset.modex[i]
|
unit.onboard_num=asset.modex[i]
|
||||||
end
|
end
|
||||||
if asset.callsign then
|
if asset.callsign then
|
||||||
unit.callsign=asset.callsign[i]
|
unit.callsign=asset.callsign[i]
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -5778,12 +5800,12 @@ function WAREHOUSE:_SpawnAssetPrepareTemplate(asset, alias)
|
|||||||
|
|
||||||
-- No late activation.
|
-- No late activation.
|
||||||
template.lateActivation=false
|
template.lateActivation=false
|
||||||
|
|
||||||
if asset.missionTask then
|
if asset.missionTask then
|
||||||
self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
|
self:I(self.lid..string.format("Setting mission task to %s", tostring(asset.missionTask)))
|
||||||
template.task=asset.missionTask
|
template.task=asset.missionTask
|
||||||
end
|
end
|
||||||
|
|
||||||
-- No predefined task.
|
-- No predefined task.
|
||||||
--template.taskSelected=false
|
--template.taskSelected=false
|
||||||
|
|
||||||
@@ -6067,7 +6089,7 @@ end
|
|||||||
--- Get a warehouse request from its unique id.
|
--- Get a warehouse request from its unique id.
|
||||||
-- @param #WAREHOUSE self
|
-- @param #WAREHOUSE self
|
||||||
-- @param #number id Request ID.
|
-- @param #number id Request ID.
|
||||||
-- @return #WAREHOUSE.Pendingitem The warehouse requested - either queued or pending.
|
-- @return #WAREHOUSE.Pendingitem The warehouse requested - either queued or pending.
|
||||||
-- @return #boolean If *true*, request is queued, if *false*, request is pending, if *nil*, request could not be found.
|
-- @return #boolean If *true*, request is queued, if *false*, request is pending, if *nil*, request could not be found.
|
||||||
function WAREHOUSE:GetRequestByID(id)
|
function WAREHOUSE:GetRequestByID(id)
|
||||||
|
|
||||||
@@ -6105,14 +6127,14 @@ function WAREHOUSE:_OnEventBirth(EventData)
|
|||||||
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
local wid,aid,rid=self:_GetIDsFromGroup(group)
|
||||||
|
|
||||||
if wid==self.uid then
|
if wid==self.uid then
|
||||||
|
|
||||||
-- Get asset and request from id.
|
-- Get asset and request from id.
|
||||||
local asset=self:GetAssetByID(aid)
|
local asset=self:GetAssetByID(aid)
|
||||||
local request=self:GetRequestByID(rid)
|
local request=self:GetRequestByID(rid)
|
||||||
|
|
||||||
-- Debug message.
|
-- Debug message.
|
||||||
self:T(self.lid..string.format("Warehouse %s captured event birth of its asset unit %s. spawned=%s", self.alias, EventData.IniUnitName, tostring(asset.spawned)))
|
self:T(self.lid..string.format("Warehouse %s captured event birth of its asset unit %s. spawned=%s", self.alias, EventData.IniUnitName, tostring(asset.spawned)))
|
||||||
|
|
||||||
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
-- Birth is triggered for each unit. We need to make sure not to call this too often!
|
||||||
if not asset.spawned then
|
if not asset.spawned then
|
||||||
|
|
||||||
@@ -6397,7 +6419,7 @@ function WAREHOUSE:_UnitDead(deadunit, request)
|
|||||||
-- Remove dead group from cargo group set.
|
-- Remove dead group from cargo group set.
|
||||||
if groupdead==true then
|
if groupdead==true then
|
||||||
request.cargogroupset:Remove(groupname, NoTriggerEvent)
|
request.cargogroupset:Remove(groupname, NoTriggerEvent)
|
||||||
self:T(self.lid..string.format("Removed selfpropelled cargo %s: ncargo=%d.", groupname, request.cargogroupset:Count()))
|
self:T(self.lid..string.format("Removed selfpropelled cargo %s: ncargo=%d.", groupname, request.cargogroupset:Count()))
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@@ -7724,27 +7746,27 @@ end
|
|||||||
function WAREHOUSE:_GroupIsTransport(group, request)
|
function WAREHOUSE:_GroupIsTransport(group, request)
|
||||||
|
|
||||||
local asset=self:FindAssetInDB(group)
|
local asset=self:FindAssetInDB(group)
|
||||||
|
|
||||||
if asset and asset.iscargo~=nil then
|
if asset and asset.iscargo~=nil then
|
||||||
return not asset.iscargo
|
return not asset.iscargo
|
||||||
else
|
else
|
||||||
|
|
||||||
-- Name of the group under question.
|
-- Name of the group under question.
|
||||||
local groupname=self:_GetNameWithOut(group)
|
local groupname=self:_GetNameWithOut(group)
|
||||||
|
|
||||||
if request.transportgroupset then
|
if request.transportgroupset then
|
||||||
local transporters=request.transportgroupset:GetSetObjects()
|
local transporters=request.transportgroupset:GetSetObjects()
|
||||||
|
|
||||||
for _,transport in pairs(transporters) do
|
for _,transport in pairs(transporters) do
|
||||||
if transport:GetName()==groupname then
|
if transport:GetName()==groupname then
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if request.cargogroupset then
|
if request.cargogroupset then
|
||||||
local cargos=request.cargogroupset:GetSetObjects()
|
local cargos=request.cargogroupset:GetSetObjects()
|
||||||
|
|
||||||
for _,cargo in pairs(cargos) do
|
for _,cargo in pairs(cargos) do
|
||||||
if self:_GetNameWithOut(cargo)==groupname then
|
if self:_GetNameWithOut(cargo)==groupname then
|
||||||
return false
|
return false
|
||||||
@@ -7764,14 +7786,14 @@ end
|
|||||||
function WAREHOUSE:_GetNameWithOut(group)
|
function WAREHOUSE:_GetNameWithOut(group)
|
||||||
|
|
||||||
local groupname=type(group)=="string" and group or group:GetName()
|
local groupname=type(group)=="string" and group or group:GetName()
|
||||||
|
|
||||||
if groupname:find("CARGO") then
|
if groupname:find("CARGO") then
|
||||||
local name=groupname:gsub("#CARGO", "")
|
local name=groupname:gsub("#CARGO", "")
|
||||||
return name
|
return name
|
||||||
else
|
else
|
||||||
return groupname
|
return groupname
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -7934,23 +7956,23 @@ function WAREHOUSE:_FilterStock(stock, descriptor, attribute, nmax, mobile)
|
|||||||
|
|
||||||
-- Filtered array.
|
-- Filtered array.
|
||||||
local filtered={}
|
local filtered={}
|
||||||
|
|
||||||
-- A specific list of assets was required.
|
-- A specific list of assets was required.
|
||||||
if descriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
if descriptor==WAREHOUSE.Descriptor.ASSETLIST then
|
||||||
|
|
||||||
-- Count total number in stock.
|
-- Count total number in stock.
|
||||||
local ntot=0
|
local ntot=0
|
||||||
for _,_rasset in pairs(attribute) do
|
for _,_rasset in pairs(attribute) do
|
||||||
local rasset=_rasset --#WAREHOUSE.Assetitem
|
local rasset=_rasset --#WAREHOUSE.Assetitem
|
||||||
for _,_asset in ipairs(stock) do
|
for _,_asset in ipairs(stock) do
|
||||||
local asset=_asset --#WAREHOUSE.Assetitem
|
local asset=_asset --#WAREHOUSE.Assetitem
|
||||||
if rasset.uid==asset.uid then
|
if rasset.uid==asset.uid then
|
||||||
table.insert(filtered, asset)
|
table.insert(filtered, asset)
|
||||||
break
|
break
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
return filtered, #filtered, #filtered>=#attribute
|
return filtered, #filtered, #filtered>=#attribute
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -8419,25 +8441,25 @@ function WAREHOUSE:_UpdateWarehouseMarkText()
|
|||||||
if self.markerid~=nil then
|
if self.markerid~=nil then
|
||||||
trigger.action.removeMark(self.markerid)
|
trigger.action.removeMark(self.markerid)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get assets in stock.
|
-- Get assets in stock.
|
||||||
local _data=self:GetStockInfo(self.stock)
|
local _data=self:GetStockInfo(self.stock)
|
||||||
|
|
||||||
-- Text.
|
-- Text.
|
||||||
local text=string.format("Warehouse state: %s\nTotal assets in stock %d:\n", self:GetState(), #self.stock)
|
local text=string.format("Warehouse state: %s\nTotal assets in stock %d:\n", self:GetState(), #self.stock)
|
||||||
|
|
||||||
for _attribute,_count in pairs(_data) do
|
for _attribute,_count in pairs(_data) do
|
||||||
if _count>0 then
|
if _count>0 then
|
||||||
local attribute=tostring(UTILS.Split(_attribute, "_")[2])
|
local attribute=tostring(UTILS.Split(_attribute, "_")[2])
|
||||||
text=text..string.format("%s=%d, ", attribute,_count)
|
text=text..string.format("%s=%d, ", attribute,_count)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create/update marker at warehouse in F10 map.
|
-- Create/update marker at warehouse in F10 map.
|
||||||
self.markerid=self:GetCoordinate():MarkToCoalition(text, self:GetCoalition(), true)
|
self.markerid=self:GetCoordinate():MarkToCoalition(text, self:GetCoalition(), true)
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Display stock items of warehouse.
|
--- Display stock items of warehouse.
|
||||||
|
|||||||
Reference in New Issue
Block a user