Core/Movement: Delay creating MoveSplineInit objects used by GenericMovementGenerator to spline launch time

Port From (https://github.com/TrinityCore/TrinityCore/commit/36dde87249e87c5693162a6e890875d828f93d6d)
This commit is contained in:
hondacrx
2022-06-15 15:48:07 -04:00
parent 5ff87102ca
commit f91230ae33
7 changed files with 154 additions and 127 deletions
+6 -4
View File
@@ -234,10 +234,12 @@ namespace Game.Entities
public void MonsterMoveWithSpeed(float x, float y, float z, float speed, bool generatePath = false, bool forceDestination = false)
{
MoveSplineInit init = new(this);
init.MoveTo(x, y, z, generatePath, forceDestination);
init.SetVelocity(speed);
GetMotionMaster().LaunchMoveSpline(init, 0, MovementGeneratorPriority.Normal, MovementGeneratorType.Point);
var initializer = (MoveSplineInit init) =>
{
init.MoveTo(x, y, z, generatePath, forceDestination);
init.SetVelocity(speed);
};
GetMotionMaster().LaunchMoveSpline(initializer, 0, MovementGeneratorPriority.Normal, MovementGeneratorType.Point);
}
public void KnockbackFrom(Position origin, float speedXY, float speedZ, SpellEffectExtraData spellEffectExtraData = null)
+11 -9
View File
@@ -1108,18 +1108,20 @@ namespace Game.Entities
}
}
float height = pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight();
var initializer = (MoveSplineInit init) =>
{
float height = pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight();
MoveSplineInit init = new(this);
// Creatures without inhabit type air should begin falling after exiting the vehicle
if (IsTypeId(TypeId.Unit) && !CanFly() && height > GetMap().GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight(), ref height))
init.SetFall();
// Creatures without inhabit type air should begin falling after exiting the vehicle
if (IsTypeId(TypeId.Unit) && !ToCreature().CanFly() && height > GetMap().GetWaterOrGroundLevel(GetPhaseShift(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ() + vehicle.GetBase().GetCollisionHeight(), ref height))
init.SetFall();
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
init.SetFacing(pos.GetOrientation());
init.SetTransportExit();
};
init.MoveTo(pos.GetPositionX(), pos.GetPositionY(), height, false);
init.SetFacing(pos.GetOrientation());
init.SetTransportExit();
GetMotionMaster().LaunchMoveSpline(init, EventId.VehicleExit, MovementGeneratorPriority.Highest);
GetMotionMaster().LaunchMoveSpline(initializer, EventId.VehicleExit, MovementGeneratorPriority.Highest);
if (player != null)
player.ResummonPetTemporaryUnSummonedIfAny();