TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
RotateMovementGenerator Class Reference

#include <IdleMovementGenerator.h>

Public Member Functions

 RotateMovementGenerator (uint32 time, RotateDirection direction)
 
void Initialize (Unit *) override
 
void Finalize (Unit *) override
 
void Reset (Unit *owner) override
 
bool Update (Unit *, uint32) override
 
MovementGeneratorType GetMovementGeneratorType () const override
 
- Public Member Functions inherited from MovementGenerator
virtual ~MovementGenerator ()
 
virtual void unitSpeedChanged ()
 
virtual bool GetResetPosition (Unit *, float &, float &, float &)
 

Private Attributes

uint32 m_duration
 
uint32 m_maxDuration
 
RotateDirection m_direction
 

Constructor & Destructor Documentation

RotateMovementGenerator::RotateMovementGenerator ( uint32  time,
RotateDirection  direction 
)
inlineexplicit
40 : m_duration(time), m_maxDuration(time), m_direction(direction) { }
RotateDirection m_direction
Definition: IdleMovementGenerator.h:50
uint32 m_maxDuration
Definition: IdleMovementGenerator.h:49
uint32 m_duration
Definition: IdleMovementGenerator.h:49

Member Function Documentation

void RotateMovementGenerator::Finalize ( Unit unit)
overridevirtual

Implements MovementGenerator.

69 {
71  if (unit->GetTypeId() == TYPEID_UNIT)
73 }
Definition: MotionMaster.h:53
Definition: ObjectGuid.h:32
Definition: Unit.h:570
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
TypeID GetTypeId() const
Definition: Object.h:113
CreatureAI * AI() const
Definition: Creature.h:525
Creature * ToCreature()
Definition: Object.h:194
virtual void MovementInform(uint32, uint32)
Definition: CreatureAI.h:143

+ Here is the call graph for this function:

MovementGeneratorType RotateMovementGenerator::GetMovementGeneratorType ( ) const
inlineoverridevirtual

Implements MovementGenerator.

46 { return ROTATE_MOTION_TYPE; }
Definition: MotionMaster.h:53
void RotateMovementGenerator::Initialize ( Unit owner)
overridevirtual

Implements MovementGenerator.

40 {
41  if (!owner->IsStopped())
42  owner->StopMoving();
43 
44  if (owner->GetVictim())
45  owner->SetInFront(owner->GetVictim());
46 
48  owner->AttackStop();
49 }
bool AttackStop()
Definition: Unit.cpp:7337
void AddUnitState(uint32 f)
Definition: Unit.h:1394
Definition: Unit.h:570
bool IsStopped() const
Definition: Unit.h:2104
Unit * GetVictim() const
Definition: Unit.h:1379
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:15771
void StopMoving()
-------—End of Pet responses methods-------—
Definition: Unit.cpp:12743

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void RotateMovementGenerator::Reset ( Unit owner)
inlineoverridevirtual

Implements MovementGenerator.

44 { Initialize(owner); }
void Initialize(Unit *) override
Definition: IdleMovementGenerator.cpp:39

+ Here is the call graph for this function:

bool RotateMovementGenerator::Update ( Unit owner,
uint32  diff 
)
overridevirtual

Implements MovementGenerator.

52 {
53  float angle = owner->GetOrientation();
54  angle += (float(diff) * static_cast<float>(M_PI * 2) / m_maxDuration) * (m_direction == ROTATE_DIRECTION_LEFT ? 1.0f : -1.0f);
55  angle = G3D::wrap(angle, 0.0f, float(G3D::twoPi()));
56 
57  owner->SetOrientation(angle); // UpdateSplinePosition does not set orientation with UNIT_STATE_ROTATING
58  owner->SetFacingTo(angle); // Send spline movement to clients
59 
60  if (m_duration > diff)
61  m_duration -= diff;
62  else
63  return false;
64 
65  return true;
66 }
RotateDirection m_direction
Definition: IdleMovementGenerator.h:50
#define M_PI
Definition: Common.h:163
Definition: MotionMaster.h:75
void SetOrientation(float orientation)
Definition: Position.h:99
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
uint32 m_maxDuration
Definition: IdleMovementGenerator.h:49
float GetOrientation() const
Definition: Position.h:107
uint32 m_duration
Definition: IdleMovementGenerator.h:49
void SetFacingTo(float ori)
Definition: Unit.cpp:15777
double twoPi()
Definition: g3dmath.h:159

+ Here is the call graph for this function:

Member Data Documentation

RotateDirection RotateMovementGenerator::m_direction
private
uint32 RotateMovementGenerator::m_duration
private
uint32 RotateMovementGenerator::m_maxDuration
private

The documentation for this class was generated from the following files: