diff --git a/EndlessClient/Controllers/ArrowKeyController.cs b/EndlessClient/Controllers/ArrowKeyController.cs index 000bf3012..e1f74e515 100644 --- a/EndlessClient/Controllers/ArrowKeyController.cs +++ b/EndlessClient/Controllers/ArrowKeyController.cs @@ -109,19 +109,23 @@ private void AttemptToStartWalking() { if (!_walkValidationActions.CanMoveToDestinationCoordinates()) { - var (unwalkableAction, cellState) = _unwalkableTileActions.HandleUnwalkableTile(); - switch (unwalkableAction) + var (unwalkableActions, cellState) = _unwalkableTileActions.HandleUnwalkableTile(); + + foreach (var action in unwalkableActions) { - case UnwalkableTileAction.Chest: - _mapActions.OpenChest((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); - _inGameDialogActions.ShowChestDialog(); - break; - case UnwalkableTileAction.Locker: - _mapActions.OpenLocker((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); - _inGameDialogActions.ShowLockerDialog(); - break; - case UnwalkableTileAction.Chair: _characterActions.SitInChair(); break; - case UnwalkableTileAction.Door: cellState.Warp.MatchSome(w => _mapActions.OpenDoor(w)); break; + switch (action) + { + case UnwalkableTileAction.Chest: + _mapActions.OpenChest((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); + _inGameDialogActions.ShowChestDialog(); + break; + case UnwalkableTileAction.Locker: + _mapActions.OpenLocker((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); + _inGameDialogActions.ShowLockerDialog(); + break; + case UnwalkableTileAction.Chair: _characterActions.SitInChair(); break; + case UnwalkableTileAction.Door: cellState.Warp.MatchSome(w => _mapActions.OpenDoor(w)); break; + } } } else diff --git a/EndlessClient/Controllers/MapInteractionController.cs b/EndlessClient/Controllers/MapInteractionController.cs index 9dab6beb9..d9a1e311a 100644 --- a/EndlessClient/Controllers/MapInteractionController.cs +++ b/EndlessClient/Controllers/MapInteractionController.cs @@ -125,29 +125,32 @@ public void LeftClick(IMapCellState cellState, Option mous } else if (InteractableTileSpec(cellState.TileSpec) && CharacterIsCloseEnough(cellState.Coordinate)) { - var unwalkableAction = _unwalkableTileActions.HandleUnwalkableTile(cellState); + var unwalkableActions = _unwalkableTileActions.HandleUnwalkableTile(cellState); - switch (cellState.TileSpec) + foreach (var unwalkableAction in unwalkableActions) { - // todo: implement for other clickable tile specs (board, jukebox, etc) - case TileSpec.Chest: - if (unwalkableAction == UnwalkableTileAction.Chest) - { - _mapActions.OpenChest((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); - _inGameDialogActions.ShowChestDialog(); + switch (cellState.TileSpec) + { + // todo: implement for other clickable tile specs (board, jukebox, etc) + case TileSpec.Chest: + if (unwalkableAction == UnwalkableTileAction.Chest) + { + _mapActions.OpenChest((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); + _inGameDialogActions.ShowChestDialog(); - _userInputRepository.ClickHandled = true; - } - break; - case TileSpec.BankVault: - if (unwalkableAction == UnwalkableTileAction.Locker) - { - _mapActions.OpenLocker((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); - _inGameDialogActions.ShowLockerDialog(); + _userInputRepository.ClickHandled = true; + } + break; + case TileSpec.BankVault: + if (unwalkableAction == UnwalkableTileAction.Locker) + { + _mapActions.OpenLocker((byte)cellState.Coordinate.X, (byte)cellState.Coordinate.Y); + _inGameDialogActions.ShowLockerDialog(); - _userInputRepository.ClickHandled = true; - } - break; + _userInputRepository.ClickHandled = true; + } + break; + } } } else if (cellState.InBounds && !cellState.Character.HasValue && !cellState.NPC.HasValue) diff --git a/EndlessClient/Input/UnwalkableTileActions.cs b/EndlessClient/Input/UnwalkableTileActions.cs index b9fd65fc7..b062ef0db 100644 --- a/EndlessClient/Input/UnwalkableTileActions.cs +++ b/EndlessClient/Input/UnwalkableTileActions.cs @@ -6,6 +6,7 @@ using EOLib.Domain.Map; using EOLib.IO.Map; using EOLib.Localization; +using System.Collections.Generic; namespace EndlessClient.Input { @@ -49,30 +50,30 @@ public class UnwalkableTileActions : IUnwalkableTileActions _messageBoxFactory = messageBoxFactory; } - public (UnwalkableTileAction, IMapCellState) HandleUnwalkableTile() + public (IReadOnlyList, IMapCellState) HandleUnwalkableTile() { var destX = MainCharacter.RenderProperties.GetDestinationX(); var destY = MainCharacter.RenderProperties.GetDestinationY(); return HandleUnwalkableTile(destX, destY); } - public (UnwalkableTileAction, IMapCellState) HandleUnwalkableTile(int x, int y) + public (IReadOnlyList, IMapCellState) HandleUnwalkableTile(int x, int y) { var cellState = _mapCellStateProvider.GetCellStateAt(x, y); var action = HandleUnwalkableTile(cellState); return (action, cellState); } - public UnwalkableTileAction HandleUnwalkableTile(IMapCellState cellState) + public IReadOnlyList HandleUnwalkableTile(IMapCellState cellState) { if (MainCharacter.RenderProperties.SitState != SitState.Standing) - return UnwalkableTileAction.None; + return new[] { UnwalkableTileAction.None }; return cellState.Character.Match( - some: c => HandleWalkThroughOtherCharacter(c), //todo: walk through players after certain elapsed time (3-5sec?) + some: c => new[] { HandleWalkThroughOtherCharacter(c) }, //todo: walk through players after certain elapsed time (3-5sec?) none: () => cellState.Warp.Match( - some: w => HandleWalkToWarpTile(w), - none: () => HandleWalkToTileSpec(cellState))); + some: w => new[] { HandleWalkToWarpTile(w), HandleWalkToTileSpec(cellState) }, + none: () => new[] { HandleWalkToTileSpec(cellState) })); } private UnwalkableTileAction HandleWalkThroughOtherCharacter(Character c) @@ -176,10 +177,10 @@ private UnwalkableTileAction HandleWalkToTileSpec(IMapCellState cellState) public interface IUnwalkableTileActions { - (UnwalkableTileAction, IMapCellState) HandleUnwalkableTile(); + (IReadOnlyList, IMapCellState) HandleUnwalkableTile(); - (UnwalkableTileAction, IMapCellState) HandleUnwalkableTile(int x, int y); + (IReadOnlyList, IMapCellState) HandleUnwalkableTile(int x, int y); - UnwalkableTileAction HandleUnwalkableTile(IMapCellState mapCellState); + IReadOnlyList HandleUnwalkableTile(IMapCellState mapCellState); } }