Working pretty well
This commit is contained in:
@@ -3,8 +3,10 @@ using JetBrains.Annotations;
|
||||
using System;
|
||||
using System.Drawing;
|
||||
using System.Text;
|
||||
using TMPro;
|
||||
using UdonSharp;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using VRC.SDK3.UdonNetworkCalling;
|
||||
using VRC.SDKBase;
|
||||
using VRC.Udon.ClientBindings.Interfaces;
|
||||
@@ -75,7 +77,7 @@ namespace Marro.PacManUdon
|
||||
/// <summary>
|
||||
/// The delay at which the receiving side replays events.
|
||||
/// </summary>
|
||||
private const float Delay = 0.250f;
|
||||
private const float Delay = 1f;
|
||||
#endregion
|
||||
|
||||
#region Private attributes
|
||||
@@ -84,11 +86,6 @@ namespace Marro.PacManUdon
|
||||
/// </summary>
|
||||
[SerializeField] private SyncedObject[] syncedObjects;
|
||||
|
||||
/// <summary>
|
||||
/// An animator which visualizes whether the current perspective is the owner.
|
||||
/// </summary>
|
||||
[SerializeField] private Animator DebugImageToIndicateOwner;
|
||||
|
||||
/// <summary>
|
||||
/// Whether the current perspective is the transmitting side.
|
||||
/// </summary>
|
||||
@@ -171,12 +168,6 @@ namespace Marro.PacManUdon
|
||||
|
||||
public void Initialize()
|
||||
{
|
||||
if (Ready)
|
||||
{
|
||||
Debug.LogWarning($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Already initialized, rejecting repeat call to {nameof(Initialize)}");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!BitConverter.IsLittleEndian)
|
||||
{
|
||||
Debug.LogError($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Fatal: NetworkManager only supports little endian! Network sync will not be possible.");
|
||||
@@ -377,8 +368,8 @@ namespace Marro.PacManUdon
|
||||
|
||||
private void ProcessIncomingFullSync(int index, int size)
|
||||
{
|
||||
// Intentionally not doing a buffer size check here, since this is not appending to the buffer
|
||||
// (and there is no good way to continue if event is too large)
|
||||
// Intentionally not doing a buffer size check here, since this is not appended to the buffer
|
||||
// (and there is no good way to continue if this event is too large)
|
||||
|
||||
// Clear buffer and copy the full sync into it
|
||||
buffer = new byte[size];
|
||||
@@ -390,7 +381,7 @@ namespace Marro.PacManUdon
|
||||
SyncToTimestamp(timestamp);
|
||||
|
||||
// Immediately apply the full sync
|
||||
UpdateNextEventTime();
|
||||
UpdateNextEventTime(ignoreOrder: true);
|
||||
isSynced = true;
|
||||
}
|
||||
|
||||
@@ -550,7 +541,7 @@ namespace Marro.PacManUdon
|
||||
Debug.Log($"({nameof(PacManUdon)} {nameof(NetworkManager)}) Synced to timestamp {timestamp}, current time is {Time.fixedTime}, timeToSyncTo is {timeToSyncTo}, offsetTime is now {offsetTime}, internalTime is now {internalTime}, SyncedTime is now {SyncedTime}");
|
||||
}
|
||||
|
||||
private void UpdateNextEventTime()
|
||||
private void UpdateNextEventTime(bool ignoreOrder = false)
|
||||
{
|
||||
if (bufferIndex == 0)
|
||||
{
|
||||
@@ -558,7 +549,7 @@ namespace Marro.PacManUdon
|
||||
}
|
||||
|
||||
var nextEventTime = TimestampToTime(BitConverter.ToUInt32(buffer, HeaderTimestampIndex));
|
||||
if (nextEventTime >= this.nextEventTime)
|
||||
if (ignoreOrder || nextEventTime >= this.nextEventTime)
|
||||
{
|
||||
this.nextEventTime = nextEventTime;
|
||||
}
|
||||
@@ -662,6 +653,23 @@ namespace Marro.PacManUdon
|
||||
{
|
||||
SyncToTimestamp(timestamp);
|
||||
}
|
||||
|
||||
public void WriteDebugOutput(TMP_InputField debugOutput)
|
||||
{
|
||||
debugOutput.text += $"{nameof(NetworkManager)}:\n" +
|
||||
$"IsOwner: {isOwner}\n" +
|
||||
$"Time.fixedTime: {Time.fixedTime}\n" +
|
||||
$"offsetTime: {offsetTime}\n" +
|
||||
$"internalTime: {internalTime}\n" +
|
||||
$"SyncedTime: {SyncedTime}\n" +
|
||||
$"Dt: {Dt}\n" +
|
||||
$"\n";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// An animator which visualizes whether the current perspective is the owner.
|
||||
/// </summary>
|
||||
[SerializeField] private Animator DebugImageToIndicateOwner;
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user