package components

import (
	"log"

	"github.com/hajimehoshi/ebiten/v2"
)

// A hidden door in a wall. If the player bumps into it once, it shows
// damage and it vanishes the next time.

type Destroyable struct {
	Activated bool
	Sprites   []*ebiten.Image
	Current   int // sprite index
}

func (door *Destroyable) GetNext() *ebiten.Image {
	if len(door.Sprites) > door.Current {
		door.Current++
		return door.Sprites[door.Current]
	}

	log.Fatalf("not enough sprites in transient tile, have %d sprites, index requested: %d",
		len(door.Sprites), door.Current+1,
	)

	return nil
}
