Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Task_Wait.cpp
Go to the documentation of this file.
1/**
2 * @file Task_Wait.cpp
3 * @brief Atomic task: wait for a specified duration.
4 * @author Olympe Engine
5 * @date 2026-02-23
6 *
7 * @details
8 * Uses ctx.StateTimer (accumulated per-node time managed by TaskSystem) to
9 * determine when the wait duration has elapsed.
10 *
11 * C++14 compliant - no C++17/20 features.
12 */
13
14#include "Task_Wait.h"
15#include "../../AtomicTaskRegistry.h"
16#include "../../../system/system_utils.h"
17
18namespace Olympe {
19
21
23{
24 SYSTEM_LOG << "[Task_Wait] Abort()\n";
25}
26
28{
29 return TaskStatus::Failure; // requires context; use ExecuteWithContext
30}
31
33 const ParameterMap& params)
34{
35 // --- Resolve Duration parameter ---
36 float duration = 0.0f;
37 {
38 auto it = params.find("Duration");
39 if (it != params.end() && it->second.GetType() == VariableType::Float)
40 {
41 duration = it->second.AsFloat();
42 }
43 else
44 {
45 SYSTEM_LOG << "[Task_Wait] Missing or invalid 'Duration' parameter\n";
47 }
48
49 if (duration <= 0.0f)
50 {
51 SYSTEM_LOG << "[Task_Wait] Duration must be positive (got " << duration << ")\n";
53 }
54 }
55
56 SYSTEM_LOG << "[Task_Wait] Entity " << ctx.Entity
57 << " timer=" << ctx.StateTimer
58 << " duration=" << duration << "\n";
59
60 if (ctx.StateTimer >= duration)
61 {
62 SYSTEM_LOG << "[Task_Wait] Entity " << ctx.Entity
63 << " wait complete - Success\n";
65 }
66
68}
69
71
72} // namespace Olympe
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Atomic task that waits for a specified duration.
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition IAtomicTask.h:67
Atomic task that idles for a fixed duration then succeeds.
Definition Task_Wait.h:32
TaskStatus Execute(const ParameterMap &params) override
Executes the atomic task for one frame.
Definition Task_Wait.cpp:27
void Abort() override
Aborts the task, releasing any in-progress state.
Definition Task_Wait.cpp:22
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap &params) override
Executes the atomic task for one frame with full runtime context.
Definition Task_Wait.cpp:32
< Provides AssetID and INVALID_ASSET_ID
@ Float
Single-precision float.
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition IAtomicTask.h:38
@ Success
Task completed successfully.
@ Running
Task is still in progress (multi-frame tasks)
@ Failure
Task failed.
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().
#define SYSTEM_LOG