Core/Movement: MotionMaster reimplementation
Port From (https://github.com/TrinityCore/TrinityCore/commit/426f9f2f92b26fbb68e7cda9290ccbd586c6af4e)
This commit is contained in:
@@ -172,11 +172,11 @@ namespace Game.Entities
|
||||
if (MotionMaster.IsInvalidMovementSlot(slot))
|
||||
return;
|
||||
|
||||
IMovementGenerator movementGenerator = GetMotionMaster().GetMotionSlot(slot);
|
||||
MovementGenerator movementGenerator = GetMotionMaster().GetCurrentMovementGenerator(slot);
|
||||
if (movementGenerator != null)
|
||||
movementGenerator.Pause(timer);
|
||||
|
||||
if (forced)
|
||||
if (forced && GetMotionMaster().GetCurrentSlot() == slot)
|
||||
StopMoving();
|
||||
}
|
||||
|
||||
@@ -185,7 +185,7 @@ namespace Game.Entities
|
||||
if (MotionMaster.IsInvalidMovementSlot(slot))
|
||||
return;
|
||||
|
||||
IMovementGenerator movementGenerator = GetMotionMaster().GetMotionSlot(slot);
|
||||
MovementGenerator movementGenerator = GetMotionMaster().GetCurrentMovementGenerator(slot);
|
||||
if (movementGenerator != null)
|
||||
movementGenerator.Resume(timer);
|
||||
}
|
||||
@@ -208,7 +208,7 @@ namespace Game.Entities
|
||||
init.DisableTransportPathTransformations(); // It makes no sense to target global orientation
|
||||
init.SetFacing(ori);
|
||||
|
||||
//GetMotionMaster().LaunchMoveSpline(init, EventId.Face, MovementSlot.Controlled);
|
||||
//GetMotionMaster().LaunchMoveSpline(init, EventId.Face, MovementGeneratorPriority.Highest);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
@@ -223,7 +223,7 @@ namespace Game.Entities
|
||||
init.MoveTo(GetPositionX(), GetPositionY(), GetPositionZ(), false);
|
||||
init.SetFacing(GetAbsoluteAngle(obj)); // when on transport, GetAbsoluteAngle will still return global coordinates (and angle) that needs transforming
|
||||
|
||||
//GetMotionMaster().LaunchMoveSpline(init, EventId.Face, MovementSlot.Controlled);
|
||||
//GetMotionMaster().LaunchMoveSpline(init, EventId.Face, MovementGeneratorPriority.Highest);
|
||||
init.Launch();
|
||||
}
|
||||
|
||||
@@ -232,7 +232,7 @@ namespace Game.Entities
|
||||
MoveSplineInit init = new(this);
|
||||
init.MoveTo(x, y, z, generatePath, forceDestination);
|
||||
init.SetVelocity(speed);
|
||||
GetMotionMaster().LaunchMoveSpline(init, 0, MovementSlot.Active, MovementGeneratorType.Point);
|
||||
GetMotionMaster().LaunchMoveSpline(init, 0, MovementGeneratorPriority.Normal, MovementGeneratorType.Point);
|
||||
}
|
||||
|
||||
public void KnockbackFrom(float x, float y, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
|
||||
@@ -539,7 +539,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Follow)
|
||||
{
|
||||
Unit followed = ((AbstractFollower)GetMotionMaster().Top()).GetTarget();
|
||||
Unit followed = (GetMotionMaster().GetCurrentMovementGenerator() as FollowMovementGenerator).GetTarget();
|
||||
if (followed != null && followed.GetGUID() == GetOwnerGUID() && !followed.IsInCombat())
|
||||
{
|
||||
float ownerSpeed = followed.GetSpeedRate(mtype);
|
||||
@@ -1254,8 +1254,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (IsAlive())
|
||||
{
|
||||
if (GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Fleeing)
|
||||
GetMotionMaster().MovementExpired();
|
||||
GetMotionMaster().Remove(MovementGeneratorType.Fleeing);
|
||||
if (GetVictim() != null)
|
||||
SetTarget(GetVictim().GetGUID());
|
||||
}
|
||||
@@ -1280,8 +1279,7 @@ namespace Game.Entities
|
||||
{
|
||||
if (IsAlive())
|
||||
{
|
||||
if (GetMotionMaster().GetCurrentMovementGeneratorType() == MovementGeneratorType.Confused)
|
||||
GetMotionMaster().MovementExpired();
|
||||
GetMotionMaster().Remove(MovementGeneratorType.Confused);
|
||||
if (GetVictim() != null)
|
||||
SetTarget(GetVictim().GetGUID());
|
||||
}
|
||||
|
||||
@@ -353,11 +353,8 @@ namespace Game.Entities
|
||||
|
||||
if (IsTypeId(TypeId.Unit))
|
||||
{
|
||||
IMovementGenerator movementGenerator = GetMotionMaster().GetMotionSlot(MovementSlot.Idle);
|
||||
if (movementGenerator != null)
|
||||
movementGenerator.Pause(0);
|
||||
|
||||
GetMotionMaster().Clear(MovementSlot.Active);
|
||||
PauseMovement(0, 0, false);
|
||||
GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
|
||||
|
||||
StopMoving();
|
||||
|
||||
@@ -476,7 +473,7 @@ namespace Game.Entities
|
||||
RestoreFaction();
|
||||
|
||||
///@todo Handle SLOT_IDLE motion resume
|
||||
GetMotionMaster().InitDefault();
|
||||
GetMotionMaster().InitializeDefault();
|
||||
|
||||
Creature creature = ToCreature();
|
||||
if (creature)
|
||||
@@ -547,8 +544,6 @@ namespace Game.Entities
|
||||
player.SetClientControl(this, true);
|
||||
}
|
||||
|
||||
EngageWithTarget(charmer);
|
||||
|
||||
// a guardian should always have charminfo
|
||||
if (playerCharmer && this != charmer.GetFirstControlled())
|
||||
playerCharmer.SendRemoveControlBar();
|
||||
|
||||
@@ -171,7 +171,7 @@ namespace Game.Entities
|
||||
}
|
||||
|
||||
UpdateSplineMovement(diff);
|
||||
GetMotionMaster().UpdateMotion(diff);
|
||||
GetMotionMaster().Update(diff);
|
||||
}
|
||||
|
||||
void _UpdateSpells(uint diff)
|
||||
@@ -999,7 +999,7 @@ namespace Game.Entities
|
||||
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
|
||||
init.SetFacing(GetOrientation());
|
||||
init.SetTransportExit();
|
||||
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementSlot.Controlled);
|
||||
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementGeneratorPriority.Highest);
|
||||
|
||||
if (player != null)
|
||||
player.ResummonPetTemporaryUnSummonedIfAny();
|
||||
@@ -1353,7 +1353,7 @@ namespace Game.Entities
|
||||
// * Using 'call pet' on dead pets
|
||||
// * Using 'call stabled pet'
|
||||
// * Logging in with dead pets
|
||||
GetMotionMaster().Clear(false);
|
||||
GetMotionMaster().Clear();
|
||||
GetMotionMaster().MoveIdle();
|
||||
}
|
||||
StopMoving();
|
||||
|
||||
Reference in New Issue
Block a user