Skip to content

Commit

Permalink
Ensure animated ground tiles have at least 2 full frames before anima…
Browse files Browse the repository at this point in the history
…ting them. Fixes rendering issue on slightly oversized ground tiles (e.g. 66x33)
  • Loading branch information
ethanmoffat committed Sep 9, 2022
1 parent ea19e68 commit 4f9286e
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ namespace EndlessClient.Rendering.MapEntityRenderers
{
public class GroundLayerRenderer : BaseMapEntityRenderer
{
protected const int TILE_FRAME_WIDTH = 64;
protected const int ANIMATED_TILE_MIN_WIDTH = 128;

protected readonly INativeGraphicsManager _nativeGraphicsManager;
private readonly ICurrentMapProvider _currentMapProvider;
Expand Down Expand Up @@ -66,7 +66,7 @@ public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col,
return;
}

var src = tileTexture.Width > TILE_FRAME_WIDTH
var src = tileTexture.Width >= ANIMATED_TILE_MIN_WIDTH
? new Rectangle?(new Rectangle((tileTexture.Width / 4) * _frameIndex, 0, tileTexture.Width / 4, tileTexture.Height))
: null;
spriteBatch.Draw(tileTexture, pos + additionalOffset, src, Color.FromNonPremultiplied(255, 255, 255, alpha));
Expand Down Expand Up @@ -94,7 +94,7 @@ protected override bool ElementExistsAt(int row, int col)
var tileExists = ((tileId = CurrentMap.Properties.FillTile) > 0 && CurrentMap.GFX[MapLayer.GroundTile][row, col] < 0) ||
(tileId = CurrentMap.GFX[MapLayer.GroundTile][row, col]) > 0;

return tileExists && _nativeGraphicsManager.TextureFromResource(GFXTypes.MapTiles, tileId, true).Width > TILE_FRAME_WIDTH;
return tileExists && _nativeGraphicsManager.TextureFromResource(GFXTypes.MapTiles, tileId, true).Width >= ANIMATED_TILE_MIN_WIDTH;
}

public override Vector2 GetDrawCoordinatesFromGridUnits(int gridX, int gridY)
Expand Down

0 comments on commit 4f9286e

Please sign in to comment.