Olympe Engine
2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Source
TaskSystem
AtomicTasks
Utility
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
18
namespace
Olympe
{
19
20
Task_Wait::Task_Wait
() {}
21
22
void
Task_Wait::Abort
()
23
{
24
SYSTEM_LOG
<<
"[Task_Wait] Abort()\n"
;
25
}
26
27
TaskStatus
Task_Wait::Execute
(
const
ParameterMap
&
/*params*/
)
28
{
29
return
TaskStatus::Failure
;
// requires context; use ExecuteWithContext
30
}
31
32
TaskStatus
Task_Wait::ExecuteWithContext
(
const
AtomicTaskContext
&
ctx
,
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"
;
46
return
TaskStatus::Failure
;
47
}
48
49
if
(duration <= 0.0f)
50
{
51
SYSTEM_LOG
<<
"[Task_Wait] Duration must be positive (got "
<< duration <<
")\n"
;
52
return
TaskStatus::Failure
;
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"
;
64
return
TaskStatus::Success
;
65
}
66
67
return
TaskStatus::Running
;
68
}
69
70
REGISTER_ATOMIC_TASK
(
Task_Wait
,
"Task_Wait"
)
71
72
}
// namespace Olympe
REGISTER_ATOMIC_TASK
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
Definition
AtomicTaskRegistry.h:119
GetComponentTypeID_Static
ComponentTypeID GetComponentTypeID_Static()
Definition
ECS_Entity.h:56
Task_Wait.h
Atomic task that waits for a specified duration.
Olympe::IAtomicTask::ParameterMap
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition
IAtomicTask.h:67
Olympe::Task_Wait
Atomic task that idles for a fixed duration then succeeds.
Definition
Task_Wait.h:32
Olympe::Task_Wait::Execute
TaskStatus Execute(const ParameterMap ¶ms) override
Executes the atomic task for one frame.
Definition
Task_Wait.cpp:27
Olympe::Task_Wait::Task_Wait
Task_Wait()
Definition
Task_Wait.cpp:20
Olympe::Task_Wait::Abort
void Abort() override
Aborts the task, releasing any in-progress state.
Definition
Task_Wait.cpp:22
Olympe::Task_Wait::ExecuteWithContext
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap ¶ms) override
Executes the atomic task for one frame with full runtime context.
Definition
Task_Wait.cpp:32
Olympe
< Provides AssetID and INVALID_ASSET_ID
Definition
BTEditorCommand.cpp:16
Olympe::VariableType::Float
@ Float
Single-precision float.
Olympe::TaskStatus
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition
IAtomicTask.h:38
Olympe::TaskStatus::Success
@ Success
Task completed successfully.
Olympe::TaskStatus::Running
@ Running
Task is still in progress (multi-frame tasks)
Olympe::TaskStatus::Failure
@ Failure
Task failed.
Olympe::AtomicTaskContext
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().
Definition
AtomicTaskContext.h:36
SYSTEM_LOG
#define SYSTEM_LOG
Definition
system_utils.h:23
Generated on Mon Apr 13 2026 08:15:20 for Olympe Engine by
1.9.8