
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using UnityEngine;

public class DanMachiCharacterKeyframeData : KeyframeData
{
    public BoneList Bones = new BoneList();
    public Dictionary<string, List<MorphHelper>> Morphs = new Dictionary<string, List<MorphHelper>>();

    public DanMachiCharacterKeyframeData() { }

    public DanMachiCharacterKeyframeData(DanMachiCharacterContainer container)
    {
        this.Root = new SerializableTransform(container.transform);
        this.Bones = new BoneList() { Name = "", Bones = container.Bones.Select(b => new SerializableBone(b)).ToArray() };
        this.Morphs = container.Morphs.ToDictionary(m => m.Key.name, m => m.Value);
    }

    public override KeyframeData Clone()
    {
        var keyframe = new DanMachiCharacterKeyframeData();
        keyframe.Root = new SerializableTransform(this.Root);
        keyframe.Bones = new BoneList() { Name = Bones.Name, Bones = Bones.Bones.Select(b=> new SerializableBone(b)).ToArray() };
        keyframe.Morphs = Morphs.ToDictionary(m => m.Key, m => m.Value.Select(v=>new MorphHelper(v.ParentName, v.Name, v.Strength, v.Value)).ToList());
        return keyframe;
    }
}
