mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
113 lines
3.2 KiB
Lua
113 lines
3.2 KiB
Lua
--- **Tasking** -- The TASK_CARGO models tasks for players to transport @{Cargo}.
|
|
--
|
|
-- 
|
|
--
|
|
-- ===
|
|
-- @module Tasking.Task_Cargo_Transport
|
|
|
|
|
|
do -- TASK_CARGO_TRANSPORT
|
|
|
|
--- The TASK_CARGO_TRANSPORT class
|
|
-- @type TASK_CARGO_TRANSPORT
|
|
-- @extends Tasking.Task_CARGO#TASK_CARGO
|
|
TASK_CARGO_TRANSPORT = {
|
|
ClassName = "TASK_CARGO_TRANSPORT",
|
|
}
|
|
|
|
--- Instantiates a new TASK_CARGO_TRANSPORT.
|
|
-- @param #TASK_CARGO_TRANSPORT self
|
|
-- @param Tasking.Mission#MISSION Mission
|
|
-- @param Core.Set#SET_GROUP SetGroup The set of groups for which the Task can be assigned.
|
|
-- @param #string TaskName The name of the Task.
|
|
-- @param Core.Set#SET_CARGO SetCargo The scope of the cargo to be transported.
|
|
-- @param #string TaskBriefing The Cargo Task briefing.
|
|
-- @return #TASK_CARGO_TRANSPORT self
|
|
function TASK_CARGO_TRANSPORT:New( Mission, SetGroup, TaskName, SetCargo, TaskBriefing )
|
|
local self = BASE:Inherit( self, TASK_CARGO:New( Mission, SetGroup, TaskName, SetCargo, "Transport", TaskBriefing ) ) -- #TASK_CARGO_TRANSPORT
|
|
self:F()
|
|
|
|
Mission:AddTask( self )
|
|
|
|
local Fsm = self:GetUnitProcess()
|
|
|
|
local CargoReport = REPORT:New( "Transport Cargo. The following cargo needs to be transported including initial positions:")
|
|
|
|
SetCargo:ForEachCargo(
|
|
--- @param Core.Cargo#CARGO Cargo
|
|
function( Cargo )
|
|
local CargoType = Cargo:GetType()
|
|
local CargoName = Cargo:GetName()
|
|
local CargoCoordinate = Cargo:GetCoordinate()
|
|
CargoReport:Add( string.format( '- "%s" (%s) at %s', CargoName, CargoType, CargoCoordinate:ToStringMGRS() ) )
|
|
end
|
|
)
|
|
|
|
self:SetBriefing(
|
|
TaskBriefing or
|
|
CargoReport:Text()
|
|
)
|
|
|
|
|
|
return self
|
|
end
|
|
|
|
function TASK_CARGO_TRANSPORT:ReportOrder( ReportGroup )
|
|
|
|
return 0
|
|
end
|
|
|
|
|
|
---
|
|
-- @param #TASK_CARGO_TRANSPORT self
|
|
-- @return #boolean
|
|
function TASK_CARGO_TRANSPORT:IsAllCargoTransported()
|
|
|
|
local CargoSet = self:GetCargoSet()
|
|
local Set = CargoSet:GetSet()
|
|
|
|
local DeployZones = self:GetDeployZones()
|
|
|
|
local CargoDeployed = true
|
|
|
|
-- Loop the CargoSet (so evaluate each Cargo in the SET_CARGO ).
|
|
for CargoID, CargoData in pairs( Set ) do
|
|
local Cargo = CargoData -- Core.Cargo#CARGO
|
|
|
|
self:F( { Cargo = Cargo:GetName(), CargoDeployed = Cargo:IsDeployed() } )
|
|
|
|
if Cargo:IsDeployed() then
|
|
|
|
-- -- Loop the DeployZones set for the TASK_CARGO_TRANSPORT.
|
|
-- for DeployZoneID, DeployZone in pairs( DeployZones ) do
|
|
--
|
|
-- -- If all cargo is in one of the deploy zones, then all is good.
|
|
-- self:T( { Cargo.CargoObject } )
|
|
-- if Cargo:IsInZone( DeployZone ) == false then
|
|
-- CargoDeployed = false
|
|
-- end
|
|
-- end
|
|
else
|
|
CargoDeployed = false
|
|
end
|
|
end
|
|
|
|
self:F( { CargoDeployed = CargoDeployed } )
|
|
|
|
return CargoDeployed
|
|
end
|
|
|
|
--- @param #TASK_CARGO_TRANSPORT self
|
|
function TASK_CARGO_TRANSPORT:onafterGoal( TaskUnit, From, Event, To )
|
|
local CargoSet = self.CargoSet
|
|
|
|
if self:IsAllCargoTransported() then
|
|
self:Success()
|
|
end
|
|
|
|
self:__Goal( -10 )
|
|
end
|
|
|
|
end
|
|
|