Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Task_Flee.h
Go to the documentation of this file.
1/**
2 * @file Task_Flee.h
3 * @brief Atomic AI task that moves an entity away from a 2D threat position.
4 * @author Olympe Engine
5 * @date 2026-03-08
6 *
7 * @details
8 * Task_Flee computes a flee direction opposite to the threat (TargetX, TargetY)
9 * and moves the entity away from it. Returns Running while the entity is
10 * closer than Distance to the threat; returns Success once the entity is
11 * far enough away.
12 *
13 * Parameters (ParameterMap):
14 * "TargetX" (Float) — X coordinate of the threat (required).
15 * "TargetY" (Float) — Y coordinate of the threat (required).
16 * "Distance" (Float) — safe flee distance in units (optional, default 200.0).
17 *
18 * Returns:
19 * Running while the entity's distance to the threat < Distance.
20 * Success once the entity's distance to the threat >= Distance.
21 * Failure if "TargetX" or "TargetY" are missing.
22 *
23 * C++14 compliant - no C++17/20 features.
24 */
25
26#pragma once
27
28#include "../../IAtomicTask.h"
29
30namespace Olympe {
31
32/**
33 * @class Task_Flee
34 * @brief Moves an entity away from a 2D threat position until safe distance is reached.
35 */
36class Task_Flee : public IAtomicTask {
37public:
38 Task_Flee();
39
41 const ParameterMap& params) override;
42
43 TaskStatus Execute(const ParameterMap& params) override;
44
45 void Abort() override;
46};
47
48} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
Abstract interface for a single atomic unit of work.
Definition IAtomicTask.h:63
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition IAtomicTask.h:67
Moves an entity away from a 2D threat position until safe distance is reached.
Definition Task_Flee.h:36
void Abort() override
Aborts the task, releasing any in-progress state.
Definition Task_Flee.cpp:25
TaskStatus Execute(const ParameterMap &params) override
Executes the atomic task for one frame.
Definition Task_Flee.cpp:30
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap &params) override
Executes the atomic task for one frame with full runtime context.
Definition Task_Flee.cpp:35
< Provides AssetID and INVALID_ASSET_ID
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition IAtomicTask.h:38
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().