In your code, I see one big mistake:

---
class TileRenderer
{
private Tile[] tiles;
/*...*/
}

class CTileRenderer : TileRenderer
{
private CTile[] tiles;
/*...*/
}
---


Those are two separate arrays! Stuff examined through TileRenderer will be looking at a different array than looking through CTileRenderer.

I would just remove the `tiles` variable from the subclass and only use the base class one. I think that will work for you. writeTiles can do if(auto ctile = cast(CTile) tile) in the loop to get to the more specific class (or you might refactor your interfaces a bit. Really, I'd say `render` should just be a method in Tile, which its own subclasses can override.)

Reply via email to