Fix for nightly and scripting branches

This commit is contained in:
SDraw 2024-07-24 22:04:03 +03:00
parent bcbb07c172
commit 8bead6a764
No known key found for this signature in database
GPG key ID: BB95B4DAB2BB8BB5

View file

@ -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<Type>)?.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<RagdollController>();
}
System.Collections.IEnumerator WaitForWhitelist()
{
// Whitelist the toggle script
FieldInfo l_field = typeof(SharedFilter).GetField("_localComponentWhitelist", BindingFlags.NonPublic | BindingFlags.Static);
HashSet<Type> l_hashSet = l_field?.GetValue(null) as HashSet<Type>;
while(l_hashSet == null)
{
l_hashSet = l_field?.GetValue(null) as HashSet<Type>;
yield return null;
}
l_hashSet.Add(typeof(RagdollToggle));
}
}
}