21#include "G3DPosition.hpp"
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 const minTarget = (
_range ?
_range->MinTolerance : 0.0f) + hitboxSum;
133 cOwner->SetCannotReachTarget(
false);
147 cOwner->SetCannotReachTarget(
false);
171 bool const moveToward = !owner->
IsInDist(target, maxRange);
175 _path = std::make_unique<PathGenerator>(owner);
180 if (moveToward && !angle)
196 bool success =
_path->CalculatePath(x, y, z, owner->
CanFly());
206 _path->ShortenPathUntilDist(PositionToVector3(target), maxTarget);
212 if (cOwner && !cOwner->
IsPet())
248 cOwner->SetCannotReachTarget(
false);
258 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={})
Optional< Position > _lastTargetPosition
bool Initialize(Unit *) override
void Finalize(Unit *, bool, bool) override
Optional< ChaseRange > const _range
~ChaseMovementGenerator()
std::unique_ptr< PathGenerator > _path
bool Reset(Unit *) override
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
Movement::MoveSpline * movespline
void StopMoving(bool force=false)
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
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
bool IsInDist(float x, float y, float z, float dist) const
float GetAbsoluteAngle(float x, float y) const
void GetPosition(float &x, float &y) const
float GetExactDistSq(float x, float y, float z) const