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

namespace OCES.Haptic
{
[Serializable]
public partial class HapticObject : IBinarySerializable
{
	/// <summary>
	/// 
	/// </summary>
	public uint Id { get; set; }

	/// <summary>
	/// 类型
	/// </summary>
	public HapticType Type { get; set; }

	/// <summary>
	/// 强度
	/// </summary>
	public float Amplitude { get; set; }

	/// <summary>
	/// 尖锐度
	/// </summary>
	public float Frequency { get; set; }

	/// <summary>
	/// 时长
	/// </summary>
	public float Duration { get; set; }

	/// <summary>
	/// 播放来源
	/// </summary>
	public string Payload { get; set; }

	/// <summary>
	/// 回退预设
	/// </summary>
	public string FallbackPreset { get; set; }


	public void DeSerialize(BinaryReader reader)
	{
		Id = reader.ReadUInt32();
		Type = (HapticType)reader.ReadByte();
		Amplitude = reader.ReadSingle();
		Frequency = reader.ReadSingle();
		Duration = reader.ReadSingle();
		Payload = reader.ReadString();
		FallbackPreset = reader.ReadString();
	}

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(Id);
		writer.Write((byte)Type);
		writer.Write(Amplitude);
		writer.Write(Frequency);
		writer.Write(Duration);
		writer.Write(Payload);
		writer.Write(FallbackPreset);
	}
}

[Serializable]
public partial class HapticObjectConfig : IBinarySerializable
{
	Dictionary<uint,HapticObject> m_hapticObjectInfos = new();
	List<HapticObject> m_hapticObjectInfoList;

	public List<HapticObject> HapticObjectList()
	{
		this.m_hapticObjectInfoList ??= new List<HapticObject>(this.m_hapticObjectInfos.Values);
		return this.m_hapticObjectInfoList;
	}

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

	public void Serialize(BinaryWriter writer)
	{
		writer.Write(this.m_hapticObjectInfos.Count);
		foreach (HapticObject hapticObject in this.m_hapticObjectInfos.Values)
		{
			hapticObject.Serialize(writer);
		}
	}

	public HapticObject QueryById(uint id)
	{
		return this.m_hapticObjectInfos.GetValueOrDefault(id);
	}
}
}
