Switched to 1d array CollectSyncedData

This commit is contained in:
2026-01-17 19:25:45 +01:00
parent 3642006bb2
commit b68b3d1c25
16 changed files with 216 additions and 78 deletions

View File

@@ -128,26 +128,25 @@ public class TestBall : SyncedObject
Debug.Log($"({nameof(TestBall)}) Up button pressed, jumped up at {GetProgress()} to {amountUp}.");
}
public override void AppendSyncedData(byte[][] data, ref int index, NetworkEventType eventType)
public override void CollectSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType == NetworkEventType.FullSync
|| eventType == NetworkEventType.FullSyncForced)
{
Debug.Log($"({nameof(TestBall)}) Sending sync data at progress {GetProgress()} and amountUp {amountUp}.");
data[index++] = BitConverter.GetBytes(amountUp);
data[index++] = BitConverter.GetBytes(GetProgress());
ByteUtils.Append(amountUp, data, ref index);
ByteUtils.Append(GetProgress(), data, ref index);
}
}
public override bool SetSyncedData(byte[] data, ref int index, NetworkEventType eventType)
public override bool WriteSyncedData(byte[] data, ref int index, NetworkEventType eventType)
{
if (eventType == NetworkEventType.FullSync
|| eventType == NetworkEventType.FullSyncForced)
{
amountUp = BitConverter.ToSingle(data, index);
SetProgress(BitConverter.ToSingle(data, index + 4));
amountUp = ByteUtils.ReadFloat(data, ref index);
SetProgress(ByteUtils.ReadFloat(data, ref index));
//Debug.Log($"({nameof(TestBall)}) Received sync event, synced to progress {GetProgress()} and amountUp {amountUp}.");
index += 8;
}
else
{