This commit is contained in:
Sven Van de Velde 2016-12-10 09:38:35 +01:00
parent 038c10c4d4
commit 46aa9ddf65

View File

@ -137,11 +137,14 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType )
if self:IsStateAssigned() then
local TaskUnit = EventData.IniUnit
local TaskGroup = EventData.IniUnit:GetGroup()
self:E( self.SetGroup:IsIncludeObject( TaskGroup ) )
if self.SetGroup:IsIncludeObject( TaskGroup ) then
self:E( self:IsAssignedToGroup( TaskGroup ) )
if self:IsAssignedToGroup( TaskGroup ) then
self:UnAssignFromUnit( TaskUnit )
self:MessageToGroups( TaskUnit:GetPlayerName() .. " aborted Task " .. self:GetName() )
end
if self:AreUnitsAlive() == false then
self:__Abort( 1 )
end
self:MessageToGroups( TaskUnit:GetPlayerName() .. " aborted Task " .. self:GetName() )
end
end
)
@ -281,7 +284,7 @@ function TASK_BASE:MessageToGroups( Message )
local CC = Mission:GetCommandCenter()
for TaskGroupName, TaskGroup in pairs( self.SetGroup:GetSet() ) do
CC:MessageToGroup( Message , 60, TaskGroup )
CC:MessageToGroup( Message, TaskGroup )
end
end
@ -338,6 +341,26 @@ function TASK_BASE:IsAssignedToGroup( TaskGroup )
return false
end
--- Returns if the @{Task} has still alive and assigned Units.
-- @param #TASK_BASE self
-- @return #boolean
function TASK_BASE:HasAliveUnits( TaskGroup )
for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do
if self:IsStateAssigned() then
if self:IsAssignedToGroup( TaskGroup ) then
for TaskUnitID, TaskUnit in pairs( TaskGroup:GetUnits() ) do
if TaskUnit:IsAlive() then
return true
end
end
end
end
end
return false
end
--- Set the menu options of the @{Task} to all the groups in the SetGroup.
-- @param #TASK_BASE self
function TASK_BASE:SetMenu()