Skip to content

Commit

Permalink
Support clicking to open doors
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Sep 16, 2022
1 parent 02bb182 commit 3dcda22
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 3 deletions.
3 changes: 3 additions & 0 deletions EOLib/Domain/Map/MapActions.cs
Expand Up @@ -51,6 +51,9 @@ public ItemPickupResult PickUpItem(MapItem item)

public void OpenDoor(Warp warp)
{
if (_currentMapStateRepository.PendingDoors.Contains(warp))
return;

var packet = new PacketBuilder(PacketFamily.Door, PacketAction.Open)
.AddChar((byte)warp.X)
.AddChar((byte)warp.Y)
Expand Down
10 changes: 10 additions & 0 deletions EndlessClient/Controllers/MapInteractionController.cs
Expand Up @@ -162,6 +162,16 @@ public void LeftClick(IMapCellState cellState, Option<IMouseCursorRenderer> mous
_userInputRepository.ClickHandled = true;
}

cellState.Warp.MatchSome(w =>
{
w.SomeWhen(d => d.DoorType != DoorSpec.NoDoor)
.MatchSome(d =>
{
_mapActions.OpenDoor(d);
_userInputRepository.ClickHandled = true;
});
});

_userInputTimeRepository.LastInputTime = DateTime.Now;
}

Expand Down
4 changes: 1 addition & 3 deletions EndlessClient/Rendering/MouseCursorRenderer.cs
Expand Up @@ -300,9 +300,7 @@ private void CheckForClicks(IMapCellState cellState)
var currentMouseState = _userInputProvider.CurrentMouseState;
var previousMouseState = _userInputProvider.PreviousMouseState;

// todo: some left clicks should be on the graphic itself instead of based on the grid where the cursor is (map sign, board, etc.)
if (currentMouseState.LeftButton == ButtonState.Released &&
previousMouseState.LeftButton == ButtonState.Pressed)
if (currentMouseState.LeftButton == ButtonState.Released && previousMouseState.LeftButton == ButtonState.Pressed)
{
_mapInteractionController.LeftClick(cellState, Option.Some<IMouseCursorRenderer>(this));
}
Expand Down

0 comments on commit 3dcda22

Please sign in to comment.