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!
-- @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)
-- Place.
+30 -12
View File
@@ -1756,28 +1756,41 @@ function AIRWING:GetAssetsOnMission(MissionTypes, IncludeQueued)
return assets
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.
-- @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.
function AIRWING:GetAircraftTypes(onlyactive)
function AIRWING:GetAircraftTypes(onlyactive, squadrons)
-- Get all unit types that can do the job.
local unittypes={}
-- 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 gotit=false
for _,unittype in pairs(unittypes) do
if squadron.aircrafttype==unittype then
gotit=true
break
if (not onlyactive) or squadron:IsOnDuty() then
local gotit=false
for _,unittype in pairs(unittypes) do
if squadron.aircrafttype==unittype then
gotit=true
break
end
end
end
if not gotit then
table.insert(unittypes, squadron.aircrafttype)
if not gotit then
table.insert(unittypes, squadron.aircrafttype)
end
end
end
@@ -1795,8 +1808,13 @@ function AIRWING:CanMission(Mission)
local Can=true
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)
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.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 #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 #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 #number missionAltitude Mission altitude in meters.
@@ -303,13 +303,13 @@ AUFTRAG.TargetType={
--- AUFTRAG class version.
-- @field #string version
AUFTRAG.version="0.1.0"
AUFTRAG.version="0.1.1"
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-- 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: Add mission start conditions.
-- TODO: Add recovery tanker mission for boat ops.
@@ -1130,6 +1130,21 @@ function AUFTRAG:SetROT(rot)
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.
-- @param #AUFTRAG self
-- @param Ops.FlightGroup#FLIGHTGROUP FlightGroup The FLIGHTGROUP object.
@@ -1213,6 +1228,13 @@ function AUFTRAG:IsDone()
return self.status==AUFTRAG.Status.DONE
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.
-- @param #AUFTRAG self
-- @return #boolean If true, mission is currently executing.
+2 -2
View File
@@ -577,13 +577,13 @@ function SQUADRON:CanMission(Mission)
-- On duty?=
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
end
-- 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
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
end