Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
MoveSplineInit.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 SKYFIRESERVER_MOVESPLINEINIT_H
7
#define SKYFIRESERVER_MOVESPLINEINIT_H
8
9
#include "
MoveSplineInitArgs.h
"
10
#include "
PathGenerator.h
"
11
12
class
Unit
;
13
14
namespace
Movement
15
{
16
enum
AnimType
17
{
18
ToGround
= 0,
// 460 = ToGround, index of AnimationData.dbc
19
FlyToFly
= 1,
// 461 = FlyToFly?
20
ToFly
= 2,
// 458 = ToFly
21
FlyToGround
= 3
// 463 = FlyToGround
22
};
23
24
// Transforms coordinates from global to transport offsets
25
class
TransportPathTransform
26
{
27
public
:
28
TransportPathTransform
(
Unit
* owner,
bool
transformForTransport)
29
:
_owner
(owner),
_transformForTransport
(transformForTransport) { }
30
Vector3
operator()
(Vector3 input);
31
32
private
:
33
Unit
*
_owner
;
34
bool
_transformForTransport
;
35
};
36
37
/* Initializes and launches spline movement
38
*/
39
class
MoveSplineInit
40
{
41
public
:
42
explicit
MoveSplineInit
(
Unit
* m);
43
44
/* Final pass of initialization that launches spline movement.
45
*/
46
int32
Launch
();
47
48
/* Final pass of initialization that stops movement.
49
*/
50
void
Stop
();
51
52
/* Adds movement by parabolic trajectory
53
* @param amplitude - the maximum height of parabola, value could be negative and positive
54
* @param start_time - delay between movement starting time and beginning to move by parabolic trajectory
55
* can't be combined with final animation
56
*/
57
void
SetParabolic
(
float
amplitude,
float
start_time);
58
/* Plays animation after movement done
59
* can't be combined with parabolic movement
60
*/
61
void
SetAnimation
(
AnimType
anim);
62
63
/* Adds final facing animation
64
* sets unit's facing to specified point/angle after all path done
65
* you can have only one final facing: previous will be overriden
66
*/
67
void
SetFacing
(
float
angle);
68
void
SetFacing
(Vector3
const
& point);
69
void
SetFacing
(
const
Unit
* target);
70
71
/* Initializes movement by path
72
* @param path - array of points, shouldn't be empty
73
* @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done
74
*/
75
void
MovebyPath
(
const
PointsArray
& path,
int32
pointId = 0);
76
77
/* Initializes simple A to B motion, A is current unit's position, B is destination
78
*/
79
void
MoveTo
(
const
Vector3& destination,
bool
generatePath =
true
,
bool
forceDestination =
false
);
80
void
MoveTo
(
float
x,
float
y,
float
z,
bool
generatePath =
true
,
bool
forceDestination =
false
);
81
82
/* Sets Id of fisrt point of the path. When N-th path point will be done ILisener will notify that pointId + N done
83
* Needed for waypoint movement where path splitten into parts
84
*/
85
void
SetFirstPointId
(
int32
pointId) {
args
.path_Idx_offset = pointId; }
86
87
/* Enables CatmullRom spline interpolation mode(makes path smooth)
88
* if not enabled linear spline mode will be choosen. Disabled by default
89
*/
90
void
SetSmooth
();
91
92
/* Waypoints in packets will be sent without compression
93
*/
94
void
SetUncompressed
();
95
96
/* Enables flying animation. Disabled by default
97
*/
98
void
SetFly
();
99
100
/* Enables walk mode. Disabled by default
101
*/
102
void
SetWalk
(
bool
enable);
103
104
/* Makes movement cyclic. Disabled by default
105
*/
106
void
SetCyclic
();
107
108
/* Enables falling mode. Disabled by default
109
*/
110
void
SetFall
();
111
112
/* Enters transport. Disabled by default
113
*/
114
void
SetTransportEnter
();
115
116
/* Exits transport. Disabled by default
117
*/
118
void
SetTransportExit
();
119
120
/* Inverses unit model orientation. Disabled by default
121
*/
122
void
SetOrientationInversed
();
123
124
/* Fixes unit's model rotation. Disabled by default
125
*/
126
void
SetOrientationFixed
(
bool
enable);
127
128
/* Sets the velocity (in case you want to have custom movement velocity)
129
* if no set, speed will be selected based on unit's speeds and current movement mode
130
* Has no effect if falling mode enabled
131
* velocity shouldn't be negative
132
*/
133
void
SetVelocity
(
float
velocity);
134
135
PointsArray
&
Path
() {
return
args
.path; }
136
137
/* Disables transport coordinate transformations for cases where raw offsets are available
138
*/
139
void
DisableTransportPathTransformations
();
140
141
protected
:
142
MoveSplineInitArgs
args
;
143
Unit
*
unit
;
144
};
145
146
inline
void
MoveSplineInit::SetFly
() {
args
.flags.EnableFlying(); }
147
inline
void
MoveSplineInit::SetWalk
(
bool
enable) {
args
.flags.walkmode = enable; }
148
inline
void
MoveSplineInit::SetSmooth
() {
args
.flags.EnableCatmullRom(); }
149
inline
void
MoveSplineInit::SetUncompressed
() {
args
.flags.uncompressedPath =
true
; }
150
inline
void
MoveSplineInit::SetCyclic
() {
args
.flags.cyclic =
true
; }
151
inline
void
MoveSplineInit::SetVelocity
(
float
vel) {
args
.velocity = vel;
args
.HasVelocity =
true
; }
152
inline
void
MoveSplineInit::SetOrientationInversed
() {
args
.flags.orientationInversed =
true
; }
153
inline
void
MoveSplineInit::SetTransportEnter
() {
args
.flags.EnableTransportEnter(); }
154
inline
void
MoveSplineInit::SetTransportExit
() {
args
.flags.EnableTransportExit(); }
155
inline
void
MoveSplineInit::SetOrientationFixed
(
bool
enable) {
args
.flags.orientationFixed = enable; }
156
157
inline
void
MoveSplineInit::MovebyPath
(
const
PointsArray
& controls,
int32
path_offset)
158
{
159
args
.path_Idx_offset = path_offset;
160
args
.path.resize(controls.size());
161
std::transform(controls.begin(), controls.end(),
args
.path.begin(),
TransportPathTransform
(
unit
,
args
.TransformForTransport));
162
}
163
164
inline
void
MoveSplineInit::MoveTo
(
float
x,
float
y,
float
z,
bool
generatePath,
bool
forceDestination)
165
{
166
MoveTo
(G3D::Vector3(x, y, z), generatePath, forceDestination);
167
}
168
169
inline
void
MoveSplineInit::SetParabolic
(
float
amplitude,
float
time_shift)
170
{
171
args
.time_perc = time_shift;
172
args
.parabolic_amplitude = amplitude;
173
args
.flags.EnableParabolic();
174
}
175
176
inline
void
MoveSplineInit::SetAnimation
(
AnimType
anim)
177
{
178
args
.time_perc = 0.f;
179
args
.flags.EnableAnimation((
uint8
)anim);
180
}
181
182
inline
void
MoveSplineInit::SetFacing
(Vector3
const
& spot)
183
{
184
TransportPathTransform
transform(
unit
,
args
.TransformForTransport);
185
Vector3 finalSpot = transform(spot);
186
args
.facing.f.x = finalSpot.x;
187
args
.facing.f.y = finalSpot.y;
188
args
.facing.f.z = finalSpot.z;
189
args
.flags.EnableFacingPoint();
190
}
191
192
inline
void
MoveSplineInit::DisableTransportPathTransformations
() {
args
.TransformForTransport =
false
; }
193
}
194
#endif
// SKYFIRESERVER_MOVESPLINEINIT_H
int32
std::int32_t int32
Definition
Define.h:73
uint8
std::uint8_t uint8
Definition
Define.h:79
MoveSplineInitArgs.h
PathGenerator.h
Movement::MoveSplineInit::DisableTransportPathTransformations
void DisableTransportPathTransformations()
Definition
MoveSplineInit.h:192
Movement::MoveSplineInit::SetAnimation
void SetAnimation(AnimType anim)
Definition
MoveSplineInit.h:176
Movement::MoveSplineInit::SetTransportExit
void SetTransportExit()
Definition
MoveSplineInit.h:154
Movement::MoveSplineInit::MoveSplineInit
MoveSplineInit(Unit *m)
Definition
MoveSplineInit.cpp:126
Movement::MoveSplineInit::Path
PointsArray & Path()
Definition
MoveSplineInit.h:135
Movement::MoveSplineInit::SetWalk
void SetWalk(bool enable)
Definition
MoveSplineInit.h:147
Movement::MoveSplineInit::Launch
int32 Launch()
Definition
MoveSplineInit.cpp:46
Movement::MoveSplineInit::SetFirstPointId
void SetFirstPointId(int32 pointId)
Definition
MoveSplineInit.h:85
Movement::MoveSplineInit::SetUncompressed
void SetUncompressed()
Definition
MoveSplineInit.h:149
Movement::MoveSplineInit::SetParabolic
void SetParabolic(float amplitude, float start_time)
Definition
MoveSplineInit.h:169
Movement::MoveSplineInit::SetVelocity
void SetVelocity(float velocity)
Definition
MoveSplineInit.h:151
Movement::MoveSplineInit::SetFacing
void SetFacing(float angle)
Definition
MoveSplineInit.cpp:143
Movement::MoveSplineInit::SetTransportEnter
void SetTransportEnter()
Definition
MoveSplineInit.h:153
Movement::MoveSplineInit::MoveTo
void MoveTo(const Vector3 &destination, bool generatePath=true, bool forceDestination=false)
Definition
MoveSplineInit.cpp:157
Movement::MoveSplineInit::Stop
void Stop()
Definition
MoveSplineInit.cpp:107
Movement::MoveSplineInit::SetSmooth
void SetSmooth()
Definition
MoveSplineInit.h:148
Movement::MoveSplineInit::SetOrientationInversed
void SetOrientationInversed()
Definition
MoveSplineInit.h:152
Movement::MoveSplineInit::args
MoveSplineInitArgs args
Definition
MoveSplineInit.h:142
Movement::MoveSplineInit::MovebyPath
void MovebyPath(const PointsArray &path, int32 pointId=0)
Definition
MoveSplineInit.h:157
Movement::MoveSplineInit::SetFall
void SetFall()
Definition
MoveSplineInit.cpp:176
Movement::MoveSplineInit::SetCyclic
void SetCyclic()
Definition
MoveSplineInit.h:150
Movement::MoveSplineInit::SetFly
void SetFly()
Definition
MoveSplineInit.h:146
Movement::MoveSplineInit::unit
Unit * unit
Definition
MoveSplineInit.h:143
Movement::MoveSplineInit::SetOrientationFixed
void SetOrientationFixed(bool enable)
Definition
MoveSplineInit.h:155
Movement::TransportPathTransform
Definition
MoveSplineInit.h:26
Movement::TransportPathTransform::_owner
Unit * _owner
Definition
MoveSplineInit.h:33
Movement::TransportPathTransform::operator()
Vector3 operator()(Vector3 input)
Definition
MoveSplineInit.cpp:182
Movement::TransportPathTransform::TransportPathTransform
TransportPathTransform(Unit *owner, bool transformForTransport)
Definition
MoveSplineInit.h:28
Movement::TransportPathTransform::_transformForTransport
bool _transformForTransport
Definition
MoveSplineInit.h:34
Unit
Definition
Unit.h:1367
Movement
Definition
Unit.h:365
Movement::PointsArray
std::vector< Vector3 > PointsArray
Definition
MoveSplineInitArgs.h:16
Movement::AnimType
AnimType
Definition
MoveSplineInit.h:17
Movement::ToFly
@ ToFly
Definition
MoveSplineInit.h:20
Movement::ToGround
@ ToGround
Definition
MoveSplineInit.h:18
Movement::FlyToFly
@ FlyToFly
Definition
MoveSplineInit.h:19
Movement::FlyToGround
@ FlyToGround
Definition
MoveSplineInit.h:21
Movement::MoveSplineInitArgs
Definition
MoveSplineInitArgs.h:30
src
server
game
Movement
Spline
MoveSplineInit.h
Generated on
for Project SkyFire Core by
1.17.0