Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RadialRebind v1.0.4
BepInEx/plugins/RadialRebind/RadialRebind.dll
Decompiled 2 months agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; using UnityEngine.SceneManagement; using Valheim.SettingsGui; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("RadialRebind")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("RadialRebind")] [assembly: AssemblyTitle("RadialRebind")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } [HarmonyPatch(typeof(ZInput), "OnRebindComplete")] internal static class RadialRebind_ZInputPatch { [HarmonyPostfix] private static void OnRebindComplete_Postfix() { if (!((Object)(object)RadialRebind.Instance == (Object)null)) { RadialRebind.Instance.OnNativeRebindFinished(); } } } [HarmonyPatch(typeof(RadialSettings), "OnTabOpen")] internal static class RadialRebind_RadialSettingsPatch { [HarmonyPostfix] private static void OnTabOpen_Postfix(RadialSettings __instance) { if (!((Object)(object)RadialRebind.Instance == (Object)null)) { RadialRebind.Instance.OnRadialSettingsTabOpened(__instance); } } } [BepInPlugin("com.lukas.radialrebind", "Radial Rebind", "1.0.6")] public class RadialRebind : BaseUnityPlugin { private static RadialRebind _instance; private Harmony _harmony; private const string ActionName = "OpenRadial"; private const string DisplayName = "Open Radial Menu"; private RectTransform _radialRow; private Component _radialKeyButton; private Component _radialKeyText; private Component _radialNameText; private Transform _currentRadialSettings; private object _localizationInstance; private MethodInfo _getBoundKeyStringMethod; private GameObject _radialBindDialog; private bool _radialRebindActive; internal static RadialRebind Instance => _instance; private void Awake() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Expected O, but got Unknown _instance = this; _harmony = new Harmony("com.lukas.radialrebind"); try { _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Radial Rebind loaded (1.0.6 event-driven performance build)."); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("[Radial Rebind] Harmony patching failed: " + ex)); } } private void OnDestroy() { HideNativeStyleRebindDialog(); if (_harmony != null) { try { _harmony.UnpatchSelf(); } catch { } } if ((Object)(object)_instance == (Object)(object)this) { _instance = null; } } internal void OnRadialSettingsTabOpened(RadialSettings radial) { if (!((Object)(object)radial == (Object)null)) { ((MonoBehaviour)this).StartCoroutine(InitializeAfterTabOpen(radial)); } } private IEnumerator InitializeAfterTabOpen(RadialSettings radial) { yield return null; if (!((Object)(object)radial == (Object)null) && !((Object)(object)((Component)radial).gameObject == (Object)null)) { Scene scene = ((Component)radial).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { CreateOrRebuildRow(radial); } } } private void CreateOrRebuildRow(RadialSettings radial) { _currentRadialSettings = ((Component)radial).transform; DestroyStaleRows(((Component)radial).transform); RectTransform val = FindOwnRowUnder(((Component)radial).transform); if ((Object)(object)val != (Object)null) { _radialRow = val; ConfigureRow(radial, _radialRow); UpdateDisplayedKey(); return; } RectTransform val2 = FindKeyboardTemplate("Attack"); if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Radial Rebind] Could not find Attack visual template."); return; } GameObject val3 = Object.Instantiate<GameObject>(((Component)val2).gameObject, ((Component)radial).transform); ((Object)val3).name = "OpenRadialVisual"; _radialRow = val3.GetComponent<RectTransform>(); if ((Object)(object)_radialRow == (Object)null) { Object.Destroy((Object)(object)val3); return; } ConfigureRow(radial, _radialRow); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Radial Rebind] Created independent OpenRadial visual row."); } private RectTransform FindOwnRowUnder(Transform root) { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return null; } Transform val = root.Find("OpenRadialVisual"); if ((Object)(object)val != (Object)null) { return (RectTransform)(object)((val is RectTransform) ? val : null); } foreach (Transform item in root) { Transform root2 = item; RectTransform val2 = FindOwnRowUnder(root2); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private void DestroyStaleRows(Transform activeRoot) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) RectTransform[] array = Resources.FindObjectsOfTypeAll<RectTransform>(); RectTransform[] array2 = array; foreach (RectTransform val in array2) { if (!((Object)(object)val == (Object)null) && !(((Object)val).name != "OpenRadialVisual")) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid() && (!((Object)(object)activeRoot != (Object)null) || !((Component)val).transform.IsChildOf(activeRoot))) { Object.Destroy((Object)(object)((Component)val).gameObject); } } } } private void ConfigureRow(RadialSettings radial, RectTransform row) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0184: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01c6: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)row == (Object)null) { return; } AddIgnoreLayout(((Component)row).gameObject); ((Transform)row).localScale = Vector3.one; ((Transform)row).localRotation = Quaternion.identity; Transform val = ((Transform)row).Find("Button"); Transform val2 = ((Transform)row).Find("Label"); if ((Object)(object)val != (Object)null) { Component val3 = FindComponentWithProperty(((Component)val).gameObject, "onClick"); if ((Object)(object)val3 != (Object)null) { RemoveAllClickListeners(val3); AddClickListener(val3, OnRadialKeyClicked); _radialKeyButton = val3; Transform val4 = val.Find("Label"); _radialKeyText = FindComponentWithProperty(((Object)(object)val4 != (Object)null) ? ((Component)val4).gameObject : null, "text"); } } if ((Object)(object)val2 != (Object)null) { _radialNameText = FindComponentWithProperty(((Component)val2).gameObject, "text"); SetStringProperty(_radialNameText, "text", "Open Radial Menu"); } RectTransform val5 = FindRadialRowContainingText(((Component)radial).transform, "Flick Interact"); if ((Object)(object)val5 != (Object)null) { CopyRowGeometry(val5, row); CopyLabelStyleFromFlickRow(val5, row); ((Transform)row).position = ((Transform)val5).position + GetRadialRowStep(((Component)radial).transform, val5); } else { row.anchorMin = new Vector2(0.5f, 0.5f); row.anchorMax = new Vector2(0.5f, 0.5f); row.pivot = new Vector2(0.5f, 0.5f); row.sizeDelta = new Vector2(430f, 26f); row.anchoredPosition = new Vector2(0f, -215f); } PositionKeyButtonToRightOfLabel(row); SetStringProperty(_radialNameText, "text", "Open Radial Menu"); UpdateDisplayedKey(); } private Vector3 GetRadialRowStep(Transform radialRoot, RectTransform flickRow) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)radialRoot != (Object)null && (Object)(object)flickRow != (Object)null) { RectTransform val = FindRadialRowContainingText(radialRoot, "Double Tap"); if ((Object)(object)val != (Object)null) { Vector3 result = ((Transform)flickRow).position - ((Transform)val).position; if (((Vector3)(ref result)).sqrMagnitude > 0.0001f) { return result; } } } return new Vector3(0f, -30f, 0f); } private void PositionKeyButtonToRightOfLabel(RectTransform row) { //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)row == (Object)null || (Object)(object)_currentRadialSettings == (Object)null) { return; } Transform obj = ((Transform)row).Find("Button"); RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null); Transform obj2 = ((Transform)row).Find("Label"); RectTransform val2 = (RectTransform)(object)((obj2 is RectTransform) ? obj2 : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return; } Transform val3 = _currentRadialSettings.Find("List"); if (!((Object)(object)val3 == (Object)null)) { Transform val4 = val3.Find("Radial Size"); RectTransform val5 = (RectTransform)(object)((val4 is RectTransform) ? val4 : null); if (!((Object)(object)val5 == (Object)null)) { Vector3[] array = (Vector3[])(object)new Vector3[4]; val5.GetWorldCorners(array); float x = array[0].x; Vector3[] array2 = (Vector3[])(object)new Vector3[4]; val2.GetWorldCorners(array2); float num = (array2[0].y + array2[2].y) * 0.5f; Rect rect = val.rect; float num2 = ((Rect)(ref rect)).width * ((Transform)val).lossyScale.x; Vector3 position = default(Vector3); ((Vector3)(ref position))..ctor(x + num2, num, ((Transform)val).position.z); ((Transform)val).position = position; } } } private void CopyRowGeometry(RectTransform source, RectTransform target) { //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_01ea: Unknown result type (might be due to invalid IL or missing references) //IL_01f9: Unknown result type (might be due to invalid IL or missing references) //IL_0208: Unknown result type (might be due to invalid IL or missing references) //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) target.anchorMin = source.anchorMin; target.anchorMax = source.anchorMax; target.pivot = source.pivot; target.sizeDelta = source.sizeDelta; target.anchoredPosition = source.anchoredPosition; Transform val = ((Transform)source).Find("Button"); Transform val2 = ((Transform)target).Find("Button"); if ((Object)(object)val != (Object)null && (Object)(object)val2 != (Object)null) { RectTransform val3 = (RectTransform)(object)((val is RectTransform) ? val : null); RectTransform val4 = (RectTransform)(object)((val2 is RectTransform) ? val2 : null); if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null) { val4.anchorMin = val3.anchorMin; val4.anchorMax = val3.anchorMax; val4.pivot = val3.pivot; val4.sizeDelta = val3.sizeDelta; val4.anchoredPosition = val3.anchoredPosition; ((Transform)val4).localScale = ((Transform)val3).localScale; } Transform val5 = val.Find("Label"); Transform val6 = val2.Find("Label"); RectTransform val7 = (RectTransform)(object)((val5 is RectTransform) ? val5 : null); RectTransform val8 = (RectTransform)(object)((val6 is RectTransform) ? val6 : null); if ((Object)(object)val7 != (Object)null && (Object)(object)val8 != (Object)null) { val8.anchorMin = val7.anchorMin; val8.anchorMax = val7.anchorMax; val8.pivot = val7.pivot; val8.sizeDelta = val7.sizeDelta; val8.anchoredPosition = val7.anchoredPosition; ((Transform)val8).localScale = ((Transform)val7).localScale; } } Transform val9 = ((Transform)source).Find("Label"); Transform val10 = ((Transform)target).Find("Label"); RectTransform val11 = (RectTransform)(object)((val9 is RectTransform) ? val9 : null); RectTransform val12 = (RectTransform)(object)((val10 is RectTransform) ? val10 : null); if ((Object)(object)val11 != (Object)null && (Object)(object)val12 != (Object)null) { val12.anchorMin = val11.anchorMin; val12.anchorMax = val11.anchorMax; val12.pivot = val11.pivot; val12.sizeDelta = val11.sizeDelta; val12.anchoredPosition = val11.anchoredPosition; ((Transform)val12).localScale = ((Transform)val11).localScale; } } private void CopyLabelStyleFromFlickRow(RectTransform flickRow, RectTransform targetRow) { if ((Object)(object)flickRow == (Object)null || (Object)(object)targetRow == (Object)null) { return; } Transform val = ((Transform)flickRow).Find("Label"); Transform val2 = ((Transform)targetRow).Find("Label"); if (!((Object)(object)val == (Object)null) && !((Object)(object)val2 == (Object)null)) { Component val3 = FindComponentWithProperty(((Component)val).gameObject, "fontSize"); Component val4 = FindComponentWithProperty(((Component)val2).gameObject, "fontSize"); if (!((Object)(object)val3 == (Object)null) && !((Object)(object)val4 == (Object)null)) { CopyProperty(val3, val4, "fontSize"); CopyProperty(val3, val4, "fontSizeMin"); CopyProperty(val3, val4, "fontSizeMax"); CopyProperty(val3, val4, "enableAutoSizing"); CopyProperty(val3, val4, "font"); CopyProperty(val3, val4, "fontSharedMaterial"); CopyProperty(val3, val4, "alignment"); CopyProperty(val3, val4, "characterSpacing"); CopyProperty(val3, val4, "wordSpacing"); CopyProperty(val3, val4, "lineSpacing"); ScaleNumericProperty(val4, "fontSize", 1.04f); ScaleNumericProperty(val4, "fontSizeMin", 1.04f); ScaleNumericProperty(val4, "fontSizeMax", 1.04f); } } } private static void ScaleNumericProperty(Component component, string propertyName, float multiplier) { if ((Object)(object)component == (Object)null) { return; } PropertyInfo property = ((object)component).GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property == null || !property.CanRead || !property.CanWrite) { return; } try { if (property.PropertyType == typeof(float)) { float num = (float)property.GetValue(component, null); property.SetValue(component, num * multiplier, null); } } catch { } } private RectTransform FindRadialRowContainingText(Transform root, string wantedText) { Transform val = FindTextTransform(root, wantedText); if ((Object)(object)val == (Object)null) { return null; } Transform parent = val.parent; return (RectTransform)(object)((parent is RectTransform) ? parent : null); } private Transform FindTextTransform(Transform root, string wantedText) { //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return null; } Component[] components = ((Component)root).GetComponents<Component>(); foreach (Component val in components) { if ((Object)(object)val == (Object)null) { continue; } PropertyInfo property = ((object)val).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); if (property == null || property.PropertyType != typeof(string) || !property.CanRead) { continue; } try { object value = property.GetValue(val, null); if (value is string text && text.IndexOf(wantedText, StringComparison.OrdinalIgnoreCase) >= 0) { return val.transform; } } catch { } } foreach (Transform item in root) { Transform root2 = item; Transform val2 = FindTextTransform(root2, wantedText); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private void CacheLocalization() { if (_getBoundKeyStringMethod != null && _localizationInstance != null) { return; } try { Type type = AccessTools.TypeByName("Localization"); if (type == null) { return; } if (_getBoundKeyStringMethod == null) { _getBoundKeyStringMethod = AccessTools.Method(type, "GetBoundKeyString", (Type[])null, (Type[])null); } if (_localizationInstance == null) { PropertyInfo propertyInfo = AccessTools.Property(type, "instance"); if (propertyInfo != null) { _localizationInstance = propertyInfo.GetValue(null, null); } } } catch { } } private void UpdateDisplayedKey() { if ((Object)(object)_radialKeyText == (Object)null) { return; } try { CacheLocalization(); if (_localizationInstance != null && !(_getBoundKeyStringMethod == null)) { string value = _getBoundKeyStringMethod.Invoke(_localizationInstance, new object[2] { "OpenRadial", true }) as string; if (!string.IsNullOrEmpty(value)) { SetStringProperty(_radialKeyText, "text", value); } } } catch { } } private void OnRadialKeyClicked() { PlayNativeButtonSfx(); if (ZInput.instance != null) { ShowNativeStyleRebindDialog(); ZInput.instance.StartBindKey("OpenRadial"); _radialRebindActive = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Radial Rebind] Started native rebinding with visible native-style dialog."); } } private void ShowNativeStyleRebindDialog() { //IL_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) HideNativeStyleRebindDialog(); KeyboardMouseSettings val = FindKeyboardMouseSettings(); if ((Object)(object)val == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Radial Rebind] Could not find KeyboardMouseSettings for bind-dialog template."); return; } FieldInfo fieldInfo = AccessTools.Field(typeof(KeyboardMouseSettings), "m_bindDialog"); if (fieldInfo == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Radial Rebind] Could not find KeyboardMouseSettings.m_bindDialog."); return; } object value = fieldInfo.GetValue(val); GameObject val2 = (GameObject)((value is GameObject) ? value : null); if ((Object)(object)val2 == (Object)null) { Component val3 = (Component)((value is Component) ? value : null); if ((Object)(object)val3 != (Object)null) { val2 = val3.gameObject; } } if ((Object)(object)val2 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Radial Rebind] m_bindDialog is not a GameObject/Component."); return; } Transform val4 = FindVisibleSettingsRoot(); if ((Object)(object)val4 == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"[Radial Rebind] Could not find visible Settings root."); return; } _radialBindDialog = Object.Instantiate<GameObject>(val2, val4, false); ((Object)_radialBindDialog).name = "RadialRebind_NativeBindDialog"; RectTransform component = _radialBindDialog.GetComponent<RectTransform>(); RectTransform component2 = val2.GetComponent<RectTransform>(); if ((Object)(object)component != (Object)null && (Object)(object)component2 != (Object)null) { component.anchorMin = component2.anchorMin; component.anchorMax = component2.anchorMax; component.pivot = component2.pivot; component.sizeDelta = component2.sizeDelta; component.anchoredPosition = component2.anchoredPosition; ((Transform)component).localScale = ((Transform)component2).localScale; ((Transform)component).localRotation = ((Transform)component2).localRotation; } _radialBindDialog.SetActive(true); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[Radial Rebind] Cloned native bind dialog from " + ((Object)val2).name + " into visible Settings root.")); } private void HideNativeStyleRebindDialog() { if (!((Object)(object)_radialBindDialog == (Object)null)) { Object.Destroy((Object)(object)_radialBindDialog); _radialBindDialog = null; } } private Transform FindVisibleSettingsRoot() { if ((Object)(object)_currentRadialSettings != (Object)null) { Transform val = _currentRadialSettings; while ((Object)(object)val != (Object)null) { if (((Object)val).name == "Panel") { return val; } val = val.parent; } } return null; } private KeyboardMouseSettings FindKeyboardMouseSettings() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) KeyboardMouseSettings[] array = Resources.FindObjectsOfTypeAll<KeyboardMouseSettings>(); KeyboardMouseSettings[] array2 = array; foreach (KeyboardMouseSettings val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).gameObject == (Object)null)) { Scene scene = ((Component)val).gameObject.scene; if (((Scene)(ref scene)).IsValid()) { return val; } } } return null; } internal void OnNativeRebindFinished() { if (_radialRebindActive) { _radialRebindActive = false; HideNativeStyleRebindDialog(); UpdateDisplayedKey(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"[Radial Rebind] Rebinding finished; closed bind dialog."); } } private void PlayNativeButtonSfx() { if ((Object)(object)_radialKeyButton == (Object)null) { return; } try { Type type = AccessTools.TypeByName("ButtonSfx"); if (type == null) { return; } Component component = _radialKeyButton.gameObject.GetComponent(type); if ((Object)(object)component == (Object)null) { return; } string[] array = new string[8] { "OnClickSfx", "OnClickSFX", "OnClick", "PlayClickSfx", "PlayClickSFX", "PlaySfx", "PlaySFX", "PlayClickSound" }; string[] array2 = array; foreach (string name in array2) { MethodInfo method = type.GetMethod(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (!(method == null) && method.GetParameters().Length == 0) { method.Invoke(component, null); return; } } MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); foreach (MethodInfo methodInfo in methods) { string text = methodInfo.Name.ToLowerInvariant(); if (methodInfo.GetParameters().Length == 0 && text.Contains("click") && (text.Contains("sfx") || text.Contains("sound"))) { methodInfo.Invoke(component, null); break; } } } catch { } } private RectTransform FindKeyboardTemplate(string keyName) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) KeyboardMouseSettings[] array = Resources.FindObjectsOfTypeAll<KeyboardMouseSettings>(); FieldInfo fieldInfo = AccessTools.Field(typeof(KeyboardMouseSettings), "m_keys"); if (fieldInfo == null) { return null; } KeyboardMouseSettings[] array2 = array; foreach (KeyboardMouseSettings val in array2) { if ((Object)(object)val == (Object)null || (Object)(object)((Component)val).gameObject == (Object)null) { continue; } Scene scene = ((Component)val).gameObject.scene; if (!((Scene)(ref scene)).IsValid() || !(fieldInfo.GetValue(val) is List<KeySetting> list)) { continue; } foreach (KeySetting item in list) { if (item != null && item.m_keyName == keyName && (Object)(object)item.m_keyTransform != (Object)null) { return item.m_keyTransform; } } } return null; } private RectTransform FindRowContainingText(Transform root, string wantedText) { //IL_00f4: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Expected O, but got Unknown if ((Object)(object)root == (Object)null) { return null; } Component[] components = ((Component)root).GetComponents<Component>(); Component[] array = components; foreach (Component val in array) { if ((Object)(object)val == (Object)null) { continue; } PropertyInfo property = ((object)val).GetType().GetProperty("text", BindingFlags.Instance | BindingFlags.Public); if (property == null || property.PropertyType != typeof(string) || !property.CanRead) { continue; } try { object value = property.GetValue(val, null); if (value is string text && text.IndexOf(wantedText, StringComparison.OrdinalIgnoreCase) >= 0) { return (RectTransform)(object)((root is RectTransform) ? root : null); } } catch { } } foreach (Transform item in root) { Transform root2 = item; RectTransform val2 = FindRowContainingText(root2, wantedText); if ((Object)(object)val2 != (Object)null) { return val2; } } return null; } private static void AddIgnoreLayout(GameObject gameObject) { if ((Object)(object)gameObject == (Object)null) { return; } try { Type type = Type.GetType("UnityEngine.UI.LayoutElement, UnityEngine.UI"); if (!(type == null)) { Component val = gameObject.GetComponent(type); if ((Object)(object)val == (Object)null) { val = gameObject.AddComponent(type); } PropertyInfo property = type.GetProperty("ignoreLayout", BindingFlags.Instance | BindingFlags.Public); if (property != null && property.CanWrite) { property.SetValue(val, true, null); } } } catch { } } private static Component FindComponentWithProperty(GameObject gameObject, string propertyName) { if ((Object)(object)gameObject == (Object)null) { return null; } Component[] components = gameObject.GetComponents<Component>(); foreach (Component val in components) { if (!((Object)(object)val == (Object)null)) { PropertyInfo property = ((object)val).GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property != null) { return val; } } } return null; } private static void RemoveAllClickListeners(Component button) { if ((Object)(object)button == (Object)null) { return; } try { PropertyInfo property = ((object)button).GetType().GetProperty("onClick", BindingFlags.Instance | BindingFlags.Public); if (property == null) { return; } object value = property.GetValue(button, null); if (value != null) { MethodInfo method = value.GetType().GetMethod("RemoveAllListeners", BindingFlags.Instance | BindingFlags.Public); if (method != null) { method.Invoke(value, null); } } } catch { } } private static void AddClickListener(Component button, Action callback) { if ((Object)(object)button == (Object)null || callback == null) { return; } PropertyInfo property = ((object)button).GetType().GetProperty("onClick", BindingFlags.Instance | BindingFlags.Public); if (property == null) { return; } object value = property.GetValue(button, null); if (value != null) { MethodInfo method = value.GetType().GetMethod("AddListener", BindingFlags.Instance | BindingFlags.Public); if (!(method == null)) { Delegate obj = Delegate.CreateDelegate(method.GetParameters()[0].ParameterType, callback.Target, callback.Method); method.Invoke(value, new object[1] { obj }); } } } private static void SetStringProperty(Component component, string propertyName, string value) { if ((Object)(object)component == (Object)null) { return; } PropertyInfo property = ((object)component).GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property == null || property.PropertyType != typeof(string) || !property.CanWrite) { return; } try { property.SetValue(component, value, null); } catch { } } private static void CopyProperty(Component source, Component target, string propertyName) { if ((Object)(object)source == (Object)null || (Object)(object)target == (Object)null) { return; } PropertyInfo property = ((object)source).GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); PropertyInfo property2 = ((object)target).GetType().GetProperty(propertyName, BindingFlags.Instance | BindingFlags.Public); if (property == null || property2 == null || !property.CanRead || !property2.CanWrite || property.PropertyType != property2.PropertyType) { return; } try { property2.SetValue(target, property.GetValue(source, null), null); } catch { } } }