Ghosts synced with some issues

This commit is contained in:
2026-01-24 15:04:54 +01:00
parent 9554d1c512
commit 1433b9bdfc
11 changed files with 1489 additions and 1168 deletions

View File

@@ -19,7 +19,7 @@ namespace Marro.PacManUdon
target[index++] = (byte)value;
public static void Append(this byte[] target, bool value, ref int index) =>
target[index++] = value ? (byte)1 : (byte)1;
target[index++] = value ? (byte)1 : (byte)0;
public static void Append(this byte[] target, ushort value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
@@ -33,6 +33,13 @@ namespace Marro.PacManUdon
public static void Append(this byte[] target, int value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
/// <summary>
/// Casts <paramref name="value"/> to a byte and then appends it.
/// Safer than doing <c>Append((byte)value, ref index)</c>, which can crash the Udonbehaviour.
/// </summary>
public static void AppendAsByte(this byte[] target, int value, ref int index) =>
target.Append(value.ToByte(), ref index);
public static void Append(this byte[] target, ulong value, ref int index) =>
target.Append(BitConverter.GetBytes(value), ref index);
@@ -143,5 +150,12 @@ namespace Marro.PacManUdon
index += 12;
return value;
}
/// <summary>
/// Casts an Int32 to a byte.
/// Doing this inline sometimes causes an udon exception, but doing it via a separate method seems to work fine.
/// </summary>
public static byte ToByte(this int value) =>
(byte)value;
}
}