21#include "G3DPosition.hpp"
46 if (minDistance && owner->
IsInDist(target, *minDistance))
48 if (maxDistance && !owner->
IsInDist(target, *maxDistance))
67 _angle(angle), _rangeCheckTimer(RANGE_CHECK_INTERVAL)
95 if (!owner || !owner->
IsAlive())
109 cOwner->SetCannotReachTarget(
false);
116 float minTarget = (
_range ?
_range->MinTolerance : 0.0f) + hitboxSum;
122 if (cOwner->IsIgnoringChaseRange())
123 minRange = minTarget = maxRange = maxTarget = 0.0f;
135 cOwner->SetCannotReachTarget(
false);
149 cOwner->SetCannotReachTarget(
false);
173 bool const moveToward = !owner->
IsInDist(target, maxRange);
177 _path = std::make_unique<PathGenerator>(owner);
182 if (moveToward && !angle)
198 bool success =
_path->CalculatePath(x, y, z, owner->
CanFly());
208 _path->ShortenPathUntilDist(PositionToVector3(target->
GetPosition()), maxTarget);
214 if (cOwner && !cOwner->
IsPet())
250 cOwner->SetCannotReachTarget(
false);
260 cOwner->SetCannotReachTarget(
false);
static bool PositionOkay(Unit *owner, Unit *target, Optional< float > minDistance, Optional< float > maxDistance, Optional< ChaseAngle > angle)
static bool HasLostTarget(Unit *owner, Unit *target)
static bool IsMutualChase(Unit *owner, Unit *target)
static void DoMovementInform(Unit *owner, Unit *target)
#define ASSERT_NOTNULL(pointer)
@ MOVEMENTGENERATOR_FLAG_INITIALIZATION_PENDING
@ MOVEMENTGENERATOR_FLAG_DEACTIVATED
@ MOVEMENTGENERATOR_FLAG_FINALIZED
@ MOVEMENTGENERATOR_FLAG_TRANSITORY
@ MOVEMENTGENERATOR_FLAG_INFORM_ENABLED
@ MOVEMENTGENERATOR_FLAG_INITIALIZED
std::optional< T > Optional
Optional helper class to wrap optional values within.
ObjectGuid const & GetGUID() const
ChaseMovementGenerator(Unit *target, Optional< ChaseRange > range={}, Optional< ChaseAngle > angle={})
void Reset(Unit *) override
Optional< Position > _lastTargetPosition
void Initialize(Unit *) override
void Finalize(Unit *, bool, bool) override
Optional< ChaseRange > const _range
~ChaseMovementGenerator()
std::unique_ptr< PathGenerator > _path
bool Update(Unit *, uint32) override
void Deactivate(Unit *) override
Optional< ChaseAngle > const _angle
TimeTracker _rangeCheckTimer
static constexpr uint32 RANGE_CHECK_INTERVAL
void SetCannotReachTarget(bool cannotReach)
CreatureMovementData const & GetMovementTemplate() const
MovementGeneratorType GetCurrentMovementGeneratorType() const
MovementGenerator * GetCurrentMovementGenerator() const
void AddFlag(uint16 const flag)
bool HasFlag(uint16 const flag) const
void RemoveFlag(uint16 const flag)
void SetWalk(bool enable)
void MovebyPath(std::span< Vector3 const > path, int32 pointId=0)
void SetFacing(float angle)
LowType GetCounter() const
void ClearUnitState(uint32 f)
virtual bool IsMovementPreventedByCasting() const
virtual bool CanFly() const =0
MotionMaster * GetMotionMaster()
float GetCombatReach() const override
void AddUnitState(uint32 f)
bool isInAccessiblePlaceFor(Creature const *c) const
bool HasUnitState(const uint32 f) const
std::unique_ptr< Movement::MoveSpline > movespline
float GetMeleeRange(Unit const *target) const
void SetInFront(WorldObject const *target)
ObjectGuid GetTarget() const
void UpdateAllowedPositionZ(float x, float y, float &z, float *groundZ=nullptr) const
void GetNearPoint(WorldObject const *searcher, float &x, float &y, float &z, float distance2d, float absAngle) const
bool IsWithinLOSInMap(WorldObject const *obj, LineOfSightChecks checks=LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags ignoreFlags=VMAP::ModelIgnoreFlags::Nothing) const
CreatureChaseMovementType GetChase() const
float GetRelativeAngle(float x, float y) const
float ToAbsoluteAngle(float relAngle) const
float GetAbsoluteAngle(float x, float y) const
constexpr void GetPosition(float &x, float &y) const
constexpr bool IsInDist(float x, float y, float z, float dist) const