TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
PointMovementGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITY_POINTMOVEMENTGENERATOR_H
20 #define TRINITY_POINTMOVEMENTGENERATOR_H
21 
22 #include "MovementGenerator.h"
23 #include "FollowerReference.h"
24 
25 template<class T>
26 class PointMovementGenerator : public MovementGeneratorMedium< T, PointMovementGenerator<T> >
27 {
28  public:
29  PointMovementGenerator(uint32 _id, float _x, float _y, float _z, bool _generatePath, float _speed = 0.0f) : id(_id),
30  i_x(_x), i_y(_y), i_z(_z), speed(_speed), m_generatePath(_generatePath), i_recalculateSpeed(false) { }
31 
32  void DoInitialize(T*);
33  void DoFinalize(T*);
34  void DoReset(T*);
35  bool DoUpdate(T*, uint32);
36 
37  void MovementInform(T*);
38 
39  void unitSpeedChanged() override { i_recalculateSpeed = true; }
40 
42 
43  void GetDestination(float& x, float& y, float& z) const { x = i_x; y = i_y; z = i_z; }
44  private:
46  float i_x, i_y, i_z;
47  float speed;
50 };
51 
53 {
54  public:
55  AssistanceMovementGenerator(float _x, float _y, float _z) :
56  PointMovementGenerator<Creature>(0, _x, _y, _z, true) { }
57 
59  void Finalize(Unit*) override;
60 };
61 
62 // Does almost nothing - just doesn't allows previous movegen interrupt current effect.
64 {
65  public:
66  EffectMovementGenerator(uint32 id, uint32 arrivalSpellId = 0, ObjectGuid const& arrivalSpellTargetGuid = ObjectGuid::Empty)
67  : _id(id), _arrivalSpellId(arrivalSpellId), _arrivalSpellTargetGuid(arrivalSpellTargetGuid) { }
68  void Initialize(Unit*) override { }
69  void Finalize(Unit*) override;
70  void Reset(Unit*) override { }
71  bool Update(Unit*, uint32) override;
73  private:
77 };
78 
79 #endif
AssistanceMovementGenerator(float _x, float _y, float _z)
Definition: PointMovementGenerator.h:55
void GetDestination(float &x, float &y, float &z) const
Definition: PointMovementGenerator.h:43
Definition: MotionMaster.h:49
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
PointMovementGenerator(uint32 _id, float _x, float _y, float _z, bool _generatePath, float _speed=0.0f)
Definition: PointMovementGenerator.h:29
void DoInitialize(T *)
Definition: PointMovementGenerator.cpp:32
float i_z
Definition: PointMovementGenerator.h:46
bool DoUpdate(T *, uint32)
Definition: PointMovementGenerator.cpp:55
void Reset(Unit *) override
Definition: PointMovementGenerator.h:70
float speed
Definition: PointMovementGenerator.h:47
#define false
Definition: CascPort.h:18
Definition: Creature.h:467
Definition: PointMovementGenerator.h:52
MovementGeneratorType GetMovementGeneratorType() const override
Definition: PointMovementGenerator.h:72
bool m_generatePath
Definition: PointMovementGenerator.h:48
#define true
Definition: CascPort.h:17
uint32 _arrivalSpellId
Definition: PointMovementGenerator.h:75
Definition: PointMovementGenerator.h:26
void DoFinalize(T *)
Definition: PointMovementGenerator.cpp:87
float i_y
Definition: PointMovementGenerator.h:46
G3D::int16 z
Definition: Vector3int16.h:46
Definition: MotionMaster.h:54
uint32 id
Definition: PointMovementGenerator.h:45
uint32_t uint32
Definition: Define.h:150
ObjectGuid _arrivalSpellTargetGuid
Definition: PointMovementGenerator.h:76
G3D::int16 y
Definition: Vector2int16.h:38
void MovementInform(T *)
Definition: PointMovementGenerator.cpp:106
void Finalize(Unit *) override
Definition: PointMovementGenerator.cpp:123
bool i_recalculateSpeed
Definition: PointMovementGenerator.h:49
Definition: MovementGenerator.h:51
void Finalize(Unit *) override
Definition: PointMovementGenerator.cpp:136
void unitSpeedChanged() override
Definition: PointMovementGenerator.h:39
Definition: PointMovementGenerator.h:63
void DoReset(T *)
Definition: PointMovementGenerator.cpp:97
MovementGeneratorType GetMovementGeneratorType() const override
Definition: PointMovementGenerator.h:41
EffectMovementGenerator(uint32 id, uint32 arrivalSpellId=0, ObjectGuid const &arrivalSpellTargetGuid=ObjectGuid::Empty)
Definition: PointMovementGenerator.h:66
MovementGeneratorType
Definition: MotionMaster.h:35
void Initialize(Unit *) override
Definition: PointMovementGenerator.h:68
float i_x
Definition: PointMovementGenerator.h:46
Definition: ObjectGuid.h:189
G3D::int16 x
Definition: Vector2int16.h:37
Definition: MovementGenerator.h:30
bool Update(Unit *, uint32) override
Definition: PointMovementGenerator.cpp:131
Definition: Unit.h:1305
Definition: MotionMaster.h:46
MovementGeneratorType GetMovementGeneratorType() const override
Definition: PointMovementGenerator.h:58
uint32 _id
Definition: PointMovementGenerator.h:74