Skip to content

Commit

Permalink
Don't handle mouse click if clicking outside the map bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
ethanmoffat committed Jan 23, 2021
1 parent 163ba88 commit 5aa6581
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 2 deletions.
2 changes: 2 additions & 0 deletions EOLib/Domain/Map/IMapCellState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace EOLib.Domain.Map
{
public interface IMapCellState
{
bool InBounds { get; }

MapCoordinate Coordinate { get; }

IReadOnlyList<IItem> Items { get; }
Expand Down
2 changes: 2 additions & 0 deletions EOLib/Domain/Map/MapCellState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ namespace EOLib.Domain.Map
{
public class MapCellState : IMapCellState
{
public bool InBounds { get; set; }

public MapCoordinate Coordinate { get; set; }

public IReadOnlyList<IItem> Items { get; set; }
Expand Down
3 changes: 2 additions & 1 deletion EOLib/Domain/Map/MapCellStateProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class MapCellStateProvider : IMapCellStateProvider
public IMapCellState GetCellStateAt(int x, int y)
{
if (x < 0 || y < 0 || x > CurrentMap.Properties.Width || y > CurrentMap.Properties.Height)
return new MapCellState {TileSpec = TileSpec.MapEdge};
return new MapCellState { InBounds = false, TileSpec = TileSpec.MapEdge };

var tileSpec = CurrentMap.Tiles[y, x];
var warp = CurrentMap.Warps[y, x];
Expand All @@ -42,6 +42,7 @@ public IMapCellState GetCellStateAt(int x, int y)

return new MapCellState
{
InBounds = true,
Coordinate = new MapCoordinate(x, y),
Items = items.ToList(),
TileSpec = tileSpec,
Expand Down
2 changes: 1 addition & 1 deletion EndlessClient/Controllers/MapInteractionController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void LeftClick(IMapCellState cellState, IMouseCursorRenderer mouseRendere
else if (cellState.Sign.HasValue) { /* TODO: sign interaction */ }
else if (cellState.Chest.HasValue) { /* TODO: chest interaction */ }
else if (cellState.Character.HasValue) { /* TODO: character spell cast */ }
else
else if (cellState.InBounds)
{
mouseRenderer.AnimateClick();
_hudControlProvider.GetComponent<IClickWalkPathHandler>(HudControlIdentifier.ClickWalkPathHandler)
Expand Down

0 comments on commit 5aa6581

Please sign in to comment.