Initial progress syncing + many existing bugs

This commit is contained in:
2026-01-15 23:00:15 +01:00
parent fb902aaddc
commit c41491e55e
11 changed files with 345 additions and 230 deletions

View File

@@ -34,6 +34,11 @@ namespace Marro.PacManUdon
public override void AppendSyncedData(byte[][] data, ref int offset, NetworkEventType eventType)
{
if (eventType != NetworkEventType.PacManTurn)
{
return;
}
var position = GetPosition();
data[offset++] = BitConverter.GetBytes(position.x);
data[offset++] = BitConverter.GetBytes(position.y);
@@ -45,9 +50,14 @@ namespace Marro.PacManUdon
public override bool SetSyncedData(byte[] data, ref int offset, NetworkEventType eventType)
{
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 2)));
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 4), BitConverter.ToSingle(data, offset + 6)));
offset += 8;
if (eventType != NetworkEventType.PacManTurn)
{
return true;
}
SetPosition(new Vector2(BitConverter.ToSingle(data, offset), BitConverter.ToSingle(data, offset + 4)));
SetDirection(new Vector2(BitConverter.ToSingle(data, offset + 8), BitConverter.ToSingle(data, offset + 12)));
offset += 16;
return true;
}