mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/Units: Added Unit::SetFacingToPoint function
This commit is contained in:
@@ -12679,6 +12679,23 @@ void Unit::SetFacingToObject(WorldObject const* object, bool force)
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
void Unit::SetFacingToPoint(Position const& point, bool force)
|
||||
{
|
||||
// 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.
|
||||
Movement::MoveSplineInit init(this);
|
||||
init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false);
|
||||
if (GetTransport())
|
||||
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();
|
||||
}
|
||||
|
||||
bool Unit::SetWalk(bool enable)
|
||||
{
|
||||
if (enable == IsWalking())
|
||||
|
||||
@@ -1248,6 +1248,7 @@ class TC_GAME_API Unit : public WorldObject
|
||||
void SetInFront(WorldObject const* target);
|
||||
void SetFacingTo(float const ori, bool force = true);
|
||||
void SetFacingToObject(WorldObject const* object, bool force = true);
|
||||
void SetFacingToPoint(Position const& point, bool force = true);
|
||||
|
||||
bool IsAlive() const { return (m_deathState == ALIVE); }
|
||||
bool isDying() const { return (m_deathState == JUST_DIED); }
|
||||
|
||||
@@ -220,6 +220,11 @@ namespace Movement
|
||||
args.facing.type = MONSTER_MOVE_FACING_SPOT;
|
||||
}
|
||||
|
||||
void MoveSplineInit::SetFacing(float x, float y, float z)
|
||||
{
|
||||
SetFacing({ x, y, z });
|
||||
}
|
||||
|
||||
void MoveSplineInit::SetFacing(Unit const* target)
|
||||
{
|
||||
args.facing.angle = unit->GetAbsoluteAngle(target);
|
||||
|
||||
@@ -87,6 +87,7 @@ namespace Movement
|
||||
*/
|
||||
void SetFacing(float angle);
|
||||
void SetFacing(Vector3 const& point);
|
||||
void SetFacing(float x, float y, float z);
|
||||
void SetFacing(Unit const* target);
|
||||
|
||||
/* Initializes movement by path
|
||||
|
||||
Reference in New Issue
Block a user