Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
WaypointMovementGenerator.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_WAYPOINTMOVEMENTGENERATOR_H
7
#define SKYFIRE_WAYPOINTMOVEMENTGENERATOR_H
8
14
15
#include "
MovementGenerator.h
"
16
#include "
Path.h
"
17
#include "
WaypointManager.h
"
18
19
#include "
Player.h
"
20
21
#include <set>
22
#include <vector>
23
24
#define FLIGHT_TRAVEL_UPDATE 100
25
#define STOP_TIME_FOR_PLAYER 3 * MINUTE * IN_MILLISECONDS
// 3 Minutes
26
#define TIMEDIFF_NEXT_WP 250
27
28
template
<
class
T,
class
P>
29
class
PathMovementBase
30
{
31
public
:
32
PathMovementBase
() :
i_path
(NULL),
i_currentNode
(0) { }
33
virtual
~PathMovementBase
() { };
34
35
// template pattern, not defined .. override required
36
void
LoadPath
(T&);
37
uint32
GetCurrentNode
()
const
{
return
i_currentNode
; }
38
39
protected
:
40
P
i_path
;
41
uint32
i_currentNode
;
42
};
43
44
template
<
class
T>
45
class
WaypointMovementGenerator
;
46
47
template
<>
48
class
WaypointMovementGenerator
<
Creature
> :
public
MovementGeneratorMedium
< Creature, WaypointMovementGenerator<Creature> >,
49
public
PathMovementBase
<Creature, WaypointPath const*>
50
{
51
public
:
52
WaypointMovementGenerator
(
uint32
_path_id = 0,
bool
_repeating =
true
)
53
:
i_nextMoveTime
(0),
m_isArrivalDone
(false),
path_id
(_path_id),
repeating
(_repeating) { }
54
~WaypointMovementGenerator
() {
i_path
= NULL; }
55
void
DoInitialize(
Creature
*);
56
void
DoFinalize(
Creature
*);
57
void
DoReset(
Creature
*);
58
bool
DoUpdate(
Creature
*,
uint32
diff);
59
60
void
MovementInform(
Creature
*);
61
62
MovementGeneratorType
GetMovementGeneratorType
() {
return
WAYPOINT_MOTION_TYPE
; }
63
64
// now path movement implmementation
65
void
LoadPath(
Creature
*);
66
67
bool
GetResetPos(
Creature
*,
float
& x,
float
& y,
float
& z);
68
69
private
:
70
void
Stop
(
int32
time) {
i_nextMoveTime
.Reset(time); }
71
72
bool
Stopped
() {
return
!
i_nextMoveTime
.Passed(); }
73
74
bool
CanMove
(
int32
diff)
75
{
76
i_nextMoveTime
.Update(diff);
77
return
i_nextMoveTime
.Passed();
78
}
79
80
void
OnArrived(
Creature
*);
81
bool
StartMove(
Creature
*);
82
83
void
StartMoveNow
(
Creature
* creature)
84
{
85
i_nextMoveTime
.Reset(0);
86
StartMove
(creature);
87
}
88
89
TimeTrackerSmall
i_nextMoveTime
;
90
bool
m_isArrivalDone
;
91
uint32
path_id
;
92
bool
repeating
;
93
};
94
98
class
FlightPathMovementGenerator
:
public
MovementGeneratorMedium
< Player, FlightPathMovementGenerator >,
99
public
PathMovementBase
<Player, TaxiPathNodeList const*>
100
{
101
public
:
102
explicit
FlightPathMovementGenerator
(
TaxiPathNodeList
const
& pathnodes,
uint32
startNode = 0) :
103
_endGridX
(0.0f),
_endGridY
(0.0f),
_endMapId
(0),
_preloadTargetNode
(0)
104
{
105
i_path
= &pathnodes;
106
i_currentNode
= startNode;
107
}
108
void
DoInitialize
(
Player
*);
109
void
DoReset
(
Player
*);
110
void
DoFinalize
(
Player
*);
111
bool
DoUpdate
(
Player
*,
uint32
);
112
MovementGeneratorType
GetMovementGeneratorType
() {
return
FLIGHT_MOTION_TYPE
; }
113
114
TaxiPathNodeList
const
&
GetPath
() {
return
*
i_path
; }
115
uint32
GetPathAtMapEnd
()
const
;
116
bool
HasArrived
()
const
{
return
(
i_currentNode
>=
i_path
->size()); }
117
void
SetCurrentNodeAfterTeleport
();
118
void
SkipCurrentNode
() { ++
i_currentNode
; }
119
void
DoEventIfAny
(
Player
* player,
TaxiPathNodeEntry
const
& node,
bool
departure);
120
121
bool
GetResetPos
(
Player
*,
float
& x,
float
& y,
float
& z);
122
123
void
InitEndGridInfo
();
124
void
PreloadEndGrid
();
125
126
private
:
127
float
_endGridX
;
128
float
_endGridY
;
129
uint32
_endMapId
;
130
uint32
_preloadTargetNode
;
131
};
132
#endif
TaxiPathNodeList
Path< TaxiPathNodePtr, TaxiPathNodeEntry const > TaxiPathNodeList
Definition
DBCStructure.h:3083
int32
std::int32_t int32
Definition
Define.h:73
uint32
std::uint32_t uint32
Definition
Define.h:77
MovementGeneratorType
MovementGeneratorType
Definition
MotionMaster.h:23
WAYPOINT_MOTION_TYPE
@ WAYPOINT_MOTION_TYPE
Definition
MotionMaster.h:26
FLIGHT_MOTION_TYPE
@ FLIGHT_MOTION_TYPE
Definition
MotionMaster.h:32
MovementGenerator.h
Path.h
Player.h
WaypointManager.h
Creature
Definition
Creature.h:427
FlightPathMovementGenerator::GetPathAtMapEnd
uint32 GetPathAtMapEnd() const
Definition
WaypointMovementGenerator.cpp:208
FlightPathMovementGenerator::SkipCurrentNode
void SkipCurrentNode()
Definition
WaypointMovementGenerator.h:118
FlightPathMovementGenerator::_endGridY
float _endGridY
X coord of last node location.
Definition
WaypointMovementGenerator.h:128
FlightPathMovementGenerator::DoUpdate
bool DoUpdate(Player *, uint32)
Definition
WaypointMovementGenerator.cpp:273
FlightPathMovementGenerator::_preloadTargetNode
uint32 _preloadTargetNode
map Id of last node location
Definition
WaypointMovementGenerator.h:130
FlightPathMovementGenerator::DoInitialize
void DoInitialize(Player *)
Definition
WaypointMovementGenerator.cpp:223
FlightPathMovementGenerator::GetMovementGeneratorType
MovementGeneratorType GetMovementGeneratorType()
Definition
WaypointMovementGenerator.h:112
FlightPathMovementGenerator::InitEndGridInfo
void InitEndGridInfo()
Definition
WaypointMovementGenerator.cpp:326
FlightPathMovementGenerator::SetCurrentNodeAfterTeleport
void SetCurrentNodeAfterTeleport()
Definition
WaypointMovementGenerator.cpp:294
FlightPathMovementGenerator::_endGridX
float _endGridX
Definition
WaypointMovementGenerator.h:127
FlightPathMovementGenerator::GetPath
TaxiPathNodeList const & GetPath()
Definition
WaypointMovementGenerator.h:114
FlightPathMovementGenerator::_endMapId
uint32 _endMapId
Y coord of last node location.
Definition
WaypointMovementGenerator.h:129
FlightPathMovementGenerator::FlightPathMovementGenerator
FlightPathMovementGenerator(TaxiPathNodeList const &pathnodes, uint32 startNode=0)
Definition
WaypointMovementGenerator.h:102
FlightPathMovementGenerator::DoReset
void DoReset(Player *)
Definition
WaypointMovementGenerator.cpp:251
FlightPathMovementGenerator::DoEventIfAny
void DoEventIfAny(Player *player, TaxiPathNodeEntry const &node, bool departure)
Definition
WaypointMovementGenerator.cpp:310
FlightPathMovementGenerator::PreloadEndGrid
void PreloadEndGrid()
Definition
WaypointMovementGenerator.cpp:337
FlightPathMovementGenerator::HasArrived
bool HasArrived() const
Definition
WaypointMovementGenerator.h:116
FlightPathMovementGenerator::GetResetPos
bool GetResetPos(Player *, float &x, float &y, float &z)
Definition
WaypointMovementGenerator.cpp:319
FlightPathMovementGenerator::DoFinalize
void DoFinalize(Player *)
Definition
WaypointMovementGenerator.cpp:229
MovementGeneratorMedium
Definition
MovementGenerator.h:39
PathMovementBase::~PathMovementBase
virtual ~PathMovementBase()
Definition
WaypointMovementGenerator.h:33
PathMovementBase::i_path
P i_path
Definition
WaypointMovementGenerator.h:40
PathMovementBase::i_currentNode
uint32 i_currentNode
Definition
WaypointMovementGenerator.h:41
PathMovementBase::LoadPath
void LoadPath(T &)
PathMovementBase::PathMovementBase
PathMovementBase()
Definition
WaypointMovementGenerator.h:32
PathMovementBase::GetCurrentNode
uint32 GetCurrentNode() const
Definition
WaypointMovementGenerator.h:37
Player
Definition
Player.h:1289
WaypointMovementGenerator< Creature >::Stopped
bool Stopped()
Definition
WaypointMovementGenerator.h:72
WaypointMovementGenerator< Creature >::StartMoveNow
void StartMoveNow(Creature *creature)
Definition
WaypointMovementGenerator.h:83
WaypointMovementGenerator< Creature >::GetMovementGeneratorType
MovementGeneratorType GetMovementGeneratorType()
Definition
WaypointMovementGenerator.h:62
WaypointMovementGenerator< Creature >::m_isArrivalDone
bool m_isArrivalDone
Definition
WaypointMovementGenerator.h:90
WaypointMovementGenerator< Creature >::~WaypointMovementGenerator
~WaypointMovementGenerator()
Definition
WaypointMovementGenerator.h:54
WaypointMovementGenerator< Creature >::repeating
bool repeating
Definition
WaypointMovementGenerator.h:92
WaypointMovementGenerator< Creature >::i_nextMoveTime
TimeTrackerSmall i_nextMoveTime
Definition
WaypointMovementGenerator.h:89
WaypointMovementGenerator< Creature >::Stop
void Stop(int32 time)
Definition
WaypointMovementGenerator.h:70
WaypointMovementGenerator< Creature >::path_id
uint32 path_id
Definition
WaypointMovementGenerator.h:91
WaypointMovementGenerator< Creature >::CanMove
bool CanMove(int32 diff)
Definition
WaypointMovementGenerator.h:74
WaypointMovementGenerator< Creature >::WaypointMovementGenerator
WaypointMovementGenerator(uint32 _path_id=0, bool _repeating=true)
Definition
WaypointMovementGenerator.h:52
WaypointMovementGenerator< Creature >::StartMove
bool StartMove(Creature *)
Definition
WaypointMovementGenerator.cpp:80
WaypointMovementGenerator
Definition
WaypointMovementGenerator.h:45
TaxiPathNodeEntry
Definition
DBCStructure.h:2758
TimeTrackerSmall
Definition
Timer.h:105
src
server
game
Movement
MovementGenerators
WaypointMovementGenerator.h
Generated on
for Project SkyFire Core by
1.17.0