This commit is contained in:
Frank
2020-04-15 00:45:28 +02:00
parent 2810acc1f4
commit 5a6a9d1aed
4 changed files with 59 additions and 19 deletions
@@ -8491,7 +8491,7 @@ end
--- Fireworks! --- Fireworks!
-- @param #WAREHOUSE self -- @param #WAREHOUSE self
-- @param Core.Point#COORDINATE coord -- @param Core.Point#COORDINATE coord Coordinate where to ignite the fireworks. Default is at the warehouse position.
function WAREHOUSE:_Fireworks(coord) function WAREHOUSE:_Fireworks(coord)
-- Place. -- Place.
+31 -13
View File
@@ -1756,28 +1756,41 @@ function AIRWING:GetAssetsOnMission(MissionTypes, IncludeQueued)
return assets return assets
end end
--- Check
-- @param #AIRWING self
-- @param #boolean onlyactive Count only the active ones.
-- @return #table Table of unit types.
function AIRWING:_CheckSquads(onlyactive)
end
--- Get the aircraft types of this airwing. --- Get the aircraft types of this airwing.
-- @param #AIRWING self -- @param #AIRWING self
-- @return #boolean onlyactive Count only the active ones. -- @param #boolean onlyactive Count only the active ones.
-- @param #table squadrons Table of squadrons. Default all.
-- @return #table Table of unit types. -- @return #table Table of unit types.
function AIRWING:GetAircraftTypes(onlyactive) function AIRWING:GetAircraftTypes(onlyactive, squadrons)
-- Get all unit types that can do the job. -- Get all unit types that can do the job.
local unittypes={} local unittypes={}
-- Loop over all squadrons. -- Loop over all squadrons.
for squadname,_squadron in pairs(self.squadrons) do for _,_squadron in pairs(squadrons or self.squadrons) do
local squadron=_squadron --Ops.Squadron#SQUADRON local squadron=_squadron --Ops.Squadron#SQUADRON
local gotit=false if (not onlyactive) or squadron:IsOnDuty() then
for _,unittype in pairs(unittypes) do
if squadron.aircrafttype==unittype then local gotit=false
gotit=true for _,unittype in pairs(unittypes) do
break if squadron.aircrafttype==unittype then
gotit=true
break
end
end end
end if not gotit then
if not gotit then table.insert(unittypes, squadron.aircrafttype)
table.insert(unittypes, squadron.aircrafttype) end
end end
end end
@@ -1794,9 +1807,14 @@ function AIRWING:CanMission(Mission)
-- Assume we CAN and NO assets are available. -- Assume we CAN and NO assets are available.
local Can=true local Can=true
local Assets={} local Assets={}
local unittypes=self:GetAircraftTypes(true)
-- Squadrons for the job. If user assigned to mission or simply all.
local squadrons=Mission.squadrons or self.squadrons
-- Get aircraft unit types for the job.
local unittypes=self:GetAircraftTypes(true, squadrons)
-- Count all payloads in stock.
local Npayloads=self:CountPayloadsInStock(Mission.type, unittypes) local Npayloads=self:CountPayloadsInStock(Mission.type, unittypes)
if Npayloads<Mission.nassets then if Npayloads<Mission.nassets then
+25 -3
View File
@@ -68,11 +68,11 @@
-- --
-- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission. -- @field Ops.WingCommander#WINGCOMMANDER wingcommander The WINGCOMMANDER managing this mission.
-- @field Ops.AirWing#AIRWING airwing The assigned airwing. -- @field Ops.AirWing#AIRWING airwing The assigned airwing.
-- @field #string squadname Name of the assigned Airwing squadron.
-- @field #table assets Airwing Assets assigned for this mission. -- @field #table assets Airwing Assets assigned for this mission.
-- @field #number nassets Number of required assets by the Airwing. -- @field #number nassets Number of required assets by the Airwing.
-- @field #number requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed. -- @field #number requestID The ID of the queued warehouse request. Necessary to cancel the request if the mission was cancelled before the request is processed.
-- @field #boolean cancelContactLost If true, cancel mission if the contact is lost. -- @field #boolean cancelContactLost If true, cancel mission if the contact is lost.
-- @field #table squadrons User specifed airwing squadrons assigned for this mission. Only these will be considered for the job!
-- --
-- @field #string missionTask Mission task. See `ENUMS.MissionTask`. -- @field #string missionTask Mission task. See `ENUMS.MissionTask`.
-- @field #number missionAltitude Mission altitude in meters. -- @field #number missionAltitude Mission altitude in meters.
@@ -303,13 +303,13 @@ AUFTRAG.TargetType={
--- AUFTRAG class version. --- AUFTRAG class version.
-- @field #string version -- @field #string version
AUFTRAG.version="0.1.0" AUFTRAG.version="0.1.1"
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO list -- TODO list
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- TODO: Option to assign mission to a specific squadron. -- TODO: Option to assign mission to specific squadrons (requires an AIRWING).
-- TODO: Option to assign a specific payload for the mission (requires an AIRWING). -- TODO: Option to assign a specific payload for the mission (requires an AIRWING).
-- TODO: Add mission start conditions. -- TODO: Add mission start conditions.
-- TODO: Add recovery tanker mission for boat ops. -- TODO: Add recovery tanker mission for boat ops.
@@ -1130,6 +1130,21 @@ function AUFTRAG:SetROT(rot)
end end
--- Assign airwing squadron(s) to the mission. Only these squads will be considered for the job.
-- @param #AUFTRAG self
-- @param #table Squadrons A table of SQUADRONs or a single SQUADRON object.
-- @return #AUFTRAG self
function AUFTRAG:AssignSquadrons(Squadrons)
if Squadrons:IsInstanceOf("SQUADRON") then
Squadrons={Squadrons}
end
self.squadrons=Squadrons
end
--- Add a flight group to the mission. --- Add a flight group to the mission.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP object. -- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP object.
@@ -1213,6 +1228,13 @@ function AUFTRAG:IsDone()
return self.status==AUFTRAG.Status.DONE return self.status==AUFTRAG.Status.DONE
end end
--- Check if mission was a success.
-- @param #AUFTRAG self
-- @return #boolean If true, mission was successful.
function AUFTRAG:IsSuccess()
return self.status==AUFTRAG.Status.SUCCESS
end
--- Check if mission is over. This could be state DONE or CANCELLED. --- Check if mission is over. This could be state DONE or CANCELLED.
-- @param #AUFTRAG self -- @param #AUFTRAG self
-- @return #boolean If true, mission is currently executing. -- @return #boolean If true, mission is currently executing.
+2 -2
View File
@@ -577,13 +577,13 @@ function SQUADRON:CanMission(Mission)
-- On duty?= -- On duty?=
if not self:IsOnDuty() then if not self:IsOnDuty() then
self:I(self.lid..string.format("Squad in not OnDuty but in state %s", self:GetState())) self:I(self.lid..string.format("Squad in not OnDuty but in state %s. Cannot do mission %s with target %s", self:GetState(), Mission.name, Mission:GetTargetName()))
return false return false
end end
-- Check mission type. WARNING: This assumes that all assets of the squad can do the same mission types! -- Check mission type. WARNING: This assumes that all assets of the squad can do the same mission types!
if not self:CheckMissionType(Mission.type, self:GetMissionTypes()) then if not self:CheckMissionType(Mission.type, self:GetMissionTypes()) then
self:I(self.lid..string.format("INFO: Squad cannot do mission type %s", Mission.type)) self:I(self.lid..string.format("INFO: Squad cannot do mission type %s (%s, %s)", Mission.type, Mission.name, Mission:GetTargetName()))
return false return false
end end