From 4ec757d87a8f6f929a9c4e04f72e5f1bd4d784c4 Mon Sep 17 00:00:00 2001 From: Frank Date: Wed, 29 Jan 2020 22:52:06 +0100 Subject: [PATCH] FGFC --- Moose Development/Moose/Ops/FlightControl.lua | 1 + Moose Development/Moose/Ops/FlightGroup.lua | 63 +++++++++---------- Moose Development/Moose/Wrapper/Group.lua | 2 +- 3 files changed, 31 insertions(+), 35 deletions(-) diff --git a/Moose Development/Moose/Ops/FlightControl.lua b/Moose Development/Moose/Ops/FlightControl.lua index d8982abcf..7c9d44149 100644 --- a/Moose Development/Moose/Ops/FlightControl.lua +++ b/Moose Development/Moose/Ops/FlightControl.lua @@ -1760,6 +1760,7 @@ function FLIGHTCONTROL:_CheckFlights() --TODO: check parking? + -- NOTE: This is now done in FLIGHTGROUP! -- Check if parking flights started to taxi. for _,_flight in pairs(self.Qparking) do local flight=_flight --Ops.FlightGroup#FLIGHTGROUP diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index d1a5cadfc..5bc04c369 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -896,27 +896,31 @@ function FLIGHTGROUP:onafterStart(From, Event, To) -- Check if the group is already alive and if so, add its elements. local group=GROUP:FindByName(self.groupname) - if group and group:IsAlive() then + + if group then -- Set group object. - self.group=group + self.group=group + + if group:IsAlive() then - -- Get units of group. - local units=group:GetUnits() + -- Get units of group. + local units=group:GetUnits() + + -- Debug info. + self:I(self.lid..string.format("FF Found alive group %s at start with %d units", group:GetName(), #units)) + + -- Add elemets. + for _,unit in pairs(units) do + local element=self:AddElementByName(unit:GetName()) + end + + -- Trigger spawned event for all elements. + for _,element in pairs(self.elements) do + -- Add a little delay or the OnAfterSpawned function is not even initialized and will not be called. + self:__ElementSpawned(0.1, element) + end - -- Debug info. - self:I(self.lid..string.format("FF Found alive group %s at start with %d units", group:GetName(), #units)) - - - -- Add elemets. - for _,unit in pairs(units) do - local element=self:AddElementByName(unit:GetName()) - end - - -- Trigger spawned event for all elements. - for _,element in pairs(self.elements) do - -- Add a little delay or the OnAfterSpawned function is not even initialized and will not be called. - self:__ElementSpawned(0.1, element) end end @@ -1179,8 +1183,8 @@ function FLIGHTGROUP:OnEventBirth(EventData) end -- Set element to spawned state. - self:T(self.lid..string.format("EVENT: Element %s born ==> spawned", element.name)) - self:ElementSpawned(element) + self:I(self.lid..string.format("EVENT: Element %s born ==> spawned", element.name)) + self:__ElementSpawned(0.1, element) end @@ -1378,7 +1382,7 @@ end -- @param #string To To state. -- @param #FLIGHTGROUP.Element Element The flight group element. function FLIGHTGROUP:onafterElementSpawned(From, Event, To, Element) - self:T(self.lid..string.format("Element spawned %s.", Element.name)) + self:I(self.lid..string.format("Element spawned %s", Element.name)) -- Set element status. self:_UpdateStatus(Element, FLIGHTGROUP.ElementStatus.SPAWNED) @@ -1606,7 +1610,6 @@ end --- On after "FlightParking" event. Add flight to flightcontrol of airbase. -- @param #FLIGHTGROUP self --- @param Wrapper.Group#GROUP Group Flight group. -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. @@ -1640,7 +1643,6 @@ end --- On after "FlightTaxiing" event. -- @param #FLIGHTGROUP self --- @param Wrapper.Group#GROUP Group Flight group. -- @param #string From From state. -- @param #string Event Event. -- @param #string To To state. @@ -3209,7 +3211,7 @@ function FLIGHTGROUP:_AllSimilarStatus(status) end -- Debug info. - self:T2(self.lid..string.format("All similar status %s ==> returning TRUE", status)) + self:I(self.lid..string.format("All %d elements have similar status %s ==> returning TRUE", #self.elements, status)) return true end @@ -3235,15 +3237,7 @@ function FLIGHTGROUP:_UpdateStatus(element, newstatus, airbase) if self:_AllSimilarStatus(newstatus) then self:FlightSpawned() end - - --[[ - if element.unit:InAir() then - self:ElementAirborne(element) - else - self:ElementParking(element) - end - ]] - + elseif newstatus==FLIGHTGROUP.ElementStatus.PARKING then --- -- PARKING @@ -3285,7 +3279,8 @@ function FLIGHTGROUP:_UpdateStatus(element, newstatus, airbase) --- if self:_AllSimilarStatus(newstatus) then - + self:FlightAirborne() + --[[ if self:IsTaxiing() then self:FlightAirborne() elseif self:IsParking() then @@ -3296,7 +3291,7 @@ function FLIGHTGROUP:_UpdateStatus(element, newstatus, airbase) --self:FlightTaxiing() self:FlightAirborne() end - + ]] end elseif newstatus==FLIGHTGROUP.ElementStatus.LANDED then diff --git a/Moose Development/Moose/Wrapper/Group.lua b/Moose Development/Moose/Wrapper/Group.lua index e67a38581..8330da417 100644 --- a/Moose Development/Moose/Wrapper/Group.lua +++ b/Moose Development/Moose/Wrapper/Group.lua @@ -810,7 +810,7 @@ end function GROUP:Activate() self:F2( { self.GroupName } ) trigger.action.activateGroup( self:GetDCSObject() ) - return self:GetDCSObject() + return self end