mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2026-08-22 05:52:54 +00:00
Update FlightGroup.lua
This commit is contained in:
@@ -904,7 +904,7 @@ end
|
|||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
-- @return Core.Point#COORDINATE The coordinate (of the first unit) of the group.
|
-- @return Core.Point#COORDINATE The coordinate (of the first unit) of the group.
|
||||||
function FLIGHTGROUP:GetCoordinate()
|
function FLIGHTGROUP:GetCoordinate()
|
||||||
if self:IsAlive() then
|
if self:IsAlive()~=nil then
|
||||||
return self.group:GetCoordinate()
|
return self.group:GetCoordinate()
|
||||||
else
|
else
|
||||||
self:E(self.lid.."WARNING: Group is not alive. Cannot get coordinate!")
|
self:E(self.lid.."WARNING: Group is not alive. Cannot get coordinate!")
|
||||||
@@ -1376,9 +1376,7 @@ function FLIGHTGROUP:onafterStop(From, Event, To)
|
|||||||
if self.flightcontrol then
|
if self.flightcontrol then
|
||||||
for _,_element in pairs(self.elements) do
|
for _,_element in pairs(self.elements) do
|
||||||
local element=_element --#FLIGHTGROUP.Element
|
local element=_element --#FLIGHTGROUP.Element
|
||||||
if element.parking then
|
self:_SetElementParkingFree(element)
|
||||||
self.flightcontrol:SetParkingFree(element.parking)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -1996,7 +1994,7 @@ function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element)
|
|||||||
if spot then
|
if spot then
|
||||||
|
|
||||||
-- Set
|
-- Set
|
||||||
Element.parking=spot
|
self:_SetElementParkingAt(Element, spot)
|
||||||
|
|
||||||
-- Trigger ElementParking event. Add a little delay because spawn is also delayed!
|
-- Trigger ElementParking event. Add a little delay because spawn is also delayed!
|
||||||
self:__ElementParking(0.11, Element)
|
self:__ElementParking(0.11, Element)
|
||||||
@@ -2056,13 +2054,8 @@ function FLIGHTGROUP:onafterElementTaxiing(From, Event, To, Element)
|
|||||||
-- Debug info.
|
-- Debug info.
|
||||||
self:I(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID))
|
self:I(self.lid..string.format("Element taxiing %s. Parking spot %s is now free", Element.name, TerminalID))
|
||||||
|
|
||||||
-- Set parking to FREE.
|
-- Set parking spot to free. Also for FC.
|
||||||
if self.flightcontrol and Element.parking then
|
self:_SetElementParkingFree(Element)
|
||||||
self.flightcontrol:SetParkingFree(Element.parking)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Not parking any more.
|
|
||||||
Element.parking=nil
|
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.TAXIING)
|
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.TAXIING)
|
||||||
@@ -2076,7 +2069,12 @@ end
|
|||||||
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
-- @param #FLIGHTGROUP.Element Element The flight group element.
|
||||||
-- @param Wrapper.Airbase#AIRBASE airbase The airbase if applicable or nil.
|
-- @param Wrapper.Airbase#AIRBASE airbase The airbase if applicable or nil.
|
||||||
function FLIGHTGROUP:onafterElementTakeoff(From, Event, To, Element, airbase)
|
function FLIGHTGROUP:onafterElementTakeoff(From, Event, To, Element, airbase)
|
||||||
self:T(self.lid..string.format("Element takeoff %s at %s airbase.", Element.name, airbase and airbase:GetName() or "unknown"))
|
self:I(self.lid..string.format("Element takeoff %s at %s airbase.", Element.name, airbase and airbase:GetName() or "unknown"))
|
||||||
|
|
||||||
|
-- Helos with skids just take off without taxiing!
|
||||||
|
if Element.parking then
|
||||||
|
self:_SetElementParkingFree(Element)
|
||||||
|
end
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.TAKEOFF, airbase)
|
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.TAKEOFF, airbase)
|
||||||
@@ -2123,21 +2121,7 @@ end
|
|||||||
function FLIGHTGROUP:onafterElementArrived(From, Event, To, Element, airbase, Parking)
|
function FLIGHTGROUP:onafterElementArrived(From, Event, To, Element, airbase, Parking)
|
||||||
self:T(self.lid..string.format("Element arrived %s at %s airbase using parking spot %d", Element.name, airbase and airbase:GetName() or "unknown", Parking and Parking.TerminalID or -99))
|
self:T(self.lid..string.format("Element arrived %s at %s airbase using parking spot %d", Element.name, airbase and airbase:GetName() or "unknown", Parking and Parking.TerminalID or -99))
|
||||||
|
|
||||||
|
self:_SetElementParkingAt(Element, Parking)
|
||||||
-- Get parking spot
|
|
||||||
--local parking=self:GetParkingSpot(Element, 10, self.flightcontrol and self.flightcontrol.airbase or nil)
|
|
||||||
|
|
||||||
-- Element is parking here.
|
|
||||||
Element.parking=Parking
|
|
||||||
|
|
||||||
if Parking then
|
|
||||||
if self.flightcontrol then
|
|
||||||
|
|
||||||
-- Set parking spot to OCCUPIED.
|
|
||||||
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Set element status.
|
-- Set element status.
|
||||||
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.ARRIVED)
|
self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.ARRIVED)
|
||||||
@@ -4818,6 +4802,46 @@ function FLIGHTGROUP:_SetElementStatusAll(status)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
--- Set parking spot of element.
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #FLIGHTGROUP.FlightElement Element The element.
|
||||||
|
-- @param Wrapper.Airbase#AIRBASE.ParkingSpot Spot Parking Spot.
|
||||||
|
function FLIGHTGROUP:_SetElementParkingAt(Element, Spot)
|
||||||
|
|
||||||
|
-- Element is parking here.
|
||||||
|
Element.parking=Spot
|
||||||
|
|
||||||
|
if Spot then
|
||||||
|
if self.flightcontrol then
|
||||||
|
|
||||||
|
-- Set parking spot to OCCUPIED.
|
||||||
|
self.flightcontrol:SetParkingOccupied(Element.parking, Element.name)
|
||||||
|
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set parking spot of element to free
|
||||||
|
-- @param #FLIGHTGROUP self
|
||||||
|
-- @param #FLIGHTGROUP.FlightElement Element The element.
|
||||||
|
function FLIGHTGROUP:_SetElementParkingFree(Element)
|
||||||
|
|
||||||
|
if Element.parking then
|
||||||
|
|
||||||
|
-- Set parking to FREE.
|
||||||
|
if self.flightcontrol and Element.parking then
|
||||||
|
self.flightcontrol:SetParkingFree(Element.parking)
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Not parking any more.
|
||||||
|
Element.parking=nil
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
--- Check if flight is in zones.
|
--- Check if flight is in zones.
|
||||||
-- @param #FLIGHTGROUP self
|
-- @param #FLIGHTGROUP self
|
||||||
function FLIGHTGROUP:_CheckInZones()
|
function FLIGHTGROUP:_CheckInZones()
|
||||||
|
|||||||
Reference in New Issue
Block a user