Vector3Half reader/writer

This commit is contained in:
miwarnec 2024-11-06 12:39:35 +01:00
parent c36feeb0fe
commit cb6a7812f5
2 changed files with 13 additions and 0 deletions

View File

@ -63,6 +63,13 @@ public static class NetworkReaderExtensions
public static decimal? ReadDecimalNullable(this NetworkReader reader) => reader.ReadBlittableNullable<decimal>(); public static decimal? ReadDecimalNullable(this NetworkReader reader) => reader.ReadBlittableNullable<decimal>();
public static Half ReadHalf(this NetworkReader reader) => new Half(reader.ReadUShort()); public static Half ReadHalf(this NetworkReader reader) => new Half(reader.ReadUShort());
public static Vector3Half ReadVector3Half(this NetworkReader reader)
{
Half x = reader.ReadHalf();
Half y = reader.ReadHalf();
Half z = reader.ReadHalf();
return new Vector3Half(x, y, z);
}
/// <exception cref="T:System.ArgumentException">if an invalid utf8 string is sent</exception> /// <exception cref="T:System.ArgumentException">if an invalid utf8 string is sent</exception>
public static string ReadString(this NetworkReader reader) public static string ReadString(this NetworkReader reader)

View File

@ -58,6 +58,12 @@ public static class NetworkWriterExtensions
public static void WriteDecimalNullable(this NetworkWriter writer, decimal? value) => writer.WriteBlittableNullable(value); public static void WriteDecimalNullable(this NetworkWriter writer, decimal? value) => writer.WriteBlittableNullable(value);
public static void WriteHalf(this NetworkWriter writer, Half value) => writer.WriteUShort(value._value); public static void WriteHalf(this NetworkWriter writer, Half value) => writer.WriteUShort(value._value);
public static void WriteVector3Half(this NetworkWriter writer, Vector3Half value)
{
writer.WriteHalf(value.x);
writer.WriteHalf(value.y);
writer.WriteHalf(value.z);
}
public static void WriteString(this NetworkWriter writer, string value) public static void WriteString(this NetworkWriter writer, string value)
{ {