mirror of
https://github.com/Gurge44/EndlessHostRoles.git
synced 2026-10-19 15:51:58 +00:00
fix
This commit is contained in:
1 parent
00ecb1ff93
commit
2a730c177f
1 file changed
+14
-2
@@ -49,6 +49,7 @@ public static class ModGameOptionsMenu
|
||||
public static class GameOptionsMenuPatch
|
||||
{
|
||||
private static readonly Dictionary<GameOptionsMenu, Coroutine> BuildCoroutines = new();
|
||||
private static readonly Dictionary<GameOptionsMenu, int> BuildGenerations = new();
|
||||
|
||||
[HarmonyPatch(nameof(GameOptionsMenu.Initialize))]
|
||||
[HarmonyPrefix]
|
||||
@@ -139,10 +140,14 @@ public static class GameOptionsMenuPatch
|
||||
BuildCoroutines.Remove(__instance);
|
||||
}
|
||||
|
||||
BuildCoroutines[__instance] = __instance.StartCoroutine(CoRoutine().WrapToIl2Cpp());
|
||||
BuildGenerations.TryGetValue(__instance, out int currentGen);
|
||||
currentGen++;
|
||||
BuildGenerations[__instance] = currentGen;
|
||||
|
||||
BuildCoroutines[__instance] = __instance.StartCoroutine(CoRoutine(currentGen).WrapToIl2Cpp());
|
||||
return false;
|
||||
|
||||
IEnumerator CoRoutine()
|
||||
IEnumerator CoRoutine(int gen)
|
||||
{
|
||||
var num = 2.0f;
|
||||
const float posX = 0.952f;
|
||||
@@ -245,6 +250,13 @@ public static class GameOptionsMenuPatch
|
||||
}
|
||||
}
|
||||
|
||||
// Bail if a newer build coroutine was started on this instance while we were running
|
||||
if (!BuildGenerations.TryGetValue(__instance, out int latestGen) || latestGen != gen)
|
||||
{
|
||||
BuildCoroutines.Remove(__instance);
|
||||
yield break;
|
||||
}
|
||||
|
||||
__instance.ControllerSelectable.Clear();
|
||||
|
||||
foreach (UiElement x in __instance.scrollBar.GetComponentsInChildren<UiElement>())
|
||||
|
||||
Reference in new issue
Block a user