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)); + } } }