mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 03:32:28 -04:00
Core/Scripts: Remove Optional<> wrapper from all Scripting::v2::ActionResultSetter uses
This commit is contained in:
@@ -47,7 +47,7 @@ bool SmartAI::IsAIControlled() const
|
||||
}
|
||||
|
||||
void SmartAI::StartPath(uint32 pathId/* = 0*/, bool repeat/* = false*/, Unit* invoker/* = nullptr*/, uint32 nodeId/* = 0*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult/* = {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult/* = {}*/)
|
||||
{
|
||||
if (HasEscortState(SMART_ESCORT_ESCORTING))
|
||||
StopPath();
|
||||
|
||||
@@ -53,7 +53,7 @@ class TC_GAME_API SmartAI : public CreatureAI
|
||||
|
||||
// Start moving to the desired MovePoint
|
||||
void StartPath(uint32 pathId = 0, bool repeat = false, Unit* invoker = nullptr, uint32 nodeId = 0,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
WaypointPath const* LoadPath(uint32 entry);
|
||||
void PausePath(uint32 delay, bool forced = false);
|
||||
bool CanResumePath();
|
||||
|
||||
@@ -1198,7 +1198,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
y = pos.GetPositionY() + (std::sin(o - (M_PI / 2))*e.target.x) + (std::sin(o)*e.target.y);
|
||||
z = pos.GetPositionZ() + e.target.z;
|
||||
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
|
||||
if (waitEvent)
|
||||
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });
|
||||
|
||||
@@ -1424,7 +1424,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
|
||||
std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
|
||||
if (waitEvent)
|
||||
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);
|
||||
|
||||
@@ -1499,7 +1499,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
target = Trinity::Containers::SelectRandomContainerElement(targets);
|
||||
|
||||
std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
|
||||
if (waitEvent)
|
||||
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);
|
||||
|
||||
@@ -1807,13 +1807,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (Player* playerTarget = target->ToPlayer())
|
||||
{
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> scriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> scriptResult;
|
||||
if (waitEvent)
|
||||
scriptResult = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });
|
||||
|
||||
if (!playerTarget->ActivateTaxiPathTo(e.action.taxi.id, 0, {}, scriptResult))
|
||||
if (scriptResult)
|
||||
scriptResult->SetResult(MovementStopReason::Interrupted);
|
||||
scriptResult.SetResult(MovementStopReason::Interrupted);
|
||||
}
|
||||
}
|
||||
if (waitEvent && !waitEvent->Results.empty())
|
||||
@@ -1919,7 +1919,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
break;
|
||||
|
||||
std::shared_ptr<Scripting::v2::ActionResult<MovementStopReason>> waitEvent = CreateTimedActionListWaitEventFor<MovementStopReason>(e);
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
|
||||
if (waitEvent)
|
||||
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter(waitEvent);
|
||||
|
||||
@@ -2138,7 +2138,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
|
||||
if (closest.first != 0)
|
||||
{
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
|
||||
if (waitEvent)
|
||||
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });
|
||||
|
||||
@@ -2681,7 +2681,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
{
|
||||
if (Unit* unitTarget = target->ToUnit())
|
||||
{
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> actionResultSetter;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> actionResultSetter;
|
||||
if (waitEvent)
|
||||
actionResultSetter = Scripting::v2::ActionResult<MovementStopReason>::GetResultSetter({ waitEvent, &waitEvent->Results.emplace_back() });
|
||||
|
||||
|
||||
@@ -22896,7 +22896,7 @@ UF::PVPInfo const* Player::GetPvpInfoForBracket(int8 bracket) const
|
||||
}
|
||||
|
||||
bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc /*= nullptr*/, uint32 spellid /*= 0*/, uint32 preferredMountDisplay /*= 0*/,
|
||||
Optional<float> speed /*= {}*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult /*= {}*/)
|
||||
Optional<float> speed /*= {}*/, Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult /*= {}*/)
|
||||
{
|
||||
if (nodes.size() < 2)
|
||||
{
|
||||
@@ -23076,13 +23076,13 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
|
||||
ModifyMoney(-int64(firstcost));
|
||||
UpdateCriteria(CriteriaType::MoneySpentOnTaxis, firstcost);
|
||||
GetSession()->SendActivateTaxiReply(ERR_TAXIOK);
|
||||
StartTaxiMovement(mount_display_id, sourcepath, 0, speed, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>(scriptResult));
|
||||
StartTaxiMovement(mount_display_id, sourcepath, 0, speed, Scripting::v2::ActionResultSetter(scriptResult));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Player::ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid /*= 0*/, Optional<float> speed /*= {}*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult /*= {}*/)
|
||||
{
|
||||
TaxiPathEntry const* entry = sTaxiPathStore.LookupEntry(taxi_path_id);
|
||||
if (!entry)
|
||||
@@ -23158,7 +23158,7 @@ void Player::ContinueTaxiFlight()
|
||||
}
|
||||
|
||||
void Player::StartTaxiMovement(uint32 mountDisplayId, uint32 path, uint32 pathNode, Optional<float> speed,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult)
|
||||
{
|
||||
// remove fake death
|
||||
RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags::Interacting);
|
||||
|
||||
@@ -1234,14 +1234,14 @@ class TC_GAME_API Player final : public Unit, public GridObject<Player>
|
||||
PlayerTaxi m_taxi;
|
||||
void InitTaxiNodesForLevel() { m_taxi.InitTaxiNodesForLevel(GetRace(), GetClass(), GetLevel()); }
|
||||
bool ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc = nullptr, uint32 spellid = 0, uint32 preferredMountDisplay = 0, Optional<float> speed = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult = {});
|
||||
bool ActivateTaxiPathTo(uint32 taxi_path_id, uint32 spellid = 0, Optional<float> speed = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> const& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> const& scriptResult = {});
|
||||
void FinishTaxiFlight();
|
||||
void CleanupAfterTaxiFlight();
|
||||
void ContinueTaxiFlight();
|
||||
void StartTaxiMovement(uint32 mountDisplayId, uint32 path, uint32 pathNode, Optional<float> speed,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult);
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult);
|
||||
|
||||
bool IsDeveloper() const { return HasPlayerFlag(PLAYER_FLAGS_DEVELOPER); }
|
||||
void SetDeveloper(bool on) { if (on) SetPlayerFlag(PLAYER_FLAGS_DEVELOPER); else RemovePlayerFlag(PLAYER_FLAGS_DEVELOPER); }
|
||||
|
||||
@@ -595,7 +595,7 @@ void MotionMaster::MoveTargetedHome()
|
||||
|
||||
void MotionMaster::MoveRandom(float wanderDistance /*= 0.0f*/, Optional<Milliseconds> duration /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::ForceWalk*/, MovementSlot slot /*= MOTION_SLOT_DEFAULT*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRandom: '{}', started random movement (spawnDist: {})", _owner->GetGUID(), wanderDistance);
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
@@ -605,13 +605,13 @@ void MotionMaster::MoveRandom(float wanderDistance /*= 0.0f*/, Optional<Millisec
|
||||
}
|
||||
|
||||
void MotionMaster::MoveFollow(Unit* target, float dist, Optional<ChaseAngle> angle /*= {}*/, Optional<Milliseconds> duration /*= {}*/, bool ignoreTargetWalk /*= false*/, MovementSlot slot/* = MOTION_SLOT_ACTIVE*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
// Ignore movement request if target not exist
|
||||
if (!target || target == _owner)
|
||||
{
|
||||
if (scriptResult)
|
||||
scriptResult->SetResult(MovementStopReason::Interrupted);
|
||||
scriptResult.SetResult(MovementStopReason::Interrupted);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -644,12 +644,12 @@ void MotionMaster::MoveConfused()
|
||||
}
|
||||
|
||||
void MotionMaster::MoveFleeing(Unit* enemy, Milliseconds time /*= 0ms*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
if (!enemy)
|
||||
{
|
||||
if (scriptResult)
|
||||
scriptResult->SetResult(MovementStopReason::Interrupted);
|
||||
scriptResult.SetResult(MovementStopReason::Interrupted);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -662,14 +662,14 @@ void MotionMaster::MoveFleeing(Unit* enemy, Milliseconds time /*= 0ms*/,
|
||||
|
||||
void MotionMaster::MovePoint(uint32 id, Position const& pos, bool generatePath/* = true*/, Optional<float> finalOrient/* = {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
MovePoint(id, pos.m_positionX, pos.m_positionY, pos.m_positionZ, generatePath, finalOrient, speed, speedSelectionMode, closeEnoughDistance, std::move(scriptResult));
|
||||
}
|
||||
|
||||
void MotionMaster::MovePoint(uint32 id, float x, float y, float z, bool generatePath /*= true*/, Optional<float> finalOrient /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/, Optional<float> closeEnoughDistance /*= {}*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePoint: '{}', targeted point Id: {} (X: {}, Y: {}, Z: {})", _owner->GetGUID(), id, x, y, z);
|
||||
Add(new PointMovementGenerator(id, x, y, z, generatePath, speed, finalOrient, nullptr, nullptr, speedSelectionMode, closeEnoughDistance, std::move(scriptResult)));
|
||||
@@ -700,21 +700,21 @@ void MotionMaster::MoveCloserAndStop(uint32 id, Unit* target, float distance)
|
||||
|
||||
void MotionMaster::MoveLand(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
MoveTierTransition(id, pos, AnimTier::Ground, tierTransitionId, velocity, speedSelectionMode, std::move(scriptResult));
|
||||
}
|
||||
|
||||
void MotionMaster::MoveTakeoff(uint32 id, Position const& pos, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
MoveTierTransition(id, pos, AnimTier::Fly, tierTransitionId, velocity, speedSelectionMode, std::move(scriptResult));
|
||||
}
|
||||
|
||||
void MotionMaster::MoveTierTransition(uint32 id, Position const& pos, AnimTier newAnimTier, Optional<int32> tierTransitionId /*= {}*/, Optional<float> velocity /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveTierTransition: '{}', anim tier transition to {} Id: {} (X: {}, Y: {}, Z: {})",
|
||||
_owner->GetGUID(), newAnimTier, id, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ());
|
||||
@@ -858,7 +858,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
|
||||
Optional<float> minHeight /*= {}*/, Optional<float> maxHeight /*= {}*/,
|
||||
MovementFacingTarget const& facing /*= {}*/, bool orientationFixed, bool unlimitedSpeed /*= false*/, Optional<float> speedMultiplier /*= {}*/,
|
||||
JumpArrivalCastArgs const* arrivalCast /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveJump: '{}', jumps to point Id: {} ({})", _owner->GetGUID(), id, pos.ToString());
|
||||
|
||||
@@ -894,7 +894,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
|
||||
if (speedXY < 0.01f)
|
||||
{
|
||||
if (scriptResult)
|
||||
scriptResult->SetResult(MovementStopReason::Interrupted);
|
||||
scriptResult.SetResult(MovementStopReason::Interrupted);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -933,7 +933,7 @@ void MotionMaster::MoveJump(uint32 id, Position const& pos, std::variant<std::mo
|
||||
void MotionMaster::MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount,
|
||||
Optional<Milliseconds> duration /*= {}*/, Optional<float> speed /*= {}*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
std::function<void(Movement::MoveSplineInit&)> initializer = [=, this](Movement::MoveSplineInit& init)
|
||||
{
|
||||
@@ -1019,12 +1019,12 @@ void MotionMaster::ResumeSplineChain(SplineChainResumeInfo const& info)
|
||||
}
|
||||
|
||||
void MotionMaster::MoveFall(uint32 id /*= 0*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
auto setterScopeExit = Trinity::make_unique_ptr_with_deleter(&scriptResult, [](Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>* opt)
|
||||
auto setterScopeExit = Trinity::make_unique_ptr_with_deleter(&scriptResult, [](Scripting::v2::ActionResultSetter<MovementStopReason>* opt)
|
||||
{
|
||||
if (opt->has_value())
|
||||
(*opt)->SetResult(MovementStopReason::Interrupted);
|
||||
if (bool(*opt))
|
||||
opt->SetResult(MovementStopReason::Interrupted);
|
||||
});
|
||||
|
||||
// Use larger distance for vmap height search than in most other cases
|
||||
@@ -1091,7 +1091,7 @@ void MotionMaster::MoveSeekAssistanceDistract(uint32 time)
|
||||
}
|
||||
|
||||
void MotionMaster::MoveTaxiFlight(uint32 path, uint32 pathnode, Optional<float> speed /*= {}*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
if (_owner->GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
@@ -1129,12 +1129,12 @@ void MotionMaster::MovePath(uint32 pathId, bool repeatable, Optional<Millisecond
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd /*= {}*/,
|
||||
Optional<float> wanderDistanceAtPathEnds /*= {}*/, Optional<bool> followPathBackwardsFromEndToStart /*= {}*/,
|
||||
Optional<bool> exactSplinePath /*= {}*/, bool generatePath /*= true*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
if (!pathId)
|
||||
{
|
||||
if (scriptResult)
|
||||
scriptResult->SetResult(MovementStopReason::Interrupted);
|
||||
scriptResult.SetResult(MovementStopReason::Interrupted);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -1154,7 +1154,7 @@ void MotionMaster::MovePath(WaypointPath const& path, bool repeatable, Optional<
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd /*= {}*/,
|
||||
Optional<float> wanderDistanceAtPathEnds /*= {}*/, Optional<bool> followPathBackwardsFromEndToStart /*= {}*/,
|
||||
Optional<bool> exactSplinePath /*= {}*/, bool generatePath /*= true*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MovePath: '{}', starts moving over path Id: {} (repeatable: {})",
|
||||
_owner->GetGUID(), path.Id, repeatable ? "YES" : "NO");
|
||||
@@ -1169,7 +1169,7 @@ void MotionMaster::MovePath(WaypointPath const& path, bool repeatable, Optional<
|
||||
|
||||
void MotionMaster::MoveRotate(uint32 id, RotateDirection direction, Optional<Milliseconds> time /*= {}*/,
|
||||
Optional<float> turnSpeed /*= {}*/, Optional<float> totalTurnAngle /*= {}*/,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
{
|
||||
TC_LOG_DEBUG("movement.motionmaster", "MotionMaster::MoveRotate: '{}', starts rotate (time: {}ms, turnSpeed: {}, totalTurnAngle: {}, direction: {})",
|
||||
_owner->GetGUID(), time.value_or(0ms).count(), turnSpeed, totalTurnAngle, direction);
|
||||
|
||||
@@ -159,20 +159,20 @@ class TC_GAME_API MotionMaster
|
||||
void MoveTargetedHome();
|
||||
void MoveRandom(float wanderDistance = 0.0f, Optional<Milliseconds> duration = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::ForceWalk, MovementSlot slot = MOTION_SLOT_DEFAULT,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveFollow(Unit* target, float dist, Optional<ChaseAngle> angle = {}, Optional<Milliseconds> duration = {}, bool ignoreTargetWalk = false, MovementSlot slot = MOTION_SLOT_ACTIVE,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveChase(Unit* target, Optional<ChaseRange> dist = {}, Optional<ChaseAngle> angle = {});
|
||||
void MoveChase(Unit* target, float dist, float angle) { MoveChase(target, ChaseRange(dist), ChaseAngle(angle)); }
|
||||
void MoveConfused();
|
||||
void MoveFleeing(Unit* enemy, Milliseconds time = 0ms,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MovePoint(uint32 id, Position const& pos, bool generatePath = true, Optional<float> finalOrient = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default, Optional<float> closeEnoughDistance = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MovePoint(uint32 id, float x, float y, float z, bool generatePath = true, Optional<float> finalOrient = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default, Optional<float> closeEnoughDistance = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
/*
|
||||
* Makes the unit move toward the target until it is at a certain distance from it. The unit then stops.
|
||||
* Only works in 2D.
|
||||
@@ -182,13 +182,13 @@ class TC_GAME_API MotionMaster
|
||||
// These two movement types should only be used with creatures having landing/takeoff animations
|
||||
void MoveLand(uint32 id, Position const& pos, Optional<int32> tierTransitionId = {}, Optional<float> velocity = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveTakeoff(uint32 id, Position const& pos, Optional<int32> tierTransitionId = {}, Optional<float> velocity = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveTierTransition(uint32 id, Position const& pos, AnimTier newAnimTier, Optional<int32> tierTransitionId = {}, Optional<float> velocity = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveCharge(float x, float y, float z, float speed = SPEED_CHARGE, uint32 id = EVENT_CHARGE, bool generatePath = false, Unit const* target = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr);
|
||||
void MoveCharge(PathGenerator const& path, float speed = SPEED_CHARGE, Unit const* target = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr);
|
||||
void MoveKnockbackFrom(Position const& origin, float speedXY, float speedZ, float angle = M_PI, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr);
|
||||
@@ -196,32 +196,32 @@ class TC_GAME_API MotionMaster
|
||||
Optional<float> minHeight = {}, Optional<float> maxHeight = {},
|
||||
MovementFacingTarget const& facing = {}, bool orientationFixed = false, bool unlimitedSpeed = false, Optional<float> speedMultiplier = {},
|
||||
JumpArrivalCastArgs const* arrivalCast = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveCirclePath(float x, float y, float z, float radius, bool clockwise, uint8 stepCount,
|
||||
Optional<Milliseconds> duration = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
// Walk along spline chain stored in DB (script_spline_chain_meta and script_spline_chain_waypoints)
|
||||
void MoveAlongSplineChain(uint32 pointId, uint16 dbChainId, bool walk);
|
||||
void MoveAlongSplineChain(uint32 pointId, std::vector<SplineChainLink> const& chain, bool walk);
|
||||
void ResumeSplineChain(SplineChainResumeInfo const& info);
|
||||
void MoveFall(uint32 id = 0,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveSeekAssistance(float x, float y, float z);
|
||||
void MoveSeekAssistanceDistract(uint32 timer);
|
||||
void MoveTaxiFlight(uint32 path, uint32 pathnode, Optional<float> speed = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveDistract(uint32 time, float orientation);
|
||||
void MovePath(uint32 pathId, bool repeatable, Optional<Milliseconds> duration = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd = {}, Optional<float> wanderDistanceAtPathEnds = {},
|
||||
Optional<bool> followPathBackwardsFromEndToStart = {}, Optional<bool> exactSplinePath = {}, bool generatePath = true,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MovePath(WaypointPath const& path, bool repeatable, Optional<Milliseconds> duration = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd = {}, Optional<float> wanderDistanceAtPathEnds = {},
|
||||
Optional<bool> followPathBackwardsFromEndToStart = {}, Optional<bool> exactSplinePath = {}, bool generatePath = true,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
|
||||
/**
|
||||
* \brief Makes the Unit turn in place
|
||||
@@ -234,7 +234,7 @@ class TC_GAME_API MotionMaster
|
||||
*/
|
||||
void MoveRotate(uint32 id, RotateDirection direction, Optional<Milliseconds> time = {},
|
||||
Optional<float> turnSpeed = {}, Optional<float> totalTurnAngle = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
void MoveFormation(Unit* leader, float range, float angle, uint32 point1, uint32 point2);
|
||||
|
||||
void LaunchMoveSpline(std::function<void(Movement::MoveSplineInit& init)>&& initializer, uint32 id = 0, MovementGeneratorPriority priority = MOTION_PRIORITY_NORMAL, MovementGeneratorType type = EFFECT_MOTION_TYPE);
|
||||
|
||||
@@ -34,7 +34,7 @@ void MovementGenerator::SetScriptResult(MovementStopReason reason)
|
||||
{
|
||||
if (ScriptResult)
|
||||
{
|
||||
ScriptResult->SetResult(reason);
|
||||
ScriptResult.reset();
|
||||
ScriptResult.SetResult(reason);
|
||||
ScriptResult.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,7 +22,6 @@
|
||||
#include "FactoryHolder.h"
|
||||
#include "MovementDefines.h"
|
||||
#include "ObjectRegistry.h"
|
||||
#include "Optional.h"
|
||||
#include "ScriptActionResult.h"
|
||||
|
||||
class Creature;
|
||||
@@ -87,7 +86,7 @@ class TC_GAME_API MovementGenerator
|
||||
uint8 Priority;
|
||||
uint16 Flags;
|
||||
uint32 BaseUnitState;
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> ScriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> ScriptResult;
|
||||
|
||||
protected:
|
||||
void SetScriptResult(MovementStopReason reason);
|
||||
|
||||
@@ -27,7 +27,7 @@
|
||||
#define MAX_QUIET_DISTANCE 43.0f
|
||||
|
||||
FleeingMovementGenerator::FleeingMovementGenerator(ObjectGuid fleeTargetGUID,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/) : _fleeTargetGUID(fleeTargetGUID), _timer(0)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/) : _fleeTargetGUID(fleeTargetGUID), _timer(0)
|
||||
{
|
||||
Mode = MOTION_MODE_DEFAULT;
|
||||
Priority = MOTION_PRIORITY_HIGHEST;
|
||||
|
||||
@@ -29,7 +29,7 @@ class FleeingMovementGenerator : public MovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit FleeingMovementGenerator(ObjectGuid fleeTargetGUID,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
FleeingMovementGenerator(FleeingMovementGenerator const&) = delete;
|
||||
FleeingMovementGenerator(FleeingMovementGenerator&&) = delete;
|
||||
FleeingMovementGenerator& operator=(FleeingMovementGenerator const&) = delete;
|
||||
@@ -59,7 +59,7 @@ class TimedFleeingMovementGenerator : public FleeingMovementGenerator
|
||||
{
|
||||
public:
|
||||
explicit TimedFleeingMovementGenerator(ObjectGuid fleeTargetGUID, Milliseconds time,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {})
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {})
|
||||
: FleeingMovementGenerator(fleeTargetGUID, std::move(scriptResult)), _totalFleeTime(time) { }
|
||||
|
||||
bool Update(Unit*, uint32) override;
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#define PLAYER_FLIGHT_SPEED 32.0f
|
||||
|
||||
FlightPathMovementGenerator::FlightPathMovementGenerator(Optional<float> speed,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult)
|
||||
{
|
||||
_speed = speed;
|
||||
_endGridX = 0.0f;
|
||||
|
||||
@@ -34,7 +34,7 @@ class FlightPathMovementGenerator : public MovementGeneratorMedium<Player, Fligh
|
||||
{
|
||||
public:
|
||||
explicit FlightPathMovementGenerator(Optional<float> speed,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult);
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult);
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
bool GetResetPosition(Unit* owner, float& x, float& y, float& z) override;
|
||||
|
||||
@@ -35,7 +35,7 @@ static void DoMovementInform(Unit* owner, Unit* target)
|
||||
}
|
||||
|
||||
FollowMovementGenerator::FollowMovementGenerator(Unit* target, float range, Optional<ChaseAngle> angle, Optional<Milliseconds> duration,
|
||||
bool ignoreTargetWalk /*= false*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
bool ignoreTargetWalk /*= false*/, Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
: AbstractFollower(ASSERT_NOTNULL(target)), _range(range), _angle(angle), _ignoreTargetWalk(ignoreTargetWalk), _checkTimer(CHECK_INTERVAL)
|
||||
{
|
||||
Mode = MOTION_MODE_DEFAULT;
|
||||
|
||||
@@ -33,7 +33,7 @@ class FollowMovementGenerator : public MovementGenerator, public AbstractFollowe
|
||||
{
|
||||
public:
|
||||
explicit FollowMovementGenerator(Unit* target, float range, Optional<ChaseAngle> angle, Optional<Milliseconds> duration,
|
||||
bool ignoreTargetWalk = false, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
bool ignoreTargetWalk = false, Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
~FollowMovementGenerator();
|
||||
|
||||
void Initialize(Unit*) override;
|
||||
|
||||
@@ -32,7 +32,7 @@ struct GenericMovementGeneratorArgs
|
||||
Optional<uint32> ArrivalSpellId;
|
||||
Optional<ObjectGuid> ArrivalSpellTarget;
|
||||
Optional<Milliseconds> Duration;
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>> ScriptResult;
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason> ScriptResult;
|
||||
};
|
||||
|
||||
class GenericMovementGenerator : public MovementGenerator
|
||||
|
||||
@@ -70,7 +70,7 @@ MovementGenerator* IdleMovementFactory::Create(Unit* /*object*/) const
|
||||
|
||||
RotateMovementGenerator::RotateMovementGenerator(uint32 id, RotateDirection direction, Optional<Milliseconds> duration,
|
||||
Optional<float> turnSpeed, Optional<float> totalTurnAngle,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult) : _id(id), _duration(duration),
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult) : _id(id), _duration(duration),
|
||||
_turnSpeed(turnSpeed), _totalTurnAngle(totalTurnAngle),
|
||||
_direction(direction), _diffSinceLastUpdate(0)
|
||||
{
|
||||
|
||||
@@ -44,7 +44,7 @@ class RotateMovementGenerator : public MovementGenerator
|
||||
|
||||
explicit RotateMovementGenerator(uint32 id, RotateDirection direction, Optional<Milliseconds> duration,
|
||||
Optional<float> turnSpeed, Optional<float> totalTurnAngle,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult);
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult);
|
||||
|
||||
void Initialize(Unit*) override;
|
||||
void Reset(Unit*) override;
|
||||
|
||||
@@ -31,7 +31,7 @@
|
||||
PointMovementGenerator::PointMovementGenerator(uint32 id, float x, float y, float z, bool generatePath, Optional<float> speed /*= {}*/, Optional<float> finalOrient /*= {}*/,
|
||||
Unit const* faceTarget /*= nullptr*/, Movement::SpellEffectExtraData const* spellEffectExtraData /*= nullptr*/,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode /*= MovementWalkRunSpeedSelectionMode::Default*/,
|
||||
Optional<float> closeEnoughDistance /*= {}*/, Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Optional<float> closeEnoughDistance /*= {}*/, Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
: _movementId(id), _destination(x, y, z), _speed(speed), _generatePath(generatePath), _finalOrient(finalOrient),
|
||||
i_faceTarget(faceTarget), _speedSelectionMode(speedSelectionMode), _closeEnoughDistance(closeEnoughDistance)
|
||||
{
|
||||
|
||||
@@ -34,7 +34,7 @@ class PointMovementGenerator : public MovementGenerator
|
||||
Unit const* faceTarget = nullptr, Movement::SpellEffectExtraData const* spellEffectExtraData = nullptr,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<float> closeEnoughDistance = {},
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
PointMovementGenerator(PointMovementGenerator const&) = delete;
|
||||
PointMovementGenerator(PointMovementGenerator&&) = delete;
|
||||
PointMovementGenerator& operator=(PointMovementGenerator const&) = delete;
|
||||
|
||||
@@ -28,7 +28,7 @@
|
||||
template<class T>
|
||||
RandomMovementGenerator<T>::RandomMovementGenerator(float distance, Optional<Milliseconds> duration, Optional<float> speed,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
: _timer(0), _speed(speed), _speedSelectionMode(speedSelectionMode), _wanderDistance(distance), _wanderSteps(0)
|
||||
{
|
||||
this->Mode = MOTION_MODE_DEFAULT;
|
||||
|
||||
@@ -31,7 +31,7 @@ class RandomMovementGenerator : public MovementGeneratorMedium<T, RandomMovement
|
||||
public:
|
||||
explicit RandomMovementGenerator(float distance, Optional<Milliseconds> duration = {}, Optional<float> speed = {},
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
|
||||
|
||||
@@ -39,7 +39,7 @@ template <typename T>
|
||||
WaypointMovementGenerator<T>::WaypointMovementGenerator(uint32 pathId, bool repeating, Optional<Milliseconds> duration, Optional<float> speed,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode, Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd,
|
||||
Optional<float> wanderDistanceAtPathEnds, Optional<bool> followPathBackwardsFromEndToStart, Optional<bool> exactSplinePath, bool generatePath,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
: PathMovementBase(sWaypointMgr->GetPath(pathId)), _speed(speed), _speedSelectionMode(speedSelectionMode),
|
||||
_waitTimeRangeAtPathEnd(std::move(waitTimeRangeAtPathEnd)), _wanderDistanceAtPathEnds(wanderDistanceAtPathEnds),
|
||||
_followPathBackwardsFromEndToStart(followPathBackwardsFromEndToStart), _exactSplinePath(exactSplinePath), _repeating(repeating), _generatePath(generatePath),
|
||||
@@ -58,7 +58,7 @@ template <typename T>
|
||||
WaypointMovementGenerator<T>::WaypointMovementGenerator(WaypointPath const& path, bool repeating, Optional<Milliseconds> duration, Optional<float> speed,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode, Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd,
|
||||
Optional<float> wanderDistanceAtPathEnds, Optional<bool> followPathBackwardsFromEndToStart, Optional<bool> exactSplinePath, bool generatePath,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult /*= {}*/)
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult /*= {}*/)
|
||||
: PathMovementBase(std::make_unique<WaypointPath>(path)), _speed(speed), _speedSelectionMode(speedSelectionMode),
|
||||
_waitTimeRangeAtPathEnd(std::move(waitTimeRangeAtPathEnd)), _wanderDistanceAtPathEnds(wanderDistanceAtPathEnds),
|
||||
_followPathBackwardsFromEndToStart(followPathBackwardsFromEndToStart), _exactSplinePath(exactSplinePath), _repeating(repeating), _generatePath(generatePath),
|
||||
|
||||
@@ -35,12 +35,12 @@ class WaypointMovementGenerator : public MovementGeneratorMedium<T, WaypointMove
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode = MovementWalkRunSpeedSelectionMode::Default,
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd = {}, Optional<float> wanderDistanceAtPathEnds = {},
|
||||
Optional<bool> followPathBackwardsFromEndToStart = {}, Optional<bool> exactSplinePath = {}, bool generatePath = true,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
explicit WaypointMovementGenerator(WaypointPath const& path, bool repeating, Optional<Milliseconds> duration, Optional<float> speed,
|
||||
MovementWalkRunSpeedSelectionMode speedSelectionMode,
|
||||
Optional<std::pair<Milliseconds, Milliseconds>> waitTimeRangeAtPathEnd, Optional<float> wanderDistanceAtPathEnds,
|
||||
Optional<bool> followPathBackwardsFromEndToStart, Optional<bool> exactSplinePath, bool generatePath,
|
||||
Optional<Scripting::v2::ActionResultSetter<MovementStopReason>>&& scriptResult = {});
|
||||
Scripting::v2::ActionResultSetter<MovementStopReason>&& scriptResult = {});
|
||||
~WaypointMovementGenerator();
|
||||
|
||||
MovementGeneratorType GetMovementGeneratorType() const override;
|
||||
|
||||
@@ -24,32 +24,46 @@ namespace Scripting::v2
|
||||
{
|
||||
class ActionBase;
|
||||
|
||||
template <typename T>
|
||||
struct ActionResultValueHolder
|
||||
{
|
||||
ActionBase& Action;
|
||||
T Result = { };
|
||||
};
|
||||
|
||||
void MarkActionCompleted(ActionBase& action);
|
||||
|
||||
template <typename T>
|
||||
class ActionResultSetter
|
||||
{
|
||||
public:
|
||||
explicit ActionResultSetter(std::shared_ptr<ActionBase> action, T* result) : _action(std::move(action)), _result(result) { }
|
||||
ActionResultSetter() = default;
|
||||
|
||||
explicit ActionResultSetter(std::shared_ptr<ActionResultValueHolder<T>>&& action) : _action(std::move(action)) { }
|
||||
|
||||
void SetResult(T result)
|
||||
{
|
||||
if (std::shared_ptr<ActionBase> ptr = _action.lock())
|
||||
if (std::shared_ptr<ActionResultValueHolder<T>> ptr = _action.lock())
|
||||
{
|
||||
*_result = std::move(result);
|
||||
MarkActionCompleted(*ptr);
|
||||
ptr->Result = result;
|
||||
MarkActionCompleted(ptr->Action);
|
||||
}
|
||||
}
|
||||
|
||||
explicit operator bool() const { return !_action.expired(); }
|
||||
|
||||
void Reset() { _action.reset(); }
|
||||
|
||||
private:
|
||||
std::weak_ptr<ActionBase> _action;
|
||||
T* _result;
|
||||
std::weak_ptr<ActionResultValueHolder<T>> _action;
|
||||
};
|
||||
|
||||
template <>
|
||||
class ActionResultSetter<void>
|
||||
{
|
||||
public:
|
||||
ActionResultSetter() = default;
|
||||
|
||||
explicit ActionResultSetter(std::shared_ptr<ActionBase> action) : _action(std::move(action)) { }
|
||||
|
||||
void SetResult()
|
||||
@@ -58,6 +72,10 @@ public:
|
||||
MarkActionCompleted(*ptr);
|
||||
}
|
||||
|
||||
explicit operator bool() const { return !_action.expired(); }
|
||||
|
||||
void Reset() { _action.reset(); }
|
||||
|
||||
private:
|
||||
std::weak_ptr<ActionBase> _action;
|
||||
};
|
||||
|
||||
@@ -65,12 +65,11 @@ class ActionResult : public ActionBase
|
||||
public:
|
||||
[[nodiscard]] static ActionResultSetter<T> GetResultSetter(std::shared_ptr<ActionResult> action)
|
||||
{
|
||||
T* resultPtr = &action->_result;
|
||||
return ActionResultSetter<T>(std::move(action), resultPtr);
|
||||
return ActionResultSetter<T>(std::shared_ptr<ActionResultValueHolder<T>>(std::move(action), &action->_result));
|
||||
}
|
||||
|
||||
private:
|
||||
T _result = { };
|
||||
ActionResultValueHolder<T> _result = { .Action = *this };
|
||||
};
|
||||
|
||||
template<>
|
||||
|
||||
@@ -3892,7 +3892,7 @@ void Spell::_cast(bool skipCheck)
|
||||
}
|
||||
|
||||
if (m_scriptResult && !m_scriptWaitsForSpellHit)
|
||||
m_scriptResult->SetResult(SPELL_CAST_OK);
|
||||
m_scriptResult.SetResult(SPELL_CAST_OK);
|
||||
|
||||
CallScriptAfterCastHandlers();
|
||||
|
||||
@@ -4381,7 +4381,7 @@ void Spell::finish(SpellCastResult result)
|
||||
m_spellState = SPELL_STATE_FINISHED;
|
||||
|
||||
if (m_scriptResult && (m_scriptWaitsForSpellHit || result != SPELL_CAST_OK))
|
||||
m_scriptResult->SetResult(result);
|
||||
m_scriptResult.SetResult(result);
|
||||
|
||||
if (!m_caster)
|
||||
return;
|
||||
|
||||
@@ -630,7 +630,7 @@ class TC_GAME_API Spell
|
||||
|
||||
UsedSpellMods m_appliedMods;
|
||||
|
||||
Optional<Scripting::v2::ActionResultSetter<SpellCastResult>> m_scriptResult;
|
||||
Scripting::v2::ActionResultSetter<SpellCastResult> m_scriptResult;
|
||||
bool m_scriptWaitsForSpellHit = false;
|
||||
|
||||
int32 GetCastTime() const { return m_casttime; }
|
||||
|
||||
@@ -484,7 +484,7 @@ struct CastSpellExtraArgsInit
|
||||
};
|
||||
std::vector<SpellValueOverride> SpellValueOverrides;
|
||||
std::any CustomArg;
|
||||
Optional<Scripting::v2::ActionResultSetter<SpellCastResult>> ScriptResult;
|
||||
Scripting::v2::ActionResultSetter<SpellCastResult> ScriptResult;
|
||||
bool ScriptWaitsForSpellHit = false;
|
||||
};
|
||||
|
||||
@@ -520,7 +520,7 @@ struct TC_GAME_API CastSpellExtraArgs : public CastSpellExtraArgsInit
|
||||
CastSpellExtraArgs& AddSpellMod(SpellValueModFloat mod, float val) { SpellValueOverrides.emplace_back(mod, val); return *this; }
|
||||
CastSpellExtraArgs& AddSpellBP0(int32 val) { return AddSpellMod(SPELLVALUE_BASE_POINT0, val); } // because i don't want to type SPELLVALUE_BASE_POINT0 300 times
|
||||
CastSpellExtraArgs& SetCustomArg(std::any customArg) { CustomArg = std::move(customArg); return *this; }
|
||||
CastSpellExtraArgs& SetScriptResult(Scripting::v2::ActionResultSetter<SpellCastResult> scriptResult) { ScriptResult.emplace(std::move(scriptResult)); return *this; }
|
||||
CastSpellExtraArgs& SetScriptResult(Scripting::v2::ActionResultSetter<SpellCastResult>&& scriptResult) { ScriptResult = std::move(scriptResult); return *this; }
|
||||
CastSpellExtraArgs& SetScriptWaitsForSpellHit(bool scriptWaitsForSpellHit) { ScriptWaitsForSpellHit = scriptWaitsForSpellHit; return *this; }
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user