Skip to content

Commit

Permalink
OPS
Browse files Browse the repository at this point in the history
- Added method to reduce asset count for cohorts #2103
- Added tacview on legion level
  • Loading branch information
funkyfranky committed Jul 7, 2024
1 parent f74c0e2 commit 1a0e2e0
Show file tree
Hide file tree
Showing 5 changed files with 101 additions and 2 deletions.
3 changes: 3 additions & 0 deletions Moose Development/Moose/Ops/AirWing.lua
Original file line number Diff line number Diff line change
Expand Up @@ -1041,6 +1041,9 @@ function AIRWING:onafterStatus(From, Event, To)

-- Check Recon missions.
self:CheckRECON()

-- Display tactival overview.
self:_TacticalOverview()

----------------
-- Transport ---
Expand Down
3 changes: 3 additions & 0 deletions Moose Development/Moose/Ops/Brigade.lua
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ function BRIGADE:onafterStatus(From, Event, To)
-- Info ---
-----------

-- Display tactival overview.
self:_TacticalOverview()

-- General info:
if self.verbose>=1 then

Expand Down
36 changes: 35 additions & 1 deletion Moose Development/Moose/Ops/Cohort.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 3 additions & 0 deletions Moose Development/Moose/Ops/Fleet.lua
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,9 @@ function FLEET:onafterStatus(From, Event, To)
-- Info ---
-----------

-- Display tactival overview.
self:_TacticalOverview()

-- General info:
if self.verbose>=1 then

Expand Down
58 changes: 57 additions & 1 deletion Moose Development/Moose/Ops/Legion.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1a0e2e0

Please sign in to comment.