AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
RotateMovementGenerator Class Reference

#include "IdleMovementGenerator.h"

Inheritance diagram for RotateMovementGenerator:
MovementGenerator

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 () override
 
- Public Member Functions inherited from MovementGenerator
virtual ~MovementGenerator ()
 
virtual void Initialize (Unit *)=0
 
virtual void Finalize (Unit *)=0
 
virtual void Reset (Unit *)=0
 
virtual bool Update (Unit *, uint32 time_diff)=0
 
virtual MovementGeneratorType GetMovementGeneratorType ()=0
 
virtual uint32 GetSplineId () const
 
virtual void unitSpeedChanged ()
 
virtual void Pause (uint32)
 
virtual void Resume (uint32)
 
virtual bool GetResetPosition (float &, float &, float &)
 

Private Attributes

uint32 m_duration
 
uint32 m_maxDuration
 
RotateDirection m_direction
 

Detailed Description

Constructor & Destructor Documentation

◆ RotateMovementGenerator()

RotateMovementGenerator::RotateMovementGenerator ( uint32  time,
RotateDirection  direction 
)
inlineexplicit
36: m_duration(time), m_maxDuration(time), m_direction(direction) {}
uint32 m_duration
Definition: IdleMovementGenerator.h:45
uint32 m_maxDuration
Definition: IdleMovementGenerator.h:45
RotateDirection m_direction
Definition: IdleMovementGenerator.h:46

Member Function Documentation

◆ Finalize()

void RotateMovementGenerator::Finalize ( Unit unit)
overridevirtual

Implements MovementGenerator.

73{
75 if (unit->IsCreature())
77}
@ ROTATE_MOTION_TYPE
Definition: MotionMaster.h:53
@ UNIT_STATE_ROTATING
Definition: UnitDefines.h:169
virtual void MovementInform(uint32, uint32)
Definition: CreatureAI.h:156
CreatureAI * AI() const
Definition: Creature.h:143
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
void ClearUnitState(uint32 f)
Definition: Unit.h:674

References Creature::AI(), Unit::ClearUnitState(), Object::IsCreature(), CreatureAI::MovementInform(), ROTATE_MOTION_TYPE, Object::ToCreature(), and UNIT_STATE_ROTATING.

◆ GetMovementGeneratorType()

MovementGeneratorType RotateMovementGenerator::GetMovementGeneratorType ( )
inlineoverridevirtual

Implements MovementGenerator.

42{ return ROTATE_MOTION_TYPE; }

References ROTATE_MOTION_TYPE.

◆ Initialize()

void RotateMovementGenerator::Initialize ( Unit owner)
overridevirtual

Implements MovementGenerator.

36{
37 if (!owner->IsStopped())
38 owner->StopMoving();
39
40 if (owner->GetVictim())
41 owner->SetInFront(owner->GetVictim());
42
44
45 owner->AttackStop();
46}
bool IsStopped() const
Definition: Unit.h:1605
void StopMoving()
Definition: Unit.cpp:16606
void AddUnitState(uint32 f)
Definition: Unit.h:672
Unit * GetVictim() const
Definition: Unit.h:789
void SetInFront(WorldObject const *target)
Definition: Unit.cpp:20477
bool AttackStop()
Force the unit to stop attacking. This will clear UNIT_STATE_MELEE_ATTACKING, Interrupt current spell...
Definition: Unit.cpp:10365

References Unit::AddUnitState(), Unit::AttackStop(), Unit::GetVictim(), Unit::IsStopped(), Unit::SetInFront(), Unit::StopMoving(), and UNIT_STATE_ROTATING.

Referenced by Reset().

◆ Reset()

void RotateMovementGenerator::Reset ( Unit owner)
inlineoverridevirtual

Implements MovementGenerator.

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

References Initialize().

◆ Update()

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

Implements MovementGenerator.

49{
50 float angle = owner->GetOrientation();
52 {
53 angle += (float)diff * static_cast<float>(M_PI * 2) / m_maxDuration;
54 while (angle >= static_cast<float>(M_PI * 2)) angle -= static_cast<float>(M_PI * 2);
55 }
56 else
57 {
58 angle -= (float)diff * static_cast<float>(M_PI * 2) / m_maxDuration;
59 while (angle < 0) angle += static_cast<float>(M_PI * 2);
60 }
61
62 owner->SetFacingTo(angle);
63
64 if (m_duration > diff)
65 m_duration -= diff;
66 else
67 return false;
68
69 return true;
70}
@ ROTATE_DIRECTION_LEFT
Definition: MotionMaster.h:77
float GetOrientation() const
Definition: Position.h:120
void SetFacingTo(float ori)
Definition: Unit.cpp:20483

References Position::GetOrientation(), m_direction, m_duration, m_maxDuration, ROTATE_DIRECTION_LEFT, and Unit::SetFacingTo().

Member Data Documentation

◆ m_direction

RotateDirection RotateMovementGenerator::m_direction
private

Referenced by Update().

◆ m_duration

uint32 RotateMovementGenerator::m_duration
private

Referenced by Update().

◆ m_maxDuration

uint32 RotateMovementGenerator::m_maxDuration
private

Referenced by Update().