using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Assets.Scripts { public static class BitConvertHelper { public static byte Lsn(byte b) { return (byte)(b & 15); } // Token: 0x060032F7 RID: 13047 RVA: 0x000C22C3 File Offset: 0x000C04C3 public static byte Lsn(byte[] bytes, int index) { return BitConvertHelper.Lsn(bytes[index]); } public static byte ToUInt8(byte[] bytes, int index) { return bytes[index]; } // Token: 0x060032FB RID: 13051 RVA: 0x000C22E8 File Offset: 0x000C04E8 public static ushort ToUInt12(byte[] bytes, int index) { return (ushort)((int)bytes[index] + ((int)BitConvertHelper.Lsn(bytes[index + 1]) << 8)); } public static ushort ToUInt16(byte[] bytes, int startIndex) { return BitConverter.ToUInt16(bytes, startIndex); } public static short ToInt16(byte[] bytes, int startIndex) { return BitConverter.ToInt16(bytes, startIndex); } public static uint ToUInt32(byte[] bytes, int startIndex) { return BitConverter.ToUInt32(bytes, startIndex); } public static uint ToUInt24(byte[] bytes, int startIndex) { return (uint)((int)bytes[startIndex] | (int)bytes[startIndex + 1] << 8 | (int)bytes[startIndex + 2] << 16); } public static byte[] HexToByteArray(string hex) { hex=hex.Replace(" ", ""); return Enumerable.Range(0, hex.Length) .Where(x => x % 2 == 0) .Select(x => Convert.ToByte(hex.Substring(x, 2), 16)) .ToArray(); } } }