using System.Collections.Generic;
using Godot;
namespace Cthangover.Mods.Effects.Animation
{
///
/// Editor-configured bridge between a frame Texture2D array and an AnimationController.
/// Converts Godot's typed Array into a List, wires the NextCycle event, and starts
/// playback. When the animation completes one cycle, it detaches the handler and
/// self-destructs — the "fire and forget" glue between artist-authored data and
/// the animation runtime.
///
public partial class EffectDataSet : Control
{
[Export] private AnimationController controller;
[Export] private Godot.Collections.Array frameSet;
/// Converts the exported frame array, hands it to the controller and starts one playback cycle.
public override void _Ready()
{
AnchorLeft = 0f;
AnchorRight = 1f;
AnchorTop = 0f;
AnchorBottom = 1f;
var frames = new List();
foreach (var tex in frameSet)
frames.Add(tex);
controller.Clear();
controller.NextCycle += ControllerOnNextCycle;
controller.FrameSet = frames;
controller.Play();
}
private void ControllerOnNextCycle()
{
controller.NextCycle -= ControllerOnNextCycle;
controller.Clear();
QueueFree();
}
}
}