/*
 * auto generated by tools(注意:千万不要手动修改本文件)
 * MusicTransition
 */
using System;
using System.IO;
using System.Collections.Generic;
using System.Text;

namespace OCES.Audio
{
[Serializable]
public partial class MusicTransition : IBinarySerializable
{
	/// <summary>
	/// FromPathId x 1000 + ToPathId
	/// </summary>
	public uint Id { get; set; }

	/// <summary>
	/// 淡出总时长(s)
	/// </summary>
	public float FadeOutTime { get; set; }

	/// <summary>
	/// source的段尾偏移量(s)
	/// </summary>
	public float FadeOutOffset { get; set; }

	/// <summary>
	/// 淡入总时长(s)
	/// </summary>
	public float FadeInTime { get; set; }

	/// <summary>
	/// Destination段首偏移量(s)
	/// </summary>
	public float FadeInOffset { get; set; }

	/// <summary>
	/// 0 = 立即切换
	/// 1 = 拍
	/// 2 = 小节
	/// </summary>
	public AlignMode AlignMode { get; set; }

	/// <summary>
	/// 0 = Start
	/// 1 = Same Time
	/// </summary>
	public SyncPoint SyncPoint { get; set; }

	/// <summary>
	/// samples
	/// </summary>
	public uint StartOffset { get; set; }

	/// <summary>
	/// samples
	/// </summary>
	public uint EndOffset { get; set; }


	public void DeSerialize(BinaryReader reader)
	{
		Id = reader.ReadUInt32();
		FadeOutTime = reader.ReadSingle();
		FadeOutOffset = reader.ReadSingle();
		FadeInTime = reader.ReadSingle();
		FadeInOffset = reader.ReadSingle();
		AlignMode = (AlignMode)reader.ReadByte();
		SyncPoint = (SyncPoint)reader.ReadByte();
		StartOffset = reader.ReadUInt32();
		EndOffset = reader.ReadUInt32();
	}

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(Id);
		writer.Write(FadeOutTime);
		writer.Write(FadeOutOffset);
		writer.Write(FadeInTime);
		writer.Write(FadeInOffset);
		writer.Write((byte)AlignMode);
		writer.Write((byte)SyncPoint);
		writer.Write(StartOffset);
		writer.Write(EndOffset);
	}
}

[Serializable]
public partial class MusicTransitionConfig : IBinarySerializable
{
	Dictionary<uint,MusicTransition> m_musicTransitionInfos = new();
	List<MusicTransition> m_musicTransitionInfoList;

	public List<MusicTransition> MusicTransitionList()
	{
		this.m_musicTransitionInfoList ??= new List<MusicTransition>(this.m_musicTransitionInfos.Values);
		return this.m_musicTransitionInfoList;
	}

	public void DeSerialize(BinaryReader reader)
	{
		int count = reader.ReadInt32();
		for (int i = 0; i < count; i++)
		{
			MusicTransition tempData = new();
			tempData.DeSerialize(reader);
			this.m_musicTransitionInfos.Add(tempData.Id, tempData);
		}
	}

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(this.m_musicTransitionInfos.Count);
		foreach (MusicTransition musicTransition in this.m_musicTransitionInfos.Values)
		{
			musicTransition.Serialize(writer);
		}
	}

	public MusicTransition QueryById(uint id)
	{
		return this.m_musicTransitionInfos.GetValueOrDefault(id);
	}
}
}
