TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Movement::MoveSplineInit Class Reference

#include <MoveSplineInit.h>

Public Member Functions

 MoveSplineInit (Unit *m)
 
int32 Launch ()
 
void Stop ()
 
void SetParabolic (float amplitude, float start_time)
 
void SetAnimation (AnimType anim)
 
void SetFacing (float angle)
 
void SetFacing (Vector3 const &point)
 
void SetFacing (const Unit *target)
 
void MovebyPath (const PointsArray &path, int32 pointId=0)
 
void MoveTo (const Vector3 &destination, bool generatePath=true, bool forceDestination=false)
 
void MoveTo (float x, float y, float z, bool generatePath=true, bool forceDestination=false)
 
void SetFirstPointId (int32 pointId)
 
void SetSmooth ()
 
void SetUncompressed ()
 
void SetFly ()
 
void SetWalk (bool enable)
 
void SetCyclic ()
 
void SetFall ()
 
void SetTransportEnter ()
 
void SetTransportExit ()
 
void SetOrientationInversed ()
 
void SetOrientationFixed (bool enable)
 
void SetVelocity (float velocity)
 
PointsArrayPath ()
 
void DisableTransportPathTransformations ()
 

Protected Attributes

MoveSplineInitArgs args
 
Unitunit
 

Constructor & Destructor Documentation

Movement::MoveSplineInit::MoveSplineInit ( Unit m)
explicit
175  : unit(m)
176  {
178  // Elevators also use MOVEMENTFLAG_ONTRANSPORT but we do not keep track of their position changes
180  // mix existing state into new
183  args.flags.smoothGroundPath = true; // enabled by default, CatmullRom mode or client config "pathSmoothing" will disable this
184  }
Definition: Unit.h:784
bool HasMovementFlag(uint32 flag) const
Definition: Object.h:330
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:14355
bool smoothGroundPath
Definition: MoveSplineFlag.h:129
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MovementInfo m_movementInfo
Definition: Object.h:612
Definition: Unit.h:799
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60
Unit * unit
Definition: MoveSplineInit.h:157
T NewId()
Definition: MovementTypedefs.h:70
Definition: Unit.h:785
bool flying
Definition: MoveSplineFlag.h:118
bool walkmode
Definition: MoveSplineFlag.h:130
MovementFlags
Definition: Unit.h:773
uint32 splineId
Definition: MoveSplineInitArgs.h:57
bool IsEmpty() const
Definition: ObjectGuid.h:242
TC_GAME_API UInt32Counter splineIdGen
Definition: MovementUtil.cpp:24

+ Here is the call graph for this function:

Member Function Documentation

void Movement::MoveSplineInit::DisableTransportPathTransformations ( )
inline
206 { args.TransformForTransport = false; }
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60

+ Here is the caller graph for this function:

int32 Movement::MoveSplineInit::Launch ( )
57  {
58  MoveSpline& move_spline = *unit->movespline;
59 
60  bool transport = !unit->GetTransGUID().IsEmpty();
61  Location real_position;
62  // there is a big chance that current position is unknown if current state is not finalized, need compute it
63  // this also allows calculate spline position and update map position in much greater intervals
64  // Don't compute for transport movement if the unit is in a motion between two transports
65  if (!move_spline.Finalized() && move_spline.onTransport == transport)
66  real_position = move_spline.ComputePosition();
67  else
68  {
69  Position const* pos;
70  if (!transport)
71  pos = unit;
72  else
74 
75  real_position.x = pos->GetPositionX();
76  real_position.y = pos->GetPositionY();
77  real_position.z = pos->GetPositionZ();
78  real_position.orientation = unit->GetOrientation();
79  }
80 
81  // should i do the things that user should do? - no.
82  if (args.path.empty())
83  return 0;
84 
85  // correct first vertex
86  args.path[0] = real_position;
87  args.initialOrientation = real_position.orientation;
88  move_spline.onTransport = !unit->GetTransGUID().IsEmpty();
89 
91  moveFlags |= MOVEMENTFLAG_FORWARD;
92 
93  if (moveFlags & MOVEMENTFLAG_ROOT)
94  moveFlags &= ~MOVEMENTFLAG_MASK_MOVING;
95 
96  if (!args.HasVelocity)
97  {
98  // If spline is initialized with SetWalk method it only means we need to select
99  // walk move speed for it but not add walk flag to unit
100  uint32 moveFlagsForSpeed = moveFlags;
101  if (args.flags.walkmode)
102  moveFlagsForSpeed |= MOVEMENTFLAG_WALKING;
103  else
104  moveFlagsForSpeed &= ~MOVEMENTFLAG_WALKING;
105 
106  args.velocity = unit->GetSpeed(SelectSpeedType(moveFlagsForSpeed));
107  }
108 
109  if (!args.Validate(unit))
110  return 0;
111 
113  move_spline.Initialize(args);
114 
116  packet.MoverGUID = unit->GetGUID();
117  packet.Pos = real_position;
118  packet.InitializeSplineData(move_spline);
119  if (transport)
120  {
123  }
124 
125  unit->SendMessageToSet(packet.Write(), true);
126 
127  return move_spline.Duration();
128  }
bool HasVelocity
Definition: MoveSplineInitArgs.h:59
Definition: Unit.h:784
UnitMoveType SelectSpeedType(uint32 moveFlags)
Definition: MoveSplineInit.cpp:27
float initialOrientation
Definition: MoveSplineInitArgs.h:58
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:14355
float GetSpeed(UnitMoveType mtype) const
Definition: Unit.cpp:10526
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MovementInfo m_movementInfo
Definition: Object.h:612
Movement::MoveSpline * movespline
Definition: Unit.h:2213
Definition: Unit.h:808
ObjectGuid MoverGUID
Definition: MovementPackets.h:117
MovementSpline Move
Definition: MovementPackets.h:98
G3D::Vector3 Pos
Definition: MovementPackets.h:118
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
struct MovementInfo::TransportInfo transport
bool Validate(Unit *unit) const
============================================================================================ ...
Definition: MoveSpline.cpp:200
PointsArray path
Definition: MoveSplineInitArgs.h:50
float GetOrientation() const
Definition: Position.h:107
Unit * unit
Definition: MoveSplineInit.h:157
void SetMovementFlags(uint32 flag)
Definition: Object.h:327
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint32_t uint32
Definition: Define.h:150
uint8 VehicleSeat
Definition: MovementPackets.h:85
bool walkmode
Definition: MoveSplineFlag.h:130
float velocity
Definition: MoveSplineInitArgs.h:54
Definition: Unit.h:776
ObjectGuid TransportGUID
Definition: MovementPackets.h:84
Position pos
Definition: Object.h:290
int8 GetTransSeat() const
Definition: Object.h:608
ObjectGuid const & GetGUID() const
Definition: Object.h:105
static Position Location[]
Definition: boss_skadi.cpp:46
MovementMonsterSpline SplineData
Definition: MovementPackets.h:116
Definition: Position.h:27
WorldPacket const * Write() override
Definition: MovementPackets.cpp:427
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
uint32 GetMovementFlags() const
Definition: Object.h:326
Definition: Unit.h:786
float GetPositionX() const
Definition: Position.h:104
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: MovementPackets.h:107
void InitializeSplineData(::Movement::MoveSpline const &moveSpline)
Definition: MovementPackets.cpp:348

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::MovebyPath ( const PointsArray path,
int32  pointId = 0 
)
inline
172  {
173  args.path_Idx_offset = path_offset;
174  args.path.resize(controls.size());
175  std::transform(controls.begin(), controls.end(), args.path.begin(), TransportPathTransform(unit, args.TransformForTransport));
176  }
int32 path_Idx_offset
Definition: MoveSplineInitArgs.h:53
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60
PointsArray path
Definition: MoveSplineInitArgs.h:50
Unit * unit
Definition: MoveSplineInit.h:157

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::MoveTo ( const Vector3 destination,
bool  generatePath = true,
bool  forceDestination = false 
)
207  {
208  if (generatePath)
209  {
210  PathGenerator path(unit);
211  bool result = path.CalculatePath(dest.x, dest.y, dest.z, forceDestination);
212  if (result && !(path.GetPathType() & PATHFIND_NOPATH))
213  {
214  MovebyPath(path.GetPath());
215  return;
216  }
217  }
218 
219  args.path_Idx_offset = 0;
220  args.path.resize(2);
221  TransportPathTransform transform(unit, args.TransformForTransport);
222  args.path[1] = transform(dest);
223  }
Definition: PathGenerator.h:47
int32 path_Idx_offset
Definition: MoveSplineInitArgs.h:53
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void MovebyPath(const PointsArray &path, int32 pointId=0)
Definition: MoveSplineInit.h:171
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60
PointsArray path
Definition: MoveSplineInitArgs.h:50
Unit * unit
Definition: MoveSplineInit.h:157
Definition: PathGenerator.h:52

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::MoveTo ( float  x,
float  y,
float  z,
bool  generatePath = true,
bool  forceDestination = false 
)
inline
179  {
180  MoveTo(G3D::Vector3(x, y, z), generatePath, forceDestination);
181  }
Definition: Vector3.h:58
void MoveTo(const Vector3 &destination, bool generatePath=true, bool forceDestination=false)
Definition: MoveSplineInit.cpp:206
G3D::int16 z
Definition: Vector3int16.h:46
G3D::int16 y
Definition: Vector2int16.h:38
G3D::int16 x
Definition: Vector2int16.h:37

+ Here is the call graph for this function:

PointsArray& Movement::MoveSplineInit::Path ( )
inline
149 { return args.path; }
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
PointsArray path
Definition: MoveSplineInitArgs.h:50

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetAnimation ( AnimType  anim)
inline
191  {
192  args.time_perc = 0.f;
194  }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
float time_perc
Definition: MoveSplineInitArgs.h:56
void EnableAnimation(uint8 anim)
Definition: MoveSplineFlag.h:100
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetCyclic ( )
inline
164 { args.flags.cyclic = true; }
bool cyclic
Definition: MoveSplineFlag.h:121
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetFacing ( float  angle)
193  {
195  {
196  if (Unit* vehicle = unit->GetVehicleBase())
197  angle -= vehicle->GetOrientation();
198  else if (Transport* transport = unit->GetTransport())
199  angle -= transport->GetOrientation();
200  }
201 
202  args.facing.angle = G3D::wrap(angle, 0.f, (float)G3D::twoPi());
204  }
Unit * GetVehicleBase() const
Definition: Unit.cpp:14341
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
Definition: Transport.h:28
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
float wrap(float t, float lo, float hi)
Definition: g3dmath.h:495
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60
Unit * unit
Definition: MoveSplineInit.h:157
FacingInfo facing
Definition: MoveSplineInitArgs.h:51
void EnableFacingAngle()
Definition: MoveSplineFlag.h:106
float angle
Definition: MoveSplineInitArgs.h:36
double twoPi()
Definition: g3dmath.h:159
Transport * GetTransport() const
Definition: Object.h:602
Definition: Unit.h:1305

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetFacing ( Vector3 const point)
inline
197  {
198  TransportPathTransform transform(unit, args.TransformForTransport);
199  Vector3 finalSpot = transform(spot);
200  args.facing.f.x = finalSpot.x;
201  args.facing.f.y = finalSpot.y;
202  args.facing.f.z = finalSpot.z;
204  }
float x
Definition: Vector3.h:62
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
float y
Definition: Vector3.h:62
bool TransformForTransport
Definition: MoveSplineInitArgs.h:60
G3D::Vector3 f
Definition: MoveSplineInitArgs.h:34
Unit * unit
Definition: MoveSplineInit.h:157
FacingInfo facing
Definition: MoveSplineInitArgs.h:51
float z
Definition: Vector3.h:62
void EnableFacingPoint()
Definition: MoveSplineFlag.h:105

+ Here is the call graph for this function:

void Movement::MoveSplineInit::SetFacing ( const Unit target)
187  {
189  args.facing.target = target->GetGUID();
190  }
ObjectGuid target
Definition: MoveSplineInitArgs.h:35
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
FacingInfo facing
Definition: MoveSplineInitArgs.h:51
ObjectGuid const & GetGUID() const
Definition: Object.h:105
void EnableFacingTarget()
Definition: MoveSplineFlag.h:107

+ Here is the call graph for this function:

void Movement::MoveSplineInit::SetFall ( )
226  {
229  }
bool HasUnitMovementFlag(uint32 f) const
Definition: Unit.h:2109
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
Unit * unit
Definition: MoveSplineInit.h:157
Definition: Unit.h:803
bool fallingSlow
Definition: MoveSplineFlag.h:113
void EnableFalling()
Definition: MoveSplineFlag.h:103

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetFirstPointId ( int32  pointId)
inline
99 { args.path_Idx_offset = pointId; }
int32 path_Idx_offset
Definition: MoveSplineInitArgs.h:53
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetFly ( )
inline
160 { args.flags.EnableFlying(); }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void EnableFlying()
Definition: MoveSplineFlag.h:102

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetOrientationFixed ( bool  enable)
inline
169 { args.flags.orientationFixed = enable; }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool orientationFixed
Definition: MoveSplineFlag.h:119

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetOrientationInversed ( )
inline
166 { args.flags.orientationInversed = true;}
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
bool orientationInversed
Definition: MoveSplineFlag.h:128
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void Movement::MoveSplineInit::SetParabolic ( float  amplitude,
float  start_time 
)
inline
184  {
185  args.time_perc = time_shift;
186  args.parabolic_amplitude = amplitude;
188  }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
float parabolic_amplitude
Definition: MoveSplineInitArgs.h:55
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
float time_perc
Definition: MoveSplineInitArgs.h:56
void EnableParabolic()
Definition: MoveSplineFlag.h:101

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetSmooth ( )
inline
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void EnableCatmullRom()
Definition: MoveSplineFlag.h:104

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetTransportEnter ( )
inline
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void EnableTransportEnter()
Definition: MoveSplineFlag.h:108

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetTransportExit ( )
inline
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
void EnableTransportExit()
Definition: MoveSplineFlag.h:109

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetUncompressed ( )
inline
163 { args.flags.uncompressedPath = true; }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool uncompressedPath
Definition: MoveSplineFlag.h:131

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetVelocity ( float  velocity)
inline
165 { args.velocity = vel; args.HasVelocity = true; }
bool HasVelocity
Definition: MoveSplineInitArgs.h:59
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
float velocity
Definition: MoveSplineInitArgs.h:54

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::SetWalk ( bool  enable)
inline
161 { args.flags.walkmode = enable; }
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
bool walkmode
Definition: MoveSplineFlag.h:130

+ Here is the caller graph for this function:

void Movement::MoveSplineInit::Stop ( )
131  {
132  MoveSpline& move_spline = *unit->movespline;
133 
134  // No need to stop if we are not moving
135  if (move_spline.Finalized())
136  return;
137 
138  bool transport = !unit->GetTransGUID().IsEmpty();
139  Location loc;
140  if (move_spline.onTransport == transport)
141  loc = move_spline.ComputePosition();
142  else
143  {
144  Position const* pos;
145  if (!transport)
146  pos = unit;
147  else
149 
150  loc.x = pos->GetPositionX();
151  loc.y = pos->GetPositionY();
152  loc.z = pos->GetPositionZ();
153  loc.orientation = unit->GetOrientation();
154  }
155 
158  move_spline.onTransport = transport;
159  move_spline.Initialize(args);
160 
162  packet.MoverGUID = unit->GetGUID();
163  packet.Pos = loc;
164  packet.SplineData.ID = move_spline.GetId();
165 
166  if (transport)
167  {
170  }
171 
172  unit->SendMessageToSet(packet.Write(), true);
173  }
ObjectGuid GetTransGUID() const override
Definition: Unit.cpp:14355
MoveSplineFlag flags
Definition: MoveSplineInitArgs.h:52
void RemoveMovementFlag(uint32 flag)
Definition: Object.h:329
MovementInfo m_movementInfo
Definition: Object.h:612
Movement::MoveSpline * movespline
Definition: Unit.h:2213
ObjectGuid MoverGUID
Definition: MovementPackets.h:117
MovementSpline Move
Definition: MovementPackets.h:98
uint32 ID
Definition: MovementPackets.h:95
G3D::Vector3 Pos
Definition: MovementPackets.h:118
MoveSplineInitArgs args
Definition: MoveSplineInit.h:156
struct MovementInfo::TransportInfo transport
Definition: MoveSplineFlag.h:37
float GetOrientation() const
Definition: Position.h:107
Unit * unit
Definition: MoveSplineInit.h:157
float GetPositionY() const
Definition: Position.h:105
float GetPositionZ() const
Definition: Position.h:106
uint8 VehicleSeat
Definition: MovementPackets.h:85
Definition: Unit.h:776
ObjectGuid TransportGUID
Definition: MovementPackets.h:84
Position pos
Definition: Object.h:290
int8 GetTransSeat() const
Definition: Object.h:608
ObjectGuid const & GetGUID() const
Definition: Object.h:105
static Position Location[]
Definition: boss_skadi.cpp:46
MovementMonsterSpline SplineData
Definition: MovementPackets.h:116
Definition: Position.h:27
WorldPacket const * Write() override
Definition: MovementPackets.cpp:427
virtual void SendMessageToSet(WorldPacket const *data, bool self)
Definition: Object.cpp:2144
float GetPositionX() const
Definition: Position.h:104
bool IsEmpty() const
Definition: ObjectGuid.h:242
Definition: MovementPackets.h:107

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Member Data Documentation

MoveSplineInitArgs Movement::MoveSplineInit::args
protected
Unit* Movement::MoveSplineInit::unit
protected

The documentation for this class was generated from the following files: