[7719] Use all existed 4 world map overlay area ids instead 3, replace values by...
[AHbot.git] / src / game / MovementGenerator.h
blob2653ea63665fd8e65373db2ed05f7fb998c4ae9e
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_MOVEMENTGENERATOR_H
20 #define MANGOS_MOVEMENTGENERATOR_H
22 #include "Platform/Define.h"
23 #include "Policies/Singleton.h"
24 #include "Dynamic/ObjectRegistry.h"
25 #include "Dynamic/FactoryHolder.h"
26 #include "Common.h"
27 #include "MotionMaster.h"
29 class Unit;
31 class MANGOS_DLL_SPEC MovementGenerator
33 public:
34 virtual ~MovementGenerator();
36 virtual void Initialize(Unit &) = 0;
37 virtual void Finalize(Unit &) = 0;
39 virtual void Reset(Unit &) = 0;
41 virtual bool Update(Unit &, const uint32 &time_diff) = 0;
43 virtual MovementGeneratorType GetMovementGeneratorType() = 0;
45 virtual void unitSpeedChanged() { }
47 virtual bool GetDestination(float& /*x*/, float& /*y*/, float& /*z*/) const { return false; }
50 template<class T, class D>
51 class MANGOS_DLL_SPEC MovementGeneratorMedium : public MovementGenerator
53 public:
54 void Initialize(Unit &u)
56 //u->AssertIsType<T>();
57 (static_cast<D*>(this))->Initialize(*((T*)&u));
59 void Finalize(Unit &u)
61 //u->AssertIsType<T>();
62 (static_cast<D*>(this))->Finalize(*((T*)&u));
64 void Reset(Unit &u)
66 //u->AssertIsType<T>();
67 (static_cast<D*>(this))->Reset(*((T*)&u));
69 bool Update(Unit &u, const uint32 &time_diff)
71 //u->AssertIsType<T>();
72 return (static_cast<D*>(this))->Update(*((T*)&u), time_diff);
74 public:
75 // will not link if not overridden in the generators
76 void Initialize(T &u);
77 void Finalize(T &u);
78 void Reset(T &u);
79 bool Update(T &u, const uint32 &time_diff);
82 struct SelectableMovement : public FactoryHolder<MovementGenerator,MovementGeneratorType>
84 SelectableMovement(MovementGeneratorType mgt) : FactoryHolder<MovementGenerator,MovementGeneratorType>(mgt) {}
87 template<class REAL_MOVEMENT>
88 struct MovementGeneratorFactory : public SelectableMovement
90 MovementGeneratorFactory(MovementGeneratorType mgt) : SelectableMovement(mgt) {}
92 MovementGenerator* Create(void *) const;
95 typedef FactoryHolder<MovementGenerator,MovementGeneratorType> MovementGeneratorCreator;
96 typedef FactoryHolder<MovementGenerator,MovementGeneratorType>::FactoryHolderRegistry MovementGeneratorRegistry;
97 typedef FactoryHolder<MovementGenerator,MovementGeneratorType>::FactoryHolderRepository MovementGeneratorRepository;
98 #endif