1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef TRINITY_WAYPOINTDEFINES_H
#define TRINITY_WAYPOINTDEFINES_H
#include "Define.h"
#include "Duration.h"
#include "EnumFlag.h"
#include "Optional.h"
#include <vector>
static inline constexpr std::size_t WAYPOINT_PATH_FLAG_FOLLOW_PATH_BACKWARDS_MINIMUM_NODES = 2;
enum class WaypointMoveType : uint8
{
Walk = 0,
Run = 1,
Land = 2,
TakeOff = 3,
Max
};
enum class WaypointPathFlags : uint8
{
None = 0x00,
FollowPathBackwardsFromEndToStart = 0x01,
ExactSplinePath = 0x02, // Points are going to be merged into single packets and pathfinding is disabled
FlyingPath = ExactSplinePath // flying paths are always exact splines
};
DEFINE_ENUM_FLAG(WaypointPathFlags);
struct WaypointNode
{
constexpr WaypointNode() : Id(0), X(0.f), Y(0.f), Z(0.f), MoveType(WaypointMoveType::Walk) { }
constexpr WaypointNode(uint32 id, float x, float y, float z, Optional<float> orientation = { }, Optional<Milliseconds> delay = {})
: Id(id), X(x), Y(y), Z(z), Orientation(orientation), Delay(delay), MoveType(WaypointMoveType::Walk) { }
uint32 Id;
float X;
float Y;
float Z;
Optional<float> Orientation;
Optional<Milliseconds> Delay;
WaypointMoveType MoveType;
};
struct WaypointPath
{
WaypointPath() = default;
WaypointPath(uint32 id, std::vector<WaypointNode>&& nodes, WaypointMoveType moveType = WaypointMoveType::Walk, WaypointPathFlags flags = WaypointPathFlags::None)
: Nodes(std::move(nodes)), Id(id), MoveType(moveType), Flags(flags) { }
std::vector<WaypointNode> Nodes;
std::vector<std::pair<std::size_t, std::size_t>> ContinuousSegments;
uint32 Id = 0;
WaypointMoveType MoveType = WaypointMoveType::Walk;
EnumFlag<WaypointPathFlags> Flags = WaypointPathFlags::None;
Optional<float> Velocity;
void BuildSegments();
};
#endif
|