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

#include <FleeingMovementGenerator.h>

Public Member Functions

 TimedFleeingMovementGenerator (ObjectGuid fright, uint32 time)
 
MovementGeneratorType GetMovementGeneratorType () const override
 
bool Update (Unit *, uint32) override
 
void Finalize (Unit *) override
 
- Public Member Functions inherited from FleeingMovementGenerator< Creature >
 FleeingMovementGenerator (ObjectGuid fright)
 
void DoInitialize (Creature *)
 
void DoFinalize (Creature *)
 
void DoReset (Creature *)
 
bool DoUpdate (Creature *, uint32)
 
MovementGeneratorType GetMovementGeneratorType () const override
 
- Public Member Functions inherited from MovementGeneratorMedium< Creature, FleeingMovementGenerator< Creature > >
void Initialize (Unit *u) override
 
void Finalize (Unit *u) override
 
void Reset (Unit *u) override
 
bool Update (Unit *u, uint32 time_diff) override
 
- Public Member Functions inherited from MovementGenerator
virtual ~MovementGenerator ()
 
virtual void unitSpeedChanged ()
 
virtual bool GetResetPosition (Unit *, float &, float &, float &)
 

Private Attributes

TimeTracker i_totalFleeTime
 

Constructor & Destructor Documentation

TimedFleeingMovementGenerator::TimedFleeingMovementGenerator ( ObjectGuid  fright,
uint32  time 
)
inline
48  :
50  i_totalFleeTime(time) { }
TimeTracker i_totalFleeTime
Definition: FleeingMovementGenerator.h:57

Member Function Documentation

void TimedFleeingMovementGenerator::Finalize ( Unit owner)
overridevirtual

Implements MovementGenerator.

181 {
184  if (Unit* victim = owner->GetVictim())
185  {
186  if (owner->IsAlive())
187  {
188  owner->AttackStop();
189  owner->ToCreature()->AI()->AttackStart(victim);
190  }
191  }
192 }
bool AttackStop()
Definition: Unit.cpp:7337
Definition: Unit.h:574
Definition: Unit.h:557
Definition: Unit.h:696
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
bool IsAlive() const
Definition: Unit.h:1692
Unit * GetVictim() const
Definition: Unit.h:1379
CreatureAI * AI() const
Definition: Creature.h:525
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
Definition: UpdateFields.h:109
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:1305
virtual void AttackStart(Unit *)
Definition: UnitAI.cpp:29

+ Here is the call graph for this function:

MovementGeneratorType TimedFleeingMovementGenerator::GetMovementGeneratorType ( ) const
inlineoverridevirtual

Implements MovementGenerator.

52 { return TIMED_FLEEING_MOTION_TYPE; }
Definition: MotionMaster.h:51
bool TimedFleeingMovementGenerator::Update ( Unit owner,
uint32  time_diff 
)
overridevirtual

Implements MovementGenerator.

195 {
196  if (!owner->IsAlive())
197  return false;
198 
200  {
202  return true;
203  }
204 
205  i_totalFleeTime.Update(time_diff);
206  if (i_totalFleeTime.Passed())
207  return false;
208 
209  // This calls grant-parent Update method hiden by FleeingMovementGenerator::Update(Creature &, uint32) version
210  // This is done instead of casting Unit& to Creature& and call parent method, then we can use Unit directly
212 }
TimeTracker i_totalFleeTime
Definition: FleeingMovementGenerator.h:57
Definition: Unit.h:574
void ClearUnitState(uint32 f)
Definition: Unit.h:1396
Definition: Unit.h:553
bool IsAlive() const
Definition: Unit.h:1692
void Update(time_t diff)
Definition: Timer.h:109
Definition: MovementGenerator.h:51
Definition: Unit.h:560
bool HasUnitState(const uint32 f) const
Definition: Unit.h:1395
bool Passed() const
Definition: Timer.h:114
bool Update(Unit *, uint32) override
Definition: FleeingMovementGenerator.cpp:194

+ Here is the call graph for this function:

Member Data Documentation

TimeTracker TimedFleeingMovementGenerator::i_totalFleeTime
private

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