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

Revision 2, 3.6 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_MOTIONMASTER_H
20#define MANGOS_MOTIONMASTER_H
21
22#include "Common.h"
23#include <stack>
24
25class MovementGenerator;
26class Unit;
27
28// Creature Entry ID used for waypoints show, visible only for GMs
29#define VISUAL_WAYPOINT 1
30
31// values 0 ... MAX_DB_MOTION_TYPE-1 used in DB
32enum MovementGeneratorType
33{
34    IDLE_MOTION_TYPE      = 0,                              // IdleMovementGenerator.h
35    RANDOM_MOTION_TYPE    = 1,                              // RandomMovementGenerator.h
36    WAYPOINT_MOTION_TYPE  = 2,                              // WaypointMovementGenerator.h
37    MAX_DB_MOTION_TYPE    = 3,                              // *** this and below motion types can't be set in DB.
38    ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE,         // AnimalRandomMovementGenerator.h
39    CONFUSED_MOTION_TYPE  = 4,                              // ConfusedMovementGenerator.h
40    TARGETED_MOTION_TYPE  = 5,                              // TargetedMovementGenerator.h
41    HOME_MOTION_TYPE      = 6,                              // HomeMovementGenerator.h
42    FLIGHT_MOTION_TYPE    = 7,                              // WaypointMovementGenerator.h
43    POINT_MOTION_TYPE     = 8,                              // PointMovementGenerator.h
44    FLEEING_MOTION_TYPE   = 9,                              // FleeingMovementGenerator.h
45    DISTRACT_MOTION_TYPE  = 10,                             // IdleMovementGenerator.h
46};
47
48class MANGOS_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *>
49{
50    private:
51        typedef std::stack<MovementGenerator *> Impl;
52    public:
53
54        explicit MotionMaster(Unit *unit) : i_owner(unit) {}
55        ~MotionMaster();
56
57        void Initialize();
58
59        MovementGenerator* operator->(void) { return top(); }
60
61        using Impl::top;
62        using Impl::empty;
63
64        typedef Impl::container_type::const_iterator const_iterator;
65        const_iterator begin() const { return Impl::c.begin(); }
66        const_iterator end() const { return Impl::c.end(); }
67
68        void UpdateMotion(const uint32 &diff);
69        void Clear(bool reset = true);
70        void MovementExpired(bool reset = true);
71
72        void MoveIdle();
73        void MoveTargetedHome();
74        void MoveFollow(Unit* target, float dist, float angle);
75        void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f);
76        void MoveConfused();
77        void MoveFleeing(Unit* enemy);
78        void MovePoint(uint32 id, float x,float y,float z);
79        void MoveTaxiFlight(uint32 path, uint32 pathnode);
80        void MoveDistract(uint32 time);
81
82        MovementGeneratorType GetCurrentMovementGeneratorType() const;
83
84        void propagateSpeedChange();
85
86        bool GetDestination(float &x, float &y, float &z);
87    private:
88        void Mutate(MovementGenerator *m);                  // use Move* functions instead
89
90        Unit *i_owner;
91};
92#endif
Note: See TracBrowser for help on using the browser.