![]() |
Olympe Engine 2.0
2D Game Engine with ECS Architecture
|
ECS system responsible for advancing task graph execution each frame. More...
#include <TaskSystem.h>
Inheritance diagram for Olympe::TaskSystem:
Collaboration diagram for Olympe::TaskSystem:Public Member Functions | |
| TaskSystem () | |
| Constructs the system and configures the required component signature. | |
| virtual void | Process () override |
| Processes all entities registered with this system for one frame. | |
| void | ExecuteNode (EntityID entity, TaskRunnerComponent &runner, const TaskGraphTemplate *tmpl, float dt) |
| Advances execution of one node in the task graph for the given entity. | |
| void | ExecuteVSFrame (EntityID entity, TaskRunnerComponent &runner, const TaskGraphTemplate *tmpl, float dt) |
| Dispatches VS-graph execution to VSGraphExecutor. | |
| void | AbortActiveTask (TaskRunnerComponent &runner) |
| Aborts the active atomic task on a runner, if any. | |
Public Member Functions inherited from ECS_System | |
| ECS_System () | |
| virtual void | Render () |
| virtual void | RenderDebug () |
| void | AddEntity (EntityID entity) |
| void | RemoveEntity (EntityID entity) |
Static Public Member Functions | |
| static void | SetEditorPublishCallback (TaskEditorPublishFn fn) |
| Register a callback that receives live task-runner state each frame while a task is executing. | |
Private Member Functions | |
| void | ExecuteAtomicTask (EntityID entity, TaskRunnerComponent &runner, const TaskNodeDefinition &node, const TaskGraphTemplate *tmpl, float dt) |
| Executes one tick of an AtomicTask node. | |
| void | TransitionToNextNode (TaskRunnerComponent &runner, const TaskNodeDefinition &node, bool success) |
| Advances runner.CurrentNodeID after a node completes. | |
Static Private Attributes | |
| static TaskEditorPublishFn | s_EditorPublishFn = nullptr |
| Callback registered by the editor to receive live runtime info. | |
Additional Inherited Members | |
Public Attributes inherited from ECS_System | |
| ComponentSignature | requiredSignature |
| std::set< EntityID > | m_entities |
ECS system responsible for advancing task graph execution each frame.
Usage:
Inheritance: TaskSystem : ECS_System
Definition at line 77 of file TaskSystem.h.
| Olympe::TaskSystem::TaskSystem | ( | ) |
Constructs the system and configures the required component signature.
Definition at line 53 of file TaskSystem.cpp.
| void Olympe::TaskSystem::AbortActiveTask | ( | TaskRunnerComponent & | runner | ) |
Aborts the active atomic task on a runner, if any.
Calls Abort() on runner.activeTask (if non-null), resets the unique_ptr, and sets runner.LastStatus to TaskRunnerComponent::TaskStatus::Aborted. Safe to call when runner.activeTask is nullptr (no-op).
| runner | Reference to the entity's TaskRunnerComponent. |
Definition at line 339 of file TaskSystem.cpp.
References Olympe::TaskRunnerComponent::Aborted, and GetComponentTypeID_Static().
Here is the call graph for this function:
|
private |
Executes one tick of an AtomicTask node.
Creates runner.activeTask on first call for this node, ticks it, and handles Running / completion transitions.
| entity | The entity being processed. |
| runner | Reference to the entity's TaskRunnerComponent. |
| node | The current AtomicTask node definition. |
| tmpl | Non-null pointer to the resolved TaskGraphTemplate (used to resolve LocalVariable bindings). |
| dt | Delta-time in seconds for the current frame. |
Definition at line 220 of file TaskSystem.cpp.
References Olympe::AtomicTaskRegistry::Create(), Olympe::AtomicTaskContext::Entity, Olympe::TaskRunnerComponent::Failure, Olympe::AtomicTaskRegistry::Get(), GetComponentTypeID_Static(), Olympe::LocalBlackboard::Initialize(), Olympe::Literal, Olympe::LocalVariable, Olympe::Running, s_EditorPublishFn, Olympe::TaskRunnerComponent::Success, Olympe::Success, SYSTEM_LOG, and TransitionToNextNode().
Referenced by ExecuteNode().
Here is the call graph for this function:
Here is the caller graph for this function:| void Olympe::TaskSystem::ExecuteNode | ( | EntityID | entity, |
| TaskRunnerComponent & | runner, | ||
| const TaskGraphTemplate * | tmpl, | ||
| float | dt | ||
| ) |
Advances execution of one node in the task graph for the given entity.
Implements the AtomicTask lifecycle described in the class documentation. runner.CurrentNodeID is treated as a NodeID (looked up via TaskGraphTemplate::GetNode()). NODE_INDEX_NONE (-1) means there is no active node; any lingering activeTask is Abort()ed and released.
| entity | The entity being processed. |
| runner | Reference to the entity's TaskRunnerComponent. |
| tmpl | Non-null pointer to the resolved TaskGraphTemplate. |
| dt | Delta-time in seconds for the current frame. |
Definition at line 162 of file TaskSystem.cpp.
References Olympe::AtomicTask, ExecuteAtomicTask(), GetComponentTypeID_Static(), Olympe::NODE_INDEX_NONE, and SYSTEM_LOG.
Here is the call graph for this function:| void Olympe::TaskSystem::ExecuteVSFrame | ( | EntityID | entity, |
| TaskRunnerComponent & | runner, | ||
| const TaskGraphTemplate * | tmpl, | ||
| float | dt | ||
| ) |
Dispatches VS-graph execution to VSGraphExecutor.
Called from Process() when tmpl->GraphType == "VisualScript".
| entity | The entity being processed. |
| runner | Reference to the entity's TaskRunnerComponent. |
| tmpl | Non-null pointer to the resolved TaskGraphTemplate. |
| dt | Delta-time in seconds for the current frame. |
Definition at line 101 of file TaskSystem.cpp.
References Olympe::BlackboardEntry::Default, Olympe::VSGraphExecutor::ExecuteFrame(), GetComponentTypeID_Static(), and Olympe::LocalBlackboard::InitializeFromEntries().
Referenced by Process().
Here is the call graph for this function:
Here is the caller graph for this function:
|
overridevirtual |
Processes all entities registered with this system for one frame.
For each entity in m_entities:
Reimplemented from ECS_System.
Definition at line 63 of file TaskSystem.cpp.
References ExecuteVSFrame(), Olympe::AssetManager::Get(), GetComponentTypeID_Static(), Olympe::AssetManager::GetTaskGraph(), ECS_System::m_entities, and SYSTEM_LOG.
Here is the call graph for this function:
|
static |
Register a callback that receives live task-runner state each frame while a task is executing.
Pass nullptr to unregister. The callback is invoked from ExecuteAtomicTask() after ticking the task when the task is Running. It is safe to call this from any thread before the first Process().
| fn | Function matching TaskEditorPublishFn, or nullptr. |
Definition at line 44 of file TaskSystem.cpp.
References GetComponentTypeID_Static(), and s_EditorPublishFn.
Referenced by Olympe::TaskExecutionBridge::Install(), and Olympe::TaskExecutionBridge::Uninstall().
Here is the call graph for this function:
Here is the caller graph for this function:
|
private |
Advances runner.CurrentNodeID after a node completes.
Sets runner.CurrentNodeID to node.NextOnSuccess if success is true, or node.NextOnFailure otherwise. NODE_INDEX_NONE signals that the graph has finished. Also resets runner.StateTimer to 0.
| runner | The runner component to update. |
| node | The node that just completed. |
| success | true if the node succeeded, false if it failed. |
Definition at line 324 of file TaskSystem.cpp.
References GetComponentTypeID_Static().
Referenced by ExecuteAtomicTask().
Here is the call graph for this function:
Here is the caller graph for this function:
|
staticprivate |
Callback registered by the editor to receive live runtime info.
Definition at line 214 of file TaskSystem.h.
Referenced by ExecuteAtomicTask(), and SetEditorPublishCallback().