Please disclose if your mod was created primarily 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 ImprovSkill v1.0.0
ImprovedSkills.dll
Decompiled 2 years agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using ModSettingsUI; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")] [assembly: AssemblyCompany("ImprovedSkillsPlugin")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ImprovedSkillsPlugin")] [assembly: AssemblyTitle("ImprovedSkillsPlugin")] [assembly: AssemblyVersion("1.0.0.0")] namespace ImprovedSkills; [BepInPlugin("nonamepaul.plugins.improvedskills", "Improved Skills", "1.0.0")] public class ImprovedSkillsPlugin : BaseUnityPlugin { public const string pluginGUID = "nonamepaul.plugins.improvedskills"; public const string pluginName = "Improved Skills"; public const string pluginVersion = "1.0.0"; internal readonly Harmony harmony; internal readonly Assembly assembly; public static List<KeyValuePair<string, ConfigEntry<float>>> _skillConfigurations; public static ConfigEntry<bool> _configIsEnabled; public static ConfigEntry<bool> _configMultiplayerActive; public static ManualLogSource logger; public static ConfigFile config; public static bool initialized; public ImprovedSkillsPlugin() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Expected O, but got Unknown assembly = Assembly.GetExecutingAssembly(); harmony = new Harmony("nonamepaul.plugins.improvedskills"); } public static float GetMultiplierForSkillBySkillType(SkillType skillType) { string text = ((object)(SkillType)(ref skillType)).ToString().ToLower(); foreach (KeyValuePair<string, ConfigEntry<float>> skillConfiguration in _skillConfigurations) { if (skillConfiguration.Key == text) { return skillConfiguration.Value.Value; } } return 1f; } public static bool IsEnabled() { return _configIsEnabled.Value; } public static bool IsMultiplayerActive() { return _configMultiplayerActive.Value; } private void Awake() { logger = ((BaseUnityPlugin)this).Logger; config = ((BaseUnityPlugin)this).Config; try { harmony.PatchAll(assembly); } catch (Exception ex) { logger.LogError((object)ex.Message); } } } [HarmonyPatch] public static class SkillsPatch { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static SettingsSavedCallback <>9__0_0; public static SettingsSavedCallback <>9__0_1; internal void <Initialize>b__0_0(object value) { ImprovedSkillsPlugin._configIsEnabled.Value = (bool)value; ImprovedSkillsPlugin.config.Save(); } internal void <Initialize>b__0_1(object value) { ImprovedSkillsPlugin._configMultiplayerActive.Value = (bool)value; ImprovedSkillsPlugin.config.Save(); } } [HarmonyPostfix] [HarmonyPatch(typeof(Skills), "Load")] private static void Initialize() { //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Expected O, but got Unknown //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Expected O, but got Unknown if (ImprovedSkillsPlugin.initialized) { return; } ImprovedSkillsPlugin._configIsEnabled = ImprovedSkillsPlugin.config.Bind<bool>("Settings", "is_enabled", true, "If the plugin is active at all"); object obj = ImprovedSkillsPlugin._configIsEnabled.Value; object obj2 = <>c.<>9__0_0; if (obj2 == null) { SettingsSavedCallback val = delegate(object value) { ImprovedSkillsPlugin._configIsEnabled.Value = (bool)value; ImprovedSkillsPlugin.config.Save(); }; <>c.<>9__0_0 = val; obj2 = (object)val; } ModSettingsUI.AddInputField("Improved Skills", (OptionType)2, "Enabled", obj, (SettingsSavedCallback)obj2); ImprovedSkillsPlugin._configMultiplayerActive = ImprovedSkillsPlugin.config.Bind<bool>("Settings", "multiplayer_active", false, "If the plugin is active in multiplayer"); object obj3 = ImprovedSkillsPlugin._configMultiplayerActive.Value; object obj4 = <>c.<>9__0_1; if (obj4 == null) { SettingsSavedCallback val2 = delegate(object value) { ImprovedSkillsPlugin._configMultiplayerActive.Value = (bool)value; ImprovedSkillsPlugin.config.Save(); }; <>c.<>9__0_1 = val2; obj4 = (object)val2; } ModSettingsUI.AddInputField("Improved Skills", (OptionType)2, "Active during multiplayer", obj3, (SettingsSavedCallback)obj4); ImprovedSkillsPlugin._skillConfigurations = new List<KeyValuePair<string, ConfigEntry<float>>>(); foreach (Skill skill in Object.FindObjectOfType<Skills>().GetSkillList()) { string text = ((object)(SkillType)(ref skill.m_info.m_skill)).ToString().ToLower(); ConfigEntry<float> value2 = ImprovedSkillsPlugin.config.Bind<float>("Skills", text, 1f, $"Multiplier for Skill '{skill.m_info.m_skill}'"); ImprovedSkillsPlugin._skillConfigurations.Add(new KeyValuePair<string, ConfigEntry<float>>(text, value2)); } foreach (KeyValuePair<string, ConfigEntry<float>> keypair in ImprovedSkillsPlugin._skillConfigurations) { string text2 = Localization.instance.Localize("$skill_" + keypair.Key.ToLower()); ModSettingsUI.AddInputField("Improved Skills", (OptionType)1, text2, (object)keypair.Value.Value, (SettingsSavedCallback)delegate(object value) { keypair.Value.Value = (float)value; ImprovedSkillsPlugin.config.Save(); }); } ImprovedSkillsPlugin.initialized = true; } } public class XPPatch { [HarmonyPatch] private static class ImprovedSkillsPatch { [HarmonyPrefix] [HarmonyPatch(typeof(Skills), "RaiseSkill")] private static void multiply(ref Skills __instance, ref SkillType skillType, ref float factor) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: 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) bool flag = false; foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { flag |= player.m_host != ""; } if (ImprovedSkillsPlugin.IsEnabled() && (!flag || ImprovedSkillsPlugin.IsMultiplayerActive())) { factor *= ImprovedSkillsPlugin.GetMultiplierForSkillBySkillType(skillType); } } } }