Cleaned up the way many custom network event calls were written.

This commit is contained in:
2025-08-05 04:53:12 -04:00
parent 1841c72eaf
commit 8c8111828f
4 changed files with 141 additions and 97 deletions
@@ -52,10 +52,7 @@ public class GameManagerRound1 : GameManagerBase
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_PlayerPodiums[i],
NetworkEventTarget.All,
"ResetPodium");
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "ResetPodium");
}
_PlayerBuzzInAllowed = new bool[_PlayerPodiums.Length];
@@ -128,7 +125,7 @@ public class GameManagerRound1 : GameManagerBase
MapIndices[i] = (int)Maps[i].Number;
}
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_VideoPlayer, NetworkEventTarget.All,
_VideoPlayer.SendCustomNetworkEvent(NetworkEventTarget.All,
"QueueMapDownloads", MapIndices);
}
}
@@ -139,13 +136,10 @@ public class GameManagerRound1 : GameManagerBase
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_PlayerPodiums[i],
NetworkEventTarget.All,
"DisplayScore");
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "DisplayScore");
}
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.D6);
ShowBetweenQuestionsInterface();
@@ -279,7 +273,7 @@ public class GameManagerRound1 : GameManagerBase
Interface.ChoiceButtonImages[0].color = (_QuestionCorrectResponse == 1) ? Color.green : Color.red;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.As5);
EnableInteraction("Reveal Choice 2");
@@ -293,7 +287,7 @@ public class GameManagerRound1 : GameManagerBase
Interface.ChoiceButtonImages[1].color = (_QuestionCorrectResponse == 2) ? Color.green : Color.red;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.C6);
EnableInteraction("Reveal Choice 3");
@@ -331,10 +325,11 @@ public class GameManagerRound1 : GameManagerBase
Indices[Choice3Index] = -1;
string[] ChoiceStrings = { Choices[0].ToString(), Choices[1].ToString(), Choices[2].ToString() };
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "SetCardChoices", ChoiceStrings, ChoiceOrder);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All,
"SetCardChoices", ChoiceStrings, ChoiceOrder);
}
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.D6);
EnableInteraction("Lock Answers");
@@ -344,7 +339,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "LockInChoice");
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "LockInChoice");
}
HostCardMultipleChoiceInterface Interface =
@@ -383,12 +378,12 @@ public class GameManagerRound1 : GameManagerBase
if (IsSomeoneCorrect)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFX", SFXEventType.Round1Correct);
}
else
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFX", SFXEventType.Round1Incorrect);
}
@@ -521,7 +516,7 @@ public class GameManagerRound1 : GameManagerBase
HostCardTheChaseInterface Interface =
(HostCardTheChaseInterface)GetHostCardInterface(RoundSegmentType.TheChase);
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusic", MusicEventType.TheChase);
Interface.HeaderUI.text = RoundSegmentTypeToString(RoundSegmentType.TheChase);
@@ -602,7 +597,7 @@ public class GameManagerRound1 : GameManagerBase
}
public void TheChaseEndClue()
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.D6);
HostCardTheChaseInterface Interface =
@@ -656,7 +651,7 @@ public class GameManagerRound1 : GameManagerBase
(HostCardBetweenRoundsInterface)GetHostCardInterface(RoundSegmentType.BetweenSegments);
Interface.HeaderUI.text = "Think about it...";
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlayMusic", MusicEventType.ThinkAboutIt);
SendCustomEventDelayedSeconds(nameof(ThinkAboutItCountdownFinished), 15.0f);
}
@@ -683,7 +678,7 @@ public class GameManagerRound1 : GameManagerBase
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "LockInRisk");
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "LockInRisk");
}
EnableInteraction("Present Clues");
@@ -703,7 +698,7 @@ public class GameManagerRound1 : GameManagerBase
(HostCardMultipleChoiceInterface)GetHostCardInterface(RoundSegmentType.FinalRound);
Interface.ChoiceButtonImages[0].color = (_QuestionCorrectResponse == 1) ? Color.green : Color.red;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.As5);
EnableInteraction("Reveal Choice 2");
@@ -716,7 +711,7 @@ public class GameManagerRound1 : GameManagerBase
(HostCardMultipleChoiceInterface)GetHostCardInterface(RoundSegmentType.FinalRound);
Interface.ChoiceButtonImages[1].color = (_QuestionCorrectResponse == 2) ? Color.green : Color.red;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.C6);
EnableInteraction("Reveal Choice 3");
@@ -754,10 +749,11 @@ public class GameManagerRound1 : GameManagerBase
Indices[Choice3Index] = -1;
string[] ChoiceStrings = { Choices[0].ToString(), Choices[1].ToString(), Choices[2].ToString() };
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "SetCardChoices", ChoiceStrings, ChoiceOrder);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All,
"SetCardChoices", ChoiceStrings, ChoiceOrder);
}
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFXAtPitch", SFXEventType.Ding, AudioManager.D6);
EnableInteraction("Lock Answers");
@@ -767,7 +763,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "LockInChoice");
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "LockInChoice");
}
HostCardMultipleChoiceInterface Interface =
@@ -1065,9 +1061,7 @@ public class GameManagerRound1 : GameManagerBase
int PodiumIndex = _BuzzedInPlayer - 1;
if (PodiumIndex >= 0 && PodiumIndex < _PlayerPodiums.Length)
{
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_PlayerPodiums[PodiumIndex],
NetworkEventTarget.All,
_PlayerPodiums[PodiumIndex].SendCustomNetworkEvent(NetworkEventTarget.All,
"EnableBuzzInEffect", false);
}
@@ -1120,7 +1114,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableChoiceCards", true);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableChoiceCards", true);
}
}
@@ -1128,7 +1122,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableChoiceCards", false);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableChoiceCards", false);
}
}
@@ -1137,7 +1131,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableRiskCards", true);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableRiskCards", true);
}
}
@@ -1145,7 +1139,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableRiskCards", false);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableRiskCards", false);
}
}
@@ -1154,7 +1148,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableBuzzer", true);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableBuzzer", true);
}
}
@@ -1162,7 +1156,7 @@ public class GameManagerRound1 : GameManagerBase
{
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableBuzzer", false);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableBuzzer", false);
}
}
@@ -1179,7 +1173,7 @@ public class GameManagerRound1 : GameManagerBase
if (_PlayerPodiums[i].PlayerNumber == PlayerNumber)
{
_PlayerBuzzInAllowed[i] = true;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableBuzzer", true);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableBuzzer", true);
_BuzzedInPlayer = -1;
break;
}
@@ -1193,9 +1187,7 @@ public class GameManagerRound1 : GameManagerBase
int PodiumIndex = _BuzzedInPlayer - 1;
if (PodiumIndex >= 0 && PodiumIndex < _PlayerPodiums.Length)
{
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_PlayerPodiums[PodiumIndex],
NetworkEventTarget.All,
_PlayerPodiums[PodiumIndex].SendCustomNetworkEvent(NetworkEventTarget.All,
"EnableBuzzInEffect", false);
_BuzzedInPlayer = -1;
}
@@ -1215,13 +1207,11 @@ public class GameManagerRound1 : GameManagerBase
_BuzzedInPlayer = PlayerNumber;
RequestSerialization();
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_PlayerPodiums[PlayerIndex],
NetworkEventTarget.All,
_PlayerPodiums[PlayerIndex].SendCustomNetworkEvent(NetworkEventTarget.All,
"EnableBuzzInEffect", true);
// Play the buzzer sound globally.
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_AudioManager, NetworkEventTarget.All,
_AudioManager.SendCustomNetworkEvent(NetworkEventTarget.All,
"PlaySFX", SFXEventType.Buzzer);
}
@@ -1236,7 +1226,7 @@ public class GameManagerRound1 : GameManagerBase
for (int i = 0; i < _PlayerPodiums.Length; i++)
{
_PlayerBuzzInAllowed[i] = true;
NetworkCalling.SendCustomNetworkEvent((IUdonEventReceiver)_PlayerPodiums[i], NetworkEventTarget.All, "EnableBuzzInEffect", false);
_PlayerPodiums[i].SendCustomNetworkEvent(NetworkEventTarget.All, "EnableBuzzInEffect", false);
}
_BuzzedInPlayer = -1;
}
+4 -16
View File
@@ -115,10 +115,7 @@ public class PlayerPodium : UdonSharpBehaviour
{
_ChoiceCards.gameObject.SetActive(Enable);
_ChoiceCards.ResetCards();
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_ChoiceCards,
NetworkEventTarget.Owner,
"MakeChoiceTextVisible");
_ChoiceCards.SendCustomNetworkEvent(NetworkEventTarget.Owner, "MakeChoiceTextVisible");
}
[NetworkCallable]
@@ -131,10 +128,7 @@ public class PlayerPodium : UdonSharpBehaviour
public void LockInChoice()
{
_ChoiceCards.LockInChoice();
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_ChoiceCards,
NetworkEventTarget.All,
"MakeChoiceTextVisible");
_ChoiceCards.SendCustomNetworkEvent(NetworkEventTarget.All, "MakeChoiceTextVisible");
}
public bool VerifyMultipleChoiceResponse(int CorrectResponse)
@@ -154,20 +148,14 @@ public class PlayerPodium : UdonSharpBehaviour
{
_RiskCards.gameObject.SetActive(Enable);
_RiskCards.ResetCards();
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_RiskCards,
NetworkEventTarget.Owner,
"MakeRiskTextVisible");
_RiskCards.SendCustomNetworkEvent(NetworkEventTarget.Owner, "MakeRiskTextVisible");
}
[NetworkCallable]
public void LockInRisk()
{
_RiskCards.LockInChoice();
NetworkCalling.SendCustomNetworkEvent(
(IUdonEventReceiver)_RiskCards,
NetworkEventTarget.All,
"MakeRiskTextVisible");
_RiskCards.SendCustomNetworkEvent(NetworkEventTarget.All, "MakeRiskTextVisible");
}
[NetworkCallable]