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 task that computes a flee direction away from a target.
4 * @author Olympe Engine
5 * @date 2026-03-08
6 *
7 * @details
8 * Task_Flee reads the entity's current position from "local:Position" and
9 * an optional threat target from "local:Target" (or the "Target" parameter).
10 * It computes the direction away from the threat, scales it by Distance, and
11 * writes the resulting flee target position to "local:FleeTarget" in the
12 * LocalBlackboard. A movement task (e.g. Task_MoveToLocation) can then be
13 * used to move the entity toward the computed flee target.
14 *
15 * Parameters (ParameterMap):
16 * "Target" (Vector) — threat position override (optional; falls back to
17 * "local:Target" EntityID in LocalBB, then origin).
18 * "Distance" (Float) — flee distance in units (optional, default 200.0).
19 *
20 * Returns:
21 * Success after writing the flee target.
22 * Failure if ctx.LocalBB is null.
23 *
24 * C++14 compliant - no C++17/20 features.
25 */
26
27#pragma once
28
29#include "../../IAtomicTask.h"
30
31namespace Olympe {
32
33/**
34 * @class Task_Flee
35 * @brief Computes a flee direction and stores the target position in LocalBB.
36 */
37class Task_Flee : public IAtomicTask {
38public:
40
42 const ParameterMap& params) override;
43
45
46 void Abort() override;
47};
48
49} // namespace Olympe
ComponentTypeID GetComponentTypeID_Static()
Definition ECS_Entity.h:56
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
Definition IAtomicTask.h:67
void Abort() override
Aborts the task, releasing any in-progress state.
TaskStatus Execute(const ParameterMap &params) override
Executes the atomic task for one frame.
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap &params) override
Executes the atomic task for one frame with full runtime context.
< Provides AssetID and INVALID_ASSET_ID
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition IAtomicTask.h:38
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().