From 43cbc93a965a1db2009603c59e0465d8ae027123 Mon Sep 17 00:00:00 2001 From: funkyfranky Date: Tue, 19 Sep 2017 16:34:37 +0200 Subject: [PATCH] atc --- Moose Development/Moose/Functional/RAT.lua | 52 +++++++++++++++++++++- 1 file changed, 51 insertions(+), 1 deletion(-) diff --git a/Moose Development/Moose/Functional/RAT.lua b/Moose Development/Moose/Functional/RAT.lua index 11473633c..47ef2a361 100644 --- a/Moose Development/Moose/Functional/RAT.lua +++ b/Moose Development/Moose/Functional/RAT.lua @@ -2771,4 +2771,54 @@ function RAT:_ModifySpawnTemplate(waypoints) end end -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- \ No newline at end of file +------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- +-- @module Atc +-- +--- ATC class +-- @type ATC +ATC={ + aircraft={}, + waypoints={}, + departures={}, + destinations={}, + holding={}, +} + + +function ATC:Add(index, group, wp, departure, destination) + self.aircraft[index]=group + self.waypoints[index]=wp + self.departures[index]=departure + self.destinations[index]=destination +end + +function ATC:Status(airports) + local function tally(t) + local freq = {} + for _, v in pairs(t) do + freq[v] = (freq[v] or 0) + 1 + end + return freq + end + + local _destinations=tally(self.sestinations) + for k,v in pairs(_destinations) do + local text=string.format("Destination %s: %d",k,v) + env.info(text) + end + + for i,aircraft in pairs(self.aircraft) do + local hp=self.waypoints[i][5] + local hc={hp.x,hp.alt,hp.y} + local z=ZONE_RADIUS:New("holding", hc:GetVec2(), 3000) + local group=aircraft --Wrapper.Group#GROUP + local holding=group:IsCompletelyInZone(z) + if holding then + table.insert(self.holding[self.destination], group) + end + end + +end + + +