feat: Import Haptic System
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
using System.IO;
|
||||
|
||||
namespace OCES.Haptic
|
||||
{
|
||||
public interface IBinarySerializable
|
||||
{
|
||||
void DeSerialize(BinaryReader reader);
|
||||
void Serialize(BinaryWriter writer);
|
||||
}
|
||||
|
||||
public enum HapticType
|
||||
{
|
||||
Preset = 0, //播放预制
|
||||
Emphasis = 1, //播放瞬时
|
||||
Constant = 2, //播放连续
|
||||
Advance = 3, //播放文件
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 文件操作类
|
||||
/// </summary>
|
||||
public static class FileManager
|
||||
{
|
||||
/// <summary>
|
||||
/// 从内存流中读取二进制
|
||||
/// </summary>
|
||||
/// <param name="bytes"></param>
|
||||
/// <param name="data"></param>
|
||||
/// <returns></returns>
|
||||
public static bool ReadBinaryDataFromBytes(byte[] bytes, ref IBinarySerializable data)
|
||||
{
|
||||
if (bytes == null)
|
||||
return false;
|
||||
using (MemoryStream memoryStream = new(bytes))
|
||||
{
|
||||
using (var br = new BinaryReader(memoryStream))
|
||||
{
|
||||
data.DeSerialize(br);
|
||||
br.Close();
|
||||
}
|
||||
memoryStream.Close();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user