mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Added airports from zone (untested)
This commit is contained in:
parent
ec6961fada
commit
6952401238
@ -284,6 +284,8 @@ RAT={
|
|||||||
departure_ports={}, -- Array containing the names of the departure airports.
|
departure_ports={}, -- Array containing the names of the departure airports.
|
||||||
destination_ports={}, -- Array containing the names of the destination airports.
|
destination_ports={}, -- Array containing the names of the destination airports.
|
||||||
excluded_ports={}, -- Array containing the names of explicitly excluded airports.
|
excluded_ports={}, -- Array containing the names of explicitly excluded airports.
|
||||||
|
departure_Azone=nil, -- Zone containing the departure airports.
|
||||||
|
destination_Azone=nil, -- Zone containing the destination airports.
|
||||||
ratcraft={}, -- Array with the spawned RAT aircraft.
|
ratcraft={}, -- Array with the spawned RAT aircraft.
|
||||||
Tinactive=300, -- Time in seconds after which inactive units will be destroyed. Default is 300 seconds.
|
Tinactive=300, -- Time in seconds after which inactive units will be destroyed. Default is 300 seconds.
|
||||||
reportstatus=false, -- Aircraft report status.
|
reportstatus=false, -- Aircraft report status.
|
||||||
@ -498,6 +500,17 @@ function RAT:Spawn(naircraft)
|
|||||||
self.SubMenuName=self.alias
|
self.SubMenuName=self.alias
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- Get all departure airports inside a Moose zone.
|
||||||
|
if self.departure_Azone~=nil then
|
||||||
|
self.departure_ports=self:_GetAirportsInZone(self.departure_Azone)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Get all destination airports inside a Moose zone.
|
||||||
|
if self.destination_Azone~=nil then
|
||||||
|
self.destination_ports=self:_GetAirportsInZone(self.destination_Azone)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
-- debug message
|
-- debug message
|
||||||
local text=string.format("\n******************************************************\n")
|
local text=string.format("\n******************************************************\n")
|
||||||
text=text..string.format("Spawning %i aircraft from template %s of type %s.\n", self.ngroups, self.SpawnTemplatePrefix, self.aircraft.type)
|
text=text..string.format("Spawning %i aircraft from template %s of type %s.\n", self.ngroups, self.SpawnTemplatePrefix, self.aircraft.type)
|
||||||
@ -719,6 +732,17 @@ function RAT:SetDestination(names)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Airports, FARPs and ships explicitly excluded as departures and destinations.
|
||||||
|
-- @param #RAT self
|
||||||
|
-- @param #string ports Name or table of names of excluded airports.
|
||||||
|
function RAT:SetDestinationFromZone(zone)
|
||||||
|
|
||||||
|
-- Random departure is deactivated now that user specified departure ports.
|
||||||
|
self.random_destination=false
|
||||||
|
|
||||||
|
self.destination_Azone=zone
|
||||||
|
end
|
||||||
|
|
||||||
--- Airports, FARPs and ships explicitly excluded as departures and destinations.
|
--- Airports, FARPs and ships explicitly excluded as departures and destinations.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #string ports Name or table of names of excluded airports.
|
-- @param #string ports Name or table of names of excluded airports.
|
||||||
@ -1555,7 +1579,7 @@ function RAT:_PickDeparture(takeoff)
|
|||||||
|
|
||||||
-- All airports specified by user
|
-- All airports specified by user
|
||||||
for _,name in pairs(self.departure_ports) do
|
for _,name in pairs(self.departure_ports) do
|
||||||
if not self:_Excluded(name) then
|
if self:_IsFriendly(name) and not self:_Excluded(name) then
|
||||||
table.insert(departures, AIRBASE:FindByName(name))
|
table.insert(departures, AIRBASE:FindByName(name))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1591,23 +1615,6 @@ end
|
|||||||
-- @param #boolean _random (Optional) Switch to activate a random selection of airports.
|
-- @param #boolean _random (Optional) Switch to activate a random selection of airports.
|
||||||
-- @return Wrapper.Airbase#AIRBASE Destination airport.
|
-- @return Wrapper.Airbase#AIRBASE Destination airport.
|
||||||
function RAT:_PickDestination(destinations, _random)
|
function RAT:_PickDestination(destinations, _random)
|
||||||
|
|
||||||
--[[
|
|
||||||
-- Take destinations from user input.
|
|
||||||
if not (self.random_destination or _random) then
|
|
||||||
|
|
||||||
destinations=nil
|
|
||||||
destinations={}
|
|
||||||
|
|
||||||
-- All airports specified by user.
|
|
||||||
for _,name in pairs(self.destination_ports) do
|
|
||||||
if not self:_Excluded(name) then
|
|
||||||
table.insert(destinations, AIRBASE:FindByName(name))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
]]
|
|
||||||
|
|
||||||
-- Randomly select one possible destination.
|
-- Randomly select one possible destination.
|
||||||
local destination=nil
|
local destination=nil
|
||||||
@ -1702,6 +1709,23 @@ function RAT:_GetDestinations(departure, q, minrange, maxrange)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Find airports within a zone.
|
||||||
|
-- @param #RAT self
|
||||||
|
-- @param Core.Zone#ZONE zone
|
||||||
|
-- @return #list Table with airport names that lie within the zone.
|
||||||
|
function RAT:_GetAirportsInZone(zone)
|
||||||
|
local airports={}
|
||||||
|
for _,airport in self.airports do
|
||||||
|
local name=airport:GetName()
|
||||||
|
local coord=airport:GetCoordinate()
|
||||||
|
|
||||||
|
if zone:IsPointVec3InZone(coord) then
|
||||||
|
table.insert(airports, name)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return airports
|
||||||
|
end
|
||||||
|
|
||||||
--- Check if airport is excluded from possible departures and destinations.
|
--- Check if airport is excluded from possible departures and destinations.
|
||||||
-- @param #RAT self
|
-- @param #RAT self
|
||||||
-- @param #string port Name of airport, FARP or ship to check.
|
-- @param #string port Name of airport, FARP or ship to check.
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user