mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
#EASYGCICAP - use onbefore on foreign classes rather than OnAfter to avoid user overwrites
This commit is contained in:
parent
f05680f23d
commit
d4e141f3c5
@ -252,7 +252,7 @@ EASYGCICAP = {
|
|||||||
|
|
||||||
--- EASYGCICAP class version.
|
--- EASYGCICAP class version.
|
||||||
-- @field #string version
|
-- @field #string version
|
||||||
EASYGCICAP.version="0.1.16"
|
EASYGCICAP.version="0.1.17"
|
||||||
|
|
||||||
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
-- TODO list
|
-- TODO list
|
||||||
@ -348,9 +348,23 @@ function EASYGCICAP:SetTankerAndAWACSInvisible(Switch)
|
|||||||
return self
|
return self
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Set Maximum of alive missions to stop airplanes spamming the map
|
--- Count alive missions in our internal stack.
|
||||||
-- @param #EASYGCICAP self
|
-- @param #EASYGCICAP self
|
||||||
-- @param #number Maxiumum Maxmimum number of parallel missions allowed. Count is Cap-Missions + Intercept-Missions + Alert5-Missionsm default is 6
|
-- @return #number count
|
||||||
|
function EASYGCICAP:_CountAliveAuftrags()
|
||||||
|
local alive = 0
|
||||||
|
for _,_auftrag in pairs(self.ListOfAuftrag) do
|
||||||
|
local auftrag = _auftrag -- Ops.Auftrag#AUFTRAG
|
||||||
|
if auftrag and (not (auftrag:IsCancelled() or auftrag:IsDone() or auftrag:IsOver())) then
|
||||||
|
alive = alive + 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return alive
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Set Maximum of alive missions created by this instance to stop airplanes spamming the map
|
||||||
|
-- @param #EASYGCICAP self
|
||||||
|
-- @param #number Maxiumum Maxmimum number of parallel missions allowed. Count is Intercept-Missions + Alert5-Missions, default is 8
|
||||||
-- @return #EASYGCICAP self
|
-- @return #EASYGCICAP self
|
||||||
function EASYGCICAP:SetMaxAliveMissions(Maxiumum)
|
function EASYGCICAP:SetMaxAliveMissions(Maxiumum)
|
||||||
self:T(self.lid.."SetMaxAliveMissions")
|
self:T(self.lid.."SetMaxAliveMissions")
|
||||||
@ -585,7 +599,7 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias)
|
|||||||
|
|
||||||
local TankerInvisible = self.TankerInvisible
|
local TankerInvisible = self.TankerInvisible
|
||||||
|
|
||||||
function CAP_Wing:OnAfterFlightOnMission(From, Event, To, Flightgroup, Mission)
|
function CAP_Wing:onbeforeFlightOnMission(From, Event, To, Flightgroup, Mission)
|
||||||
local flightgroup = Flightgroup -- Ops.FlightGroup#FLIGHTGROUP
|
local flightgroup = Flightgroup -- Ops.FlightGroup#FLIGHTGROUP
|
||||||
if DespawnAfterLanding then
|
if DespawnAfterLanding then
|
||||||
flightgroup:SetDespawnAfterLanding()
|
flightgroup:SetDespawnAfterLanding()
|
||||||
@ -615,7 +629,7 @@ function EASYGCICAP:_AddAirwing(Airbasename, Alias)
|
|||||||
flightgroup:SetFuelLowRTB(true)
|
flightgroup:SetFuelLowRTB(true)
|
||||||
Intel:AddAgent(flightgroup)
|
Intel:AddAgent(flightgroup)
|
||||||
if DespawnAfterHolding then
|
if DespawnAfterHolding then
|
||||||
function flightgroup:OnAfterHolding(From,Event,To)
|
function flightgroup:onbeforeHolding(From,Event,To)
|
||||||
self:Despawn(1,true)
|
self:Despawn(1,true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -1177,7 +1191,7 @@ function EASYGCICAP:_AssignIntercept(Cluster)
|
|||||||
|
|
||||||
local wings = self.wings
|
local wings = self.wings
|
||||||
local ctlpts = self.ManagedCP
|
local ctlpts = self.ManagedCP
|
||||||
local MaxAliveMissions = self.MaxAliveMissions * self.capgrouping
|
local MaxAliveMissions = self.MaxAliveMissions --* self.capgrouping
|
||||||
local nogozoneset = self.NoGoZoneSet
|
local nogozoneset = self.NoGoZoneSet
|
||||||
local ReadyFlightGroups = self.ReadyFlightGroups
|
local ReadyFlightGroups = self.ReadyFlightGroups
|
||||||
|
|
||||||
@ -1242,9 +1256,10 @@ function EASYGCICAP:_AssignIntercept(Cluster)
|
|||||||
-- Do we have a matching airwing?
|
-- Do we have a matching airwing?
|
||||||
if targetairwing then
|
if targetairwing then
|
||||||
local AssetCount = targetairwing:CountAssetsOnMission(MissionTypes,Cohort)
|
local AssetCount = targetairwing:CountAssetsOnMission(MissionTypes,Cohort)
|
||||||
|
local missioncount = self:_CountAliveAuftrags()
|
||||||
-- Enough airframes on mission already?
|
-- Enough airframes on mission already?
|
||||||
self:T(self.lid.." Assets on Mission "..AssetCount)
|
self:T(self.lid.." Assets on Mission "..AssetCount)
|
||||||
if AssetCount <= MaxAliveMissions then
|
if missioncount < MaxAliveMissions then
|
||||||
local repeats = repeatsonfailure
|
local repeats = repeatsonfailure
|
||||||
local InterceptAuftrag = AUFTRAG:NewINTERCEPT(contact.group)
|
local InterceptAuftrag = AUFTRAG:NewINTERCEPT(contact.group)
|
||||||
:SetMissionRange(150)
|
:SetMissionRange(150)
|
||||||
@ -1312,7 +1327,7 @@ function EASYGCICAP:_StartIntel()
|
|||||||
self:_AssignIntercept(Cluster)
|
self:_AssignIntercept(Cluster)
|
||||||
end
|
end
|
||||||
|
|
||||||
function BlueIntel:OnAfterNewCluster(From,Event,To,Cluster)
|
function BlueIntel:onbeforeNewCluster(From,Event,To,Cluster)
|
||||||
AssignCluster(Cluster)
|
AssignCluster(Cluster)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1429,12 +1444,14 @@ function EASYGCICAP:onafterStatus(From,Event,To)
|
|||||||
local text = "GCICAP "..self.alias
|
local text = "GCICAP "..self.alias
|
||||||
text = text.."\nWings: "..wings.."\nSquads: "..squads.."\nCapPoints: "..caps.."\nAssets on Mission: "..assets.."\nAssets in Stock: "..instock
|
text = text.."\nWings: "..wings.."\nSquads: "..squads.."\nCapPoints: "..caps.."\nAssets on Mission: "..assets.."\nAssets in Stock: "..instock
|
||||||
text = text.."\nThreats: "..threatcount
|
text = text.."\nThreats: "..threatcount
|
||||||
text = text.."\nMissions: "..capmission+interceptmission
|
text = text.."\nAirWing managed Missions: "..capmission+awacsmission+tankermission+reconmission
|
||||||
text = text.."\n - CAP: "..capmission
|
text = text.."\n - CAP: "..capmission
|
||||||
text = text.."\n - Intercept: "..interceptmission
|
|
||||||
text = text.."\n - AWACS: "..awacsmission
|
text = text.."\n - AWACS: "..awacsmission
|
||||||
text = text.."\n - TANKER: "..tankermission
|
text = text.."\n - TANKER: "..tankermission
|
||||||
text = text.."\n - Recon: "..reconmission
|
text = text.."\n - Recon: "..reconmission
|
||||||
|
text = text.."\nSelf managed Missions:"
|
||||||
|
text = text.."\n - Mission Limit: "..self.MaxAliveMissions
|
||||||
|
text = text.."\n - Alert5+Intercept "..self:_CountAliveAuftrags()
|
||||||
MESSAGE:New(text,15,"GCICAP"):ToAll():ToLogIf(self.debug)
|
MESSAGE:New(text,15,"GCICAP"):ToAll():ToLogIf(self.debug)
|
||||||
end
|
end
|
||||||
self:__Status(30)
|
self:__Status(30)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user