Added NetworkManager

This commit is contained in:
2025-12-28 19:35:18 +01:00
parent 129ef16714
commit 74223c8139
16 changed files with 1224 additions and 367 deletions

View File

@@ -12,7 +12,7 @@ namespace Marro.PacManUdon
// While I'm not a big fan of the partial class solution that I ended up doing (static classes would still be neater, or perhaps separate UdonSharpBehaviour instances),
// I'm not redoing this unless I get instantiatable classes before I wrap up this project.
bool currentlyInTimeSequence;
bool waitingForTimeSequenceFinish;
bool waitingForTimeSequenceFinalize;
bool jumpingToTimeSequence;
PacManTimeSequence currentTimeSequence;
[UdonSynced] float timeSequenceSecondsPassed;
@@ -42,6 +42,7 @@ namespace Marro.PacManUdon
{
jumpingToTimeSequence = true;
TimeSequenceProgressToTime(100000f);
TryFinalizeTimeSequence();
jumpingToTimeSequence = false;
}
@@ -98,7 +99,39 @@ namespace Marro.PacManUdon
}
else
{
waitingForTimeSequenceFinish = true;
waitingForTimeSequenceFinalize = true;
}
}
private void TryFinalizeTimeSequence()
{
if (!waitingForTimeSequenceFinalize)
{
return;
}
TimeSequenceExecuteFinalize(currentTimeSequence);
waitingForTimeSequenceFinalize = false;
}
private void TimeSequenceSyncWithRemote(bool currentlyInTimeSequence, PacManTimeSequence currentTimeSequence, float timeSequenceProgress)
{
// If the remote is in a time sequence but we're not, or we're in a different time sequence, jump to the remote's time sequence.
if (currentlyInTimeSequence && (!this.currentlyInTimeSequence || currentTimeSequence != this.currentTimeSequence))
{
StartTimeSequence(currentTimeSequence);
}
// If we're (now) in a time sequence, jump our progress to match the one on the remote
if (this.currentlyInTimeSequence)
{
TimeSequenceProgressToTime(timeSequenceProgress);
}
// If the remote has finished it's time sequence and we have one waiting to be finalized, we can do so now
if (!currentlyInTimeSequence)
{
TryFinalizeTimeSequence();
}
}