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 CookingXP v1.3.0
CookingXP_v1.3.0.dll
Decompiled 3 weeks agousing System; 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 UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("CookingXP")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.1.2.0")] [assembly: AssemblyInformationalVersion("1.1.2")] [assembly: AssemblyProduct("CookingXP")] [assembly: AssemblyTitle("CookingXP")] [assembly: AssemblyVersion("1.1.2.0")] namespace CookingXP; [BepInPlugin("frost.cookingxp", "CookingXP", "1.3.0")] public class CookingXPPlugin : BaseUnityPlugin { public const string PluginGuid = "frost.cookingxp"; public const string PluginName = "CookingXP"; public const string PluginVersion = "1.3.0"; internal static ManualLogSource Log; internal static ConfigEntry<float> GlobalMultiplier; internal static ConfigEntry<float> BonusPerFoodPoint; internal static ConfigEntry<float> ScalingDivisor; internal static ConfigEntry<float> MeadBonusChance; internal static ConfigEntry<int> MeadBonusMax; internal static ConfigEntry<float> MeadBonusEscalation; private void Awake() { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; GlobalMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("CookingXP", "GlobalMultiplier", 2.5f, "Во сколько раз усиливается весь опыт Кулинарии (котёл, стойки, печь)"); BonusPerFoodPoint = ((BaseUnityPlugin)this).Config.Bind<float>("CookingXP", "BonusPerFoodPoint", 0.04f, "Бонусный опыт за каждую единицу силы блюда (здоровье + выносливость + эйтр)"); ScalingDivisor = ((BaseUnityPlugin)this).Config.Bind<float>("CookingXP", "ScalingDivisor", 50f, "Масштабирование опыта от навыка: XP x (1 + навык/делитель). 50 = на 100-м навыке опыт вдвое-втрое выше, чем на 55-м — скорость прокачки примерно ровная до сотни. 0 = без масштабирования"); MeadBonusChance = ((BaseUnityPlugin)this).Config.Bind<float>("CookingXP", "MeadBonusChance", 0.25f, "Бонус при сливе готовой медовухи из кадки: шанс = навык Кулинарии сливающего × это число (0.25 = как ванильный бонус крафта: на 100 Кулинарии — 25%)"); MeadBonusMax = ((BaseUnityPlugin)this).Config.Bind<int>("CookingXP", "MeadBonusMax", 4, "Максимальный бонус бутылок (+4 = кадка выдаёт до 8 вместо 4). Лестница бонуса: прокнул → +1, каждая следующая бутылка вдвое реже"); MeadBonusEscalation = ((BaseUnityPlugin)this).Config.Bind<float>("CookingXP", "MeadBonusEscalation", 20f, "Шанс (%) первой ступени лестницы (+2), каждая следующая вдвое реже: +2 ≈ 20%, +3 ≈ 10%, +4 ≈ 5%"); new Harmony("frost.cookingxp").PatchAll(); FermenterTestCommand.Register(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"CookingXP 1.3.0 загружен"); } } internal static class FermenterTestCommand { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static ConsoleEvent <>9__0_0; internal void <Register>b__0_0(ConsoleEventArgs <p0>) { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { int num = 0; Fermenter[] array = Object.FindObjectsOfType<Fermenter>(); for (int i = 0; i < array.Length; i++) { array[i].m_fermentationDuration = 1f; num++; } ((Character)Player.m_localPlayer).Message((MessageType)2, $"Кадок разогнано: {num} — закладывай основу и сливай", 0, (Sprite)null, false); CookingXPPlugin.Log.LogInfo((object)$"fermenterfast: разогнано кадок {num}"); } } } public static void Register() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Expected O, but got Unknown object obj = <>c.<>9__0_0; if (obj == null) { ConsoleEvent val = delegate { if (!((Object)(object)Player.m_localPlayer == (Object)null)) { int num = 0; Fermenter[] array = Object.FindObjectsOfType<Fermenter>(); for (int i = 0; i < array.Length; i++) { array[i].m_fermentationDuration = 1f; num++; } ((Character)Player.m_localPlayer).Message((MessageType)2, $"Кадок разогнано: {num} — закладывай основу и сливай", 0, (Sprite)null, false); CookingXPPlugin.Log.LogInfo((object)$"fermenterfast: разогнано кадок {num}"); } }; <>c.<>9__0_0 = val; obj = (object)val; } new ConsoleCommand("fermenterfast", "тест: все кадки ферментируют мгновенно (для проверки бонуса)", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false); } } internal static class DishContext { public const float None = -1f; public static float Bonus = -1f; public static string Name = ""; } [HarmonyPatch(typeof(Player), "RaiseSkill")] internal static class Player_RaiseSkill_Patch { private static void Prefix(Player __instance, SkillType skill, ref float value) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Invalid comparison between Unknown and I4 //IL_0048: Unknown result type (might be due to invalid IL or missing references) if ((int)skill == 105 && !(value <= 0f)) { float num = ((DishContext.Bonus > 0f) ? DishContext.Bonus : 0f); string name = DishContext.Name; DishContext.Bonus = -1f; DishContext.Name = ""; float skillLevel = ((Character)__instance).GetSkills().GetSkillLevel(skill); float num2 = ((CookingXPPlugin.ScalingDivisor.Value > 0f) ? (1f + skillLevel / CookingXPPlugin.ScalingDivisor.Value) : 1f); float num3 = value * CookingXPPlugin.GlobalMultiplier.Value; float num4 = num * CookingXPPlugin.BonusPerFoodPoint.Value; value = (num3 + num4) * num2; CookingXPPlugin.Log.LogInfo((object)$"Cooking XP: {value:F2} — блюдо '{name}' (сила {num:F0}, +{num4:F2}), навык {skillLevel:F0}, масштаб x{num2:F2}"); } } } [HarmonyPatch(typeof(CookingStation), "OnUseItem")] internal static class CookingStation_OnUseItem_Patch { private static void Prefix(ItemData item) { if (item?.m_shared != null) { DishContext.Bonus = FoodMath.FoodPower(item.m_shared); DishContext.Name = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : item.m_shared.m_name); } } } [HarmonyPatch(typeof(InventoryGui), "DoCrafting")] internal static class InventoryGui_DoCrafting_Patch { private static void Prefix(InventoryGui __instance) { try { object? obj = AccessTools.Field(typeof(InventoryGui), "m_craftRecipe")?.GetValue(__instance); Recipe val = (Recipe)((obj is Recipe) ? obj : null); SharedData val2 = val?.m_item?.m_itemData?.m_shared; if (val2 != null && !(val2.m_food <= 0f)) { DishContext.Bonus = FoodMath.FoodPower(val2); DishContext.Name = ((Object)((Component)val.m_item).gameObject).name; } } catch (Exception ex) { Debug.LogError((object)("[CookingXP] Ошибка бонуса за блюдо: " + ex)); } } } internal static class FoodMath { public static float FoodPower(SharedData shared) { return shared.m_food + shared.m_foodStamina + shared.m_foodEitr; } } [HarmonyPatch(typeof(Fermenter), "DelayedTap")] internal static class Fermenter_DelayedTap_Patch { private static void Postfix(Fermenter __instance) { //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0229: Unknown result type (might be due to invalid IL or missing references) //IL_022e: Unknown result type (might be due to invalid IL or missing references) //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_023b: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026f: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } int num = ((AccessTools.Field(typeof(Fermenter), "m_delayedTapItem")?.GetValue(__instance) is int num2) ? num2 : (-1)); object? obj = AccessTools.Method(typeof(Fermenter), "GetItemConversion", (Type[])null, (Type[])null)?.Invoke(__instance, new object[1] { num }); ItemConversion val = (ItemConversion)((obj is ItemConversion) ? obj : null); if (val == null || (Object)(object)val.m_from == (Object)null || (Object)(object)val.m_to == (Object)null) { CookingXPPlugin.Log.LogInfo((object)$"Кадка: конверсия не определена (content={num})"); return; } string name = ((Object)((Component)val.m_from).gameObject).name; if (!name.Contains("MeadBase")) { CookingXPPlugin.Log.LogInfo((object)("Кадка: не медовуха (" + name + ") — бонуса нет")); return; } float num3 = ((Character)localPlayer).GetSkillFactor((SkillType)105) * 100f; float num4 = num3 * CookingXPPlugin.MeadBonusChance.Value; bool flag = Random.value < num4 / 100f; CookingXPPlugin.Log.LogInfo((object)string.Format("Кадка: ролл бонуса — Кулинария {0:F0}, шанс {1:F0}%, {2}", num3, num4, flag ? "ПРОК" : "мимо")); if (!flag) { return; } int num5 = Mathf.Max(1, CookingXPPlugin.MeadBonusMax.Value); float num6 = Mathf.Clamp(CookingXPPlugin.MeadBonusEscalation.Value, 1f, 100f) / 100f; int num7 = 1; float num8 = CookingXPPlugin.MeadBonusEscalation.Value; while (num7 < num5 && Random.value < num8 / 100f) { num7++; num8 *= num6; } object? obj2 = AccessTools.Field(typeof(Fermenter), "m_outputPoint")?.GetValue(__instance); Transform val2 = (Transform)((obj2 is Transform) ? obj2 : null); if (!((Object)(object)val2 == (Object)null)) { for (int i = 0; i < num7; i++) { Vector3 val3 = val2.position + Vector3.up * (0.3f * (float)(i + 1)); ItemDrop.OnCreateNew(Object.Instantiate<ItemDrop>(val.m_to, val3, Quaternion.identity), false); } Vector3 val4 = val2.position + Vector3.up * 1.5f; DamageText.instance.ShowText((TextType)7, val4, $"+{num7}", true); CookingXPPlugin.Log.LogInfo((object)$"Бонус кадки: +{num7} {((Object)((Component)val.m_to).gameObject).name} (Кулинария {num3:F0})"); } } catch (Exception ex) { Debug.LogError((object)("[CookingXP] Ошибка бонуса кадки: " + ex)); } } }