TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PointMovementGenerator< T > Class Template Reference

#include <PointMovementGenerator.h>

Public Member Functions

 PointMovementGenerator (uint32 _id, float _x, float _y, float _z, bool _generatePath, float _speed=0.0f)
 
void DoInitialize (T *)
 
void DoFinalize (T *)
 
void DoReset (T *)
 
bool DoUpdate (T *, uint32)
 
void MovementInform (T *)
 
void unitSpeedChanged () override
 
MovementGeneratorType GetMovementGeneratorType () const override
 
void GetDestination (float &x, float &y, float &z) const
 
- Public Member Functions inherited from MovementGeneratorMedium< T, PointMovementGenerator< T > >
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 bool GetResetPosition (Unit *, float &, float &, float &)
 

Private Attributes

uint32 id
 
float i_x
 
float i_y
 
float i_z
 
float speed
 
bool m_generatePath
 
bool i_recalculateSpeed
 

Constructor & Destructor Documentation

template<class T>
PointMovementGenerator< T >::PointMovementGenerator ( uint32  _id,
float  _x,
float  _y,
float  _z,
bool  _generatePath,
float  _speed = 0.0f 
)
inline
29  : id(_id),
30  i_x(_x), i_y(_y), i_z(_z), speed(_speed), m_generatePath(_generatePath), i_recalculateSpeed(false) { }
float i_z
Definition: PointMovementGenerator.h:46
float speed
Definition: PointMovementGenerator.h:47
bool m_generatePath
Definition: PointMovementGenerator.h:48
float i_y
Definition: PointMovementGenerator.h:46
uint32 id
Definition: PointMovementGenerator.h:45
bool i_recalculateSpeed
Definition: PointMovementGenerator.h:49
float i_x
Definition: PointMovementGenerator.h:46

Member Function Documentation

template<class T>
template void PointMovementGenerator< T >::DoFinalize ( T *  )
88 {
89  if (unit->HasUnitState(UNIT_STATE_CHARGING))
90  unit->ClearUnitState(UNIT_STATE_ROAMING | UNIT_STATE_ROAMING_MOVE);
91 
92  if (unit->movespline->Finalized())
93  MovementInform(unit);
94 }
void MovementInform(T *)
Definition: PointMovementGenerator.cpp:106
Definition: Unit.h:567
Definition: Unit.h:554
Definition: Unit.h:572
template<class T>
template void PointMovementGenerator< T >::DoInitialize ( T *  )
33 {
34  if (!unit->IsStopped())
35  unit->StopMoving();
36 
37  unit->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
38 
39  if (id == EVENT_CHARGE_PREPATH)
40  return;
41 
42  Movement::MoveSplineInit init(unit);
43  init.MoveTo(i_x, i_y, i_z, m_generatePath);
44  if (speed > 0.0f)
45  init.SetVelocity(speed);
46  init.Launch();
47 
48  // Call for creature group update
49  if (Creature* creature = unit->ToCreature())
50  if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
51  creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z);
52 }
float i_z
Definition: PointMovementGenerator.h:46
float speed
Definition: PointMovementGenerator.h:47
Definition: Creature.h:467
bool m_generatePath
Definition: PointMovementGenerator.h:48
Definition: SharedDefines.h:4419
float i_y
Definition: PointMovementGenerator.h:46
Definition: Unit.h:554
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:572
float i_x
Definition: PointMovementGenerator.h:46
Definition: MoveSplineInit.h:52

+ Here is the call graph for this function:

template<class T>
template void PointMovementGenerator< T >::DoReset ( T *  )
98 {
99  if (!unit->IsStopped())
100  unit->StopMoving();
101 
102  unit->AddUnitState(UNIT_STATE_ROAMING|UNIT_STATE_ROAMING_MOVE);
103 }
Definition: Unit.h:554
Definition: Unit.h:572
template<class T>
template bool PointMovementGenerator< T >::DoUpdate ( T *  ,
uint32   
)
56 {
57  if (!unit)
58  return false;
59 
60  if (unit->HasUnitState(UNIT_STATE_ROOT | UNIT_STATE_STUNNED))
61  {
62  unit->ClearUnitState(UNIT_STATE_ROAMING_MOVE);
63  return true;
64  }
65 
66  unit->AddUnitState(UNIT_STATE_ROAMING_MOVE);
67 
68  if (id != EVENT_CHARGE_PREPATH && i_recalculateSpeed && !unit->movespline->Finalized())
69  {
70  i_recalculateSpeed = false;
71  Movement::MoveSplineInit init(unit);
72  init.MoveTo(i_x, i_y, i_z, m_generatePath);
73  if (speed > 0.0f) // Default value for point motion type is 0.0, if 0.0 spline will use GetSpeed on unit
74  init.SetVelocity(speed);
75  init.Launch();
76 
77  // Call for creature group update
78  if (Creature* creature = unit->ToCreature())
79  if (creature->GetFormation() && creature->GetFormation()->getLeader() == creature)
80  creature->GetFormation()->LeaderMoveTo(i_x, i_y, i_z);
81  }
82 
83  return !unit->movespline->Finalized();
84 }
float i_z
Definition: PointMovementGenerator.h:46
float speed
Definition: PointMovementGenerator.h:47
Definition: Creature.h:467
bool m_generatePath
Definition: PointMovementGenerator.h:48
Definition: SharedDefines.h:4419
Definition: Unit.h:553
float i_y
Definition: PointMovementGenerator.h:46
bool i_recalculateSpeed
Definition: PointMovementGenerator.h:49
Creature * ToCreature()
Definition: Object.h:194
Definition: Unit.h:560
Definition: Unit.h:572
float i_x
Definition: PointMovementGenerator.h:46
Definition: MoveSplineInit.h:52

+ Here is the call graph for this function:

template<class T>
void PointMovementGenerator< T >::GetDestination ( float &  x,
float &  y,
float &  z 
) const
inline
43 { x = i_x; y = i_y; z = i_z; }
float i_z
Definition: PointMovementGenerator.h:46
float i_y
Definition: PointMovementGenerator.h:46
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
float i_x
Definition: PointMovementGenerator.h:46
G3D::int16 x
Definition: Vector2int16.h:37
template<class T>
MovementGeneratorType PointMovementGenerator< T >::GetMovementGeneratorType ( ) const
inlineoverridevirtual

Implements MovementGenerator.

41 { return POINT_MOTION_TYPE; }
Definition: MotionMaster.h:46
template<class T>
void PointMovementGenerator< T >::MovementInform ( T *  )
106 { }
template<class T>
void PointMovementGenerator< T >::unitSpeedChanged ( )
inlineoverridevirtual

Reimplemented from MovementGenerator.

39 { i_recalculateSpeed = true; }
bool i_recalculateSpeed
Definition: PointMovementGenerator.h:49

Member Data Documentation

template<class T>
bool PointMovementGenerator< T >::i_recalculateSpeed
private
template<class T>
float PointMovementGenerator< T >::i_x
private
template<class T>
float PointMovementGenerator< T >::i_y
private
template<class T>
float PointMovementGenerator< T >::i_z
private
template<class T>
uint32 PointMovementGenerator< T >::id
private
template<class T>
bool PointMovementGenerator< T >::m_generatePath
private
template<class T>
float PointMovementGenerator< T >::speed
private

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