diff --git a/EndlessClient/Controllers/MapInteractionController.cs b/EndlessClient/Controllers/MapInteractionController.cs index d95b7d3d4..99b3ab746 100644 --- a/EndlessClient/Controllers/MapInteractionController.cs +++ b/EndlessClient/Controllers/MapInteractionController.cs @@ -13,6 +13,7 @@ using EndlessClient.Rendering.Character; using EndlessClient.Rendering.Factories; using EOLib.Domain.Character; +using EOLib.Domain.Extensions; using EOLib.Domain.Interact; using EOLib.Domain.Item; using EOLib.Domain.Map; @@ -33,6 +34,7 @@ public class MapInteractionController : IMapInteractionController private readonly ICharacterActions _characterActions; private readonly IInGameDialogActions _inGameDialogActions; private readonly IPaperdollActions _paperdollActions; + private readonly IWalkValidationActions _walkValidationActions; private readonly IUnwalkableTileActions _unwalkableTileActions; private readonly ICharacterAnimationActions _characterAnimationActions; private readonly ISpellCastValidationActions _spellCastValidationActions; @@ -54,6 +56,7 @@ public MapInteractionController(IMapActions mapActions, ICharacterActions characterActions, IInGameDialogActions inGameDialogActions, IPaperdollActions paperdollActions, + IWalkValidationActions walkValidationActions, IUnwalkableTileActions unwalkableTileActions, ICharacterAnimationActions characterAnimationActions, ISpellCastValidationActions spellCastValidationActions, @@ -75,6 +78,7 @@ public MapInteractionController(IMapActions mapActions, _characterActions = characterActions; _inGameDialogActions = inGameDialogActions; _paperdollActions = paperdollActions; + _walkValidationActions = walkValidationActions; _unwalkableTileActions = unwalkableTileActions; _characterAnimationActions = characterAnimationActions; _spellCastValidationActions = spellCastValidationActions; @@ -153,7 +157,9 @@ public void LeftClick(IMapCellState cellState, Option mous } } } - else if (cellState.InBounds && !cellState.Character.HasValue && !cellState.NPC.HasValue) + else if (cellState.InBounds && !cellState.Character.HasValue && !cellState.NPC.HasValue + && _walkValidationActions.IsCellStateWalkable(cellState) + && _characterProvider.MainCharacter.RenderProperties.IsActing(CharacterActionState.Standing)) { mouseRenderer.MatchSome(r => r.AnimateClick()); _hudControlProvider.GetComponent(HudControlIdentifier.CharacterAnimator) @@ -167,7 +173,11 @@ public void LeftClick(IMapCellState cellState, Option mous w.SomeWhen(d => d.DoorType != DoorSpec.NoDoor) .MatchSome(d => { - _mapActions.OpenDoor(d); + if (_unwalkableTileActions.HandleUnwalkableTile(cellState).Any(x => x == UnwalkableTileAction.Door)) + { + _mapActions.OpenDoor(d); + } + _userInputRepository.ClickHandled = true; }); }); diff --git a/EndlessClient/Rendering/Character/CharacterAnimator.cs b/EndlessClient/Rendering/Character/CharacterAnimator.cs index 1cfde60aa..8bd703e85 100644 --- a/EndlessClient/Rendering/Character/CharacterAnimator.cs +++ b/EndlessClient/Rendering/Character/CharacterAnimator.cs @@ -101,32 +101,43 @@ public void MainCharacterFace(EODirection direction) public void StartMainCharacterWalkAnimation(Option targetCoordinate) { _walkPath.Clear(); - targetCoordinate.MatchSome(tc => - { - _targetCoordinate = targetCoordinate; - var rp = _characterRepository.MainCharacter.RenderProperties; - var characterCoord = new MapCoordinate(rp.MapX, rp.MapY); + targetCoordinate.Match( + some: tc => + { + _targetCoordinate = targetCoordinate; - _walkPath = _pathFinder.FindPath(characterCoord, tc); + var rp = _characterRepository.MainCharacter.RenderProperties; + var characterCoord = new MapCoordinate(rp.MapX, rp.MapY); - if (!_otherPlayerStartWalkingTimes.ContainsKey(_characterRepository.MainCharacter.ID) && _walkPath.Any()) - { - rp = FaceTarget(characterCoord, _walkPath.Peek(), rp); - _characterRepository.MainCharacter = _characterRepository.MainCharacter.WithRenderProperties(rp); - } - }); + _walkPath = _pathFinder.FindPath(characterCoord, tc); - if (_otherPlayerStartWalkingTimes.ContainsKey(_characterRepository.MainCharacter.ID)) + if (_walkPath.Any()) + { + if (!_otherPlayerStartWalkingTimes.ContainsKey(_characterRepository.MainCharacter.ID)) + { + rp = FaceTarget(characterCoord, _walkPath.Peek(), rp); + _characterRepository.MainCharacter = _characterRepository.MainCharacter.WithRenderProperties(rp); + } + + doTheWalk(); + } + }, + none: doTheWalk); + + void doTheWalk() { - _otherPlayerStartWalkingTimes[_characterRepository.MainCharacter.ID].Replay = true; - return; - } + if (_otherPlayerStartWalkingTimes.ContainsKey(_characterRepository.MainCharacter.ID)) + { + _otherPlayerStartWalkingTimes[_characterRepository.MainCharacter.ID].Replay = true; + return; + } - var startWalkingTime = new RenderFrameActionTime(_characterRepository.MainCharacter.ID); - _otherPlayerStartWalkingTimes.Add(_characterRepository.MainCharacter.ID, startWalkingTime); + var startWalkingTime = new RenderFrameActionTime(_characterRepository.MainCharacter.ID); + _otherPlayerStartWalkingTimes.Add(_characterRepository.MainCharacter.ID, startWalkingTime); - _characterActions.Walk(); + _characterActions.Walk(); + } } public void StartMainCharacterAttackAnimation()