Added option for silent mission addition

This commit is contained in:
Applevangelist 2021-09-29 16:57:39 +02:00
parent b72e2b6bf9
commit 3377459df5

View File

@ -683,6 +683,7 @@ do -- TASK_CARGO_DISPATCHER
-- If no TaskPrefix is given, then "Transport" will be used as the prefix. -- If no TaskPrefix is given, then "Transport" will be used as the prefix.
-- @param Core.SetCargo#SET_CARGO SetCargo The SetCargo to be transported. -- @param Core.SetCargo#SET_CARGO SetCargo The SetCargo to be transported.
-- @param #string Briefing The briefing of the task transport to be shown to the player. -- @param #string Briefing The briefing of the task transport to be shown to the player.
-- @param #boolean Silent If true don't send a message that a new task is available.
-- @return Tasking.Task_Cargo_Transport#TASK_CARGO_TRANSPORT -- @return Tasking.Task_Cargo_Transport#TASK_CARGO_TRANSPORT
-- @usage -- @usage
-- --
@ -705,10 +706,12 @@ do -- TASK_CARGO_DISPATCHER
-- -- Here we set a TransportDeployZone. We use the WorkplaceTask as the reference, and provide a ZONE object. -- -- Here we set a TransportDeployZone. We use the WorkplaceTask as the reference, and provide a ZONE object.
-- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) ) -- TaskDispatcher:SetTransportDeployZone( WorkplaceTask, ZONE:New( "Workplace" ) )
-- --
function TASK_CARGO_DISPATCHER:AddTransportTask( TaskPrefix, SetCargo, Briefing ) function TASK_CARGO_DISPATCHER:AddTransportTask( TaskPrefix, SetCargo, Briefing, Silent )
self.TransportCount = self.TransportCount + 1 self.TransportCount = self.TransportCount + 1
local verbose = Silent and true
local TaskName = string.format( ( TaskPrefix or "Transport" ) .. ".%03d", self.TransportCount ) local TaskName = string.format( ( TaskPrefix or "Transport" ) .. ".%03d", self.TransportCount )
self.Transport[TaskName] = {} self.Transport[TaskName] = {}
@ -717,7 +720,7 @@ do -- TASK_CARGO_DISPATCHER
self.Transport[TaskName].Task = nil self.Transport[TaskName].Task = nil
self.Transport[TaskName].TaskPrefix = TaskPrefix self.Transport[TaskName].TaskPrefix = TaskPrefix
self:ManageTasks() self:ManageTasks(verbose)
return self.Transport[TaskName] and self.Transport[TaskName].Task return self.Transport[TaskName] and self.Transport[TaskName].Task
end end
@ -785,10 +788,11 @@ do -- TASK_CARGO_DISPATCHER
--- Assigns tasks to the @{Core.Set#SET_GROUP}. --- Assigns tasks to the @{Core.Set#SET_GROUP}.
-- @param #TASK_CARGO_DISPATCHER self -- @param #TASK_CARGO_DISPATCHER self
-- @param #boolean Silent Announce new task (nil/false) or not (true).
-- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop. -- @return #boolean Return true if you want the task assigning to continue... false will cancel the loop.
function TASK_CARGO_DISPATCHER:ManageTasks() function TASK_CARGO_DISPATCHER:ManageTasks(Silent)
self:F() self:F()
local verbose = Silent and true
local AreaMsg = {} local AreaMsg = {}
local TaskMsg = {} local TaskMsg = {}
local ChangeMsg = {} local ChangeMsg = {}
@ -897,7 +901,7 @@ do -- TASK_CARGO_DISPATCHER
local TaskText = TaskReport:Text(", ") local TaskText = TaskReport:Text(", ")
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
if ( not Mission:IsGroupAssigned(TaskGroup) ) and TaskText ~= "" then if ( not Mission:IsGroupAssigned(TaskGroup) ) and TaskText ~= "" and not verbose then
Mission:GetCommandCenter():MessageToGroup( string.format( "%s has tasks %s. Subscribe to a task using the radio menu.", Mission:GetShortText(), TaskText ), TaskGroup ) Mission:GetCommandCenter():MessageToGroup( string.format( "%s has tasks %s. Subscribe to a task using the radio menu.", Mission:GetShortText(), TaskText ), TaskGroup )
end end
end end