Skip to content

Commit

Permalink
Render NPCs a little earlier on the map (one row/col higher). Fixes r…
Browse files Browse the repository at this point in the history
…ender order bug with NPCs and down-facing walls.
  • Loading branch information
ethanmoffat committed Sep 19, 2022
1 parent 34a159a commit 7b603e6
Showing 1 changed file with 5 additions and 2 deletions.
Expand Up @@ -28,14 +28,17 @@ public class NPCEntityRenderer : BaseMapEntityRenderer

protected override bool ElementExistsAt(int row, int col)
{
// Render NPCs as part of a row/col one higher than they actually are
// This fixes weird layer render order bugs (without modifying the underlying data structures)
// This is a total hack because I'm not using a depth buffer for map rendering
return _npcRendererProvider.NPCRenderers.Values
.Count(n => IsNpcAt(n.NPC, row, col)) > 0;
.Count(n => IsNpcAt(n.NPC, row + 1, col + 1)) > 0;
}

public override void RenderElementAt(SpriteBatch spriteBatch, int row, int col, int alpha, Vector2 additionalOffset = default)
{
var indicesToRender = _npcRendererProvider.NPCRenderers.Values
.Where(n => IsNpcAt(n.NPC, row, col))
.Where(n => IsNpcAt(n.NPC, row + 1, col + 1))
.Select(n => n.NPC.Index);

foreach (var index in indicesToRender)
Expand Down

0 comments on commit 7b603e6

Please sign in to comment.