From 8bead6a76453aef0d50ee8c8ae00266360085af9 Mon Sep 17 00:00:00 2001 From: SDraw Date: Wed, 24 Jul 2024 22:04:03 +0300 Subject: [PATCH] Fix for nightly and scripting branches --- ml_prm/Main.cs | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/ml_prm/Main.cs b/ml_prm/Main.cs index 5ba3357..0999a45 100644 --- a/ml_prm/Main.cs +++ b/ml_prm/Main.cs @@ -17,10 +17,8 @@ namespace ml_prm GameEvents.Init(HarmonyInstance); WorldHandler.Init(); - // Whitelist the toggle script - (typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static)?.GetValue(null) as HashSet)?.Add(typeof(RagdollToggle)); - MelonLoader.MelonCoroutines.Start(WaitForLocalPlayer()); + MelonLoader.MelonCoroutines.Start(WaitForWhitelist()); } public override void OnDeinitializeMelon() @@ -39,5 +37,18 @@ namespace ml_prm m_localController = PlayerSetup.Instance.gameObject.AddComponent(); } + + System.Collections.IEnumerator WaitForWhitelist() + { + // Whitelist the toggle script + FieldInfo l_field = typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static); + HashSet l_hashSet = l_field?.GetValue(null) as HashSet; + while(l_hashSet == null) + { + l_hashSet = l_field?.GetValue(null) as HashSet; + yield return null; + } + l_hashSet.Add(typeof(RagdollToggle)); + } } }