From 4ce89c9508de420311cae75389d723cf72746ba1 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Fri, 16 Apr 2021 15:24:08 -0400 Subject: [PATCH] Core/Movement: Add MovePoint with facing Port From (https://github.com/TrinityCore/TrinityCore/commit/c6d6ece1c7a450145598d5ac3c83b399cc731ee9) --- Source/Game/Movement/Generators/PointMovement.cs | 8 +++++++- Source/Game/Movement/MotionMaster.cs | 10 +++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/Source/Game/Movement/Generators/PointMovement.cs b/Source/Game/Movement/Generators/PointMovement.cs index 59d8a95f2..df30e5a0e 100644 --- a/Source/Game/Movement/Generators/PointMovement.cs +++ b/Source/Game/Movement/Generators/PointMovement.cs @@ -22,7 +22,7 @@ namespace Game.Movement { public class PointMovementGenerator : MovementGeneratorMedium where T : Unit { - public PointMovementGenerator(uint id, float x, float y, float z, bool generatePath, float speed = 0.0f, Unit faceTarget = null, SpellEffectExtraData spellEffectExtraData = null) + public PointMovementGenerator(uint id, float x, float y, float z, bool generatePath, float speed = 0.0f, Unit faceTarget = null, SpellEffectExtraData spellEffectExtraData = null, float? finalOrient = null) { _movementId = id; _destination = new Position(x, y, z); @@ -31,6 +31,7 @@ namespace Game.Movement _spellEffectExtra = spellEffectExtraData; _generatePath = generatePath; _recalculateSpeed = false; + _finalOrient = finalOrient; } public override void DoInitialize(T owner) @@ -63,6 +64,9 @@ namespace Game.Movement if (_spellEffectExtra != null) init.SetSpellEffectExtraData(_spellEffectExtra); + if (_finalOrient.HasValue) + init.SetFacing(_finalOrient.Value); + init.Launch(); // Call for creature group update @@ -149,6 +153,8 @@ namespace Game.Movement bool _generatePath; bool _recalculateSpeed; bool _interrupt; + //! if set then unit will turn to specified _orient in provided _pos + float? _finalOrient; } public class AssistanceMovementGenerator : PointMovementGenerator diff --git a/Source/Game/Movement/MotionMaster.cs b/Source/Game/Movement/MotionMaster.cs index 6004abc06..849b10bd5 100644 --- a/Source/Game/Movement/MotionMaster.cs +++ b/Source/Game/Movement/MotionMaster.cs @@ -259,17 +259,17 @@ namespace Game.Movement } } - public void MovePoint(uint id, Position pos, bool generatePath = true) + public void MovePoint(uint id, Position pos, bool generatePath = true, float? finalOrient = null) { - MovePoint(id, pos.posX, pos.posY, pos.posZ, generatePath); + MovePoint(id, pos.posX, pos.posY, pos.posZ, generatePath, finalOrient); } - public void MovePoint(uint id, float x, float y, float z, bool generatePath = true) + public void MovePoint(uint id, float x, float y, float z, bool generatePath = true, float? finalOrient = null) { if (_owner.IsTypeId(TypeId.Player)) - StartMovement(new PointMovementGenerator(id, x, y, z, generatePath), MovementSlot.Active); + StartMovement(new PointMovementGenerator(id, x, y, z, generatePath, 0.0f, null, null, finalOrient), MovementSlot.Active); else - StartMovement(new PointMovementGenerator(id, x, y, z, generatePath), MovementSlot.Active); + StartMovement(new PointMovementGenerator(id, x, y, z, generatePath, 0.0f, null, null, finalOrient), MovementSlot.Active); } public void MoveCloserAndStop(uint id, Unit target, float distance)