using System;
using System.Collections;
using System.Collections.Generic;
#if !COMBAT_SERVER
using UnityEngine;
using UnityEngine.Timeline;
#endif

[System.Serializable]
public abstract class TimeLineAssetSerialization
{
    public bool isEquip;
    public int equipId;
    public string groupName;
    public bool isActivity;
    public float startTime;
    public float endTime;
    public float continuedTime;
    public FXTargetType targetEntityType;

    /// <summary>
    /// 总时间
    /// </summary>
    public float totalTime;
   

    public TimeLineAssetSerialization Clone()
    {
        TimeLineAssetSerialization timeLineAssetSerialization = (TimeLineAssetSerialization) this.MemberwiseClone();
        ProClone(timeLineAssetSerialization);
        return timeLineAssetSerialization;
    }

    protected void ProClone(TimeLineAssetSerialization newData)
    {
    }

    public TimeLineAssetSerialization()
    {
    }
#if !COMBAT_SERVER
    public void SettingAssetInfo(GroupTrack trackAsset)
    {
        if (trackAsset == null)
        {
            return;
        }

        // isEquip = trackAsset.isEquip;
        // equipId = trackAsset.equipId;
    }

    public TimeLineAssetSerialization(GroupTrack groupTrack, TimelineClip timelineClip)
    {
        SettingAssetInfo(groupTrack);
     GroupTrack   upGroup = groupTrack;
        GroupTrack rooGroupTrack = groupTrack;

        while (rooGroupTrack != null)
        {
            rooGroupTrack = rooGroupTrack.GetGroup();
            if (rooGroupTrack != null)
            {
                groupTrack = rooGroupTrack;
            }
        }

        groupName = groupTrack.name.Split('@')[0];
        isActivity = groupTrack.mutedInHierarchy;
        startTime = (float) timelineClip.start;
        endTime = (float) timelineClip.end;
        continuedTime = (float) timelineClip.duration;
    }

    public string ToJson()
    {
        return JsonManager.ToJson(this);
    }
#endif


    public abstract TimeLineEventLogicBasic CreateLogic();
}