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

#include "IdleMovementGenerator.h"

Inheritance diagram for DistractMovementGenerator:
MovementGenerator AssistanceDistractMovementGenerator

Public Member Functions

 DistractMovementGenerator (uint32 timer)
 
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_timer
 

Detailed Description

Constructor & Destructor Documentation

◆ DistractMovementGenerator()

DistractMovementGenerator::DistractMovementGenerator ( uint32  timer)
inlineexplicit
52: m_timer(timer) {}
uint32 m_timer
Definition: IdleMovementGenerator.h:61

Member Function Documentation

◆ Finalize()

void DistractMovementGenerator::Finalize ( Unit owner)
overridevirtual

Implements MovementGenerator.

Reimplemented in AssistanceDistractMovementGenerator.

89{
91
92 // If this is a creature, then return orientation to original position (for idle movement creatures)
93 if (owner->IsCreature() && owner->ToCreature())
94 {
95 float angle = owner->ToCreature()->GetHomePosition().GetOrientation();
96 owner->SetFacingTo(angle);
97 }
98}
@ UNIT_STATE_DISTRACTED
Definition: UnitDefines.h:161
void GetHomePosition(float &x, float &y, float &z, float &ori) const
Definition: Creature.h:339
bool IsCreature() const
Definition: Object.h:201
Creature * ToCreature()
Definition: Object.h:202
void ClearUnitState(uint32 f)
Definition: Unit.h:674
void SetFacingTo(float ori)
Definition: Unit.cpp:20483

References Unit::ClearUnitState(), Creature::GetHomePosition(), Object::IsCreature(), Unit::SetFacingTo(), Object::ToCreature(), and UNIT_STATE_DISTRACTED.

◆ GetMovementGeneratorType()

MovementGeneratorType DistractMovementGenerator::GetMovementGeneratorType ( )
inlineoverridevirtual

Implements MovementGenerator.

Reimplemented in AssistanceDistractMovementGenerator.

58{ return DISTRACT_MOTION_TYPE; }
@ DISTRACT_MOTION_TYPE
Definition: MotionMaster.h:48

References DISTRACT_MOTION_TYPE.

◆ Initialize()

void DistractMovementGenerator::Initialize ( Unit owner)
overridevirtual

Implements MovementGenerator.

80{
81 // Distracted creatures stand up if not standing
82 if (!owner->IsStandState())
84
86}
@ UNIT_STAND_STATE_STAND
Definition: UnitDefines.h:32
bool IsStandState() const
Definition: Unit.cpp:16676
void AddUnitState(uint32 f)
Definition: Unit.h:672
void SetStandState(uint8 state)
Definition: Unit.cpp:16682

References Unit::AddUnitState(), Unit::IsStandState(), Unit::SetStandState(), UNIT_STAND_STATE_STAND, and UNIT_STATE_DISTRACTED.

Referenced by Reset().

◆ Reset()

void DistractMovementGenerator::Reset ( Unit owner)
inlineoverridevirtual

Implements MovementGenerator.

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

References Initialize().

◆ Update()

bool DistractMovementGenerator::Update ( Unit owner,
uint32  time_diff 
)
overridevirtual

Implements MovementGenerator.

101{
102 if (owner->IsInCombat() || time_diff > m_timer)
103 return false;
104
105 m_timer -= time_diff;
106 return true;
107}
bool IsInCombat() const
Definition: Unit.h:820

References Unit::IsInCombat(), and m_timer.

Member Data Documentation

◆ m_timer

uint32 DistractMovementGenerator::m_timer
private

Referenced by Update().