[7297] Fixed profession spells sorting in trainer spell list at client.
[getmangos.git] / src / game / TargetedMovementGenerator.h
blob478c54fe3da116eaf80e94dc22e1ce38183425fc
1 /*
2 * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef MANGOS_TARGETEDMOVEMENTGENERATOR_H
20 #define MANGOS_TARGETEDMOVEMENTGENERATOR_H
22 #include "MovementGenerator.h"
23 #include "DestinationHolder.h"
24 #include "Traveller.h"
25 #include "FollowerReference.h"
27 class MANGOS_DLL_SPEC TargetedMovementGeneratorBase
29 public:
30 TargetedMovementGeneratorBase(Unit &target) { i_target.link(&target, this); }
31 void stopFollowing() { }
32 protected:
33 FollowerReference i_target;
36 template<class T>
37 class MANGOS_DLL_SPEC TargetedMovementGenerator
38 : public MovementGeneratorMedium< T, TargetedMovementGenerator<T> >, public TargetedMovementGeneratorBase
40 public:
42 TargetedMovementGenerator(Unit &target)
43 : TargetedMovementGeneratorBase(target), i_offset(0), i_angle(0), i_recalculateTravel(false) {}
44 TargetedMovementGenerator(Unit &target, float offset, float angle)
45 : TargetedMovementGeneratorBase(target), i_offset(offset), i_angle(angle), i_recalculateTravel(false) {}
46 ~TargetedMovementGenerator() {}
48 void Initialize(T &);
49 void Finalize(T &);
50 void Reset(T &);
51 bool Update(T &, const uint32 &);
52 MovementGeneratorType GetMovementGeneratorType() { return TARGETED_MOTION_TYPE; }
54 Unit* GetTarget() const;
56 bool GetDestination(float &x, float &y, float &z) const
58 if(!i_destinationHolder.HasDestination()) return false;
59 i_destinationHolder.GetDestination(x,y,z);
60 return true;
63 void unitSpeedChanged() { i_recalculateTravel=true; }
64 private:
66 void _setTargetLocation(T &);
68 float i_offset;
69 float i_angle;
70 DestinationHolder< Traveller<T> > i_destinationHolder;
71 bool i_recalculateTravel;
73 #endif