Skip to content

Commit

Permalink
Fix replaying a walk into walls/NPCs bumping the character back
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Sep 18, 2022
1 parent 42eee0a commit 59b71f4
Showing 1 changed file with 19 additions and 3 deletions.
22 changes: 19 additions & 3 deletions EndlessClient/Rendering/Character/CharacterAnimator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -289,20 +289,36 @@ private void AnimateCharacterWalking()
if (nextFrameRenderProperties.IsActing(CharacterActionState.Standing))
{
var isMainCharacter = currentCharacter == _characterRepository.MainCharacter;
var canMoveToDestinationCoordinates = _walkValidationActions.CanMoveToCoordinates(nextFrameRenderProperties.GetDestinationX(), nextFrameRenderProperties.GetDestinationY());

if (pair.Replay)
{
if (!isMainCharacter || (isMainCharacter && _walkValidationActions.CanMoveToCoordinates(nextFrameRenderProperties.GetDestinationX(), nextFrameRenderProperties.GetDestinationY())))
if (!isMainCharacter || (isMainCharacter && canMoveToDestinationCoordinates))
{
// send the walk packet after the game state has been updated so the correct coordinates are sent
sendWalk = isMainCharacter;
nextFrameRenderProperties = AnimateOneWalkFrame(nextFrameRenderProperties.ResetAnimationFrames());
var extraFrameProps = AnimateOneWalkFrame(nextFrameRenderProperties.ResetAnimationFrames());
pair.Replay = false;

if (_queuedDirections.ContainsKey(pair.UniqueID))
{
nextFrameRenderProperties = nextFrameRenderProperties.WithDirection(_queuedDirections[pair.UniqueID]);
extraFrameProps = extraFrameProps.WithDirection(_queuedDirections[pair.UniqueID]);
_queuedDirections.Remove(pair.UniqueID);

canMoveToDestinationCoordinates = _walkValidationActions.CanMoveToCoordinates(extraFrameProps.GetDestinationX(), extraFrameProps.GetDestinationY());
if (!canMoveToDestinationCoordinates)
{
playersDoneWalking.Add(pair.UniqueID);
sendWalk = false;
}
else
{
nextFrameRenderProperties = extraFrameProps;
}
}
else
{
nextFrameRenderProperties = extraFrameProps;
}
}
else
Expand Down

0 comments on commit 59b71f4

Please sign in to comment.