21#include "G3DPosition.hpp"
40 return movement->GetTarget() == owner;
48 if (minDistance && distSq <
square(*minDistance))
50 if (maxDistance && distSq >
square(*maxDistance))
69 _angle(angle), _rangeCheckTimer(RANGE_CHECK_INTERVAL)
97 if (!owner || !owner->
IsAlive())
111 cOwner->SetCannotReachTarget(
false);
118 float minTarget = (
_range ?
_range->MinTolerance : 0.0f) + hitboxSum;
124 if (cOwner->IsIgnoringChaseRange())
125 minRange = minTarget = maxRange = maxTarget = 0.0f;
137 cOwner->SetCannotReachTarget(
false);
151 cOwner->SetCannotReachTarget(
false);
175 bool const moveToward = !owner->
IsInDist(target, maxRange);
179 _path = std::make_unique<PathGenerator>(owner);
184 if (moveToward && !angle)
200 bool success =
_path->CalculatePath(x, y, z, owner->
CanFly());
210 _path->ShortenPathUntilDist(PositionToVector3(target), maxTarget);
216 if (cOwner && !cOwner->
IsPet())
252 cOwner->SetCannotReachTarget(
false);
262 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.
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 SetFacing(float angle)
void MovebyPath(PointsArray const &path, int32 pointId=0)
LowType GetCounter() const
static Creature * ToCreature(Object *o)
static ObjectGuid GetGUID(Object const *o)
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)
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 float GetExactDistSq(float x, float y, float z) const
constexpr bool IsInDist(float x, float y, float z, float dist) const