using CombatLibrary.CombatLibrary.CombatCore.Utility;

#if !COMBAT_SERVER


using Unity.IO.LowLevel.Unsafe;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.Timeline;
#endif
using Utility;
using UTool.CustomizeTimeLogic.FxLogic.TimeLineEventLogic;

[System.Serializable]
public class CameraShakingSerializtion : TimeLineAssetSerialization
{
    public ShakeDirection direction;
    public int type;
    public CurveInfo[] keys;
    
    public int count;
    public float qiangDu;

    public CameraShakingSerializtion()
    {
        
    }
#if !COMBAT_SERVER


    public CameraShakingSerializtion(PlayableDirector playableDirector, GroupTrack groupTrack, TimelineClip timelineClip) : base(groupTrack, timelineClip)
    {
        CameraShakingAsset audioPlayableAsset = timelineClip.asset as CameraShakingAsset;
        direction = audioPlayableAsset.direction;
        // type = audioPlayableAsset.type;
        count = audioPlayableAsset.count;
        totalTime = audioPlayableAsset.totalTime;
        qiangDu = audioPlayableAsset.qiangDu;
        if (audioPlayableAsset.AnimationCurve != null)
        {
            keys = new CurveInfo[audioPlayableAsset.AnimationCurve.keys.Length];
            for (int i = 0; i < audioPlayableAsset.AnimationCurve.keys.Length; i++)
            {
                CurveInfo curveInfo = new CurveInfo();
                curveInfo.t = audioPlayableAsset.AnimationCurve.keys[i].time;
                curveInfo.v = audioPlayableAsset.AnimationCurve.keys[i].value;
                curveInfo.it = audioPlayableAsset.AnimationCurve.keys[i].inTangent;
                curveInfo.ot = audioPlayableAsset.AnimationCurve.keys[i].outTangent;
                keys[i] = curveInfo;
            }
          
        }
        else
        {
            keys = new CurveInfo[2] {new CurveInfo(), new CurveInfo()};
        }

    }
#endif
    public override TimeLineEventLogicBasic CreateLogic()
    {
        return new CameraShakingLogic();
    }
}