2024-07-21 21:13:31 +00:00
|
|
|
using System.IO;
|
|
|
|
using System.Numerics;
|
2024-09-01 17:36:15 +00:00
|
|
|
using System.Text;
|
2024-07-21 21:13:31 +00:00
|
|
|
|
|
|
|
namespace KeepersCompound.LGS;
|
|
|
|
|
|
|
|
public static class Extensions
|
|
|
|
{
|
|
|
|
public static Vector3 ReadVec3(this BinaryReader reader)
|
|
|
|
{
|
|
|
|
return new Vector3(reader.ReadSingle(), reader.ReadSingle(), reader.ReadSingle());
|
|
|
|
}
|
2024-08-17 19:52:41 +00:00
|
|
|
|
|
|
|
public static Vector2 ReadVec2(this BinaryReader reader)
|
|
|
|
{
|
|
|
|
return new Vector2(reader.ReadSingle(), reader.ReadSingle());
|
|
|
|
}
|
2024-09-01 17:36:15 +00:00
|
|
|
|
|
|
|
// TODO: Go through and replace all usages of string reading with this
|
|
|
|
public static string ReadNullString(this BinaryReader reader, int length)
|
|
|
|
{
|
|
|
|
var tmpName = Encoding.UTF8.GetString(reader.ReadBytes(length));
|
|
|
|
var idx = tmpName.IndexOf('\0');
|
|
|
|
if (idx >= 0) tmpName = tmpName[..idx];
|
|
|
|
return tmpName;
|
|
|
|
}
|
2024-07-21 21:13:31 +00:00
|
|
|
}
|