Hexworks / zircon

Zircon is an extensible and user-friendly, multiplatform tile engine.
https://hexworks.org/projects/zircon/
Apache License 2.0
754 stars 137 forks source link

The Screen implementation violates the Liskov Substitution Principle #323

Open adam-arold opened 4 years ago

adam-arold commented 4 years ago

If a Screen instance is passed to a View's constructor it won't be displayed correctly because the underlying Screen implementation doesn't handle delegation to its underlying TileGrid properly. The display will be garbled.

Seveen commented 4 years ago

I've noticed that we're creating a new Screen for the TileGrid in BaseView: final override val screen = Screen.create(tileGrid)

Testing for the type of TileGrid passed to the View fixes the bug:

final override val screen =
            if (tileGrid is Screen) {
                tileGrid
            } else {
                Screen.create(tileGrid)
            }

but I'm not sure if I'm not simply masking an underlying problem in the Screen implementation

adam-arold commented 4 years ago

I think this is masking, because outside of these Views the problem still persists. I'm not sure that there is a simple solution for this problem unfortunately. 😢