11#include "../../AtomicTaskRegistry.h"
12#include "../../LocalBlackboard.h"
13#include "../../TaskWorldFacade.h"
14#include "../../../system/system_utils.h"
45 SYSTEM_LOG <<
"[Task_GotoPosition] Missing 'TargetX' parameter\n";
54 targetX =
static_cast<float>(
it->second.AsInt());
64 SYSTEM_LOG <<
"[Task_GotoPosition] Missing 'TargetY' parameter\n";
73 targetY =
static_cast<float>(
it->second.AsInt());
84 speed =
it->second.AsFloat();
86 speed =
static_cast<float>(
it->second.AsInt());
96 if (
ctx.ComponentFacade
97 &&
ctx.ComponentFacade->Position
98 &&
ctx.ComponentFacade->Movement)
101 ::Vector& velocity =
ctx.ComponentFacade->Movement->Velocity;
107 SYSTEM_LOG <<
"[Task_GotoPosition] (WorldMode) Entity " <<
ctx.Entity
108 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
110 <<
" dist=" <<
dist <<
"\n";
114 velocity =
::Vector(0.0f, 0.0f, 0.0f);
119 velocity =
dir * speed;
128 SYSTEM_LOG <<
"[Task_GotoPosition] No LocalBlackboard and no ComponentFacade\n";
152 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
154 <<
" dist=" <<
dist <<
"\n";
161 const float step = speed *
ctx.DeltaTime;
#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 2D target position.
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.
::Vector AsVector() const
Returns the Vector value.
Moves an entity toward a 2D (TargetX, TargetY) destination.
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.
void Abort() override
Aborts the task, releasing any in-progress state.
< Provides AssetID and INVALID_ASSET_ID
@ Int
32-bit signed integer
@ Float
Single-precision float.
@ Vector
3-component vector (Vector from vector.h)
static const float DEFAULT_GOTO_SPEED
TaskStatus
Result code returned by IAtomicTask::Execute().
@ Success
Task completed successfully.
@ Running
Task is still in progress (multi-frame tasks)
static const float ARRIVAL_TOLERANCE
static const char * BB_KEY_POSITION
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().