mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-12 16:57:50 +00:00
Ops
This commit is contained in:
@@ -149,6 +149,12 @@ function FLIGHTCONTROL:New(airbasename)
|
||||
-- Try to get the airbase.
|
||||
self.airbase=AIRBASE:FindByName(airbasename)
|
||||
|
||||
-- Name of the airbase.
|
||||
self.airbasename=airbasename
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("FLIGHTCONTROL %s | ", airbasename)
|
||||
|
||||
-- Check if the airbase exists.
|
||||
if not self.airbase then
|
||||
self:E(string.format("ERROR: Could not find airbase %s!", tostring(airbasename)))
|
||||
@@ -160,15 +166,11 @@ function FLIGHTCONTROL:New(airbasename)
|
||||
return nil
|
||||
end
|
||||
|
||||
-- Name of the airbase.
|
||||
self.airbasename=airbasename
|
||||
|
||||
|
||||
-- Airbase category airdrome, FARP, SHIP.
|
||||
self.airbasetype=self.airbase:GetAirbaseCategory()
|
||||
|
||||
-- Set some string id for output to DCS.log file.
|
||||
self.lid=string.format("FLIGHTCONTROL %s | ", airbasename)
|
||||
|
||||
-- Current map.
|
||||
self.theatre=env.mission.theatre
|
||||
|
||||
@@ -1075,49 +1077,33 @@ function FLIGHTCONTROL:_InitParkingSpots()
|
||||
-- Init parking spots table.
|
||||
self.parking={}
|
||||
|
||||
-- Get client coordinates.
|
||||
local function _clients()
|
||||
local clients=_DATABASE.CLIENTS
|
||||
local coords={}
|
||||
for clientname, client in pairs(clients) do
|
||||
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
||||
local units=template.units
|
||||
for i,unit in pairs(units) do
|
||||
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
||||
coords[unit.name]=coord
|
||||
|
||||
local _,TermID, dist, spot=coord:GetClosestParkingSpot(self.airbase)
|
||||
if dist<=10 then
|
||||
self:I(self.lid..string.format("Found client %s on parking spot %d", tostring(unit.name), TermID))
|
||||
self.parking[TermID].Reserved=tostring(unit.name)
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
self.Nparkingspots=0
|
||||
for _,_spot in pairs(parkingdata) do
|
||||
local spot=_spot --Wrapper.Airbase#AIRBASE.ParkingSpot
|
||||
|
||||
local parking=spot --#FLIGHTCONTROL.ParkingSpot
|
||||
|
||||
--TODO: reserve client spots.
|
||||
--TODO: scan spot for objects.
|
||||
|
||||
|
||||
-- Mark position.
|
||||
local text=string.format("ID=%d, Terminal=%d, Free=%s, Reserved=%s, Dist=%.1f", parking.TerminalID, parking.TerminalType, tostring(parking.Free), tostring(parking.Reserved), parking.DistToRwy)
|
||||
local text=string.format("ID=%d, Terminal=%d, Free=%s, Reserved=%s, Client=%s, Dist=%.1f", spot.TerminalID, spot.TerminalType, tostring(spot.Free), tostring(spot.Reserved), tostring(spot.ClientSpot), spot.DistToRwy)
|
||||
self:I(self.lid..text)
|
||||
|
||||
-- Add to table.
|
||||
self.parking[parking.TerminalID]=parking
|
||||
self.parking[spot.TerminalID]=spot
|
||||
|
||||
self.Nparkingspots=self.Nparkingspots+1
|
||||
end
|
||||
|
||||
-- Check clients.
|
||||
_clients()
|
||||
|
||||
end
|
||||
|
||||
--- Get free parking spots.
|
||||
-- @param #FLIGHTCONTROL self
|
||||
-- @param #number terminal Terminal type or nil.
|
||||
-- @return #number Number of free spots. Total if terminal=nil or of the requested terminal type.
|
||||
-- @return #table Table of free parking spots of data type #FLIGHCONTROL.ParkingSpot.
|
||||
function FLIGHTCONTROL:IsParkingFree(spot)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
@@ -312,6 +312,7 @@ AIRBASE.PersianGulf = {
|
||||
-- @field #string AirbaseName Name of the airbase.
|
||||
-- @field #number MarkerID Numerical ID of marker placed at parking spot.
|
||||
-- @field #boolean Reserved If true, parking spot is reserved for an aircraft.
|
||||
-- @field #boolean ClientSpot If true, a client unit sits at this parking spot (spawned or not).
|
||||
|
||||
--- Terminal Types of parking spots. See also https://wiki.hoggitworld.com/view/DCS_func_getParking
|
||||
--
|
||||
@@ -683,6 +684,29 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Get client coordinates.
|
||||
local function _isclient(_coord)
|
||||
|
||||
for clientname, client in pairs(_DATABASE.CLIENTS) do
|
||||
local template=_DATABASE:GetGroupTemplateFromUnitName(clientname)
|
||||
local units=template.units
|
||||
for i,unit in pairs(units) do
|
||||
|
||||
-- Unit coordinate.
|
||||
local coord=COORDINATE:New(unit.x, unit.alt, unit.y)
|
||||
|
||||
-- Distance to parking spot.
|
||||
local dist=coord:Get2DDistance(_coord)
|
||||
|
||||
if dist<=5 then
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
-- Put coordinates of parking spots into table.
|
||||
local spots={}
|
||||
@@ -691,7 +715,8 @@ function AIRBASE:GetParkingSpotsTable(termtype)
|
||||
self:T2({_spot=_spot})
|
||||
local _free=_isfree(_spot)
|
||||
local _coord=COORDINATE:NewFromVec3(_spot.vTerminalPos)
|
||||
table.insert(spots, {AirbaseName=self.AirbaseName, Coordinate=_coord, TerminalID=_spot.Term_Index, TerminalType=_spot.Term_Type, TOAC=_spot.TO_AC, Free=_free, TerminalID0=_spot.Term_Index_0, DistToRwy=_spot.fDistToRW})
|
||||
local _client=_isclient(_coord)
|
||||
table.insert(spots, {AirbaseName=self.AirbaseName, Coordinate=_coord, TerminalID=_spot.Term_Index, TerminalType=_spot.Term_Type, TOAC=_spot.TO_AC, Free=_free, TerminalID0=_spot.Term_Index_0, DistToRwy=_spot.fDistToRW, ClientSpot=_client})
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user