29#include "../TaskSystem/AtomicTaskContext.h"
30#include "../system/system_utils.h"
67 const float dt = 0.016f;
88 <<
" skipped: no valid TaskGraphTemplate bound.\n";
108 if (
runner.LocalBlackboard.empty() && !
tmpl->Blackboard.empty())
110 for (
size_t i = 0;
i <
tmpl->Blackboard.size(); ++
i)
123 for (
auto it =
runner.LocalBlackboard.begin();
144 const std::vector<std::string>&
keys =
localBB.GetVariableNames();
145 for (
size_t i = 0;
i <
keys.size(); ++
i)
173 SYSTEM_LOG <<
"[TaskSystem] Entity " << entity
174 <<
": node index is NODE_INDEX_NONE with active task"
175 <<
" - calling Abort()\n";
176 runner.activeTask->Abort();
177 runner.activeTask.reset();
186 SYSTEM_LOG <<
"[TaskSystem] Entity " << entity
187 <<
": node ID " <<
runner.CurrentNodeID
188 <<
" not found in template '" <<
tmpl->Name <<
"'\n";
192 runner.activeTask->Abort();
193 runner.activeTask.reset();
208 SYSTEM_LOG <<
"[TaskSystem] Entity " << entity
209 <<
": control-flow node type "
210 <<
static_cast<int>(
node->Type)
211 <<
" not yet supported in Phase 2.C\n";
232 SYSTEM_LOG <<
"[TaskSystem] Entity " << entity
233 <<
": unknown AtomicTaskID '" <<
node.AtomicTaskID <<
"'\n";
245 for (
auto it =
runner.LocalBlackboard.begin();
it !=
runner.LocalBlackboard.end(); ++
it)
247 if (
bb.HasVariable(
it->first))
249 try {
bb.SetValue(
it->first,
it->second); }
257 for (
const auto&
kv :
node.Parameters)
265 if (
bb.HasVariable(
kv.second.VariableName))
271 SYSTEM_LOG <<
"[TaskSystem] Entity " << entity
272 <<
": LocalVariable '" <<
kv.second.VariableName
273 <<
"' not found in template '" <<
tmpl->Name <<
"' - skipping binding\n";
281 ctx.WorldPtr =
nullptr;
289 const std::vector<std::string>&
keys =
bb.GetVariableNames();
290 for (
size_t i = 0;
i <
keys.size(); ++
i)
311 runner.activeTask.reset();
329 runner.CurrentNodeID = success ?
node.NextOnSuccess :
node.NextOnFailure;
343 runner.activeTask->Abort();
344 runner.activeTask.reset();
Singleton registry for atomic task factories.
ComponentTypeID GetComponentTypeID_Static()
Interface for atomic tasks in the Atomic Task System.
Runtime key-value store for task graph variables.
ECS system that iterates TaskRunnerComponent entities and drives ATS Visual Script graph execution ea...
std::set< EntityID > m_entities
const TaskGraphTemplate * GetTaskGraph(AssetID id) const
Returns a non-owning pointer to the cached TaskGraphTemplate.
static AssetManager & Get()
Returns the singleton AssetManager instance.
std::unique_ptr< IAtomicTask > Create(const std::string &id) const
Creates a new instance of the task identified by id.
static AtomicTaskRegistry & Get()
Returns the singleton instance.
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Simple map-based blackboard for task graph runtime state.
void Initialize(const TaskGraphTemplate &tmpl)
Initialises the blackboard from a template.
void InitializeFromEntries(const std::vector< BlackboardEntry > &entries)
Initializes the blackboard from a vector of BlackboardEntry (ATS VS schema v4).
Immutable, shareable task graph asset.
virtual void Process() override
Processes all entities registered with this system for one frame.
void ExecuteAtomicTask(EntityID entity, TaskRunnerComponent &runner, const TaskNodeDefinition &node, const TaskGraphTemplate *tmpl, float dt)
Executes one tick of an AtomicTask node.
void ExecuteVSFrame(EntityID entity, TaskRunnerComponent &runner, const TaskGraphTemplate *tmpl, float dt)
Dispatches VS-graph execution to VSGraphExecutor.
static void SetEditorPublishCallback(TaskEditorPublishFn fn)
Register a callback that receives live task-runner state each frame while a task is executing.
TaskSystem()
Constructs the system and configures the required component signature.
void AbortActiveTask(TaskRunnerComponent &runner)
Aborts the active atomic task on a runner, if any.
void ExecuteNode(EntityID entity, TaskRunnerComponent &runner, const TaskGraphTemplate *tmpl, float dt)
Advances execution of one node in the task graph for the given entity.
static TaskEditorPublishFn s_EditorPublishFn
Callback registered by the editor to receive live runtime info.
void TransitionToNextNode(TaskRunnerComponent &runner, const TaskNodeDefinition &node, bool success)
Advances runner.CurrentNodeID after a node completes.
static void ExecuteFrame(EntityID entity, TaskRunnerComponent &runner, const TaskGraphTemplate &tmpl, LocalBlackboard &localBB, World *worldPtr, float dt)
Point d'entrée principal : exécute le graphe pour une entité.
Core ECS manager and world coordinator.
< Provides AssetID and INVALID_ASSET_ID
void(*)(EntityID entity, int nodeIndex, const LocalBlackboard *bb) TaskEditorPublishFn
Signature of the editor publish callback.
TaskStatus
Result code returned by IAtomicTask::Execute().
@ Success
Task completed successfully.
@ Running
Task is still in progress (multi-frame tasks)
@ LocalVariable
Value is read from the local blackboard at runtime.
@ Literal
Value is embedded directly in the template.
@ AtomicTask
Leaf node that executes a single atomic task.
constexpr int32_t NODE_INDEX_NONE
Sentinel value for "no node" in node index / ID fields.
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().
EntityID Entity
The entity whose task graph is being executed.
Single entry in the graph's declared blackboard schema (local or global).
Full description of a single node in the task graph.
Per-entity runtime state for task graph execution.
@ Success
The node completed successfully.
@ Aborted
Execution was interrupted externally.
@ Failure
The node failed.