using HarmonyLib; using Il2CppInterop.Runtime; using RRUI; using RRUI.Data; using UnityEngine; internal static class DynamicUiPrefabRepair { private static bool reportedMissing; internal static void Apply(Harmony harmony) { harmony.Patch(AccessTools.PropertyGetter(typeof(DynamicUIConfig), "Instance"), postfix: new HarmonyMethod(typeof(DynamicUiPrefabRepair), nameof(Repair))); } private static void Repair(DynamicUIConfig __result) { if (__result == null) return; var standard = __result.DynamicFloatPrefab_MultiSelectConfig; var pro = __result.DynamicProUXFloatPrefab_MultiSelectConfig; var fallback = Compatible(standard) ? standard : Compatible(pro) ? pro : null; if (fallback == null) { if (!reportedMissing) { reportedMissing = true; RadicadeEacBypassPlugin.LogSource.LogWarning( "[DynamicUI] No compatible multi-select float prefab is available; leaving the missing mapping visible."); } return; } _ = __result.LandscapePrefabsByType; _ = __result.PortraitPrefabsByType; _ = __result.ProUXPrefabsByType; RepairMap(__result.landscapePrefabsByType, fallback, "landscape"); RepairMap(__result.portraitPrefabsByType, fallback, "portrait"); RepairMap(__result.proUXPrefabsByType, fallback, "ProUX"); } private static bool Compatible(GameObject prefab) => prefab != null && prefab.GetComponentInChildren(true) != null; private static void RepairMap(Il2CppSystem.Collections.Generic.Dictionary map, GameObject fallback, string layout) { if (map == null) return; var key = Il2CppType.Of(); if (map.ContainsKey(key) && map[key] != null) return; map[key] = fallback; } }