Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Public Member Functions | Static Public Member Functions | Private Member Functions | Static Private Attributes | List of all members
Olympe::TaskSystem Class Reference

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< EntityIDm_entities
 

Detailed Description

ECS system responsible for advancing task graph execution each frame.

Usage:

TaskSystem* taskSystem = world.RegisterSystem<TaskSystem>();
// TaskSystem sets its own requiredSignature in the constructor.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
ECS system responsible for advancing task graph execution each frame.
Definition TaskSystem.h:78

Inheritance: TaskSystem : ECS_System

Definition at line 77 of file TaskSystem.h.

Constructor & Destructor Documentation

◆ TaskSystem()

Olympe::TaskSystem::TaskSystem ( )

Constructs the system and configures the required component signature.

Note
Signature configuration is left as a TODO until the component registration API is fully wired up in Phase 1.5.

Definition at line 53 of file TaskSystem.cpp.

Member Function Documentation

◆ AbortActiveTask()

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).

Parameters
runnerReference 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:

◆ ExecuteAtomicTask()

void Olympe::TaskSystem::ExecuteAtomicTask ( EntityID  entity,
TaskRunnerComponent runner,
const TaskNodeDefinition node,
const TaskGraphTemplate tmpl,
float  dt 
)
private

Executes one tick of an AtomicTask node.

Creates runner.activeTask on first call for this node, ticks it, and handles Running / completion transitions.

Parameters
entityThe entity being processed.
runnerReference to the entity's TaskRunnerComponent.
nodeThe current AtomicTask node definition.
tmplNon-null pointer to the resolved TaskGraphTemplate (used to resolve LocalVariable bindings).
dtDelta-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:

◆ ExecuteNode()

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.

Parameters
entityThe entity being processed.
runnerReference to the entity's TaskRunnerComponent.
tmplNon-null pointer to the resolved TaskGraphTemplate.
dtDelta-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:

◆ ExecuteVSFrame()

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".

Parameters
entityThe entity being processed.
runnerReference to the entity's TaskRunnerComponent.
tmplNon-null pointer to the resolved TaskGraphTemplate.
dtDelta-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:

◆ Process()

void Olympe::TaskSystem::Process ( )
overridevirtual

Processes all entities registered with this system for one frame.

For each entity in m_entities:

  1. Retrieves the TaskRunnerComponent (TODO Phase 1.5: from World).
  2. Looks up the bound TaskGraphTemplate via AssetManager::Get().
  3. Skips the entity if no valid template is found.
  4. Calls ExecuteNode() to advance task graph execution.

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:

◆ SetEditorPublishCallback()

void Olympe::TaskSystem::SetEditorPublishCallback ( TaskEditorPublishFn  fn)
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().

Parameters
fnFunction 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:

◆ TransitionToNextNode()

void Olympe::TaskSystem::TransitionToNextNode ( TaskRunnerComponent runner,
const TaskNodeDefinition node,
bool  success 
)
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.

Parameters
runnerThe runner component to update.
nodeThe node that just completed.
successtrue 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:

Member Data Documentation

◆ s_EditorPublishFn

TaskEditorPublishFn Olympe::TaskSystem::s_EditorPublishFn = nullptr
staticprivate

Callback registered by the editor to receive live runtime info.

Definition at line 214 of file TaskSystem.h.

Referenced by ExecuteAtomicTask(), and SetEditorPublishCallback().


The documentation for this class was generated from the following files: