25#include "../../AtomicTaskRegistry.h"
26#include "../../LocalBlackboard.h"
27#include "../../TaskWorldFacade.h"
28#include "../../../system/system_utils.h"
50 SYSTEM_LOG <<
"[Task_MoveToLocation] Abort()\n";
75 target =
it->second.AsVector();
79 SYSTEM_LOG <<
"[Task_MoveToLocation] Missing or invalid 'Target' parameter\n";
90 speed =
it->second.AsFloat();
98 if (
ctx.ComponentFacade
99 &&
ctx.ComponentFacade->Position
100 &&
ctx.ComponentFacade->Movement)
103 ::Vector& velocity =
ctx.ComponentFacade->Movement->Velocity;
108 SYSTEM_LOG <<
"[Task_MoveToLocation] (WorldMode) Entity " <<
ctx.Entity
109 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
110 <<
" target=(" << target.
x <<
"," << target.
y <<
")"
111 <<
" dist=" <<
dist <<
"\n";
115 velocity =
::Vector(0.0f, 0.0f, 0.0f);
116 SYSTEM_LOG <<
"[Task_MoveToLocation] (WorldMode) Entity " <<
ctx.Entity
117 <<
" reached target - Success\n";
122 velocity =
dir * speed;
133 SYSTEM_LOG <<
"[Task_MoveToLocation] 'Position' key not found in LocalBlackboard\n";
144 SYSTEM_LOG <<
"[Task_MoveToLocation] Failed to read 'Position' from LocalBlackboard\n";
153 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
154 <<
" target=(" << target.
x <<
"," << target.
y <<
")"
155 <<
" dist=" <<
dist <<
"\n";
157 float step = speed *
ctx.DeltaTime;
169 <<
" reached target - Success\n";
183 SYSTEM_LOG <<
"[Task_MoveToLocation] Failed to write 'Position' to LocalBlackboard\n";
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
ComponentTypeID GetComponentTypeID_Static()
Atomic task that moves an entity toward a target location.
std::unordered_map< std::string, TaskValue > ParameterMap
Convenience alias for the parameter map passed to Execute().
C++14-compliant type-safe value container for task parameters.
Moves an entity toward a target location each tick.
void Abort() override
Aborts the task, releasing any in-progress state.
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap ¶ms) override
Executes the atomic task for one frame with full runtime context.
TaskStatus Execute(const ParameterMap ¶ms) override
Executes the atomic task for one frame.
< Provides AssetID and INVALID_ASSET_ID
@ Float
Single-precision float.
@ Vector
3-component vector (Vector from vector.h)
TaskStatus
Result code returned by IAtomicTask::Execute().
@ Success
Task completed successfully.
@ Running
Task is still in progress (multi-frame tasks)
static const float DEFAULT_SPEED
static const float ARRIVAL_TOLERANCE
static const char * BB_KEY_POSITION
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().