mirror of
https://github.com/FlightControl-Master/MOOSE.git
synced 2025-08-15 10:47:21 +00:00
Got tasking working again now, with the NEW API set!!!
This is really, really great! Now document all, and optimize the code. And start video making. And re-test the test mission, all... And PUBLISH!!!
This commit is contained in:
@@ -19,7 +19,7 @@ PROCESS = {
|
||||
-- @param Unit#UNIT ProcessUnit (Optional) If provided, it defines the UNIT for which the process is running.
|
||||
-- @return #PROCESS
|
||||
function PROCESS:New( FSMT, ProcessName, ProcessUnit )
|
||||
local self = BASE:Inherit( self, STATEMACHINE_CONTROLLABLE:New( FSMT, ProcessUnit ) )
|
||||
local self = BASE:Inherit( self, STATEMACHINE_PROCESS:New( FSMT, ProcessUnit ) )
|
||||
self:F()
|
||||
|
||||
if ProcessUnit then
|
||||
@@ -41,63 +41,20 @@ function PROCESS:GetGroup()
|
||||
return self.ProcessGroup
|
||||
end
|
||||
|
||||
--- Sets the task of the process.
|
||||
-- @param #PROCESS self
|
||||
-- @param Tasking.Task#TASK_BASE ProcessTask
|
||||
-- @return #PROCESS
|
||||
function PROCESS:SetTask( ProcessTask )
|
||||
|
||||
self.ProcessTask = ProcessTask
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Gets the task of the process.
|
||||
-- @param #PROCESS self
|
||||
-- @return Task#TASK_BASE
|
||||
function PROCESS:GetTask()
|
||||
|
||||
return self.ProcessTask
|
||||
end
|
||||
|
||||
--- Gets the mission of the process.
|
||||
-- @param #PROCESS self
|
||||
-- @return Mission#MISSION
|
||||
function PROCESS:GetMission()
|
||||
|
||||
return self.ProcessTask.Mission
|
||||
end
|
||||
|
||||
|
||||
--- Assign the process to a @{Unit} and activate the process.
|
||||
-- @param #PROCESS self
|
||||
-- @param Unit#UNIT ProcessUnit
|
||||
-- @return #PROCESS self
|
||||
function PROCESS:Assign( ProcessTask, ProcessUnit )
|
||||
|
||||
self:SetControllable( ProcessUnit )
|
||||
self:SetTask( ProcessTask )
|
||||
|
||||
self.ProcessGroup = ProcessUnit:GetGroup()
|
||||
--self:Activate()
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
--- Adds a score for the PROCESS to be achieved.
|
||||
-- @param #PROCESS self
|
||||
-- @param Task#TASK_BASE Task The task for which the process needs to account score.
|
||||
-- @param #string ProcessStatus is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).
|
||||
-- @param #string ScoreText is a text describing the score that is given according the status.
|
||||
-- @param #number Score is a number providing the score of the status.
|
||||
-- @return #PROCESS self
|
||||
function PROCESS:AddScore( Task, ProcessStatus, ScoreText, Score )
|
||||
function PROCESS:AddScore( ProcessStatus, ScoreText, Score )
|
||||
self:F2( { ProcessStatus, ScoreText, Score } )
|
||||
|
||||
self.Scores[ProcessStatus] = self.Scores[ProcessStatus] or {}
|
||||
self.Scores[ProcessStatus].ScoreText = ScoreText
|
||||
self.Scores[ProcessStatus].Score = Score
|
||||
self.Scores[ProcessStatus].Task = Task
|
||||
|
||||
return self
|
||||
end
|
||||
@@ -108,17 +65,18 @@ end
|
||||
-- @param #string Event
|
||||
-- @param #string From
|
||||
-- @param #string To
|
||||
function PROCESS:OnStateChange( ProcessUnit, Event, From, To )
|
||||
self:E( { self.ProcessName, Event, From, To, ProcessUnit.UnitName } )
|
||||
function PROCESS:onstatechange( ProcessUnit, Event, From, To, Dummy )
|
||||
self:E( { ProcessUnit, Event, From, To, Dummy } )
|
||||
|
||||
if self:IsTrace() then
|
||||
MESSAGE:New( "Process " .. self.ProcessName .. " : " .. Event .. " changed to state " .. To, 15 ):ToAll()
|
||||
end
|
||||
|
||||
self:E( self.Scores[To] )
|
||||
-- TODO: This needs to be reworked with a callback functions allocated within Task, and set within the mission script from the Task Objects...
|
||||
if self.Scores[To] then
|
||||
|
||||
local Task = self.Scores[To].Task
|
||||
local Task = self.Task
|
||||
local Scoring = Task:GetScoring()
|
||||
if Scoring then
|
||||
Scoring:_AddMissionTaskScore( Task.Mission, ProcessUnit, self.Scores[To].ScoreText, self.Scores[To].Score )
|
||||
|
||||
Reference in New Issue
Block a user