Olympe Engine 2.0
2D Game Engine with ECS Architecture
Loading...
Searching...
No Matches
Task_GotoPosition.h
Go to the documentation of this file.
1/**
2 * @file Task_GotoPosition.h
3 * @brief Atomic task that moves an entity toward a 2D target position.
4 * @author Olympe Engine
5 * @date 2026-03-08
6 *
7 * @details
8 * Task_GotoPosition moves the entity toward (TargetX, TargetY) each frame.
9 * In headless mode it integrates the entity's "Position" key in the
10 * LocalBlackboard using ctx.DeltaTime. In World mode it writes Velocity
11 * to the MovementComponent via the ComponentFacade.
12 *
13 * Parameters (ParameterMap):
14 * "TargetX" (Float) — X coordinate of the destination (required).
15 * "TargetY" (Float) — Y coordinate of the destination (required).
16 * "Speed" (Float) — Movement speed in units/s (optional, default 300.0).
17 *
18 * Returns:
19 * Running while the entity is more than 5 units from the target.
20 * Success once the entity arrives (distance <= 5 units).
21 * Success immediately when ctx.World is nullptr (headless/test mode).
22 * Failure if "TargetX" or "TargetY" parameters are missing.
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_GotoPosition
35 * @brief Moves an entity toward a 2D (TargetX, TargetY) destination.
36 */
38public:
40
42 const ParameterMap& params) override;
43
44 TaskStatus Execute(const ParameterMap& params) override;
45
46 void Abort() override;
47};
48
49} // 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 toward a 2D (TargetX, TargetY) destination.
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap &params) override
Executes the atomic task for one frame with full runtime context.
TaskStatus Execute(const ParameterMap &params) override
Executes the atomic task for one frame.
void Abort() override
Aborts the task, releasing any in-progress state.
< Provides AssetID and INVALID_ASSET_ID
TaskStatus
Result code returned by IAtomicTask::Execute().
Definition IAtomicTask.h:38
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().