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

namespace OCES.Audio
{
[Serializable]
public partial class AudioGroup : IBinarySerializable
{
	/// <summary>
	/// 唯一ID
	/// </summary>
	public uint Id { get; set; }

	/// <summary>
	/// 分组名
	/// </summary>
	public string Comment { get; set; }

	/// <summary>
	/// 组发音数限制
	/// </summary>
	public ushort GroupThrottleCount { get; set; }

	/// <summary>
	/// 打断模式 
	/// 0 = 打断最早
	/// 1 = 打断最新
	/// </summary>
	public KillMode KillMode { get; set; }


	public void DeSerialize(BinaryReader reader)
	{
		Id = reader.ReadUInt32();
		Comment = reader.ReadString();
		GroupThrottleCount = reader.ReadUInt16();
		KillMode = (KillMode)reader.ReadByte();
	}

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(Id);
		writer.Write(Comment);
		writer.Write(GroupThrottleCount);
		writer.Write((byte)KillMode);
	}
}

[Serializable]
public partial class AudioGroupConfig : IBinarySerializable
{
	Dictionary<uint,AudioGroup> m_audioGroupInfos = new();
	List<AudioGroup> m_audioGroupInfoList;

	public List<AudioGroup> AudioGroupList()
	{
		this.m_audioGroupInfoList ??= new List<AudioGroup>(this.m_audioGroupInfos.Values);
		return this.m_audioGroupInfoList;
	}

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

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(this.m_audioGroupInfos.Count);
		foreach (AudioGroup audioGroup in this.m_audioGroupInfos.Values)
		{
			audioGroup.Serialize(writer);
		}
	}

	public AudioGroup QueryById(uint id)
	{
		return this.m_audioGroupInfos.GetValueOrDefault(id);
	}
}
}
