mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
AIRWING/WAREHOUSE
- Improved parking spot check if explicitly given for an airwing or squadron - Improved parking check if airstart is requested.
This commit is contained in:
parent
cb43f9c392
commit
254d43fef1
@ -5810,6 +5810,7 @@ function WAREHOUSE:_SpawnAssetRequest(Request)
|
|||||||
-- Now we try to find all parking spots for all cargo groups in advance. Due to the for loop, the parking spots do not get updated while spawning.
|
-- Now we try to find all parking spots for all cargo groups in advance. Due to the for loop, the parking spots do not get updated while spawning.
|
||||||
local Parking={}
|
local Parking={}
|
||||||
if Request.cargocategory==Group.Category.AIRPLANE or Request.cargocategory==Group.Category.HELICOPTER then
|
if Request.cargocategory==Group.Category.AIRPLANE or Request.cargocategory==Group.Category.HELICOPTER then
|
||||||
|
--TODO: Check for airstart. Should be a request property.
|
||||||
Parking=self:_FindParkingForAssets(self.airbase, cargoassets) or {}
|
Parking=self:_FindParkingForAssets(self.airbase, cargoassets) or {}
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -6069,7 +6070,9 @@ function WAREHOUSE:_SpawnAssetAircraft(alias, asset, request, parking, uncontrol
|
|||||||
end
|
end
|
||||||
|
|
||||||
if self.Debug then
|
if self.Debug then
|
||||||
coord:MarkToAll(string.format("Spawnplace unit %s terminal %d.", unit.name, terminal))
|
local text=string.format("Spawnplace unit %s terminal %d.", unit.name, terminal)
|
||||||
|
coord:MarkToAll(text)
|
||||||
|
env.info(text)
|
||||||
end
|
end
|
||||||
|
|
||||||
unit.x=coord.x
|
unit.x=coord.x
|
||||||
@ -7374,6 +7377,7 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
local _transports
|
local _transports
|
||||||
local _assetattribute
|
local _assetattribute
|
||||||
local _assetcategory
|
local _assetcategory
|
||||||
|
local _assetairstart=false
|
||||||
|
|
||||||
-- Check if at least one (cargo) asset is available.
|
-- Check if at least one (cargo) asset is available.
|
||||||
if _nassets>0 then
|
if _nassets>0 then
|
||||||
@ -7381,21 +7385,28 @@ function WAREHOUSE:_CheckRequestNow(request)
|
|||||||
-- Get the attibute of the requested asset.
|
-- Get the attibute of the requested asset.
|
||||||
_assetattribute=_assets[1].attribute
|
_assetattribute=_assets[1].attribute
|
||||||
_assetcategory=_assets[1].category
|
_assetcategory=_assets[1].category
|
||||||
|
_assetairstart=_assets[1].takeoffType and _assets[1].takeoffType==COORDINATE.WaypointType.TurningPoint or false
|
||||||
|
|
||||||
-- Check available parking for air asset units.
|
-- Check available parking for air asset units.
|
||||||
if _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
if _assetcategory==Group.Category.AIRPLANE or _assetcategory==Group.Category.HELICOPTER then
|
||||||
|
|
||||||
if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then
|
if self.airbase and self.airbase:GetCoalition()==self:GetCoalition() then
|
||||||
|
|
||||||
if self:IsRunwayOperational() then
|
if self:IsRunwayOperational() or _assetairstart then
|
||||||
|
|
||||||
local Parking=self:_FindParkingForAssets(self.airbase,_assets)
|
if _assetairstart then
|
||||||
|
-- Airstart no need to check parking
|
||||||
|
else
|
||||||
|
|
||||||
--if Parking==nil and not (self.category==Airbase.Category.HELIPAD) then
|
-- Check parking.
|
||||||
if Parking==nil then
|
local Parking=self:_FindParkingForAssets(self.airbase,_assets)
|
||||||
local text=string.format("Warehouse %s: Request denied! Not enough free parking spots for all requested assets at the moment.", self.alias)
|
|
||||||
self:_InfoMessage(text, 5)
|
-- No parking?
|
||||||
return false
|
if Parking==nil then
|
||||||
|
local text=string.format("Warehouse %s: Request denied! Not enough free parking spots for all requested assets at the moment.", self.alias)
|
||||||
|
self:_InfoMessage(text, 5)
|
||||||
|
return false
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
@ -7987,8 +7998,35 @@ function WAREHOUSE:_FindParkingForAssets(airbase, assets)
|
|||||||
for _,_parkingspot in pairs(parkingdata) do
|
for _,_parkingspot in pairs(parkingdata) do
|
||||||
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
local parkingspot=_parkingspot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||||
|
|
||||||
|
-- Parking valid?
|
||||||
|
local valid=true
|
||||||
|
|
||||||
|
if asset.parkingIDs then
|
||||||
|
-- If asset has assigned parking spots, we take these no matter what.
|
||||||
|
valid=self:_CheckParkingAsset(parkingspot, asset)
|
||||||
|
else
|
||||||
|
|
||||||
|
-- Valid terminal type depending on attribute.
|
||||||
|
local validTerminal=AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype)
|
||||||
|
|
||||||
|
-- Valid parking list.
|
||||||
|
local validParking=self:_CheckParkingValid(parkingspot)
|
||||||
|
|
||||||
|
-- Black and white list.
|
||||||
|
local validBWlist=airbase:_CheckParkingLists(parkingspot.TerminalID)
|
||||||
|
|
||||||
|
-- Debug info.
|
||||||
|
--env.info(string.format("FF validTerminal = %s", tostring(validTerminal)))
|
||||||
|
--env.info(string.format("FF validParking = %s", tostring(validParking)))
|
||||||
|
--env.info(string.format("FF validBWlist = %s", tostring(validBWlist)))
|
||||||
|
|
||||||
|
-- Check if all are true
|
||||||
|
valid=validTerminal and validParking and validBWlist
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
-- Check correct terminal type for asset. We don't want helos in shelters etc.
|
||||||
if AIRBASE._CheckTerminalType(parkingspot.TerminalType, terminaltype) and self:_CheckParkingValid(parkingspot) and self:_CheckParkingAsset(parkingspot, asset) and airbase:_CheckParkingLists(parkingspot.TerminalID) then
|
if valid then
|
||||||
|
|
||||||
-- Coordinate of the parking spot.
|
-- Coordinate of the parking spot.
|
||||||
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
local _spot=parkingspot.Coordinate -- Core.Point#COORDINATE
|
||||||
|
|||||||
@ -863,7 +863,7 @@ function AIRWING:SetAirboss(airboss)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set takeoff type. All assets of this squadron will be spawned with cold (default) or hot engines.
|
--- Set takeoff type. All assets of this airwing will be spawned with this takeoff type.
|
||||||
-- Spawning on runways is not supported.
|
-- Spawning on runways is not supported.
|
||||||
-- @param #AIRWING self
|
-- @param #AIRWING self
|
||||||
-- @param #string TakeoffType Take off type: "Cold" (default) or "Hot" with engines on or "Air" for spawning in air.
|
-- @param #string TakeoffType Take off type: "Cold" (default) or "Hot" with engines on or "Air" for spawning in air.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user