root/trunk/src/game/MovementGenerator.h @ 83

Revision 44, 3.3 kB (checked in by yumileroy, 17 years ago)

[svn] * Merge Temp dev SVN with Assembla.
* Changes include:

  • Implementation of w12x's Outdoor PvP and Game Event Systems.
  • Temporary removal of IRC Chat Bot (until infinite loop when disabled is fixed).
  • All mangos -> trinity (to convert your mangos_string table, please run mangos_string_to_trinity_string.sql).
  • Improved Config cleanup.
  • And many more changes.

Original author: Seline
Date: 2008-10-14 11:57:03-05:00

Line 
1/*
2 * Copyright (C) 2008 Trinity <http://www.trinitycore.org/>
3 *
4 * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/>
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
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
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
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */
20
21#ifndef TRINITY_MOVEMENTGENERATOR_H
22#define TRINITY_MOVEMENTGENERATOR_H
23
24#include "Platform/Define.h"
25#include "Policies/Singleton.h"
26#include "Dynamic/ObjectRegistry.h"
27#include "Dynamic/FactoryHolder.h"
28#include "Common.h"
29#include "MotionMaster.h"
30
31class Unit;
32
33class TRINITY_DLL_SPEC MovementGenerator
34{
35    public:
36        virtual ~MovementGenerator();
37
38        virtual void Initialize(Unit &) = 0;
39        virtual void Finalize(Unit &) = 0;
40
41        virtual void Reset(Unit &) = 0;
42
43        virtual bool Update(Unit &, const uint32 &time_diff) = 0;
44
45        virtual MovementGeneratorType GetMovementGeneratorType() = 0;
46
47        virtual void unitSpeedChanged() { }
48
49        virtual bool GetDestination(float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
50};
51
52template<class T, class D>
53class TRINITY_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
54{
55    public:
56        void Initialize(Unit &u)
57        {
58            //u->AssertIsType<T>();
59            (static_cast<D*>(this))->Initialize(*((T*)&u));
60        }
61        void Finalize(Unit &u)
62        {
63            //u->AssertIsType<T>();
64            (static_cast<D*>(this))->Finalize(*((T*)&u));
65        }
66        void Reset(Unit &u)
67        {
68            //u->AssertIsType<T>();
69            (static_cast<D*>(this))->Reset(*((T*)&u));
70        }
71        bool Update(Unit &u, const uint32 &time_diff)
72        {
73            //u->AssertIsType<T>();
74            return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
75        }
76    public:
77        // will not link if not overridden in the generators
78        void Initialize(T &u);
79        void Finalize(T &u);
80        void Reset(T &u);
81        bool Update(T &u, const uint32 &time_diff);
82};
83
84struct SelectableMovement : public FactoryHolder<MovementGenerator,MovementGeneratorType>
85{
86    SelectableMovement(MovementGeneratorType mgt) : FactoryHolder<MovementGenerator,MovementGeneratorType>(mgt) {}
87};
88
89template<class REAL_MOVEMENT>
90struct MovementGeneratorFactory : public SelectableMovement
91{
92    MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) {}
93
94    MovementGenerator* Create(void *) const;
95};
96
97typedef FactoryHolder<MovementGenerator,MovementGeneratorType> MovementGeneratorCreator;
98typedef FactoryHolder<MovementGenerator,MovementGeneratorType>::FactoryHolderRegistry MovementGeneratorRegistry;
99typedef FactoryHolder<MovementGenerator,MovementGeneratorType>::FactoryHolderRepository MovementGeneratorRepository;
100#endif
Note: See TracBrowser for help on using the browser.