diff --git a/Moose Development/Moose/Fsm/Fsm.lua b/Moose Development/Moose/Fsm/Fsm.lua index 42f5d88c7..04b424afa 100644 --- a/Moose Development/Moose/Fsm/Fsm.lua +++ b/Moose Development/Moose/Fsm/Fsm.lua @@ -505,7 +505,7 @@ do -- FSM_PROCESS -- @param #FSM_PROCESS self -- @return #FSM_PROCESS function FSM_PROCESS:Copy( Controllable, Task ) - self:E( { self:GetClassNameAndID(), Controllable:GetName() } ) + self:E( { self:GetClassNameAndID() } ) local NewFsm = self:New( Controllable, Task ) -- Fsm.Fsm#FSM_PROCESS diff --git a/Moose Development/Moose/Tasking/CommandCenter.lua b/Moose Development/Moose/Tasking/CommandCenter.lua index 63a5c18b1..a9c731c23 100644 --- a/Moose Development/Moose/Tasking/CommandCenter.lua +++ b/Moose Development/Moose/Tasking/CommandCenter.lua @@ -68,6 +68,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) setmetatable( self.Missions, { __mode = "v" } ) self:EventOnBirth( + --- @param #COMMANDCENTER self --- @param Core.Event#EVENTDATA EventData function( self, EventData ) self:E( { EventData } ) @@ -75,6 +76,7 @@ function COMMANDCENTER:New( CommandCenterPositionable, CommandCenterName ) if EventGroup and self:HasGroup( EventGroup ) then local MenuReporting = MENU_GROUP:New( EventGroup, "Reporting", self.CommandCenterMenu ) local MenuMissions = MENU_GROUP_COMMAND:New( EventGroup, "Missions", MenuReporting, self.ReportMissions, self, EventGroup ) + self:ReportMissions( EventGroup ) end end ) @@ -90,6 +92,13 @@ function COMMANDCENTER:GetName() return self.HQName end +--- Gets the POSITIONABLE of the HQ command center. +-- @param #COMMANDCENTER self +-- @return Wrapper.Positionable#POSITIONABLE +function COMMANDCENTER:GetPositionable() + return self.CommandCenterPositionable +end + --- Add a MISSION to be governed by the HQ command center. -- @param #COMMANDCENTER self @@ -118,7 +127,7 @@ end -- @param #COMMANDCENTER self function COMMANDCENTER:SetMenu() - self.CommandCenterMenu = MENU_COALITION:New( self.CommandCenterCoalition, "HQ" ) + self.CommandCenterMenu = self.CommandCenterMenu or MENU_COALITION:New( self.CommandCenterCoalition, "HQ" ) for MissionID, Mission in pairs( self.Missions ) do local Mission = Mission -- Tasking.Mission#MISSION @@ -148,6 +157,7 @@ end --- Report the status of all MISSIONs to a GROUP. +-- @param #COMMANDCENTER self function COMMANDCENTER:ReportMissions( ReportGroup ) self:E( ReportGroup ) @@ -158,7 +168,7 @@ function COMMANDCENTER:ReportMissions( ReportGroup ) Report:Add( " - " .. Mission:ReportStatus() ) end - MESSAGE:New( Report:Text(), 30, "Status Report Missions from " .. self:GetName() .. "\n" ):ToGroup( ReportGroup ) + self:GetPositionable():MessageToGroup( Report:Text(), 30, ReportGroup ) end diff --git a/Moose Development/Moose/Tasking/Mission.lua b/Moose Development/Moose/Tasking/Mission.lua index 2e3cb2bd2..388071ee2 100644 --- a/Moose Development/Moose/Tasking/Mission.lua +++ b/Moose Development/Moose/Tasking/Mission.lua @@ -122,6 +122,10 @@ function MISSION:SetMenu() end end + +--- Gets the COMMANDCENTER. +-- @param #MISSION self +-- @return Tasking.CommandCenter#COMMANDCENTER function MISSION:GetCommandCenter() return self.CommandCenter end diff --git a/Moose Development/Moose/Tasking/Task.lua b/Moose Development/Moose/Tasking/Task.lua index 04f37fbd8..0967fd519 100644 --- a/Moose Development/Moose/Tasking/Task.lua +++ b/Moose Development/Moose/Tasking/Task.lua @@ -93,6 +93,7 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType ) self.Fsm = {} self.Mission = Mission + self.SetGroup = SetGroupAssign self:SetType( TaskType ) @@ -161,14 +162,30 @@ function TASK_BASE:New( Mission, SetGroupAssign, TaskName, TaskType ) end ) + Mission:AddTask( self ) + return self end +--- Get the Task FSM Process Template +-- @param #TASK_BASE self +-- @return Fsm.Fsm#FSM_PROCESS function TASK_BASE:GetFsmTemplate() return self.FsmTemplate end +--- Sets the Task FSM Process Template +-- @param #TASK_BASE self +-- @param Fsm.Fsm#FSM_PROCESS +function TASK_BASE:SetFsmTemplate( FsmTemplate ) + + self.FsmTemplate = FsmTemplate +end + +--- Gets the Mission to where the TASK belongs. +-- @param #TASK_BASE self +-- @return Tasking.Mission#MISSION function TASK_BASE:GetMission() return self.Mission @@ -283,6 +300,9 @@ function TASK_BASE:UnAssignFromGroups() for TaskGroupName, TaskGroup in pairs( self.SetGroup:GetSet() ) do TaskGroup:SetState( TaskGroup, "Assigned", nil ) + + self:RemoveMenuForGroup( TaskGroup ) + local TaskUnits = TaskGroup:GetUnits() for UnitID, UnitData in pairs( TaskUnits ) do local TaskUnit = UnitData -- Wrapper.Unit#UNIT @@ -316,7 +336,9 @@ end function TASK_BASE:SetMenu() for TaskGroupID, TaskGroup in pairs( self.SetGroup:GetSet() ) do - self:SetMenuForGroup( TaskGroup ) + if self:IsStatePlanned() or self:IsStateReplanned() then + self:SetMenuForGroup( TaskGroup ) + end end end @@ -773,8 +795,16 @@ function TASK_BASE:onenterSuccess( Event, From, To ) self:E("Success") + local Mission = self:GetMission() + local CC = Mission:GetCommandCenter() + + for TaskGroupName, TaskGroup in pairs( self.SetGroup:GetSet() ) do + CC:GetPositionable():MessageToGroup( "Task " .. self:GetName() .. " is successful! Good job!" , 60, TaskGroup ) + end + self:UnAssignFromGroups() - self:SetMenu() + + CC:SetMenu() end diff --git a/Moose Development/Moose/Wrapper/Controllable.lua b/Moose Development/Moose/Wrapper/Controllable.lua index 1d5f76969..09368668f 100644 --- a/Moose Development/Moose/Wrapper/Controllable.lua +++ b/Moose Development/Moose/Wrapper/Controllable.lua @@ -2203,118 +2203,4 @@ end -- Message APIs ---- Returns a message with the callsign embedded (if there is one). --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. --- @return Core.Message#MESSAGE -function CONTROLLABLE:GetMessage( Message, Duration ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - return MESSAGE:New( Message, Duration, self:GetCallsign() .. " (" .. self:GetTypeName() .. ")" ) - end - - return nil -end - ---- Send a message to all coalitions. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. -function CONTROLLABLE:MessageToAll( Message, Duration ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - self:GetMessage( Message, Duration ):ToAll() - end - - return nil -end - ---- Send a message to the red coalition. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTYpes#Duration Duration The duration of the message. -function CONTROLLABLE:MessageToRed( Message, Duration ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - self:GetMessage( Message, Duration ):ToRed() - end - - return nil -end - ---- Send a message to the blue coalition. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. -function CONTROLLABLE:MessageToBlue( Message, Duration ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - self:GetMessage( Message, Duration ):ToBlue() - end - - return nil -end - ---- Send a message to a client. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. --- @param Wrapper.Client#CLIENT Client The client object receiving the message. -function CONTROLLABLE:MessageToClient( Message, Duration, Client ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - self:GetMessage( Message, Duration ):ToClient( Client ) - end - - return nil -end - ---- Send a message to a @{Group}. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. --- @param Wrapper.Group#GROUP MessageGroup The GROUP object receiving the message. -function CONTROLLABLE:MessageToGroup( Message, Duration, MessageGroup ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - if DCSObject:isExist() then - self:GetMessage( Message, Duration ):ToGroup( MessageGroup ) - end - end - - return nil -end - ---- Send a message to the players in the @{Group}. --- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. --- @param #CONTROLLABLE self --- @param #string Message The message text --- @param Dcs.DCSTypes#Duration Duration The duration of the message. -function CONTROLLABLE:Message( Message, Duration ) - self:F2( { Message, Duration } ) - - local DCSObject = self:GetDCSObject() - if DCSObject then - self:GetMessage( Message, Duration ):ToGroup( self ) - end - - return nil -end diff --git a/Moose Development/Moose/Wrapper/Positionable.lua b/Moose Development/Moose/Wrapper/Positionable.lua index 7693544cb..9cee3d91e 100644 --- a/Moose Development/Moose/Wrapper/Positionable.lua +++ b/Moose Development/Moose/Wrapper/Positionable.lua @@ -276,6 +276,122 @@ function POSITIONABLE:GetVelocityKMH() return nil end +--- Returns a message with the callsign embedded (if there is one). +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +-- @return Core.Message#MESSAGE +function POSITIONABLE:GetMessage( Message, Duration ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + return MESSAGE:New( Message, Duration, self:GetCallsign() .. " (" .. self:GetTypeName() .. ")" ) + end + + return nil +end + +--- Send a message to all coalitions. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +function POSITIONABLE:MessageToAll( Message, Duration ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + self:GetMessage( Message, Duration ):ToAll() + end + + return nil +end + +--- Send a message to the red coalition. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTYpes#Duration Duration The duration of the message. +function POSITIONABLE:MessageToRed( Message, Duration ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + self:GetMessage( Message, Duration ):ToRed() + end + + return nil +end + +--- Send a message to the blue coalition. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +function POSITIONABLE:MessageToBlue( Message, Duration ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + self:GetMessage( Message, Duration ):ToBlue() + end + + return nil +end + +--- Send a message to a client. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +-- @param Wrapper.Client#CLIENT Client The client object receiving the message. +function POSITIONABLE:MessageToClient( Message, Duration, Client ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + self:GetMessage( Message, Duration ):ToClient( Client ) + end + + return nil +end + +--- Send a message to a @{Group}. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +-- @param Wrapper.Group#GROUP MessageGroup The GROUP object receiving the message. +function POSITIONABLE:MessageToGroup( Message, Duration, MessageGroup ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + if DCSObject:isExist() then + self:GetMessage( Message, Duration ):ToGroup( MessageGroup ) + end + end + + return nil +end + +--- Send a message to the players in the @{Group}. +-- The message will appear in the message area. The message will begin with the callsign of the group and the type of the first unit sending the message. +-- @param #POSITIONABLE self +-- @param #string Message The message text +-- @param Dcs.DCSTypes#Duration Duration The duration of the message. +function POSITIONABLE:Message( Message, Duration ) + self:F2( { Message, Duration } ) + + local DCSObject = self:GetDCSObject() + if DCSObject then + self:GetMessage( Message, Duration ):ToGroup( self ) + end + + return nil +end + + diff --git a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.lua b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.lua index 371bafabe..d5545a1d9 100644 --- a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.lua +++ b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.lua @@ -50,7 +50,7 @@ local TargetZone = ZONE:New( "Target Zone" ) -- 2. The set of groups of planes that pilots can join. -- 3. The name of the Task... This can be any name, and will be provided when the Pilot joins the task. -- 4. A type of the Task. When Tasks are in state Planned, then a menu can be provided that group the task based on this given type. -local TaskSEAD = TASK_BASE:New( Mission, SEADSet, "SEAD Radars", "SEAD" ) -- Tasking.Task#TASK_BASE +local TaskSEAD = TASK_BASE:New( Mission, SEADSet, "SEAD Radars Vector 1", "SEAD" ) -- Tasking.Task#TASK_BASE -- This is now an important part of the Task process definition. -- Each TASK contains a "Process Template". @@ -111,6 +111,10 @@ function FsmSEADTemplate:onenterUpdated( TaskUnit ) self:Smoke() end -Mission:AddTask( TaskSEAD ) + +local TaskSEAD2 = TASK_BASE:New( Mission, SEADSet, "SEAD Radars Vector 2", "SEAD" ) -- Tasking.Task#TASK_BASE +TaskSEAD2:SetFsmTemplate( TaskSEAD:GetFsmTemplate():Copy() ) +--Mission:AddTask( TaskSEAD2 ) + HQ:SetMenu() diff --git a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz index 032c4ec9b..fb8b6fe44 100644 Binary files a/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz and b/Moose Test Missions/TSK - Task Modelling/TSK-010 - Task Modelling - SEAD/TSK-010 - Task Modelling - SEAD.miz differ