diff --git a/Moose Development/Moose/Tasking/TaskInfo.lua b/Moose Development/Moose/Tasking/TaskInfo.lua index 601d73a30..3eb941e1c 100644 --- a/Moose Development/Moose/Tasking/TaskInfo.lua +++ b/Moose Development/Moose/Tasking/TaskInfo.lua @@ -11,10 +11,10 @@ -- @module TaskInfo --- @type TASKINFO --- @extends Core.Set#SET_BASE +-- @extends Core.Base#BASE --- --- # TASKINFO class, extends @{Set#SET} +-- # TASKINFO class, extends @{Base#BASE} -- -- ## The TASKINFO class implements the methods to contain information and display information of a task. -- @@ -37,9 +37,13 @@ TASKINFO.Detail = "" -- @return #TASKINFO self function TASKINFO:New( Task ) - local self = BASE:Inherit( self, SET_BASE:New() ) -- Core.Set#SET + local self = BASE:Inherit( self, BASE:New() ) -- Core.Base#BASE self.Task = Task + self.VolatileInfo = SET_BASE:New() + self.PersistentInfo = SET_BASE:New() + + self.Info = self.VolatileInfo return self end @@ -51,9 +55,13 @@ end -- @param Data The data of the info. -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddInfo( Key, Data, Order, Detail ) - self:Add( Key, { Data = Data, Order = Order, Detail = Detail } ) +function TASKINFO:AddInfo( Key, Data, Order, Detail, Keep ) + self.VolatileInfo:Add( Key, { Data = Data, Order = Order, Detail = Detail } ) + if Keep == true then + self.PersistentInfo:Add( Key, { Data = Data, Order = Order, Detail = Detail } ) + end return self end @@ -75,7 +83,7 @@ end -- @param #string The info key. -- @return Data The data of the info. function TASKINFO:GetData( Key ) - local Object = self:Get( Key ) + local Object = self.Info:Get( Key ) return Object.Data end @@ -86,9 +94,10 @@ end -- @param #string Text The text. -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddText( Key, Text, Order, Detail ) - self:AddInfo( Key, Text, Order, Detail ) +function TASKINFO:AddText( Key, Text, Order, Detail, Keep ) + self:AddInfo( Key, Text, Order, Detail, Keep ) return self end @@ -97,9 +106,10 @@ end -- @param #TASKINFO self -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddTaskName( Order, Detail ) - self:AddInfo( "TaskName", self.Task:GetName(), Order, Detail ) +function TASKINFO:AddTaskName( Order, Detail, Keep ) + self:AddInfo( "TaskName", self.Task:GetName(), Order, Detail, Keep ) return self end @@ -111,34 +121,48 @@ end -- @param Core.Point#COORDINATE Coordinate -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddCoordinate( Coordinate, Order, Detail ) - self:AddInfo( "Coordinate", Coordinate, Order, Detail ) +function TASKINFO:AddCoordinate( Coordinate, Order, Detail, Keep ) + self:AddInfo( "Coordinate", Coordinate, Order, Detail, Keep ) return self end + --- Add Threat. -- @param #TASKINFO self -- @param #string ThreatText The text of the Threat. -- @param #string ThreatLevel The level of the Threat. -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddThreat( ThreatText, ThreatLevel, Order, Detail ) - self:AddInfo( "Threat", ThreatText .. " [" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]", Order, Detail ) +function TASKINFO:AddThreat( ThreatText, ThreatLevel, Order, Detail, Keep ) + self:AddInfo( "Threat", ThreatText .. " [" .. string.rep( "■", ThreatLevel ) .. string.rep( "□", 10 - ThreatLevel ) .. "]", Order, Detail, Keep ) return self end +--- Get Threat. +-- @param #TASKINFO self +-- @return #string The threat +function TASKINFO:GetThreat() + self:GetInfo( "Threat" ) + return self +end + + + --- Add the Target count. -- @param #TASKINFO self -- @param #number TargetCount The amount of targets. -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddTargetCount( TargetCount, Order, Detail ) - self:AddInfo( "Counting", string.format( "%d", TargetCount ), Order, Detail ) +function TASKINFO:AddTargetCount( TargetCount, Order, Detail, Keep ) + self:AddInfo( "Counting", string.format( "%d", TargetCount ), Order, Detail, Keep ) return self end @@ -148,20 +172,33 @@ end -- @param #string TargetTypes The text containing the target types. -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddTargets( TargetCount, TargetTypes, Order, Detail ) - self:AddInfo( "Targets", string.format( "%d of %s", TargetCount, TargetTypes ), Order, Detail ) +function TASKINFO:AddTargets( TargetCount, TargetTypes, Order, Detail, Keep ) + self:AddInfo( "Targets", string.format( "%d of %s", TargetCount, TargetTypes ), Order, Detail, Keep ) return self end +--- Get Targets. +-- @param #TASKINFO self +-- @return #string The targets +function TASKINFO:GetTargets() + self:GetInfo( "Targets" ) + return self +end + + + + --- Add the QFE at a Coordinate. -- @param #TASKINFO self -- @param Core.Point#COORDINATE Coordinate -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddQFEAtCoordinate( Coordinate, Order, Detail ) - self:AddInfo( "QFE", Coordinate, Order, Detail ) +function TASKINFO:AddQFEAtCoordinate( Coordinate, Order, Detail, Keep ) + self:AddInfo( "QFE", Coordinate, Order, Detail, Keep ) return self end @@ -170,9 +207,10 @@ end -- @param Core.Point#COORDINATE Coordinate -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddTemperatureAtCoordinate( Coordinate, Order, Detail ) - self:AddInfo( "Temperature", Coordinate, Order, Detail ) +function TASKINFO:AddTemperatureAtCoordinate( Coordinate, Order, Detail, Keep ) + self:AddInfo( "Temperature", Coordinate, Order, Detail, Keep ) return self end @@ -181,9 +219,10 @@ end -- @param Core.Point#COORDINATE Coordinate -- @param #number Order The display order, which is a number from 0 to 100. -- @param #TASKINFO.Detail Detail The detail Level. +-- @param #boolean Keep (optional) If true, this would indicate that the planned taskinfo would be persistent when the task is completed, so that the original planned task info is used at the completed reports. -- @return #TASKINFO self -function TASKINFO:AddWindAtCoordinate( Coordinate, Order, Detail ) - self:AddInfo( "Wind", Coordinate, Order, Detail ) +function TASKINFO:AddWindAtCoordinate( Coordinate, Order, Detail, Keep ) + self:AddInfo( "Wind", Coordinate, Order, Detail, Keep ) return self end @@ -199,7 +238,11 @@ function TASKINFO:Report( Report, Detail, ReportGroup ) local Line = 0 local LineReport = REPORT:New() - for Key, Data in UTILS.spairs( self.Set, function( t, a, b ) return t[a].Order < t[b].Order end ) do + if not self.Task:IsStatePlanned() and not self.Task:IsStateAssigned() then + self.Info = self.PersistentInfo + end + + for Key, Data in UTILS.spairs( self.Info.Set, function( t, a, b ) return t[a].Order < t[b].Order end ) do self:E( { Key = Key, Detail = Detail, Data = Data } ) diff --git a/Moose Development/Moose/Tasking/Task_A2G.lua b/Moose Development/Moose/Tasking/Task_A2G.lua index 408574be1..b54afb3c0 100644 --- a/Moose Development/Moose/Tasking/Task_A2G.lua +++ b/Moose Development/Moose/Tasking/Task_A2G.lua @@ -289,7 +289,7 @@ do -- TASK_A2G --- Return the relative distance to the target vicinity from the player, in order to sort the targets in the reports per distance from the threats. -- @param #TASK_A2G self function TASK_A2G:ReportOrder( ReportGroup ) - local Coordinate = self:GetData( "Coordinate" ) + local Coordinate = self.TaskInfo:GetData( "Coordinate" ) local Distance = ReportGroup:GetCoordinate():Get2DDistance( Coordinate ) return Distance