mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-21 09:44:45 +01:00
Core/Movement: Some improvements to script interfaces for SplineChainMovementGenerator
(cherry picked from commit e63e0cb6fc)
This commit is contained in:
@@ -211,23 +211,18 @@ SplineChainResumeInfo SplineChainMovementGenerator::GetResumeInfo(Unit const* ow
|
||||
return SplineChainResumeInfo(_id, &_chain, _walk, uint8(_nextIndex - 1), uint8(owner->movespline->_currentSplineIdx()), _msToNext);
|
||||
}
|
||||
|
||||
/* static */ void SplineChainMovementGenerator::GetResumeInfo(Unit const* owner, uint32 id, SplineChainResumeInfo& info)
|
||||
/* static */ void SplineChainMovementGenerator::GetResumeInfo(SplineChainResumeInfo& info, Unit const* owner, Optional<uint32> id)
|
||||
{
|
||||
std::function<bool(MovementGenerator const*)> criteria = [id](MovementGenerator const* movement) -> bool
|
||||
{
|
||||
if (movement->GetMovementGeneratorType() == SPLINE_CHAIN_MOTION_TYPE)
|
||||
{
|
||||
SplineChainMovementGenerator const* splineChainMovement = dynamic_cast<SplineChainMovementGenerator const*>(movement);
|
||||
return splineChainMovement && splineChainMovement->GetId() == id;
|
||||
}
|
||||
return (!id || static_cast<SplineChainMovementGenerator const*>(movement)->GetId() == *id);
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
if (MovementGenerator const* activeGenerator = owner->GetMotionMaster()->GetMovementGenerator(criteria))
|
||||
{
|
||||
if (activeGenerator->GetMovementGeneratorType() == SPLINE_CHAIN_MOTION_TYPE)
|
||||
info = reinterpret_cast<SplineChainMovementGenerator const*>(activeGenerator)->GetResumeInfo(owner);
|
||||
}
|
||||
info = static_cast<SplineChainMovementGenerator const*>(activeGenerator)->GetResumeInfo(owner);
|
||||
else
|
||||
info.Chain = nullptr;
|
||||
info.Clear();
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
|
||||
#include "SplineChain.h"
|
||||
#include "MovementGenerator.h"
|
||||
#include "Optional.h"
|
||||
#include <vector>
|
||||
|
||||
class Unit;
|
||||
@@ -38,7 +39,7 @@ class TC_GAME_API SplineChainMovementGenerator : public MovementGenerator
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
|
||||
// Builds info that can later be used to resume this spline chain movement at the current position
|
||||
static void GetResumeInfo(Unit const* owner, uint32 id, SplineChainResumeInfo& info);
|
||||
static void GetResumeInfo(SplineChainResumeInfo& info, Unit const* owner, Optional<uint32> id = {});
|
||||
// Leaving the object method public for people that know what they're doing to use
|
||||
// But really, 99% of the time you should be using the static one instead
|
||||
SplineChainResumeInfo GetResumeInfo(Unit const* owner) const;
|
||||
|
||||
Reference in New Issue
Block a user