Olympe Engine
2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Source
TaskSystem
AtomicTasks
AI
Task_SetAnimation.cpp
Go to the documentation of this file.
1
/**
2
* @file Task_SetAnimation.cpp
3
* @brief Atomic AI task: trigger an animation on an entity.
4
* @author Olympe Engine
5
* @date 2026-03-08
6
*
7
* C++14 compliant - no C++17/20 features.
8
*/
9
10
#include "
Task_SetAnimation.h
"
11
#include "../../AtomicTaskRegistry.h"
12
#include "../../LocalBlackboard.h"
13
#include "../../../system/system_utils.h"
14
15
namespace
Olympe
{
16
17
Task_SetAnimation::Task_SetAnimation
() {}
18
19
void
Task_SetAnimation::Abort
()
20
{
21
SYSTEM_LOG
<<
"[Task_SetAnimation] Abort()\n"
;
22
}
23
24
TaskStatus
Task_SetAnimation::Execute
(
const
ParameterMap
&
/*params*/
)
25
{
26
return
TaskStatus::Failure
;
// requires context; use ExecuteWithContext
27
}
28
29
TaskStatus
Task_SetAnimation::ExecuteWithContext
(
const
AtomicTaskContext
&
ctx
,
30
const
ParameterMap
&
params
)
31
{
32
if
(!
ctx
.LocalBB)
33
{
34
SYSTEM_LOG
<<
"[Task_SetAnimation] No LocalBlackboard in context\n"
;
35
return
TaskStatus::Failure
;
36
}
37
38
// --- Resolve AnimRef parameter ---
39
std::string
animRef
;
40
{
41
auto
it
=
params
.find(
"AnimRef"
);
42
if
(
it
==
params
.end() ||
it
->second.GetType() !=
VariableType::String
)
43
{
44
SYSTEM_LOG
<<
"[Task_SetAnimation] Missing or invalid 'AnimRef' parameter\n"
;
45
return
TaskStatus::Failure
;
46
}
47
animRef
=
it
->second.AsString();
48
}
49
50
// --- Resolve Loop parameter (optional, default true) ---
51
bool
loop =
true
;
52
{
53
auto
it
=
params
.find(
"Loop"
);
54
if
(
it
!=
params
.end() &&
it
->second.GetType() ==
VariableType::Bool
)
55
{
56
loop =
it
->second.AsBool();
57
}
58
}
59
60
SYSTEM_LOG
<<
"[Task_SetAnimation] Entity "
<<
ctx
.Entity
61
<<
" anim='"
<<
animRef
<<
"' loop="
<< (loop ?
"true"
:
"false"
) <<
"\n"
;
62
63
// Write animation info to LocalBlackboard.
64
// Future: when ComponentFacade exposes an AnimationComponent, call
65
// ctx.ComponentFacade->Animation->Play(animRef, loop) here.
66
ctx
.LocalBB->SetValueScoped(
"local:current_animation"
,
TaskValue
(
animRef
));
67
68
return
TaskStatus::Success
;
69
}
70
71
REGISTER_ATOMIC_TASK
(
Task_SetAnimation
,
"Task_SetAnimation"
)
72
73
}
// 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_SetAnimation.h
Atomic AI task that triggers an animation on an entity.
Olympe::IAtomicTask::ParameterMap
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition
IAtomicTask.h:67
Olympe::TaskValue
C++14-compliant type-safe value container for task parameters.
Definition
TaskGraphTypes.h:181
Olympe::Task_SetAnimation
Requests an animation clip to play on the entity.
Definition
Task_SetAnimation.h:34
Olympe::Task_SetAnimation::Task_SetAnimation
Task_SetAnimation()
Definition
Task_SetAnimation.cpp:17
Olympe::Task_SetAnimation::Abort
void Abort() override
Aborts the task, releasing any in-progress state.
Definition
Task_SetAnimation.cpp:19
Olympe::Task_SetAnimation::ExecuteWithContext
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap ¶ms) override
Executes the atomic task for one frame with full runtime context.
Definition
Task_SetAnimation.cpp:29
Olympe::Task_SetAnimation::Execute
TaskStatus Execute(const ParameterMap ¶ms) override
Executes the atomic task for one frame.
Definition
Task_SetAnimation.cpp:24
Olympe
< Provides AssetID and INVALID_ASSET_ID
Definition
BTEditorCommand.cpp:16
Olympe::VariableType::String
@ String
std::string
Olympe::VariableType::Bool
@ Bool
Boolean.
Olympe::TaskStatus
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition
IAtomicTask.h:38
Olympe::TaskStatus::Success
@ Success
Task completed successfully.
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