Core/Units: Added Unit::SetFacingToPoint function
Port From (https://github.com/TrinityCore/TrinityCore/commit/cdc09d29bc8fcb85d97846027ddf589478e21139)
This commit is contained in:
@@ -218,6 +218,23 @@ namespace Game.Entities
|
|||||||
init.Launch();
|
init.Launch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void SetFacingToPoint(Position point, bool force = true)
|
||||||
|
{
|
||||||
|
// do not face when already moving
|
||||||
|
if (!force && (!IsStopped() || !MoveSpline.Finalized()))
|
||||||
|
return;
|
||||||
|
|
||||||
|
/// @todo figure out under what conditions creature will move towards object instead of facing it where it currently is.
|
||||||
|
MoveSplineInit init = new(this);
|
||||||
|
init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false);
|
||||||
|
if (GetTransport() != null)
|
||||||
|
init.DisableTransportPathTransformations(); // It makes no sense to target global orientation
|
||||||
|
init.SetFacing(point.GetPositionX(), point.GetPositionY(), point.GetPositionZ());
|
||||||
|
|
||||||
|
//GetMotionMaster()->LaunchMoveSpline(std::move(init), EVENT_FACE, MOTION_PRIORITY_HIGHEST);
|
||||||
|
init.Launch();
|
||||||
|
}
|
||||||
|
|
||||||
public void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false)
|
public void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false)
|
||||||
{
|
{
|
||||||
var initializer = (MoveSplineInit init) =>
|
var initializer = (MoveSplineInit init) =>
|
||||||
|
|||||||
@@ -196,6 +196,19 @@ namespace Game.Movement
|
|||||||
unit.SendMessageToSet(packet, true);
|
unit.SendMessageToSet(packet, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void SetFacing(Vector3 spot)
|
||||||
|
{
|
||||||
|
TransportPathTransform transform = new(unit, args.TransformForTransport);
|
||||||
|
Vector3 finalSpot = transform.Calc(spot);
|
||||||
|
args.facing.f = new Vector3(finalSpot.X, finalSpot.Y, finalSpot.Z);
|
||||||
|
args.facing.type = MonsterMoveType.FacingSpot;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SetFacing(float x, float y, float z)
|
||||||
|
{
|
||||||
|
SetFacing(new Vector3(x, y, z));
|
||||||
|
}
|
||||||
|
|
||||||
public void SetFacing(Unit target)
|
public void SetFacing(Unit target)
|
||||||
{
|
{
|
||||||
args.facing.angle = unit.GetAbsoluteAngle(target);
|
args.facing.angle = unit.GetAbsoluteAngle(target);
|
||||||
@@ -309,14 +322,6 @@ namespace Game.Movement
|
|||||||
args.flags.EnableAnimation();
|
args.flags.EnableAnimation();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void SetFacing(Vector3 spot)
|
|
||||||
{
|
|
||||||
TransportPathTransform transform = new(unit, args.TransformForTransport);
|
|
||||||
Vector3 finalSpot = transform.Calc(spot);
|
|
||||||
args.facing.f = new Vector3(finalSpot.X, finalSpot.Y, finalSpot.Z);
|
|
||||||
args.facing.type = MonsterMoveType.FacingSpot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void DisableTransportPathTransformations() { args.TransformForTransport = false; }
|
public void DisableTransportPathTransformations() { args.TransformForTransport = false; }
|
||||||
|
|
||||||
public void SetSpellEffectExtraData(SpellEffectExtraData spellEffectExtraData)
|
public void SetSpellEffectExtraData(SpellEffectExtraData spellEffectExtraData)
|
||||||
@@ -338,6 +343,7 @@ namespace Game.Movement
|
|||||||
_owner = owner;
|
_owner = owner;
|
||||||
_transformForTransport = transformForTransport;
|
_transformForTransport = transformForTransport;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Vector3 Calc(Vector3 input)
|
public Vector3 Calc(Vector3 input)
|
||||||
{
|
{
|
||||||
float x = input.X;
|
float x = input.X;
|
||||||
|
|||||||
Reference in New Issue
Block a user