From 322e079486067ea68b6fe041977c4c70afc4fe4c Mon Sep 17 00:00:00 2001 From: Frank Date: Mon, 18 May 2020 10:26:48 +0200 Subject: [PATCH] Refactoring --- Moose Development/Moose/Ops/FlightGroup.lua | 16 ++++++++++------ Moose Development/Moose/Ops/NavyGroup.lua | 13 +++++++------ 2 files changed, 17 insertions(+), 12 deletions(-) diff --git a/Moose Development/Moose/Ops/FlightGroup.lua b/Moose Development/Moose/Ops/FlightGroup.lua index 7430c6f6d..f48df70fe 100644 --- a/Moose Development/Moose/Ops/FlightGroup.lua +++ b/Moose Development/Moose/Ops/FlightGroup.lua @@ -257,12 +257,6 @@ function FLIGHTGROUP:New(groupname, autostart) -- Holding flag. self.flaghold=USERFLAG:New(string.format("%s_FlagHold", self.groupname)) self.flaghold:Set(0) - - -- Init waypoints. - self:InitWaypoints() - - -- Initialize group. - self:_InitGroup() -- Add FSM transitions. -- From State --> Event --> To State @@ -345,6 +339,12 @@ function FLIGHTGROUP:New(groupname, autostart) self:HandleEvent(EVENTS.Crash, self.OnEventCrash) self:HandleEvent(EVENTS.RemoveUnit, self.OnEventRemoveUnit) + -- Init waypoints. + self:InitWaypoints() + + -- Initialize group. + self:_InitGroup() + -- Start the status monitoring. self:__CheckZone(-1) self:__Status(-2) @@ -2616,6 +2616,10 @@ function FLIGHTGROUP:AddElementByName(unitname) -- Add element to table. table.insert(self.elements, element) + + if unit:IsAlive() then + self:ElementSpawned(element) + end return element end diff --git a/Moose Development/Moose/Ops/NavyGroup.lua b/Moose Development/Moose/Ops/NavyGroup.lua index 2499b9aba..d3fb34236 100644 --- a/Moose Development/Moose/Ops/NavyGroup.lua +++ b/Moose Development/Moose/Ops/NavyGroup.lua @@ -67,12 +67,6 @@ function NAVYGROUP:New(GroupName) -- Set some string id for output to DCS.log file. self.lid=string.format("NAVYGROUP %s | ", self.groupname) - -- Init waypoints. - self:InitWaypoints() - - -- Initialize the group. - self:_InitGroup() - -- Defaults self:SetDefaultROE() self:SetDetection() @@ -100,6 +94,13 @@ function NAVYGROUP:New(GroupName) -- TODO: Add pseudo functions. + + -- Init waypoints. + self:InitWaypoints() + + -- Initialize the group. + self:_InitGroup() + -- Debug trace. if false then self.Debug=true