2021-12-23 22:03:01 +01:00
|
|
|
|
using System;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Linq;
|
2022-05-30 14:32:38 +08:00
|
|
|
|
using GTA.Math;
|
2022-08-06 11:40:38 +08:00
|
|
|
|
using System.IO;
|
2021-12-23 22:03:01 +01:00
|
|
|
|
|
2022-05-22 15:55:26 +08:00
|
|
|
|
namespace RageCoop.Core
|
2021-12-23 22:03:01 +01:00
|
|
|
|
{
|
2022-08-06 11:40:38 +08:00
|
|
|
|
internal class BitReader:BinaryReader
|
2021-12-23 22:03:01 +01:00
|
|
|
|
{
|
|
|
|
|
|
2022-08-06 11:40:38 +08:00
|
|
|
|
public BitReader(byte[] array):base(new MemoryStream(array))
|
2021-12-23 22:03:01 +01:00
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
~BitReader()
|
|
|
|
|
{
|
2022-08-06 11:40:38 +08:00
|
|
|
|
Close();
|
|
|
|
|
Dispose();
|
2021-12-23 22:03:01 +01:00
|
|
|
|
}
|
|
|
|
|
|
2022-06-24 10:33:36 +08:00
|
|
|
|
public byte[] ReadByteArray()
|
|
|
|
|
{
|
2022-08-06 11:40:38 +08:00
|
|
|
|
return base.ReadBytes(ReadInt32());
|
2021-12-23 22:03:01 +01:00
|
|
|
|
}
|
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
|
|
|
|
|
2022-05-30 14:32:38 +08:00
|
|
|
|
public Vector3 ReadVector3()
|
2022-05-22 15:55:26 +08:00
|
|
|
|
{
|
2022-05-30 14:32:38 +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
|
|
|
|
{
|
2022-05-30 14:32:38 +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
|
|
|
|
};
|
|
|
|
|
}
|
2021-12-23 22:03:01 +01:00
|
|
|
|
}
|
|
|
|
|
}
|