root/trunk/src/game/TargetedMovementGenerator.h @ 9

Revision 2, 2.5 kB (checked in by yumileroy, 17 years ago)

[svn] * Proper SVN structure

Original author: Neo2003
Date: 2008-10-02 16:23:55-05:00

Line 
1/*
2 * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/>
3 *
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.
8 *
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.
13 *
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
17 */
18
19#ifndef MANGOS_TARGETEDMOVEMENTGENERATOR_H
20#define MANGOS_TARGETEDMOVEMENTGENERATOR_H
21
22#include "MovementGenerator.h"
23#include "DestinationHolder.h"
24#include "Traveller.h"
25#include "FollowerReference.h"
26
27class MANGOS_DLL_SPEC TargetedMovementGeneratorBase
28{
29    public:
30        TargetedMovementGeneratorBase(Unit &target) { i_target.link(&target, this); }
31        void stopFollowing() { }
32    protected:
33        FollowerReference i_target;
34};
35
36template<class T>
37class MANGOS_DLL_SPEC TargetedMovementGenerator
38: public MovementGeneratorMedium< T, TargetedMovementGenerator<T> >, public TargetedMovementGeneratorBase
39{
40    public:
41
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() {}
47
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; }
53
54        Unit* GetTarget() const;
55
56        bool GetDestination(float &x, float &y, float &z) const
57        {
58            if(!i_destinationHolder.HasDestination()) return false;
59            i_destinationHolder.GetDestination(x,y,z);
60            return true;
61        }
62
63        void unitSpeedChanged() { i_recalculateTravel=true; }
64    private:
65
66        void _setTargetLocation(T &);
67
68        float i_offset;
69        float i_angle;
70        DestinationHolder< Traveller<T> > i_destinationHolder;
71        bool i_recalculateTravel;
72};
73#endif
Note: See TracBrowser for help on using the browser.