mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-10-29 16:58:06 +00:00
Merge remote-tracking branch 'origin/develop' into develop
This commit is contained in:
commit
da312cd5ac
@ -2771,7 +2771,10 @@ function AUFTRAG:SetRepeatOnSuccess(Nrepeat)
|
||||
return self
|
||||
end
|
||||
|
||||
--- **[LEGION, COMMANDER, CHIEF]** Set that mission assets get reinforced if their number drops below Nmin.
|
||||
--- **[LEGION, COMMANDER, CHIEF]** Set that mission assets get reinforced if their number drops below the minimum number of required assets of the mission (*c.f.* SetRequiredAssets() function).
|
||||
--
|
||||
-- **Note** that reinforcement groups are only recruited from the legion (airwing, brigade, fleet) the mission was assigned to. If the legion does not have any more of these assets,
|
||||
-- no reinforcement can take place, even if the mission is submitted to a COMMANDER or CHIEF.
|
||||
-- @param #AUFTRAG self
|
||||
-- @param #number Nreinforce Number of max asset groups used to reinforce.
|
||||
-- @return #AUFTRAG self
|
||||
@ -4029,7 +4032,7 @@ function AUFTRAG:onafterStatus(From, Event, To)
|
||||
self:T(self.lid.."No targets left cancelling mission!")
|
||||
self:Cancel()
|
||||
|
||||
elseif self:IsExecuting() and ((not self.reinforce) or (self.reinforce==0 and Nassigned<=0)) then
|
||||
elseif self:IsExecuting() and self:_IsNotReinforcing() then
|
||||
|
||||
-- env.info("Mission Done:")
|
||||
-- env.info(string.format("Nreinforce= %d", self.reinforce or 0))
|
||||
@ -4575,7 +4578,7 @@ function AUFTRAG:CheckGroupsDone()
|
||||
end
|
||||
|
||||
-- Check if there is still reinforcement to be expected.
|
||||
if self:IsExecuting() and self.reinforce and (self.reinforce>0 or self.Nassigned-self.Ndead>0) then
|
||||
if self:IsExecuting() and self:_IsReinforcing() then
|
||||
self:T2(self.lid..string.format("CheckGroupsDone: Mission is still in state %s [FSM=%s] and reinfoce=%d. Mission NOT DONE!", self.status, self:GetState(), self.reinforce))
|
||||
return false
|
||||
end
|
||||
@ -4736,10 +4739,12 @@ function AUFTRAG:onafterAssetDead(From, Event, To, Asset)
|
||||
-- Number of groups alive.
|
||||
local N=self:CountOpsGroups()
|
||||
|
||||
self:T(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d", tostring(Asset.spawngroupname), N))
|
||||
local notreinforcing=self:_IsNotReinforcing()
|
||||
|
||||
self:T(self.lid..string.format("Asset %s dead! Number of ops groups remaining %d (reinforcing=%s)", tostring(Asset.spawngroupname), N, tostring(not notreinforcing)))
|
||||
|
||||
-- All assets dead?
|
||||
if N==0 and (self.reinforce==nil or self.reinforce==0) then
|
||||
if N==0 and notreinforcing then
|
||||
|
||||
if self:IsNotOver() then
|
||||
|
||||
@ -5374,6 +5379,12 @@ function AUFTRAG:AddAsset(Asset)
|
||||
-- Add to table.
|
||||
self.assets=self.assets or {}
|
||||
|
||||
-- Get asset if it was already added.
|
||||
local asset=self:GetAssetByName(Asset.spawngroupname)
|
||||
|
||||
-- Only add an asset is not already in.
|
||||
if not asset then
|
||||
|
||||
-- Add to table.
|
||||
table.insert(self.assets, Asset)
|
||||
|
||||
@ -5381,6 +5392,8 @@ function AUFTRAG:AddAsset(Asset)
|
||||
|
||||
self.Nassigned=self.Nassigned+1
|
||||
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
@ -5658,6 +5671,31 @@ function AUFTRAG:_SetRequestID(Legion, RequestID)
|
||||
return self
|
||||
end
|
||||
|
||||
--- Check if reinforcement is done.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #boolean If `true`, reinforcing is over.
|
||||
function AUFTRAG:_IsNotReinforcing()
|
||||
|
||||
-- Number of assigned assets that are still alive.
|
||||
local Nassigned=self.Nassigned and self.Nassigned-self.Ndead or 0
|
||||
|
||||
-- Not reinforcing?
|
||||
local notreinforcing=((not self.reinforce) or (self.reinforce==0 and Nassigned<=0))
|
||||
|
||||
return notreinforcing
|
||||
end
|
||||
|
||||
--- Check if reinforcement is still ongoing.
|
||||
-- @param #AUFTRAG self
|
||||
-- @return #boolean If `true`, reinforcing is ongoing.
|
||||
function AUFTRAG:_IsReinforcing()
|
||||
|
||||
local reinforcing=not self:_IsNotReinforcing()
|
||||
|
||||
return reinforcing
|
||||
end
|
||||
|
||||
|
||||
|
||||
--- Update mission F10 map marker.
|
||||
-- @param #AUFTRAG self
|
||||
|
||||
@ -1003,6 +1003,7 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission, Assets)
|
||||
|
||||
end
|
||||
|
||||
-- Add asset to mission.
|
||||
Mission:AddAsset(asset)
|
||||
|
||||
-- Trigger event.
|
||||
@ -1054,6 +1055,7 @@ function LEGION:onafterMissionRequest(From, Event, To, Mission, Assets)
|
||||
asset.takeoffType=COORDINATE.WaypointType.TakeOffParking
|
||||
end
|
||||
|
||||
-- Add asset to mission.
|
||||
Mission:AddAsset(asset)
|
||||
|
||||
end
|
||||
|
||||
@ -2930,6 +2930,14 @@ end
|
||||
-- @param #string CarrierGroupName (Optional) Additionally check if group is loaded into a particular carrier group(s).
|
||||
-- @return #boolean If true, group is loaded.
|
||||
function OPSGROUP:IsLoaded(CarrierGroupName)
|
||||
|
||||
local isloaded=self.cargoStatus==OPSGROUP.CargoStatus.LOADED
|
||||
|
||||
-- If not loaded, we can return false
|
||||
if not isloaded then
|
||||
return false
|
||||
end
|
||||
|
||||
if CarrierGroupName then
|
||||
if type(CarrierGroupName)~="table" then
|
||||
CarrierGroupName={CarrierGroupName}
|
||||
@ -2937,12 +2945,14 @@ function OPSGROUP:IsLoaded(CarrierGroupName)
|
||||
for _,CarrierName in pairs(CarrierGroupName) do
|
||||
local carrierGroup=self:_GetMyCarrierGroup()
|
||||
if carrierGroup and carrierGroup.groupname==CarrierName then
|
||||
return true
|
||||
return isloaded
|
||||
end
|
||||
end
|
||||
-- Not in any specified carrier.
|
||||
return false
|
||||
end
|
||||
return self.cargoStatus==OPSGROUP.CargoStatus.LOADED
|
||||
|
||||
return isloaded
|
||||
end
|
||||
|
||||
--- Check if the group is currently busy doing something.
|
||||
@ -10058,7 +10068,6 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
|
||||
-- Trigger Load event.
|
||||
CarrierGroup:Load(self)
|
||||
|
||||
end
|
||||
|
||||
else
|
||||
@ -10069,7 +10078,6 @@ function OPSGROUP:onafterBoard(From, Event, To, CarrierGroup, Carrier)
|
||||
|
||||
-- Set carrier. As long as the group is not loaded, we only reserve the cargo space.�
|
||||
CarrierGroup:_AddCargobay(self, Carrier, true)
|
||||
|
||||
end
|
||||
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user