[2] | 1 | /* |
---|
[102] | 2 | * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> |
---|
| 3 | * |
---|
[44] | 4 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
[2] | 5 | * |
---|
| 6 | * This program is free software; you can redistribute it and/or modify |
---|
| 7 | * it under the terms of the GNU General Public License as published by |
---|
| 8 | * the Free Software Foundation; either version 2 of the License, or |
---|
| 9 | * (at your option) any later version. |
---|
| 10 | * |
---|
| 11 | * This program is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
[44] | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
[2] | 14 | * GNU General Public License for more details. |
---|
| 15 | * |
---|
| 16 | * You should have received a copy of the GNU General Public License |
---|
| 17 | * along with this program; if not, write to the Free Software |
---|
[44] | 18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
[2] | 19 | */ |
---|
| 20 | |
---|
[44] | 21 | #ifndef TRINITY_MOTIONMASTER_H |
---|
| 22 | #define TRINITY_MOTIONMASTER_H |
---|
[2] | 23 | |
---|
| 24 | #include "Common.h" |
---|
| 25 | #include <stack> |
---|
| 26 | |
---|
| 27 | class MovementGenerator; |
---|
| 28 | class Unit; |
---|
| 29 | |
---|
| 30 | // Creature Entry ID used for waypoints show, visible only for GMs |
---|
| 31 | #define VISUAL_WAYPOINT 1 |
---|
| 32 | |
---|
| 33 | // values 0 ... MAX_DB_MOTION_TYPE-1 used in DB |
---|
| 34 | enum MovementGeneratorType |
---|
| 35 | { |
---|
| 36 | IDLE_MOTION_TYPE = 0, // IdleMovementGenerator.h |
---|
| 37 | RANDOM_MOTION_TYPE = 1, // RandomMovementGenerator.h |
---|
| 38 | WAYPOINT_MOTION_TYPE = 2, // WaypointMovementGenerator.h |
---|
| 39 | MAX_DB_MOTION_TYPE = 3, // *** this and below motion types can't be set in DB. |
---|
| 40 | ANIMAL_RANDOM_MOTION_TYPE = MAX_DB_MOTION_TYPE, // AnimalRandomMovementGenerator.h |
---|
| 41 | CONFUSED_MOTION_TYPE = 4, // ConfusedMovementGenerator.h |
---|
| 42 | TARGETED_MOTION_TYPE = 5, // TargetedMovementGenerator.h |
---|
| 43 | HOME_MOTION_TYPE = 6, // HomeMovementGenerator.h |
---|
| 44 | FLIGHT_MOTION_TYPE = 7, // WaypointMovementGenerator.h |
---|
| 45 | POINT_MOTION_TYPE = 8, // PointMovementGenerator.h |
---|
| 46 | FLEEING_MOTION_TYPE = 9, // FleeingMovementGenerator.h |
---|
| 47 | DISTRACT_MOTION_TYPE = 10, // IdleMovementGenerator.h |
---|
| 48 | }; |
---|
| 49 | |
---|
[44] | 50 | class TRINITY_DLL_SPEC MotionMaster : private std::stack<MovementGenerator *> |
---|
[2] | 51 | { |
---|
| 52 | private: |
---|
| 53 | typedef std::stack<MovementGenerator *> Impl; |
---|
| 54 | public: |
---|
| 55 | |
---|
| 56 | explicit MotionMaster(Unit *unit) : i_owner(unit) {} |
---|
| 57 | ~MotionMaster(); |
---|
| 58 | |
---|
| 59 | void Initialize(); |
---|
| 60 | |
---|
| 61 | MovementGenerator* operator->(void) { return top(); } |
---|
| 62 | |
---|
| 63 | using Impl::top; |
---|
| 64 | using Impl::empty; |
---|
| 65 | |
---|
| 66 | typedef Impl::container_type::const_iterator const_iterator; |
---|
| 67 | const_iterator begin() const { return Impl::c.begin(); } |
---|
| 68 | const_iterator end() const { return Impl::c.end(); } |
---|
| 69 | |
---|
| 70 | void UpdateMotion(const uint32 &diff); |
---|
| 71 | void Clear(bool reset = true); |
---|
| 72 | void MovementExpired(bool reset = true); |
---|
| 73 | |
---|
| 74 | void MoveIdle(); |
---|
| 75 | void MoveTargetedHome(); |
---|
| 76 | void MoveFollow(Unit* target, float dist, float angle); |
---|
| 77 | void MoveChase(Unit* target, float dist = 0.0f, float angle = 0.0f); |
---|
| 78 | void MoveConfused(); |
---|
| 79 | void MoveFleeing(Unit* enemy); |
---|
| 80 | void MovePoint(uint32 id, float x,float y,float z); |
---|
| 81 | void MoveTaxiFlight(uint32 path, uint32 pathnode); |
---|
| 82 | void MoveDistract(uint32 time); |
---|
| 83 | |
---|
| 84 | MovementGeneratorType GetCurrentMovementGeneratorType() const; |
---|
| 85 | |
---|
| 86 | void propagateSpeedChange(); |
---|
| 87 | |
---|
| 88 | bool GetDestination(float &x, float &y, float &z); |
---|
| 89 | private: |
---|
| 90 | void Mutate(MovementGenerator *m); // use Move* functions instead |
---|
| 91 | |
---|
| 92 | Unit *i_owner; |
---|
| 93 | }; |
---|
| 94 | #endif |
---|