Decompiled source of UKT UMM CompatPatch v1.0.1

plugins/UKT-UMM-Patch.dll

Decompiled 4 months ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using ULTRAKIT.Extensions;
using ULTRAKIT.Extensions.Classes;
using ULTRAKIT.Loader;
using ULTRAKIT.Loader.Injectors;
using UMM;
using UnityEngine;
using UnityEngine.Events;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("UKT_UMM_CompatibilityPatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("HP")]
[assembly: AssemblyProduct("UKT_UMM_CompatibilityPatch")]
[assembly: AssemblyCopyright("Copyright © HP 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("871250e8-32b9-4425-9987-c52205d1a16c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ULTRAKIT.UMM_Compatibility;

[BepInPlugin("ULTRAKIT.umm_compat", "ULTRAKIT Reloaded UMM Compatibility Patch", "1.0.1")]
[BepInDependency("UMM", "0.5.1")]
[BepInDependency("ULTRAKIT.core_module", "2.3.0")]
public class Plugin : BaseUnityPlugin
{
	public static Plugin plugin;

	private void Awake()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		plugin = this;
		Harmony val = new Harmony("ULTRAKIT.UMM_Compatibility");
		val.PatchAll();
	}
}
[HarmonyPatch(typeof(KeybindsInjector))]
public class KeybindsInjectorPostfix
{
	[HarmonyPatch("SetKeys")]
	[HarmonyPostfix]
	private static void SetKeysPostfix(InputManager instance)
	{
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Expected I4, but got Unknown
		UKLogger.Log((object)"Compatibility Patch Active");
		Registries.key_states = Registries.key_registry.ToDictionary((KeyValuePair<string, UKKeySetting> item) => item.Key, (KeyValuePair<string, UKKeySetting> item) => (InputActionState)(object)UKAPI.GetKeyBind(((UKSetting)item.Value).Name, item.Value.Binding.DefaultKey));
		foreach (KeyValuePair<string, InputActionState> key_state in Registries.key_states)
		{
			UKKeySetting setting = Registries.key_registry[key_state.Key];
			UKKeyBind keyBind = UKAPI.GetKeyBind(((UKSetting)setting).Name, (KeyCode)0);
			((UnityEvent<KeyCode>)(object)keyBind.OnBindingChanged).AddListener((UnityAction<KeyCode>)delegate(KeyCode key)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Expected I4, but got Unknown
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				instance.Inputs[setting.Binding.Name] = key;
				MonoSingleton<PrefsManager>.instance.SetInt(setting.Binding.PrefName, (int)key);
				setting.SetValue(key);
				instance.UpdateBindings();
			});
			if (MonoSingleton<PrefsManager>.Instance.HasKey(setting.Binding.PrefName))
			{
				keyBind.ChangeKeyBind((KeyCode)MonoSingleton<PrefsManager>.Instance.GetInt(setting.Binding.PrefName, (int)setting.Key));
			}
		}
		instance.UpdateBindings();
	}
}