TrinityCore
Loading...
Searching...
No Matches
AreaTriggerTemplate.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 TRINITYCORE_AREATRIGGER_TEMPLATE_H
19#define TRINITYCORE_AREATRIGGER_TEMPLATE_H
20
21#include "DBCEnums.h"
22#include "Define.h"
23#include "EnumFlag.h"
24#include "ObjectGuid.h"
25#include "Optional.h"
26#include "SpawnData.h"
27#include <variant>
28#include <vector>
29
30#define MAX_AREATRIGGER_ENTITY_DATA 8
31#define MAX_AREATRIGGER_SCALE 7
32
34{
35 None = 0x00,
36 IsServerSide = 0x01
37};
38
40
49
60
62{
63 None = 0x0000,
64 HeightIgnoresScale = 0x0001,
65 VisualAnimIsDecay = 0x0002,
66 AbsoluteOrientation = 0x0004,
67 FaceMovementDir = 0x0008, // NYI
68 FollowsTerrain = 0x0010, // NYI
69 AlwaysExterior = 0x0020,
70 UsesUnitRawFacing = 0x0040 // NYI
71};
72
74
76{
78 bool IsCustom = false;
79
80 friend bool operator==(AreaTriggerId const& left, AreaTriggerId const& right) = default;
81};
82
84
91
93{
94 struct Sphere
95 {
97 : Radius(0.0f), RadiusTarget(0.0f) { }
98 explicit Sphere(std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
99 : Radius(raw[0]), RadiusTarget(raw[1]) { }
100
101 float Radius;
103
104 float GetMaxSearchRadius() const;
105 bool IsDynamic() const;
106 };
107
108 struct Box
109 {
111 : Extents(), ExtentsTarget() { }
112 explicit Box(std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
113 : Extents(raw[0], raw[1], raw[2]), ExtentsTarget(raw[3], raw[4], raw[5]) { }
114
117
118 float GetMaxSearchRadius() const;
119 bool IsDynamic() const;
120 };
121
122 struct Polygon
123 {
126 explicit Polygon(AreaTriggerShapeType type, std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
127 : PolygonVertices(), PolygonVerticesTarget(), Height(raw[0]), HeightTarget(raw[1]), Type(type) { }
128
129 std::vector<TaggedPosition<Position::XY>> PolygonVertices;
130 std::vector<TaggedPosition<Position::XY>> PolygonVerticesTarget;
131 float Height;
134
135 float GetMaxSearchRadius() const;
136 bool IsDynamic() const;
137 };
138
139 struct Cylinder
140 {
142 : Radius(0.0f), RadiusTarget(0.0f), Height(0.0f), HeightTarget(0.0f), LocationZOffset(0.0f), LocationZOffsetTarget(0.0f) { }
143 explicit Cylinder(std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
144 : Radius(raw[0]), RadiusTarget(raw[1]), Height(raw[2]), HeightTarget(raw[3]), LocationZOffset(raw[4]), LocationZOffsetTarget(raw[5]) { }
145
146 float Radius;
148 float Height;
152
153 float GetMaxSearchRadius() const;
154 bool IsDynamic() const;
155 };
156
157 struct Disk
158 {
160 : InnerRadius(0.0f), InnerRadiusTarget(0.0f), OuterRadius(0.0f), OuterRadiusTarget(0.0f),
161 Height(0.0f), HeightTarget(0.0f), LocationZOffset(0.0f), LocationZOffsetTarget(0.0f) { }
162 explicit Disk(std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
163 : InnerRadius(raw[0]), InnerRadiusTarget(raw[1]), OuterRadius(raw[2]), OuterRadiusTarget(raw[3]),
164 Height(raw[4]), HeightTarget(raw[5]), LocationZOffset(raw[6]), LocationZOffsetTarget(raw[7]) { }
165
170 float Height;
174
175 float GetMaxSearchRadius() const;
176 bool IsDynamic() const;
177 };
178
180 {
181 BoundedPlane() = default;
182 explicit BoundedPlane(std::array<float, MAX_AREATRIGGER_ENTITY_DATA> const& raw)
183 : ExtentsY(raw[0]), ExtentsZ(raw[1]), ExtentsTargetY(raw[2]), ExtentsTargetZ(raw[3]) { }
184
185 float ExtentsY = 0.0f;
186 float ExtentsZ = 0.0f;
187 float ExtentsTargetY = 0.0f;
188 float ExtentsTargetZ = 0.0f;
189
190 float GetMaxSearchRadius() const;
191 bool IsDynamic() const;
192 };
193
194 std::variant<Sphere, Box, Polygon, Cylinder, Disk, BoundedPlane> Data;
195
196 bool IsSphere() const { return std::holds_alternative<Sphere>(Data); }
197 bool IsBox() const { return std::holds_alternative<Box>(Data); }
198 bool IsPolygon() const { return std::holds_alternative<Polygon>(Data); }
199 bool IsCylinder() const { return std::holds_alternative<Cylinder>(Data); }
200 bool IsDisk() const { return std::holds_alternative<Disk>(Data); }
201 bool IsBoundedPlane() const { return std::holds_alternative<BoundedPlane>(Data); }
202 float GetMaxSearchRadius() const;
203 bool IsDynamic() const;
204};
205
218
231
270
277
278#endif
AreaTriggerCreatePropertiesFlag
AreaTriggerActionTypes
@ AREATRIGGER_ACTION_ADDAURA
@ AREATRIGGER_ACTION_TELEPORT
@ AREATRIGGER_ACTION_TAVERN
@ AREATRIGGER_ACTION_MAX
@ AREATRIGGER_ACTION_CAST
AreaTriggerFlag
AreaTriggerId AreaTriggerCreatePropertiesId
AreaTriggerActionUserTypes
@ AREATRIGGER_ACTION_USER_ENEMY
@ AREATRIGGER_ACTION_USER_ANY
@ AREATRIGGER_ACTION_USER_FRIEND
@ AREATRIGGER_ACTION_USER_CASTER
@ AREATRIGGER_ACTION_USER_MAX
@ AREATRIGGER_ACTION_USER_RAID
@ AREATRIGGER_ACTION_USER_PARTY
AreaTriggerShapeType
Definition DBCEnums.h:196
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
#define DEFINE_ENUM_FLAG(enumType)
Definition EnumFlag.h:26
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition Optional.h:25
@ SPAWN_TYPE_AREATRIGGER
Definition SpawnData.h:38
EnumFlag< AreaTriggerCreatePropertiesFlag > Flags
AreaTriggerCreatePropertiesId Id
TaggedPosition< Position::XYZ > RollPitchYaw
std::vector< Position > SplineInfo
std::variant< std::monostate, SplineInfo, AreaTriggerOrbitInfo > Movement
AreaTriggerTemplate const * Template
Optional< TaggedPosition< Position::XYZ > > TargetRollPitchYaw
EnumFlag< AreaTriggerActionSetFlag > ActionSetFlags
std::vector< AreaTriggerAction > Actions
EnumFlag< AreaTriggerFlag > Flags
AreaTriggerActionTypes ActionType
AreaTriggerActionUserTypes TargetType
friend bool operator==(AreaTriggerId const &left, AreaTriggerId const &right)=default
Optional< TaggedPosition< Position::XYZ > > Center
Optional< ObjectGuid > PathTarget
BoundedPlane(std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
Box(std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
TaggedPosition< Position::XYZ > ExtentsTarget
TaggedPosition< Position::XYZ > Extents
Cylinder(std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
Disk(std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
Polygon(AreaTriggerShapeType type, std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
std::vector< TaggedPosition< Position::XY > > PolygonVerticesTarget
std::vector< TaggedPosition< Position::XY > > PolygonVertices
Sphere(std::array< float, MAX_AREATRIGGER_ENTITY_DATA > const &raw)
std::variant< Sphere, Box, Polygon, Cylinder, Disk, BoundedPlane > Data
AreaTriggerCreatePropertiesId Id