From 1a0e2e0ea1f7d770d0897247f47e0b43dcae2908 Mon Sep 17 00:00:00 2001 From: Frank Date: Sun, 7 Jul 2024 23:15:20 +0200 Subject: [PATCH] OPS - Added method to reduce asset count for cohorts #2103 - Added tacview on legion level --- Moose Development/Moose/Ops/AirWing.lua | 3 ++ Moose Development/Moose/Ops/Brigade.lua | 3 ++ Moose Development/Moose/Ops/Cohort.lua | 36 ++++++++++++++- Moose Development/Moose/Ops/Fleet.lua | 3 ++ Moose Development/Moose/Ops/Legion.lua | 58 ++++++++++++++++++++++++- 5 files changed, 101 insertions(+), 2 deletions(-) diff --git a/Moose Development/Moose/Ops/AirWing.lua b/Moose Development/Moose/Ops/AirWing.lua index 1d2188ba4..1282c9193 100644 --- a/Moose Development/Moose/Ops/AirWing.lua +++ b/Moose Development/Moose/Ops/AirWing.lua @@ -1041,6 +1041,9 @@ function AIRWING:onafterStatus(From, Event, To) -- Check Recon missions. self:CheckRECON() + + -- Display tactival overview. + self:_TacticalOverview() ---------------- -- Transport --- diff --git a/Moose Development/Moose/Ops/Brigade.lua b/Moose Development/Moose/Ops/Brigade.lua index 76e442df3..b8382f136 100644 --- a/Moose Development/Moose/Ops/Brigade.lua +++ b/Moose Development/Moose/Ops/Brigade.lua @@ -491,6 +491,9 @@ function BRIGADE:onafterStatus(From, Event, To) -- Info --- ----------- + -- Display tactival overview. + self:_TacticalOverview() + -- General info: if self.verbose>=1 then diff --git a/Moose Development/Moose/Ops/Cohort.lua b/Moose Development/Moose/Ops/Cohort.lua index 0d25c9c5d..b77f8978c 100644 --- a/Moose Development/Moose/Ops/Cohort.lua +++ b/Moose Development/Moose/Ops/Cohort.lua @@ -577,7 +577,7 @@ function COHORT:AddAsset(Asset) return self end ---- Remove asset from chort. +--- Remove specific asset from chort. -- @param #COHORT self -- @param Functional.Warehouse#WAREHOUSE.Assetitem Asset The asset. -- @return #COHORT self @@ -609,6 +609,40 @@ function COHORT:DelGroup(GroupName) return self end +--- Remove assets from pool. Not that assets must not be spawned or already reserved or requested. +-- @param #COHORT self +-- @param #number N Number of assets to be removed. Default 1. +-- @return #COHORT self +function COHORT:RemoveAssets(N) + self:T2(self.lid..string.format("Remove %d assets of Cohort", N)) + + N=N or 1 + + local n=0 + for i=#self.assets,1,-1 do + local asset=self.assets[i] --Functional.Warehouse#WAREHOUSE.Assetitem + + self:T2(self.lid..string.format("Checking removing asset %s", asset.spawngroupname)) + if not (asset.requested or asset.spawned or asset.isReserved) then + self:T2(self.lid..string.format("Removing asset %s", asset.spawngroupname)) + table.remove(self.assets, i) + n=n+1 + else + self:T2(self.lid..string.format("Could NOT Remove asset %s", asset.spawngroupname)) + end + + if n>=N then + break + end + + end + + self:T(self.lid..string.format("Removed %d/%d assets. New asset count=%d", n, N, #self.assets)) + + return self +end + + --- Get name of the cohort. -- @param #COHORT self -- @return #string Name of the cohort. diff --git a/Moose Development/Moose/Ops/Fleet.lua b/Moose Development/Moose/Ops/Fleet.lua index 050d06c9c..22d465164 100644 --- a/Moose Development/Moose/Ops/Fleet.lua +++ b/Moose Development/Moose/Ops/Fleet.lua @@ -334,6 +334,9 @@ function FLEET:onafterStatus(From, Event, To) -- Info --- ----------- + -- Display tactival overview. + self:_TacticalOverview() + -- General info: if self.verbose>=1 then diff --git a/Moose Development/Moose/Ops/Legion.lua b/Moose Development/Moose/Ops/Legion.lua index 69c620dd1..99a2eeac1 100644 --- a/Moose Development/Moose/Ops/Legion.lua +++ b/Moose Development/Moose/Ops/Legion.lua @@ -21,6 +21,7 @@ -- @field #table cohorts Cohorts of this legion. -- @field Ops.Commander#COMMANDER commander Commander of this legion. -- @field Ops.Chief#CHIEF chief Chief of this legion. +-- @field #boolean tacview If `true`, show tactical overview on status update. -- @extends Functional.Warehouse#WAREHOUSE --- *Per aspera ad astra.* @@ -322,6 +323,14 @@ function LEGION:SetVerbosity(VerbosityLevel) return self end +--- Set tactical overview on. +-- @param #LEGION self +-- @return #LEGION self +function LEGION:SetTacticalOverviewOn() + self.tacview=true + return self +end + --- Add a mission for the legion. It will pick the best available assets for the mission and lauch it when ready. -- @param #LEGION self -- @param Ops.Auftrag#AUFTRAG Mission Mission for this legion. @@ -1772,7 +1781,7 @@ end -- Mission Functions ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- ---- Create a new flight group after an asset was spawned. +--- Create a new OPS group after an asset was spawned. -- @param #LEGION self -- @param Functional.Warehouse#WAREHOUSE.Assetitem asset The asset. -- @return Ops.FlightGroup#FLIGHTGROUP The created flightgroup object. @@ -1836,6 +1845,53 @@ function LEGION:_CreateFlightGroup(asset) return opsgroup end +--- Display tactical overview. +-- @param #LEGION self +function LEGION:_TacticalOverview() + + if self.tacview then + + local NassetsTotal=self:CountAssets(nil) + local NassetsStock=self:CountAssets(true) + local NassetsActiv=self:CountAssets(false) + + local NmissionsTotal=#self.missionqueue + local NmissionsRunni=self:CountMissionsInQueue() + + -- Info message + local text=string.format("Tactical Overview %s\n", self.alias) + text=text..string.format("===================================\n") + + -- Asset info. + text=text..string.format("Assets: %d [Active=%d, Stock=%d]\n", NassetsTotal, NassetsActiv, NassetsStock) + + -- Mission info. + text=text..string.format("Missions: %d [Running=%d]\n", NmissionsTotal, NmissionsRunni) + for _,mtype in pairs(AUFTRAG.Type) do + local n=self:CountMissionsInQueue(mtype) + if n>0 then + local N=self:CountMissionsInQueue(mtype) + text=text..string.format(" - %s: %d [Running=%d]\n", mtype, n, N) + end + end + + + local Ntransports=#self.transportqueue + if Ntransports>0 then + text=text..string.format("Transports: %d\n", Ntransports) + for _,_transport in pairs(self.transportqueue) do + local transport=_transport --Ops.OpsTransport#OPSTRANSPORT + text=text..string.format(" - %s", transport:GetState()) + end + end + + -- Message to coalition. + MESSAGE:New(text, 60, nil, true):ToCoalition(self:GetCoalition()) + + + end + +end --- Check if an asset is currently on a mission (STARTED or EXECUTING). -- @param #LEGION self