From e9070ef3752c5d2ab1f9faac48095995772ce726 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sat, 4 Feb 2023 18:51:31 +0100 Subject: improve permanent pile support * Fix alot of bugs caused by permanents without tiles * Implement a permanent choice to select the permanents in a pile * Fix how pile hooks are called --- go/ui/mapView.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'go/ui/mapView.go') diff --git a/go/ui/mapView.go b/go/ui/mapView.go index 8c83bd41..a6fd55c1 100644 --- a/go/ui/mapView.go +++ b/go/ui/mapView.go @@ -150,8 +150,12 @@ func (vw *MapView) drawPermanentsLayer(screen *ebiten.Image) { vw.permanentsLayer = vw.newLayerImage() for i, p := range vw.gameState.Permanents { - permanentSymbol := getPermanentSymbol(p, i) t := p.Tile() + // Skip permanents with no containing tiles (e.g. piled ones) + if t == nil { + continue + } + permanentSymbol := getPermanentSymbol(p, i) x_px := t.Position.X*TILE_WIDTH + (TILE_WIDTH-PERMANENT_WIDTH)/2 y_px := t.Position.Y*TILE_HEIGHT + (TILE_HEIGHT-PERMANENT_HEIGHT)/2 @@ -206,7 +210,11 @@ func (vw *MapView) FindObjectAt(screenX, screenY int) interface{} { relativeY >= yMargin && relativeY <= TILE_HEIGHT-yMargin { for _, p := range vw.gameState.Permanents { - pos := p.Tile().Position + t := p.Tile() + if t == nil { + continue + } + pos := t.Position if pos.X == x && pos.Y == y { if isSymbolTransparentAt(p, relativeX, relativeY) { break -- cgit v1.2.3