TrinityCore
MoveSplineInit.h
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef TRINITYSERVER_MOVESPLINEINIT_H
19#define TRINITYSERVER_MOVESPLINEINIT_H
20
21#include "MoveSplineInitArgs.h"
22
23class ObjectGuid;
24class Unit;
25
26enum class AnimTier : uint8;
27
28namespace Movement
29{
30
31 // Transforms coordinates from global to transport offsets
33 {
34 public:
35 TransportPathTransform(Unit* owner, bool transformForTransport)
36 : _owner(owner), _transformForTransport(transformForTransport) { }
37 Vector3 operator()(Vector3 input);
38
39 private:
42 };
43
44 /* Initializes and launches spline movement
45 */
47 {
48 public:
49
50 explicit MoveSplineInit(Unit* m);
51
53
58
59 /* Final pass of initialization that launches spline movement.
60 */
61 int32 Launch();
62
63 /* Final pass of initialization that stops movement.
64 */
65 void Stop();
66
67 /* Adds movement by parabolic trajectory
68 * @param amplitude - the maximum height of parabola, value could be negative and positive
69 * @param start_time - delay between movement starting time and beginning to move by parabolic trajectory
70 * can't be combined with final animation
71 */
72 void SetParabolic(float amplitude, float start_time);
73 /* Adds movement by parabolic trajectory
74 * @param vertical_acceleration - vertical acceleration
75 * @param start_time - delay between movement starting time and beginning to move by parabolic trajectory
76 * can't be combined with final animation
77 */
78 void SetParabolicVerticalAcceleration(float vertical_acceleration, float time_shift);
79 /* Plays animation after movement done
80 * can't be combined with parabolic movement
81 */
82 void SetAnimation(AnimTier anim, uint32 tierTransitionId = 0, Milliseconds transitionStartTime = 0ms);
83
84 /* Adds final facing animation
85 * sets unit's facing to specified point/angle after all path done
86 * you can have only one final facing: previous will be overriden
87 */
88 void SetFacing(float angle);
89 void SetFacing(Vector3 const& point);
90 void SetFacing(float x, float y, float z);
91 void SetFacing(Unit const* target);
92
93 /* Initializes movement by path
94 * @param path - array of points, shouldn't be empty
95 * @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done
96 */
97 void MovebyPath(PointsArray const& path, int32 pointId = 0);
98
99 /* Initializes simple A to B motion, A is current unit's position, B is destination
100 */
101 void MoveTo(Vector3 const& destination, bool generatePath = true, bool forceDestination = false);
102 void MoveTo(float x, float y, float z, bool generatePath = true, bool forceDestination = false);
103
104 /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done
105 * Needed for waypoint movement where path splitten into parts
106 */
107 void SetFirstPointId(int32 pointId) { args.path_Idx_offset = pointId; }
108
109 /* Enables CatmullRom spline interpolation mode(makes path smooth)
110 * if not enabled linear spline mode will be choosen. Disabled by default
111 */
112 void SetSmooth();
113
114 /* Waypoints in packets will be sent without compression
115 */
116 void SetUncompressed();
117
118 /* Enables flying animation. Disabled by default
119 */
120 void SetFly();
121
122 /* Enables walk mode. Disabled by default
123 */
124 void SetWalk(bool enable);
125
126 /* Makes movement cyclic. Disabled by default
127 */
128 void SetCyclic();
129
130 /* Enables falling mode. Disabled by default
131 */
132 void SetFall();
133
134 /* Enters transport. Disabled by default
135 */
136 void SetTransportEnter();
137
138 /* Exits transport. Disabled by default
139 */
140 void SetTransportExit();
141
142 /* Inverses unit model orientation. Disabled by default
143 */
144 void SetBackward();
145
146 /* Fixes unit's model rotation. Disabled by default
147 */
148 void SetOrientationFixed(bool enable);
149
150 /* Enables no-speed limit
151 * if not set, the speed will be limited by certain flags to 50.0f, and otherwise 28.0f
152 */
153 void SetUnlimitedSpeed();
154
155 /* Sets the velocity (in case you want to have custom movement velocity)
156 * if no set, speed will be selected based on unit's speeds and current movement mode
157 * Has no effect if falling mode enabled
158 * velocity shouldn't be negative
159 */
160 void SetVelocity(float velocity);
161
162 void SetSpellEffectExtraData(SpellEffectExtraData const& spellEffectExtraData);
163
164 PointsArray& Path() { return args.path; }
165
166 /* Disables transport coordinate transformations for cases where raw offsets are available
167 */
168 void DisableTransportPathTransformations();
169 protected:
170
173 };
174
176 inline void MoveSplineInit::SetWalk(bool enable) { args.walk = enable; }
179 inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; }
180 inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; }
184 inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable; }
186
187 inline void MoveSplineInit::SetParabolic(float amplitude, float time_shift)
188 {
189 args.effect_start_time_percent = time_shift;
190 args.parabolic_amplitude = amplitude;
193 }
194
195 inline void MoveSplineInit::SetParabolicVerticalAcceleration(float vertical_acceleration, float time_shift)
196 {
197 args.effect_start_time_percent = time_shift;
199 args.vertical_acceleration = vertical_acceleration;
201 }
202
203 inline void MoveSplineInit::SetAnimation(AnimTier anim, uint32 tierTransitionId /*= 0*/, Milliseconds transitionStartTime /*= 0ms*/)
204 {
206 args.effect_start_time = transitionStartTime;
207 args.animTier.emplace();
208 args.animTier->TierTransitionId = tierTransitionId;
209 args.animTier->AnimTier = anim;
211 }
212
214
215 inline void MoveSplineInit::SetSpellEffectExtraData(SpellEffectExtraData const& spellEffectExtraData)
216 {
217 args.spellEffectExtra = spellEffectExtraData;
218 }
219}
220#endif // TRINITYSERVER_MOVESPLINEINIT_H
#define TC_GAME_API
Definition: Define.h:123
uint8_t uint8
Definition: Define.h:144
int32_t int32
Definition: Define.h:138
uint32_t uint32
Definition: Define.h:142
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition: Duration.h:29
AnimTier
Definition: UnitDefines.h:69
void DisableTransportPathTransformations()
void SetWalk(bool enable)
void SetFirstPointId(int32 pointId)
void SetParabolic(float amplitude, float start_time)
void SetVelocity(float velocity)
MoveSplineInit & operator=(MoveSplineInit &&)=delete
MoveSplineInit(MoveSplineInit &&init)=delete
void SetSpellEffectExtraData(SpellEffectExtraData const &spellEffectExtraData)
MoveSplineInitArgs args
MoveSplineInit(MoveSplineInit const &)=delete
void SetParabolicVerticalAcceleration(float vertical_acceleration, float time_shift)
void SetAnimation(AnimTier anim, uint32 tierTransitionId=0, Milliseconds transitionStartTime=0ms)
MoveSplineInit & operator=(MoveSplineInit const &)=delete
void SetOrientationFixed(bool enable)
TransportPathTransform(Unit *owner, bool transformForTransport)
Definition: Unit.h:627
std::vector< Vector3 > PointsArray
Optional< AnimTierTransition > animTier
Optional< SpellEffectExtraData > spellEffectExtra