extends Node2D

# Slash hit effect when sword projectile damages enemy - frames 948-952 from shade_spell_effects.png

const DURATION: float = 0.2
const FRAMES: Array = [948, 949, 950, 951, 952]
const FRAME_DURATION: float = 0.04

var elapsed: float = 0.0

@onready var fx_sprite: Sprite2D = $FxSprite

func _ready() -> void:
	if fx_sprite and FRAMES.size() > 0:
		fx_sprite.frame = FRAMES[0]

func setup(_position: Vector2 = Vector2.ZERO) -> void:
	if _position != Vector2.ZERO:
		global_position = _position

func _process(delta: float) -> void:
	elapsed += delta
	if fx_sprite and FRAMES.size() > 0:
		var idx = min(int(elapsed / FRAME_DURATION), FRAMES.size() - 1)
		fx_sprite.frame = FRAMES[idx]
	if elapsed >= DURATION:
		queue_free()
