TrinityCore
Loading...
Searching...
No Matches
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(bool force = false);
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 /* Plays animation after movement done
74 * can't be combined with parabolic movement
75 */
76 void SetAnimation(AnimTier anim);
77
78 /* Adds final facing animation
79 * sets unit's facing to specified point/angle after all path done
80 * you can have only one final facing: previous will be overriden
81 */
82 void SetFacing(float angle);
83 void SetFacing(Vector3 const& point);
84 void SetFacing(Unit const* target);
85 void SetFacing(ObjectGuid const& target);
86
87 /* Initializes movement by path
88 * @param path - array of points, shouldn't be empty
89 * @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done
90 */
91 void MovebyPath(PointsArray const& path, int32 pointId = 0);
92
93 /* Initializes simple A to B motion, A is current unit's position, B is destination
94 */
95 void MoveTo(Vector3 const& destination, bool generatePath = true, bool forceDestination = false);
96 void MoveTo(float x, float y, float z, bool generatePath = true, bool forceDestination = false);
97
98 /* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done
99 * Needed for waypoint movement where path splitten into parts
100 */
101 void SetFirstPointId(int32 pointId) { args.path_Idx_offset = pointId; }
102
103 /* Enables CatmullRom spline interpolation mode(makes path smooth)
104 * if not enabled linear spline mode will be choosen. Disabled by default
105 */
106 void SetSmooth();
107
108 /* Enables CatmullRom spline interpolation mode, enables flying animation. Disabled by default
109 */
110 void SetFly();
111
112 /* Enables walk mode. Disabled by default
113 */
114 void SetWalk(bool enable);
115
116 /* Makes movement cyclic. Disabled by default
117 */
118 void SetCyclic();
119
120 /* Enables falling mode. Disabled by default
121 */
122 void SetFall();
123
124 /* Enters transport. Disabled by default
125 */
126 void SetTransportEnter();
127
128 /* Exits transport. Disabled by default
129 */
130 void SetTransportExit();
131
132 /* Inverses unit model orientation. Disabled by default
133 */
134 void SetBackward();
135
136 /* Fixes unit's model rotation. Disabled by default
137 */
138 void SetOrientationFixed(bool enable);
139
140 /* Sets the velocity (in case you want to have custom movement velocity)
141 * if no set, speed will be selected based on unit's speeds and current movement mode
142 * Has no effect if falling mode enabled
143 * velocity shouldn't be negative
144 */
145 void SetVelocity(float velocity);
146
147 void SetSwim();
148
149 PointsArray& Path() { return args.path; }
150
151 /* Disables transport coordinate transformations for cases where raw offsets are available
152 */
153 void DisableTransportPathTransformations();
154 protected:
155
158 };
159
161 inline void MoveSplineInit::SetWalk(bool enable) { args.walk = enable; }
163 inline void MoveSplineInit::SetCyclic() { args.flags.cyclic = true; }
164 inline void MoveSplineInit::SetVelocity(float vel) { args.velocity = vel; args.HasVelocity = true; }
168 inline void MoveSplineInit::SetOrientationFixed(bool enable) { args.flags.orientationFixed = enable; }
170
171 inline void MoveSplineInit::SetParabolic(float amplitude, float time_shift)
172 {
173 args.time_perc = time_shift;
174 args.parabolic_amplitude = amplitude;
176 }
177
179 {
180 args.time_perc = 0.f;
182 }
183
185}
186#endif // TRINITYSERVER_MOVESPLINEINIT_H
#define TC_GAME_API
Definition Define.h:114
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
AnimTier
Definition UnitDefines.h:85
void EnableAnimation(uint8 anim)
void SetWalk(bool enable)
void SetFirstPointId(int32 pointId)
void SetParabolic(float amplitude, float start_time)
void SetVelocity(float velocity)
MoveSplineInit & operator=(MoveSplineInit &&)=delete
void SetAnimation(AnimTier anim)
MoveSplineInit(MoveSplineInit &&init)=delete
MoveSplineInitArgs args
MoveSplineInit(MoveSplineInit const &)=delete
MoveSplineInit & operator=(MoveSplineInit const &)=delete
void SetOrientationFixed(bool enable)
TransportPathTransform(Unit *owner, bool transformForTransport)
Definition Unit.h:769
std::vector< Vector3 > PointsArray