Module Task
This module contains the TASK_BASE class.
1) #TASK_BASE class, extends Base#BASE
1.1) The #TASK_BASE class implements the methods for task orchestration within MOOSE.
The class provides a couple of methods to:
- TASK_BASE.AssignToGroup():Assign a task to a group (of players).
- TASK_BASE.AddProcess():Add a Process to a task.
- TASK_BASE.RemoveProcesses():Remove a running Process from a running task.
- TASK_BASE.AddStateMachine():Add a StateMachine to a task.
- TASK_BASE.RemoveStateMachines():Remove StateMachines from a task.
- TASK_BASE.HasStateMachine():Enquire if the task has a StateMachine
- TASK_BASE.AssignToUnit(): Assign a task to a unit. (Needs to be implemented in the derived classes from #TASK_BASE.
- TASK_BASE.UnAssignFromUnit(): Unassign the task from a unit.
1.2) Set and enquire task status (beyond the task state machine processing).
A task needs to implement as a minimum the following task states:
- Success: Expresses the successful execution and finalization of the task.
- Failed: Expresses the failure of a task.
- Planned: Expresses that the task is created, but not yet in execution and is not assigned yet.
- Assigned: Expresses that the task is assigned to a Group of players, and that the task is in execution mode.
A task may also implement the following task states:
- Rejected: Expresses that the task is rejected by a player, who was requested to accept the task.
- Cancelled: Expresses that the task is cancelled by HQ or through a logical situation where a cancellation of the task is required.
A task can implement more statusses than the ones outlined above. Please consult the documentation of the specific tasks to understand the different status modelled.
The status of tasks can be set by the methods State followed by the task status. An example is StateAssigned().
The status of tasks can be enquired by the methods IsState followed by the task status name. An example is if IsStateAssigned() then.
1.3) Add scoring when reaching a certain task status:
Upon reaching a certain task status in a task, additional scoring can be given. If the Mission has a scoring system attached, the scores will be added to the mission scoring. Use the method TASK_BASE.AddScore() to add scores when a status is reached.
1.4) Task briefing:
A task briefing can be given that is shown to the player when he is assigned to the task.
Authors: FlightControl - Design and Programming
Global(s)
| TASK_BASE |
Type TASK_BASE
Global(s)
Type Task
Type TASK_BASE
The TASK_BASE class
Field(s)
- TASK_BASE:AddProcess(TaskUnit, Process)
-
Add Process to Task with key Unit.
Parameters
-
Unit#UNIT TaskUnit: -
Process:
Return value
#TASK_BASE: self
-
- TASK_BASE:AddScore(TaskStatus, ScoreText, Score)
-
Adds a score for the TASK to be achieved.
Parameters
-
#string TaskStatus: is the status of the TASK when the score needs to be given. -
#string ScoreText: is a text describing the score that is given according the status. -
#number Score: is a number providing the score of the status.
Return value
#TASK_BASE: self
-
- TASK_BASE:AddStateMachine(TaskUnit, Fsm)
-
Add a FiniteStateMachine to Task with key Unit
Parameters
-
Unit#UNIT TaskUnit: -
Fsm:
Return value
#TASK_BASE: self
-
- TASK_BASE:AssignToGroup(TaskGroup)
-
Parameter
-
Group#GROUP TaskGroup:
-
- TASK_BASE:AssignToUnit(TaskUnit)
-
Assign the Taskto an alive Unit.
Parameter
-
Unit#UNIT TaskUnit:
Return value
#TASK_BASE: self
-
- #string TASK_BASE.ClassName
- TASK_BASE:CleanUp()
-
Cleans all references of a TASK_BASE.
Return value
#nil:
- TASK_BASE:FailProcesses(TaskUnitName)
-
Fail processes from Task with key Unit
Parameter
-
#string TaskUnitName:
Return value
#TASK_BASE: self
-
- TASK_BASE:GetCategory()
-
Gets the Category of the Task
Return value
#string: TaskCategory
- TASK_BASE:GetID()
-
Gets the ID of the Task
Return value
#string: TaskID
- TASK_BASE:GetName()
-
Gets the Name of the Task
Return value
#string: The Task Name
- TASK_BASE:GetScoring()
-
Gets the Scoring of the task
Return value
Scoring#SCORING: Scoring
- TASK_BASE:GetStateString()
-
Gets the Task status.
- TASK_BASE:GetTaskIndex()
-
Gets the Task Index, which is a combination of the Task category, the Task type, the Task name.
Return value
#string: The Task ID
- TASK_BASE:GetTaskName()
-
Returns the Task name.
Return value
#string: TaskName
- TASK_BASE:GetType()
-
Gets the Type of the Task
Return value
#string: TaskType
- TASK_BASE:HasStateMachine(TaskUnitName)
-
Checks if there is a FiniteStateMachine assigned to Unit for Task
Parameter
-
#string TaskUnitName:
Return value
#TASK_BASE: self
-
- TASK_BASE:IsAssignedToGroup(TaskGroup)
-
Returns if the Task is assigned to the Group.
Parameter
-
Group#GROUP TaskGroup:
Return value
#boolean:
-
- TASK_BASE:IsStateAssigned()
-
Is the Task status Assigned.
- TASK_BASE:IsStateFailed()
-
Is the Task status Failed.
- TASK_BASE:IsStateHold()
-
Is the Task status Hold.
- TASK_BASE:IsStatePlanned()
-
Is the Task status Planned.
- TASK_BASE:IsStateReplanned()
-
Is the Task status Replanned.
- TASK_BASE:IsStateSuccess()
-
Is the Task status Success.
- TASK_BASE.MenuAssignToGroup(MenuParam)
-
Parameter
-
MenuParam:
-
- TASK_BASE.MenuTaskAbort(MenuParam)
-
Parameter
-
MenuParam:
-
- TASK_BASE.MenuTaskStatus(MenuParam)
-
Parameter
-
MenuParam:
-
- TASK_BASE:New(The, SetGroup, TaskName, TaskType, TaskCategory, Mission)
-
Instantiates a new TASK_BASE.
Should never be used. Interface Class.
Parameters
-
Mission#MISSION The: mission wherein the Task is registered. -
Set#SET_GROUP SetGroup: The set of groups for which the Task can be assigned. -
#string TaskName: The name of the Task -
#string TaskType: The type of the Task -
#string TaskCategory: The category of the Task (A2G, A2A, Transport, ... ) -
Mission:
Return value
#TASK_BASE: self
-
- TASK_BASE:OnAssigned(TaskUnit, Fsm, Event, From, To, Event)
-
StateMachine callback function for a TASK
Parameters
-
Unit#UNIT TaskUnit: -
#string Event: -
#string From: -
#string To: -
Event#EVENTDATA Event:
-
- TASK_BASE:OnFailed(TaskUnit, Fsm, Event, From, To, Event)
-
StateMachine callback function for a TASK
Parameters
-
Unit#UNIT TaskUnit: -
#string Event: -
#string From: -
#string To: -
Event#EVENTDATA Event:
-
- TASK_BASE:OnStateChange(TaskUnit, Fsm, Event, From, To, Event)
-
StateMachine callback function for a TASK
Parameters
-
Unit#UNIT TaskUnit: -
#string Event: -
#string From: -
#string To: -
Event#EVENTDATA Event:
-
- TASK_BASE:OnSuccess(TaskUnit, Fsm, Event, From, To, Event)
-
StateMachine callback function for a TASK
Parameters
-
Unit#UNIT TaskUnit: -
#string Event: -
#string From: -
#string To: -
Event#EVENTDATA Event:
-
- TASK_BASE:RemoveMenu()
-
Remove the menu options of the Task to all the groups in the SetGroup.
Return value
#TASK_BASE: self
- TASK_BASE:RemoveMenuForGroup(TaskGroup)
-
Remove the menu option of the Task for a Group.
Parameter
-
Group#GROUP TaskGroup:
Return value
#TASK_BASE: self
-
- TASK_BASE:RemoveProcesses(TaskUnitName)
-
Remove Processes from Task with key Unit
Parameter
-
#string TaskUnitName:
Return value
#TASK_BASE: self
-
- TASK_BASE:RemoveStateMachines(TaskUnitName)
-
Remove FiniteStateMachines from Task with key Unit
Parameter
-
#string TaskUnitName:
Return value
#TASK_BASE: self
-
- TASK_BASE:SendBriefingToAssignedGroups()
-
Send the briefng message of the Task to the assigned Groups.
- TASK_BASE:SetAssignedMenu()
-
Set the menu options of the Task to all the groups in the SetGroup.
Return value
#TASK_BASE: self
- TASK_BASE:SetAssignedMenuForGroup(TaskGroup)
-
Set the assigned menu options of the Task.
Parameter
-
Group#GROUP TaskGroup:
Return value
#TASK_BASE: self
-
- TASK_BASE:SetBriefing(TaskBriefing)
-
Sets a Task briefing.
Parameter
-
#string TaskBriefing:
Return value
#TASK_BASE: self
-
- TASK_BASE:SetCategory(TaskCategory)
-
Sets the Category of the Task
Parameter
-
#string TaskCategory:
-
- Set#SET_GROUP TASK_BASE.SetGroup
-
The Set of Groups assigned to the Task
- TASK_BASE:SetID(TaskID)
-
Sets the ID of the Task
Parameter
-
#string TaskID:
-
- TASK_BASE:SetName(TaskName)
-
Sets the Name of the Task
Parameter
-
#string TaskName:
-
- TASK_BASE:SetPlannedMenu()
-
Set the menu options of the Task to all the groups in the SetGroup.
Return value
#TASK_BASE: self
- TASK_BASE:SetPlannedMenuForGroup(TaskGroup, MenuText)
-
Set the planned menu option of the Task.
Parameters
-
Group#GROUP TaskGroup: -
#string MenuText: The menu text.
Return value
#TASK_BASE: self
-
- TASK_BASE:SetType(TaskType)
-
Sets the Type of the Task
Parameter
-
#string TaskType:
-
- TASK_BASE:StateAssigned()
-
Sets a Task to status Assigned.
- TASK_BASE:StateFailed()
-
Sets a Task to status Failed.
- TASK_BASE:StateHold()
-
Sets a Task to status Hold.
- TASK_BASE:StatePlanned()
-
Sets a Task to status Planned.
- TASK_BASE:StateReplanned()
-
Sets a Task to status Replanned.
- TASK_BASE:StateSuccess()
-
Sets a Task to status Success.
- TASK_BASE:UnAssignFromUnit(TaskUnit, TaskUnitName)
-
UnAssign the Task from an alive Unit.
Parameters
-
Unit#UNIT TaskUnit: -
TaskUnitName:
Return value
#TASK_BASE: self
-
- TASK_BASE:_EventAssignUnit(Event)
-
Register a potential new assignment for a new spawned Unit.
Tasks only get assigned if there are players in it.
Parameter
-
Event#EVENTDATA Event:
Return value
#TASK_BASE: self
-
- TASK_BASE:_EventDead(Event)
-
UnAssigns a Unit that is left by a player, crashed, dead, ....
There are only assignments if there are players in it.
Parameter
-
Event#EVENTDATA Event:
Return value
#TASK_BASE: self
-
- TASK_BASE:_EventPlayerLeaveUnit(Event)
-
Catches the "player leave unit" event for a Unit ....
When a player is an air unit, and leaves the unit:
- and he is not at an airbase runway on the ground, he will fail its task.
- and he is on an airbase and on the ground, the process for him will just continue to work, he can switch airplanes, and take-off again. This is important to model the change from plane types for a player during mission assignment.
Parameter
-
Event#EVENTDATA Event:
Return value
#TASK_BASE: self