11#include "../../AtomicTaskRegistry.h"
12#include "../../LocalBlackboard.h"
13#include "../../TaskWorldFacade.h"
14#include "../../../system/system_utils.h"
44 SYSTEM_LOG <<
"[Task_Flee(AI)] Missing 'TargetX' parameter\n";
50 threatX =
static_cast<float>(
it->second.AsInt());
59 SYSTEM_LOG <<
"[Task_Flee(AI)] Missing 'TargetY' parameter\n";
65 threatY =
static_cast<float>(
it->second.AsInt());
87 if (
ctx.ComponentFacade
88 &&
ctx.ComponentFacade->Position
89 &&
ctx.ComponentFacade->Movement)
92 ::Vector& velocity =
ctx.ComponentFacade->Movement->Velocity;
98 SYSTEM_LOG <<
"[Task_Flee(AI)] (WorldMode) Entity " <<
ctx.Entity
99 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
105 velocity =
::Vector(0.0f, 0.0f, 0.0f);
127 SYSTEM_LOG <<
"[Task_Flee(AI)] No LocalBlackboard and no ComponentFacade\n";
138 else if (
ctx.LocalBB->HasVariable(
"Position"))
140 try {
pos =
ctx.LocalBB->GetValue(
"Position").AsVector(); }
150 <<
" pos=(" <<
pos.x <<
"," <<
pos.y <<
")"
#define REGISTER_ATOMIC_TASK(ClassName, Id)
Registers a factory for ClassName under Id at static init time.
Atomic task that computes a flee direction away from a target.
ComponentTypeID GetComponentTypeID_Static()
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 away from a 2D threat position until safe distance is reached.
void Abort() override
Aborts the task, releasing any in-progress state.
TaskStatus Execute(const ParameterMap ¶ms) override
Executes the atomic task for one frame.
TaskStatus ExecuteWithContext(const AtomicTaskContext &ctx, const ParameterMap ¶ms) override
Executes the atomic task for one frame with full runtime context.
< Provides AssetID and INVALID_ASSET_ID
static const float FLEE_MOVE_SPEED
@ Int
32-bit signed integer
@ 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_FLEE_DISTANCE
Lightweight context bundle passed to IAtomicTask::ExecuteWithContext().