diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2023-02-04 18:51:31 +0100 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2025-08-20 15:46:40 +0200 |
| commit | 8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d (patch) | |
| tree | 6e201152c264184bcd5aad784386654e921c8634 /go/ui/mapView.go | |
| parent | 083ec284a9ef286729e544df9340a12760f03ab7 (diff) | |
| download | muhqs-game-8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d.tar.gz muhqs-game-8c3456f5a120a00f8a4e89065d7d50f2c1b4ad0d.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 |
