-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add check for clicks based on the bounds of the graphic associated wi…
…th a map sign
- Loading branch information
1 parent
6c05472
commit b0e6f14
Showing
6 changed files
with
103 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
using AutomaticTypeMapper; | ||
using EndlessClient.Rendering.MapEntityRenderers; | ||
using EOLib.Domain.Character; | ||
using EOLib.Graphics; | ||
using Microsoft.Xna.Framework; | ||
using System.Linq; | ||
|
||
namespace EndlessClient.Rendering.Map | ||
{ | ||
[AutoMappedType] | ||
public class MapObjectBoundsCalculator : IMapObjectBoundsCalculator | ||
{ | ||
private readonly INativeGraphicsManager _nativeGraphicsManager; | ||
private readonly ICharacterProvider _characterProvider; | ||
private readonly IRenderOffsetCalculator _renderOffsetCalculator; | ||
private readonly MapObjectLayerRenderer _objectRenderer; | ||
|
||
public MapObjectBoundsCalculator(INativeGraphicsManager nativeGraphicsManager, | ||
ICharacterProvider characterProvider, | ||
IRenderOffsetCalculator renderOffsetCalculator, | ||
IMapEntityRendererProvider mapEntityRendererProvider) | ||
{ | ||
_nativeGraphicsManager = nativeGraphicsManager; | ||
_characterProvider = characterProvider; | ||
_renderOffsetCalculator = renderOffsetCalculator; | ||
|
||
_objectRenderer = mapEntityRendererProvider.MapEntityRenderers.OfType<MapObjectLayerRenderer>().Single(); | ||
} | ||
|
||
public Rectangle GetMapObjectBounds(int gridX, int gridY, int gfxNum) | ||
{ | ||
var gfx = _nativeGraphicsManager.TextureFromResource(GFXTypes.MapObjects, gfxNum, transparent: true); | ||
var drawPosition = _objectRenderer.GetDrawCoordinatesFromGridUnits(gridX, gridY); | ||
// see: MapObjectLayerRenderer | ||
// todo: more centralized way of representing this | ||
drawPosition -= new Vector2(gfx.Width / 2, gfx.Height - 32); | ||
return gfx.Bounds.WithPosition(drawPosition); | ||
} | ||
} | ||
|
||
public interface IMapObjectBoundsCalculator | ||
{ | ||
Rectangle GetMapObjectBounds(int gridX, int gridY, int gfxNum); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters