diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-04 18:51:31 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-01-27 16:43:47 +0100 |
| commit | e9070ef3752c5d2ab1f9faac48095995772ce726 (patch) | |
| tree | d1842db95e73039224476d0a5794d951e3fdfb3b /go/ui/mapView.go | |
| parent | ea54efacae089aa3644cfe00c8e180d5cc2c8d9e (diff) | |
| download | muhqs-game-e9070ef3752c5d2ab1f9faac48095995772ce726.tar.gz muhqs-game-e9070ef3752c5d2ab1f9faac48095995772ce726.zip | |
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
Diffstat (limited to 'go/ui/mapView.go')
| -rw-r--r-- | go/ui/mapView.go | 12 |
1 files changed, 10 insertions, 2 deletions
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 |
