RAGECOOP-V/RageCoop.Core/BitReader.cs

60 lines
1.2 KiB
C#
Raw Normal View History

using System;
using System.Text;
using System.Linq;
using GTA.Math;
2022-08-06 11:40:38 +08:00
using System.IO;
2022-05-22 15:55:26 +08:00
namespace RageCoop.Core
{
2022-08-06 11:40:38 +08:00
internal class BitReader:BinaryReader
{
2022-08-06 11:40:38 +08:00
public BitReader(byte[] array):base(new MemoryStream(array))
{
}
~BitReader()
{
2022-08-06 11:40:38 +08:00
Close();
Dispose();
}
2022-06-24 10:33:36 +08:00
public byte[] ReadByteArray()
{
2022-08-06 11:40:38 +08:00
return base.ReadBytes(ReadInt32());
}
2022-08-06 11:40:38 +08:00
public override string ReadString()
2022-06-19 11:12:20 +08:00
{
2022-08-08 17:03:41 +08:00
return Encoding.UTF8.GetString(ReadBytes(ReadInt32()));
2022-06-19 11:12:20 +08:00
}
2022-05-22 15:55:26 +08:00
public Vector3 ReadVector3()
2022-05-22 15:55:26 +08:00
{
return new Vector3()
2022-05-22 15:55:26 +08:00
{
2022-08-06 11:40:38 +08:00
X = ReadSingle(),
Y = ReadSingle(),
Z = ReadSingle()
2022-05-22 15:55:26 +08:00
};
}
2022-07-03 15:28:28 +08:00
public Vector2 ReadVector2()
{
return new Vector2()
{
2022-08-06 11:40:38 +08:00
X = ReadSingle(),
Y = ReadSingle()
2022-07-03 15:28:28 +08:00
};
}
2022-06-03 14:40:41 +08:00
public Quaternion ReadQuaternion()
2022-05-22 15:55:26 +08:00
{
return new Quaternion()
2022-05-22 15:55:26 +08:00
{
2022-08-06 11:40:38 +08:00
X = ReadSingle(),
Y = ReadSingle(),
Z = ReadSingle(),
W = ReadSingle()
2022-05-22 15:55:26 +08:00
};
}
}
}