Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
28template<class T, class P>
30{
31public:
33 virtual ~PathMovementBase() { };
34
35 // template pattern, not defined .. override required
36 void LoadPath(T&);
38
39protected:
42};
43
44template<class T>
46
47template<>
48class WaypointMovementGenerator<Creature> : public MovementGeneratorMedium< Creature, WaypointMovementGenerator<Creature> >,
49 public PathMovementBase<Creature, WaypointPath const*>
50{
51public:
52 WaypointMovementGenerator(uint32 _path_id = 0, bool _repeating = true)
53 : i_nextMoveTime(0), m_isArrivalDone(false), path_id(_path_id), repeating(_repeating) { }
55 void DoInitialize(Creature*);
56 void DoFinalize(Creature*);
57 void DoReset(Creature*);
58 bool DoUpdate(Creature*, uint32 diff);
59
60 void MovementInform(Creature*);
61
63
64 // now path movement implmementation
65 void LoadPath(Creature*);
66
67 bool GetResetPos(Creature*, float& x, float& y, float& z);
68
69private:
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
93};
94
98class FlightPathMovementGenerator : public MovementGeneratorMedium< Player, FlightPathMovementGenerator >,
99 public PathMovementBase<Player, TaxiPathNodeList const*>
100{
101public:
102 explicit FlightPathMovementGenerator(TaxiPathNodeList const& pathnodes, uint32 startNode = 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);
113
114 TaxiPathNodeList const& GetPath() { return *i_path; }
115 uint32 GetPathAtMapEnd() const;
116 bool HasArrived() const { return (i_currentNode >= i_path->size()); }
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
126private:
127 float _endGridX;
128 float _endGridY;
131};
132#endif
Path< TaxiPathNodePtr, TaxiPathNodeEntry const > TaxiPathNodeList
std::int32_t int32
Definition Define.h:73
std::uint32_t uint32
Definition Define.h:77
MovementGeneratorType
@ WAYPOINT_MOTION_TYPE
@ FLIGHT_MOTION_TYPE
float _endGridY
X coord of last node location.
uint32 _preloadTargetNode
map Id of last node location
MovementGeneratorType GetMovementGeneratorType()
TaxiPathNodeList const & GetPath()
uint32 _endMapId
Y coord of last node location.
FlightPathMovementGenerator(TaxiPathNodeList const &pathnodes, uint32 startNode=0)
void DoEventIfAny(Player *player, TaxiPathNodeEntry const &node, bool departure)
bool GetResetPos(Player *, float &x, float &y, float &z)
void LoadPath(T &)
WaypointMovementGenerator(uint32 _path_id=0, bool _repeating=true)