class_name HyenaSpriteFrames extends RefCounted
## Builds a SpriteFrames resource for the Hyena (player-facing "hyena") entity.
##
## Atlas layout (single horizontal strip, 48×48 cells):
##   Hyena_idle.png  — 192×48 = 4 frames
##   Hyena_walk.png  — 288×48 = 6 frames
##
## Sprites: CraftPix Free Desert Enemy Sprite Sheets.
## License: CraftPix Free (commercial OK, attribution appreciated).
## https://free-game-assets.itch.io/free-enemy-sprite-sheets-pixel-art

const FRAME_SIZE: int = 48

## Build and return a SpriteFrames with "idle" (4f, 5 fps) and "walk" (6f, 10 fps).
static func build() -> SpriteFrames:
	var sf := SpriteFrames.new()
	var idle_tex: Texture2D = preload("res://art/sprites/Hyena_idle.png")
	var walk_tex: Texture2D = preload("res://art/sprites/Hyena_walk.png")
	if sf.has_animation(&"default"):
		sf.remove_animation(&"default")
	_add_anim(sf, &"idle", idle_tex, 4, 5.0)
	_add_anim(sf, &"walk", walk_tex, 6, 10.0)
	return sf


static func _add_anim(sf: SpriteFrames, anim_name: StringName, tex: Texture2D, count: int, fps: float) -> void:
	sf.add_animation(anim_name)
	sf.set_animation_loop(anim_name, true)
	sf.set_animation_speed(anim_name, fps)
	for i in count:
		var at := AtlasTexture.new()
		at.atlas = tex
		at.region = Rect2(i * FRAME_SIZE, 0, FRAME_SIZE, FRAME_SIZE)
		sf.add_frame(anim_name, at)
