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 EmoteSkills v2.0.0
EmoteSkills.dll
Decompiled 2 weeks agousing System; using System.Collections.Generic; using System.Reflection; using System.Runtime.CompilerServices; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace EmoteSkills; [BepInPlugin("EmoteSkills", "EmoteSkills", "2.0.0")] public class Plugin : BaseUnityPlugin { public const string Guid = "EmoteSkills"; private static readonly Dictionary<string, string> Presets = new Dictionary<string, string> { { "Vibe", "Run, Farming, Crafting" }, { "Dance", "Jump, Dodge" }, { "Sit", "Cooking, Riding" }, { "Kneel", "Sneak, Block" }, { "Relax", "Fishing" }, { "Rest", "Swim" }, { "Headbang", "Fists, Pickaxes, WoodCutting" }, { "Toast", "Cooking" }, { "ThumbsUp", "Crafting" }, { "Cower", "Block" }, { "Challenge", "Swords" }, { "Roar", "Axes" }, { "Flex", "Clubs" }, { "Point", "Spears" }, { "Wave", "Polearms" }, { "Bow", "Bows" }, { "Shrug", "Crossbows" }, { "Cry", "Knives" }, { "Despair", "Pickaxes" }, { "Cheer", "WoodCutting" }, { "BlowKiss", "ElementalMagic" }, { "LoveYou", "BloodMagic" }, { "NoNoNo", "Block" }, { "ComeHere", "ElementalMagic, BloodMagic" }, { "Laugh", "Swim, Dodge" } }; private static readonly Dictionary<string, SkillType> Aliases = new Dictionary<string, SkillType>(StringComparer.OrdinalIgnoreCase) { { "Fists", (SkillType)11 }, { "Block", (SkillType)6 }, { "Riding", (SkillType)110 } }; internal static ConfigEntry<bool> Enabled; internal static ConfigEntry<float> Multiplier; internal static ConfigEntry<bool> ChairCountsAsSit; private readonly Dictionary<string, ConfigEntry<string>> emoteEntries = new Dictionary<string, ConfigEntry<string>>(); private readonly Dictionary<SkillType, ConfigEntry<float>> rateEntries = new Dictionary<SkillType, ConfigEntry<float>>(); internal static Dictionary<string, List<SkillType>> EmoteMap = new Dictionary<string, List<SkillType>>(); internal static Dictionary<SkillType, float> BaseRates = new Dictionary<SkillType, float>(); private void Awake() { //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Invalid comparison between Unknown and I4 //IL_0197: 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_011f: Unknown result type (might be due to invalid IL or missing references) Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Turn emote skill training on or off."); Multiplier = ((BaseUnityPlugin)this).Config.Bind<float>("General", "EmoteMultiplier", 2f, "Emotes train skills at this multiple of the skill's normal rate in [BaseRates]. 2 = twice as fast as doing the real action, 1 = the same."); ChairCountsAsSit = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ChairCountsAsSit", true, "Sitting in a chair, bench or throne trains the same skills as the Sit emote."); string[] names = Enum.GetNames(typeof(Emotes)); foreach (string text in names) { if (!(text == "Count")) { Presets.TryGetValue(text, out var value); emoteEntries[text] = ((BaseUnityPlugin)this).Config.Bind<string>("Emotes", text, value ?? "", "Skills trained while doing the " + text + " emote, comma-separated (e.g. Run, Jump). Empty = none. Short emotes only count while they play."); } } foreach (SkillType value2 in Enum.GetValues(typeof(SkillType))) { if ((int)value2 != 0 && (int)value2 != 999) { rateEntries[value2] = ((BaseUnityPlugin)this).Config.Bind<float>("BaseRates", ((object)value2).ToString(), 1f, "Base skill points per second for emotes, matching the game's usual 1 per second or per action. Emotes give this times EmoteMultiplier."); } } Rebuild(); ((BaseUnityPlugin)this).Config.SettingChanged += delegate { Rebuild(); }; ((BaseUnityPlugin)this).Config.ConfigReloaded += delegate { Rebuild(); }; new Harmony("EmoteSkills").PatchAll(typeof(Plugin).Assembly); } private void Rebuild() { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) Dictionary<string, List<SkillType>> dictionary = new Dictionary<string, List<SkillType>>(); foreach (KeyValuePair<string, ConfigEntry<string>> emoteEntry in emoteEntries) { List<SkillType> list = new List<SkillType>(); string[] array = emoteEntry.Value.Value.Split(new char[1] { ',' }); foreach (string text in array) { string text2 = text.Trim(); if (text2.Length != 0) { if (TryParseSkill(text2, out var skill)) { list.Add(skill); } else { ((BaseUnityPlugin)this).Logger.LogWarning((object)("Unknown skill '" + text2 + "' for emote " + emoteEntry.Key)); } } } if (list.Count > 0) { dictionary[emoteEntry.Key.ToLowerInvariant()] = list; } } Dictionary<SkillType, float> dictionary2 = new Dictionary<SkillType, float>(); foreach (KeyValuePair<SkillType, ConfigEntry<float>> rateEntry in rateEntries) { dictionary2[rateEntry.Key] = rateEntry.Value.Value; } EmoteMap = dictionary; BaseRates = dictionary2; } private static bool TryParseSkill(string name, out SkillType skill) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Expected I4, but got Unknown if (Aliases.TryGetValue(name, out skill)) { return true; } try { skill = (SkillType)(int)(SkillType)Enum.Parse(typeof(SkillType), name.Replace(" ", ""), ignoreCase: true); return skill && (int)skill != 999; } catch (ArgumentException) { return false; } } } [HarmonyPatch(typeof(Chair), "Interact")] internal static class ChairInteractPatch { internal static bool Seated; private static void Postfix(bool __result, Humanoid __0) { if (__result && (Object)(object)__0 != (Object)null && (Object)(object)__0 == (Object)(object)Player.m_localPlayer) { Seated = true; } } } [HarmonyPatch(typeof(Player), "Update")] internal static class PlayerUpdatePatch { private static float timer; private static void Postfix(Player __instance) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)__instance != (Object)(object)Player.m_localPlayer) { return; } if (ChairInteractPatch.Seated && !((Character)__instance).IsAttached()) { ChairInteractPatch.Seated = false; } string text = null; if (((Character)__instance).InEmote()) { text = Player.LastEmote; } else if (ChairInteractPatch.Seated && Plugin.ChairCountsAsSit.Value) { text = "sit"; } if (!Plugin.Enabled.Value || text == null || !Plugin.EmoteMap.TryGetValue(text, out var value)) { timer = 0f; return; } timer += Time.deltaTime; if (timer < 1f) { return; } timer -= 1f; float value2 = Plugin.Multiplier.Value; foreach (SkillType item in value) { if (Plugin.BaseRates.TryGetValue(item, out var value3) && value3 * value2 > 0f) { ((Character)__instance).RaiseSkill(item, value3 * value2); } } } }