mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-22 06:45:20 +00:00
FC
This commit is contained in:
@@ -290,12 +290,13 @@ end
|
|||||||
-- @param Core.Event#EVENTDATA EventData
|
-- @param Core.Event#EVENTDATA EventData
|
||||||
function FLIGHTCONTROL:OnEventBirth(EventData)
|
function FLIGHTCONTROL:OnEventBirth(EventData)
|
||||||
self:F3({EvendData=EventData})
|
self:F3({EvendData=EventData})
|
||||||
|
|
||||||
self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
|
||||||
self:I(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
|
||||||
|
|
||||||
if EventData and EventData.IniGroupName and EventData.Place and EventData.Place:GetName()==self.airbasename then
|
if EventData and EventData.IniGroupName and EventData.Place and EventData.Place:GetName()==self.airbasename then
|
||||||
|
|
||||||
|
self:I(self.lid..string.format("BIRTH: unit = %s", tostring(EventData.IniUnitName)))
|
||||||
|
self:I(self.lid..string.format("BIRTH: group = %s", tostring(EventData.IniGroupName)))
|
||||||
|
|
||||||
|
|
||||||
-- We delay this, to have all elements of the group in the game.
|
-- We delay this, to have all elements of the group in the game.
|
||||||
self:ScheduleOnce(0.1, self._CreateFlightGroup, self, EventData.IniGroup)
|
self:ScheduleOnce(0.1, self._CreateFlightGroup, self, EventData.IniGroup)
|
||||||
|
|
||||||
@@ -395,7 +396,7 @@ end
|
|||||||
function FLIGHTCONTROL:_CheckQueues()
|
function FLIGHTCONTROL:_CheckQueues()
|
||||||
|
|
||||||
-- Print queues
|
-- Print queues
|
||||||
--self:_PrintQueue(self.flights, "All flights")
|
self:_PrintQueue(self.flights, "All flights")
|
||||||
self:_PrintQueue(self.Qparking, "Parking")
|
self:_PrintQueue(self.Qparking, "Parking")
|
||||||
self:_PrintQueue(self.Qtakeoff, "Takeoff")
|
self:_PrintQueue(self.Qtakeoff, "Takeoff")
|
||||||
self:_PrintQueue(self.Qwaiting, "Holding")
|
self:_PrintQueue(self.Qwaiting, "Holding")
|
||||||
@@ -413,14 +414,22 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
-- Number of parking groups.
|
-- Number of parking groups.
|
||||||
local nparking=#self.Qparking
|
local nparking=#self.Qparking
|
||||||
|
|
||||||
|
-- Get next flight in line: either holding or parking.
|
||||||
local flight, isholding=self:_GetNextFight()
|
local flight, isholding=self:_GetNextFight()
|
||||||
|
|
||||||
|
|
||||||
|
-- Check if somebody wants something.
|
||||||
if flight and ntakeoff==0 and nlanding==0 then
|
if flight and ntakeoff==0 and nlanding==0 then
|
||||||
|
|
||||||
if isholding then
|
if isholding then
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
-- Holding flight --
|
||||||
|
--------------------
|
||||||
|
|
||||||
|
-- Get free parking spots.
|
||||||
local n,parking=self:_GetFreeParkingSpots()
|
local n,parking=self:_GetFreeParkingSpots()
|
||||||
|
|
||||||
|
|
||||||
-- Get number of alive elements.
|
-- Get number of alive elements.
|
||||||
local Ne=self:GetNelements()
|
local Ne=self:GetNelements()
|
||||||
@@ -437,6 +446,10 @@ function FLIGHTCONTROL:_CheckQueues()
|
|||||||
end
|
end
|
||||||
|
|
||||||
else
|
else
|
||||||
|
|
||||||
|
--------------------
|
||||||
|
-- Takeoff flight --
|
||||||
|
--------------------
|
||||||
|
|
||||||
-- Check if flight is AI. Humans have to request taxi via F10 menu.
|
-- Check if flight is AI. Humans have to request taxi via F10 menu.
|
||||||
if flight.ai then
|
if flight.ai then
|
||||||
@@ -1401,6 +1414,8 @@ function FLIGHTCONTROL:_LandAI(flight, parking)
|
|||||||
|
|
||||||
-- Waypoints.
|
-- Waypoints.
|
||||||
local wp={}
|
local wp={}
|
||||||
|
|
||||||
|
-- Current pos.
|
||||||
wp[#wp+1]=self.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos")
|
wp[#wp+1]=self.group:GetCoordinate():WaypointAir(nil, COORDINATE.WaypointType.TurningPoint, COORDINATE.WaypointAction.FlyoverPoint, UTILS.KnotsToKmph(SpeedTo), true , nil, {}, "Current Pos")
|
||||||
|
|
||||||
-- Approach point: 10 NN in direction of runway.
|
-- Approach point: 10 NN in direction of runway.
|
||||||
|
|||||||
@@ -1525,13 +1525,6 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
|||||||
local p1=nil
|
local p1=nil
|
||||||
local wpap=nil
|
local wpap=nil
|
||||||
|
|
||||||
-- Altitude above ground for a glide slope of 3�.
|
|
||||||
local alpha=math.rad(3)
|
|
||||||
local x1=UTILS.NMToMeters(10)
|
|
||||||
local x2=UTILS.NMToMeters(5)
|
|
||||||
local h1=x1*math.tan(alpha)
|
|
||||||
local h2=x2*math.tan(alpha)
|
|
||||||
|
|
||||||
-- Do we have a flight control?
|
-- Do we have a flight control?
|
||||||
local fc=_DATABASE:GetFlightControl(airbase:GetName())
|
local fc=_DATABASE:GetFlightControl(airbase:GetName())
|
||||||
if fc then
|
if fc then
|
||||||
@@ -1579,27 +1572,6 @@ function FLIGHTGROUP:onafterHold(From, Event, To, airbase, SpeedTo, SpeedHold, S
|
|||||||
-- Set route points.
|
-- Set route points.
|
||||||
Template.route.points=wp
|
Template.route.points=wp
|
||||||
|
|
||||||
if fc then
|
|
||||||
local n,parking=fc:_GetFreeParkingSpots()
|
|
||||||
-- Get number of alive elements.
|
|
||||||
local Ne=self:GetNelements()
|
|
||||||
|
|
||||||
if n>=Ne then
|
|
||||||
for i,unit in pairs(Template.units) do
|
|
||||||
local spot=parking[i] --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot
|
|
||||||
spot.reserved=unit.name
|
|
||||||
unit.parking_landing=spot.TerminalID
|
|
||||||
local text=string.format("FF Reserving parking spot %d for unit %s", spot.TerminalID, tostring(unit.name))
|
|
||||||
env.info(text)
|
|
||||||
end
|
|
||||||
--[[
|
|
||||||
for _,_spot in pairs(parking) do
|
|
||||||
local spot=_spot --Ops.FlightControl#FLIGHTCONTROL.ParkingSpot
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
MESSAGE:New("Respawning group"):ToAll()
|
MESSAGE:New("Respawning group"):ToAll()
|
||||||
|
|
||||||
--Respawn the group.
|
--Respawn the group.
|
||||||
|
|||||||
Reference in New Issue
Block a user