Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Loading...
Searching...
No Matches
TargetedMovementGenerator.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#ifndef SKYFIRE_TARGETEDMOVEMENTGENERATOR_H
6#define SKYFIRE_TARGETEDMOVEMENTGENERATOR_H
7
8#include "FollowerReference.h"
9#include "MovementGenerator.h"
10#include "PathGenerator.h"
11#include "Timer.h"
12#include "Unit.h"
13
15{
16public:
17 TargetedMovementGeneratorBase(Unit* target) { i_target.link(target, this); }
18 void stopFollowing() { }
19protected:
21};
22
23template<class T, typename D>
25{
26protected:
27 TargetedMovementGeneratorMedium(Unit* target, float offset, float angle) :
29 i_recheckDistance(0), i_offset(offset), i_angle(angle),
31 {
32 }
34
35public:
36 bool DoUpdate(T*, uint32);
37 Unit* GetTarget() const { return i_target.getTarget(); }
38
40 bool IsReachable() const { return (i_path) ? (i_path->GetPathType() & PATHFIND_NORMAL) : true; }
41protected:
42 void _setTargetLocation(T* owner, bool updateDestination);
43
46 float i_offset;
47 float i_angle;
50};
51
52template<class T>
53class ChaseMovementGenerator : public TargetedMovementGeneratorMedium<T, ChaseMovementGenerator<T> >
54{
55public:
58 ChaseMovementGenerator(Unit* target, float offset, float angle)
59 : TargetedMovementGeneratorMedium<T, ChaseMovementGenerator<T> >(target, offset, angle) { }
61
63
64 void DoInitialize(T*);
65 void DoFinalize(T*);
66 void DoReset(T*);
67 void MovementInform(T*);
68
69 static void _clearUnitStateMove(T* u) { u->ClearUnitState(UNIT_STATE_CHASE_MOVE); }
70 static void _addUnitStateMove(T* u) { u->AddUnitState(UNIT_STATE_CHASE_MOVE); }
71 bool EnableWalking() const { return false; }
72 bool _lostTarget(T* u) const { return u->GetVictim() != this->GetTarget(); }
73 void _reachTarget(T*);
74};
75
76template<class T>
77class FollowMovementGenerator : public TargetedMovementGeneratorMedium<T, FollowMovementGenerator<T> >
78{
79public:
82 FollowMovementGenerator(Unit* target, float offset, float angle)
83 : TargetedMovementGeneratorMedium<T, FollowMovementGenerator<T> >(target, offset, angle) { }
85
87
88 void DoInitialize(T*);
89 void DoFinalize(T*);
90 void DoReset(T*);
91 void MovementInform(T*);
92
93 static void _clearUnitStateMove(T* u) { u->ClearUnitState(UNIT_STATE_FOLLOW_MOVE); }
94 static void _addUnitStateMove(T* u) { u->AddUnitState(UNIT_STATE_FOLLOW_MOVE); }
95 bool EnableWalking() const;
96 bool _lostTarget(T*) const { return false; }
97 void _reachTarget(T*) { }
98private:
99 void _updateSpeed(T* owner);
100};
101
102#endif
std::uint32_t uint32
Definition Define.h:77
MovementGeneratorType
@ CHASE_MOTION_TYPE
@ FOLLOW_MOTION_TYPE
@ PATHFIND_NORMAL
@ UNIT_STATE_CHASE_MOVE
Definition Unit.h:537
@ UNIT_STATE_FOLLOW_MOVE
Definition Unit.h:538
ChaseMovementGenerator(Unit *target, float offset, float angle)
MovementGeneratorType GetMovementGeneratorType()
FollowMovementGenerator(Unit *target, float offset, float angle)
bool EnableWalking() const
MovementGeneratorType GetMovementGeneratorType()
void _updateSpeed(T *owner)
TargetedMovementGeneratorMedium(Unit *target, float offset, float angle)
void _setTargetLocation(T *owner, bool updateDestination)
Definition Unit.h:1367