mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Movement: Use std::span argument instead of std::vector in MoveSplineInit::MovebyPath to avoid having to construct temporary containers
This commit is contained in:
@@ -272,7 +272,7 @@ namespace Movement
|
||||
args.facing.type = MONSTER_MOVE_FACING_ANGLE;
|
||||
}
|
||||
|
||||
void MoveSplineInit::MovebyPath(PointsArray const& path, int32 pointId)
|
||||
void MoveSplineInit::MovebyPath(std::span<Vector3 const> path, int32 pointId)
|
||||
{
|
||||
args.path_Idx_offset = pointId;
|
||||
args.path.resize(path.size());
|
||||
|
||||
@@ -19,6 +19,7 @@
|
||||
#define TRINITYSERVER_MOVESPLINEINIT_H
|
||||
|
||||
#include "MoveSplineInitArgs.h"
|
||||
#include <span>
|
||||
#include <variant>
|
||||
|
||||
class ObjectGuid;
|
||||
@@ -82,7 +83,7 @@ namespace Movement
|
||||
* @param path - array of points, shouldn't be empty
|
||||
* @param pointId - Id of fisrt point of the path. Example: when third path point will be done it will notify that pointId + 3 done
|
||||
*/
|
||||
void MovebyPath(PointsArray const& path, int32 pointId = 0);
|
||||
void MovebyPath(std::span<Vector3 const> path, int32 pointId = 0);
|
||||
|
||||
/* Initializes simple A to B motion, A is current unit's position, B is destination
|
||||
*/
|
||||
@@ -190,6 +191,7 @@ namespace Movement
|
||||
args.parabolic_amplitude = amplitude;
|
||||
args.vertical_acceleration = 0.0f;
|
||||
args.flags.Parabolic = true;
|
||||
args.animTier.reset();
|
||||
}
|
||||
|
||||
inline void MoveSplineInit::SetParabolicVerticalAcceleration(float vertical_acceleration, int32 start_point)
|
||||
@@ -198,16 +200,17 @@ namespace Movement
|
||||
args.parabolic_amplitude = 0.0f;
|
||||
args.vertical_acceleration = vertical_acceleration;
|
||||
args.flags.Parabolic = true;
|
||||
args.animTier.reset();
|
||||
}
|
||||
|
||||
inline void MoveSplineInit::SetAnimation(AnimTier anim, uint32 tierTransitionId /*= 0*/, int32 transitionStartPoint /*= 0*/)
|
||||
{
|
||||
args.effect_start_point = transitionStartPoint;
|
||||
args.animTier.emplace();
|
||||
args.animTier->TierTransitionId = tierTransitionId;
|
||||
args.animTier->AnimTier = anim;
|
||||
if (!tierTransitionId)
|
||||
args.flags.Animation = true;
|
||||
AnimTierTransition& animTier = args.animTier.emplace();
|
||||
animTier.TierTransitionId = tierTransitionId;
|
||||
animTier.AnimTier = anim;
|
||||
args.flags.Raw &= ~args.flags.Animation.DisallowedFlag;
|
||||
args.flags.Animation = tierTransitionId == 0;
|
||||
}
|
||||
|
||||
inline void MoveSplineInit::DisableTransportPathTransformations() { args.TransformForTransport = false; }
|
||||
|
||||
@@ -320,7 +320,7 @@ ByteBuffer& operator<<(ByteBuffer& data, MonsterSplineAnimTierTransition const&
|
||||
data << int32(animTierTransition.TierTransitionID);
|
||||
data << uint8(animTierTransition.AnimTier);
|
||||
data << uint32(animTierTransition.StartTime);
|
||||
data << uint32(animTierTransition.EndTime);
|
||||
data << uint32(animTierTransition.ExtraDuration);
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
@@ -101,7 +101,7 @@ namespace WorldPackets
|
||||
{
|
||||
int32 TierTransitionID = 0;
|
||||
uint32 StartTime = 0;
|
||||
uint32 EndTime = 0;
|
||||
uint32 ExtraDuration = 0; ///< Duration of the transition (unit does not move during this time)
|
||||
uint8 AnimTier = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -429,8 +429,7 @@ enum EyeOfAcherusMisc
|
||||
POINT_NEW_AVALON = 1
|
||||
};
|
||||
|
||||
static constexpr uint8 const EyeOfAcherusPathSize = 4;
|
||||
G3D::Vector3 const EyeOfAcherusPath[EyeOfAcherusPathSize] =
|
||||
G3D::Vector3 const EyeOfAcherusPath[] =
|
||||
{
|
||||
{ 2361.21f, -5660.45f, 496.744f },
|
||||
{ 2341.571f, -5672.797f, 538.3942f },
|
||||
@@ -486,8 +485,7 @@ struct npc_eye_of_acherus : public ScriptedAI
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=, me = me](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path(EyeOfAcherusPath, EyeOfAcherusPath + EyeOfAcherusPathSize);
|
||||
init.MovebyPath(path);
|
||||
init.MovebyPath(EyeOfAcherusPath);
|
||||
init.SetFly();
|
||||
if (Unit* owner = me->GetCharmerOrOwner())
|
||||
init.SetVelocity(owner->GetSpeed(MOVE_RUN));
|
||||
|
||||
@@ -502,8 +502,7 @@ static std::array<Position, NUM_POSITIONS> const ArthasPositions =
|
||||
}
|
||||
};
|
||||
|
||||
uint32 const chromiePathSize = 3;
|
||||
G3D::Vector3 const ChromieSplinePos[chromiePathSize] =
|
||||
G3D::Vector3 const ChromieSplinePos[] =
|
||||
{
|
||||
{ 2320.632f, 1507.193f, 152.5081f },
|
||||
{ 2319.823f, 1506.605f, 152.5081f },
|
||||
@@ -1468,10 +1467,9 @@ public:
|
||||
chromie->RemoveNpcFlag(UNIT_NPC_FLAG_GOSSIP | UNIT_NPC_FLAG_QUESTGIVER);
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path(ChromieSplinePos, ChromieSplinePos + chromiePathSize);
|
||||
init.SetFly();
|
||||
init.SetWalk(true);
|
||||
init.MovebyPath(path, 0);
|
||||
init.MovebyPath(ChromieSplinePos);
|
||||
};
|
||||
chromie->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
|
||||
}
|
||||
|
||||
@@ -225,8 +225,7 @@ Position const OrgrimsHammerTeleportExit = { 7.461699f, 0.158853f, 35.72989f, 0.
|
||||
Position const OrgrimsHammerTeleportPortal = { 47.550990f, -0.101778f, 37.61111f, 0.0f };
|
||||
Position const SkybreakerTeleportExit = { -17.55738f, -0.090421f, 21.18366f, 0.0f };
|
||||
|
||||
uint32 const MuradinExitPathSize = 10;
|
||||
G3D::Vector3 const MuradinExitPath[MuradinExitPathSize] =
|
||||
G3D::Vector3 const MuradinExitPath[] =
|
||||
{
|
||||
{ 8.130936f, -0.2699585f, 20.31728f },
|
||||
{ 6.380936f, -0.2699585f, 20.31728f },
|
||||
@@ -240,8 +239,7 @@ G3D::Vector3 const MuradinExitPath[MuradinExitPathSize] =
|
||||
{ -14.88477f, 25.20844f, 21.59985f },
|
||||
};
|
||||
|
||||
uint32 const SaurfangExitPathSize = 13;
|
||||
G3D::Vector3 const SaurfangExitPath[SaurfangExitPathSize] =
|
||||
G3D::Vector3 const SaurfangExitPath[] =
|
||||
{
|
||||
{ 30.43987f, 0.1475817f, 36.10674f },
|
||||
{ 21.36141f, -3.056458f, 35.42970f },
|
||||
@@ -935,9 +933,8 @@ struct npc_high_overlord_saurfang_igb : public ScriptedAI
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path(SaurfangExitPath, SaurfangExitPath + SaurfangExitPathSize);
|
||||
init.DisableTransportPathTransformations();
|
||||
init.MovebyPath(path, 0);
|
||||
init.MovebyPath(SaurfangExitPath);
|
||||
};
|
||||
me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
|
||||
|
||||
@@ -1192,9 +1189,8 @@ struct npc_muradin_bronzebeard_igb : public ScriptedAI
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path(MuradinExitPath, MuradinExitPath + MuradinExitPathSize);
|
||||
init.DisableTransportPathTransformations();
|
||||
init.MovebyPath(path, 0);
|
||||
init.MovebyPath(MuradinExitPath);
|
||||
};
|
||||
me->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
|
||||
|
||||
|
||||
@@ -271,7 +271,7 @@ constexpr uint32 SummonMinionsSpells[4] =
|
||||
SPELL_TRIGGER_SUMMON_IRON_VRYKUL
|
||||
};
|
||||
|
||||
constexpr Position RazorscalePath[] =
|
||||
G3D::Vector3 const RazorscalePath[] =
|
||||
{
|
||||
{ 657.0227f, -361.1278f, 519.5406f },
|
||||
{ 698.9319f, -340.9654f, 520.4857f },
|
||||
@@ -329,9 +329,7 @@ struct boss_razorscale : public BossAI
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path(std::size(RazorscalePath));
|
||||
std::ranges::transform(RazorscalePath, path.begin(), PositionToVector3);
|
||||
init.MovebyPath(path, 0);
|
||||
init.MovebyPath(RazorscalePath);
|
||||
init.SetCyclic();
|
||||
init.SetFly();
|
||||
};
|
||||
|
||||
@@ -321,7 +321,7 @@ enum DisplayIds
|
||||
THORIM_WEAPON_DISPLAY_ID = 45900
|
||||
};
|
||||
|
||||
Position const LightningOrbPath[] =
|
||||
G3D::Vector3 const LightningOrbPath[] =
|
||||
{
|
||||
{ 2134.889893f, -298.632996f, 438.247467f },
|
||||
{ 2134.570068f, -440.317993f, 438.247467f },
|
||||
@@ -332,7 +332,6 @@ Position const LightningOrbPath[] =
|
||||
{ 2202.208008f, -262.939270f, 412.168976f },
|
||||
{ 2182.310059f, -263.233093f, 414.739410f }
|
||||
};
|
||||
std::size_t const LightningOrbPathSize = std::extent<decltype(LightningOrbPath)>::value;
|
||||
|
||||
// used for trash jump calculation
|
||||
Position const ArenaCenter = { 2134.77f, -262.307f };
|
||||
@@ -635,14 +634,7 @@ class boss_thorim : public CreatureScript
|
||||
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [](Movement::MoveSplineInit& init)
|
||||
{
|
||||
Movement::PointsArray path;
|
||||
path.reserve(LightningOrbPathSize);
|
||||
std::transform(std::begin(LightningOrbPath), std::end(LightningOrbPath), std::back_inserter(path), [](Position const& pos)
|
||||
{
|
||||
return G3D::Vector3(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
});
|
||||
|
||||
init.MovebyPath(path);
|
||||
init.MovebyPath(LightningOrbPath);
|
||||
};
|
||||
summon->GetMotionMaster()->LaunchMoveSpline(std::move(initializer), 0, MOTION_PRIORITY_NORMAL, POINT_MOTION_TYPE);
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user