TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
MovementGenerator.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef TRINITY_MOVEMENTGENERATOR_H
20 #define TRINITY_MOVEMENTGENERATOR_H
21 
22 #include "Define.h"
23 #include "ObjectRegistry.h"
24 #include "FactoryHolder.h"
25 #include "Common.h"
26 #include "MotionMaster.h"
27 
28 class Unit;
29 
31 {
32  public:
33  virtual ~MovementGenerator();
34 
35  virtual void Initialize(Unit*) = 0;
36  virtual void Finalize(Unit*) = 0;
37 
38  virtual void Reset(Unit*) = 0;
39 
40  virtual bool Update(Unit*, uint32 time_diff) = 0;
41 
42  virtual MovementGeneratorType GetMovementGeneratorType() const = 0;
43 
44  virtual void unitSpeedChanged() { }
45 
46  // used by Evade code for select point to evade with expected restart default movement
47  virtual bool GetResetPosition(Unit*, float& /*x*/, float& /*y*/, float& /*z*/) { return false; }
48 };
49 
50 template<class T, class D>
52 {
53  public:
54  void Initialize(Unit* u) override
55  {
56  //u->AssertIsType<T>();
57  (static_cast<D*>(this))->DoInitialize(static_cast<T*>(u));
58  }
59 
60  void Finalize(Unit* u) override
61  {
62  //u->AssertIsType<T>();
63  (static_cast<D*>(this))->DoFinalize(static_cast<T*>(u));
64  }
65 
66  void Reset(Unit* u) override
67  {
68  //u->AssertIsType<T>();
69  (static_cast<D*>(this))->DoReset(static_cast<T*>(u));
70  }
71 
72  bool Update(Unit* u, uint32 time_diff) override
73  {
74  //u->AssertIsType<T>();
75  return (static_cast<D*>(this))->DoUpdate(static_cast<T*>(u), time_diff);
76  }
77 };
78 
79 struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType>
80 {
82 };
83 
84 template<class REAL_MOVEMENT>
86 {
88 
89  MovementGenerator* Create(void *) const override;
90 };
91 
94 #endif
MovementGenerator * Create(void *) const override
Abstract Factory create method.
Definition: MovementGeneratorImpl.h:26
Definition: MovementGenerator.h:85
Definition: FactoryHolder.h:29
void Initialize(Unit *u) override
Definition: MovementGenerator.h:54
MovementGeneratorFactory(MovementGeneratorType mgt)
Definition: MovementGenerator.h:87
bool Update(Unit *u, uint32 time_diff) override
Definition: MovementGenerator.h:72
void Reset(Unit *u) override
Definition: MovementGenerator.h:66
Definition: MovementGenerator.h:79
virtual bool GetResetPosition(Unit *, float &, float &, float &)
Definition: MovementGenerator.h:47
FactoryHolder< MovementGenerator, MovementGeneratorType > MovementGeneratorCreator
Definition: MovementGenerator.h:92
uint32_t uint32
Definition: Define.h:150
static void Initialize(PCASC_SALSA20 pState, LPBYTE pbKey, DWORD cbKeyLength, LPBYTE pbVector)
Definition: CascDecrypt.cpp:81
Definition: MovementGenerator.h:51
FactoryHolder< MovementGenerator, MovementGeneratorType >::FactoryHolderRegistry MovementGeneratorRegistry
Definition: MovementGenerator.h:93
virtual void unitSpeedChanged()
Definition: MovementGenerator.h:44
#define TC_GAME_API
Definition: Define.h:134
void Finalize(Unit *u) override
Definition: MovementGenerator.h:60
MovementGeneratorType
Definition: MotionMaster.h:35
Definition: MovementGenerator.h:30
Definition: Unit.h:1305
SelectableMovement(MovementGeneratorType mgt)
Definition: MovementGenerator.h:81
void Update(uint32 diff)
Definition: WeatherMgr.cpp:150