using System.Collections.Generic;
using CombatLibrary.CombatLibrary.CombatCore.Utility;
#if !COMBAT_SERVER

using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
#endif
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;


[System.Serializable]
public class TimeLineCurveSerializtion : TimeLineAssetSerialization
{
    public List<CurveInfo> CurveInfos = new List<CurveInfo>();
    public string guid;
    public TimeLineCurveSerializtion()
    {
    }
#if !COMBAT_SERVER

    public TimeLineCurveSerializtion(PlayableDirector playableDirector, GroupTrack groupTrack, TimelineClip timelineClip) : base(groupTrack, timelineClip)
    {
        TimeLineCurveAsset timelineClipAsset = timelineClip.asset as TimeLineCurveAsset;
        if (timelineClipAsset.AnimationCurve != null)
        {
            Keyframe[] keys = timelineClipAsset.AnimationCurve.keys;
            for (int i = 0; i < keys.Length; i++)
            {
                CurveInfo curveInfo = new CurveInfo();
                curveInfo.t = keys[i].time;
                curveInfo.v = keys[i].value;
                curveInfo.it = keys[i].inTangent;
                curveInfo.ot = keys[i].outTangent;
                CurveInfos.Add(curveInfo);
            }

            guid = timelineClipAsset.guid;
        }
    }
#endif

    public override TimeLineEventLogicBasic CreateLogic()
    {
        return new DefaultTimeLineLogic();
    }
}