Core/Movement: Fixed pauses on waypoint movement happening at wrong times when FollowPathBackwardsFromEndToStart is set and creature is going from end to start
Port From (https://github.com/TrinityCore/TrinityCore/commit/c5097114d1d08d6d6f7d2adc9f5f3f52f75c5818)
This commit is contained in:
@@ -16,7 +16,6 @@ namespace Game.Movement
|
|||||||
TimeTracker _nextMoveTime;
|
TimeTracker _nextMoveTime;
|
||||||
uint _pathId;
|
uint _pathId;
|
||||||
bool _repeating;
|
bool _repeating;
|
||||||
bool _loadedFromDB;
|
|
||||||
|
|
||||||
WaypointPath _path;
|
WaypointPath _path;
|
||||||
int _currentNode;
|
int _currentNode;
|
||||||
@@ -131,7 +130,7 @@ namespace Game.Movement
|
|||||||
{
|
{
|
||||||
RemoveFlag(MovementGeneratorFlags.InitializationPending | MovementGeneratorFlags.Transitory | MovementGeneratorFlags.Deactivated);
|
RemoveFlag(MovementGeneratorFlags.InitializationPending | MovementGeneratorFlags.Transitory | MovementGeneratorFlags.Deactivated);
|
||||||
|
|
||||||
if (_loadedFromDB)
|
if (IsLoadedFromDB())
|
||||||
{
|
{
|
||||||
if (_pathId == 0)
|
if (_pathId == 0)
|
||||||
_pathId = owner.GetWaypointPathId();
|
_pathId = owner.GetWaypointPathId();
|
||||||
@@ -296,10 +295,23 @@ namespace Game.Movement
|
|||||||
|
|
||||||
Cypher.Assert(_currentNode < _path.Nodes.Count, $"WaypointMovementGenerator.OnArrived: tried to reference a node id ({_currentNode}) which is not included in path ({_path.Id})");
|
Cypher.Assert(_currentNode < _path.Nodes.Count, $"WaypointMovementGenerator.OnArrived: tried to reference a node id ({_currentNode}) which is not included in path ({_path.Id})");
|
||||||
WaypointNode waypoint = _path.Nodes.ElementAt(_currentNode);
|
WaypointNode waypoint = _path.Nodes.ElementAt(_currentNode);
|
||||||
if (waypoint.Delay != 0)
|
|
||||||
|
TimeSpan delay = new Func<TimeSpan>(() =>
|
||||||
|
{
|
||||||
|
if (!_isReturningToStart)
|
||||||
|
return TimeSpan.FromMilliseconds(waypoint.Delay);
|
||||||
|
|
||||||
|
// when traversing the path backwards, use delays from "next" waypoint to make sure pauses happen between the same points as in forward direction
|
||||||
|
if (_currentNode > 0)
|
||||||
|
return TimeSpan.FromMilliseconds(_path.Nodes[_currentNode - 1].Delay);
|
||||||
|
|
||||||
|
return TimeSpan.Zero;
|
||||||
|
})();
|
||||||
|
|
||||||
|
if (delay > TimeSpan.Zero)
|
||||||
{
|
{
|
||||||
owner.ClearUnitState(UnitState.RoamingMove);
|
owner.ClearUnitState(UnitState.RoamingMove);
|
||||||
_nextMoveTime.Reset(waypoint.Delay);
|
_nextMoveTime.Reset(delay);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_waitTimeRangeAtPathEnd.HasValue && IsFollowingPathBackwardsFromEndToStart()
|
if (_waitTimeRangeAtPathEnd.HasValue && IsFollowingPathBackwardsFromEndToStart()
|
||||||
@@ -508,5 +520,7 @@ namespace Game.Movement
|
|||||||
public override MovementGeneratorType GetMovementGeneratorType() { return MovementGeneratorType.Waypoint; }
|
public override MovementGeneratorType GetMovementGeneratorType() { return MovementGeneratorType.Waypoint; }
|
||||||
|
|
||||||
public override void UnitSpeedChanged() { AddFlag(MovementGeneratorFlags.SpeedUpdatePending); }
|
public override void UnitSpeedChanged() { AddFlag(MovementGeneratorFlags.SpeedUpdatePending); }
|
||||||
}
|
|
||||||
|
bool IsLoadedFromDB() { return _path != null; }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user