Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
MovementGenerator.h
Go to the documentation of this file.
1/*
2* This file is part of Project SkyFire https://www.projectskyfire.org.
3* See LICENSE.md file for Copyright information
4*/
5
6#ifndef SKYFIRE_MOVEMENTGENERATOR_H
7#define SKYFIRE_MOVEMENTGENERATOR_H
8
9#include "Common.h"
10#include "Define.h"
11#include "FactoryHolder.h"
12#include "MotionMaster.h"
13#include "ObjectRegistry.h"
14
15class Unit;
16
18{
19public:
20 virtual ~MovementGenerator();
21
22 virtual void Initialize(Unit*) = 0;
23 virtual void Finalize(Unit*) = 0;
24
25 virtual void Reset(Unit*) = 0;
26
27 virtual bool Update(Unit*, uint32 time_diff) = 0;
28
30
31 virtual void unitSpeedChanged() { }
32
33 // used by Evade code for select point to evade with expected restart default movement
34 virtual bool GetResetPosition(Unit*, float& /*x*/, float& /*y*/, float& /*z*/) { return false; }
35};
36
37template<class T, class D>
39{
40public:
42 {
43 //u->AssertIsType<T>();
44 (static_cast<D*>(this))->DoInitialize(static_cast<T*>(u));
45 }
46
47 void Finalize(Unit* u)
48 {
49 //u->AssertIsType<T>();
50 (static_cast<D*>(this))->DoFinalize(static_cast<T*>(u));
51 }
52
53 void Reset(Unit* u)
54 {
55 //u->AssertIsType<T>();
56 (static_cast<D*>(this))->DoReset(static_cast<T*>(u));
57 }
58
59 bool Update(Unit* u, uint32 time_diff)
60 {
61 //u->AssertIsType<T>();
62 return (static_cast<D*>(this))->DoUpdate(static_cast<T*>(u), time_diff);
63 }
64};
65
66struct SelectableMovement : public FactoryHolder<MovementGenerator, MovementGeneratorType>
67{
69};
70
71template<class REAL_MOVEMENT>
78
82#endif
std::uint32_t uint32
Definition Define.h:77
MovementGeneratorType
FactoryHolder< MovementGenerator, MovementGeneratorType >::FactoryHolderRepository MovementGeneratorRepository
FactoryHolder< MovementGenerator, MovementGeneratorType >::FactoryHolderRegistry MovementGeneratorRegistry
FactoryHolder< MovementGenerator, MovementGeneratorType > MovementGeneratorCreator
Skyfire::Singleton< FactoryHolderRegistry, Skyfire::NullMutex > FactoryHolderRepository
ObjectRegistry< FactoryHolder< T, Key >, Key > FactoryHolderRegistry
virtual void Initialize(Unit *)=0
virtual void unitSpeedChanged()
virtual bool GetResetPosition(Unit *, float &, float &, float &)
virtual MovementGeneratorType GetMovementGeneratorType()=0
virtual void Reset(Unit *)=0
virtual bool Update(Unit *, uint32 time_diff)=0
virtual void Finalize(Unit *)=0
bool Update(Unit *u, uint32 time_diff)
Definition Unit.h:1367
MovementGenerator * Create(void *) const
Abstract Factory create method.
MovementGeneratorFactory(MovementGeneratorType mgt)
SelectableMovement(MovementGeneratorType mgt)