using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [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("MasterCooking")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("A mod that applies Smoothbrain's Cooking skill bonuses to Ashlands Feast items")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("MasterCooking")] [assembly: AssemblyTitle("MasterCooking")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace MasterCooking { [BepInPlugin("com.ruijven.mastercooking", "MasterCooking", "1.0.0")] internal class MasterCookingPlugin : BaseUnityPlugin { public const string PluginGUID = "com.ruijven.mastercooking"; public const string PluginName = "MasterCooking"; public const string PluginVersion = "1.0.0"; internal static ManualLogSource Logger; public static ConfigEntry HealthFactor; public static ConfigEntry StaminaFactor; public static ConfigEntry RegenFactor; public static ConfigEntry EitrFactor; public static ConfigEntry DurationFactor; public static ConfigEntry ExperienceGainFactor; public static ConfigEntry LogDebugInfo; internal static MasterCookingPlugin Instance { get; private set; } private void Awake() { //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; InitializeConfig(); Harmony val = new Harmony("com.ruijven.mastercooking"); val.PatchAll(Assembly.GetExecutingAssembly()); Logger.LogInfo((object)"MasterCooking v1.0.0 loaded successfully!"); Logger.LogInfo((object)"This mod applies Cooking skill bonuses to ALL food consumption."); } private void InitializeConfig() { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Expected O, but got Unknown //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Expected O, but got Unknown //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Expected O, but got Unknown //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Expected O, but got Unknown //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Expected O, but got Unknown //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Expected O, but got Unknown HealthFactor = ((BaseUnityPlugin)this).Config.Bind("Stat Multipliers", "HealthFactor", 1.3f, new ConfigDescription("Health multiplier at Cooking skill level 100 (e.g., 1.3 = 30% increase)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); StaminaFactor = ((BaseUnityPlugin)this).Config.Bind("Stat Multipliers", "StaminaFactor", 1.3f, new ConfigDescription("Stamina multiplier at Cooking skill level 100 (e.g., 1.3 = 30% increase)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); RegenFactor = ((BaseUnityPlugin)this).Config.Bind("Stat Multipliers", "RegenFactor", 1.3f, new ConfigDescription("Health regeneration multiplier at Cooking skill level 100 (e.g., 1.3 = 30% increase)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); EitrFactor = ((BaseUnityPlugin)this).Config.Bind("Stat Multipliers", "EitrFactor", 1.3f, new ConfigDescription("Eitr multiplier at Cooking skill level 100 (e.g., 1.3 = 30% increase)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 5f), Array.Empty())); DurationFactor = ((BaseUnityPlugin)this).Config.Bind("Stat Multipliers", "DurationFactor", 1f, new ConfigDescription("Duration multiplier at Cooking skill level 100 (e.g., 1.5 = 50% longer duration)", (AcceptableValueBase)(object)new AcceptableValueRange(1f, 3f), Array.Empty())); ExperienceGainFactor = ((BaseUnityPlugin)this).Config.Bind("Skill Progression", "ExperienceGainFactor", 1f, new ConfigDescription("Multiplier for Cooking skill experience gained (e.g., 2.0 = 2x XP)", (AcceptableValueBase)(object)new AcceptableValueRange(0.1f, 10f), Array.Empty())); LogDebugInfo = ((BaseUnityPlugin)this).Config.Bind("General", "LogDebugInfo", false, new ConfigDescription("Enable detailed debug logging in the console.", (AcceptableValueBase)null, Array.Empty())); } } [HarmonyPatch] internal class Patch_FeastFix { [HarmonyPatch(typeof(Player), "EatFood")] [HarmonyPrefix] private static void EatFoodPrefix(Player __instance, ItemData item) { if (!((Object)(object)__instance != (Object)(object)Player.m_localPlayer) && item != null && item.m_shared != null) { float cookingSkillLevel = GetCookingSkillLevel(__instance); float num = Mathf.Min(cookingSkillLevel / 100f, 1f); ApplyItemBonuses(item, num); if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Applied Cooking skill bonuses to item: {item.m_shared.m_name} (Skill: {cookingSkillLevel:F1}, Factor: {num:F2})"); } } } [HarmonyPatch(typeof(Player), "EatFood")] [HarmonyPostfix] private static void EatFoodPostfix(Player __instance, ItemData item, ref bool __result) { if (!__result || (Object)(object)__instance != (Object)(object)Player.m_localPlayer || item == null || item.m_shared == null) { return; } float cookingSkillLevel = GetCookingSkillLevel(__instance); float num = Mathf.Min(cookingSkillLevel / 100f, 1f); float num2 = 1f + num * (MasterCookingPlugin.DurationFactor.Value - 1f); List foods = __instance.GetFoods(); Food val = ((IEnumerable)foods).FirstOrDefault((Func)((Food f) => f.m_item.m_shared.m_name == item.m_shared.m_name)); if (val != null && val.m_time > 0f) { float time = val.m_time; val.m_time *= num2; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Duration (HUD): {time:F1}s -> {val.m_time:F1}s (x{num2:F2})"); } } } [HarmonyPatch(typeof(Player), "RaiseSkill")] [HarmonyPrefix] private static void RaiseSkillPrefix(Player __instance, SkillType skill, ref float value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 if ((int)skill == 105) { value *= MasterCookingPlugin.ExperienceGainFactor.Value; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Cooking skill XP multiplied: {value:F2}x"); } } } private static float GetCookingSkillLevel(Player player) { try { float skillLevel = ((Character)player).GetSkillLevel((SkillType)105); if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Cooking skill level: {skillLevel:F1}"); } return skillLevel; } catch (Exception ex) { MasterCookingPlugin.Logger.LogError((object)("Error getting Cooking skill level: " + ex.Message)); return 0f; } } private static void ApplyItemBonuses(ItemData item, float skillFactor) { float num = 1f + skillFactor * (MasterCookingPlugin.HealthFactor.Value - 1f); float num2 = 1f + skillFactor * (MasterCookingPlugin.StaminaFactor.Value - 1f); float num3 = 1f + skillFactor * (MasterCookingPlugin.RegenFactor.Value - 1f); float num4 = 1f + skillFactor * (MasterCookingPlugin.EitrFactor.Value - 1f); if (item.m_shared.m_food > 0f) { float food = item.m_shared.m_food; SharedData shared = item.m_shared; shared.m_food *= num; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Health: {food:F1} -> {item.m_shared.m_food:F1} (x{num:F2})"); } } if (item.m_shared.m_foodStamina > 0f) { float foodStamina = item.m_shared.m_foodStamina; SharedData shared2 = item.m_shared; shared2.m_foodStamina *= num2; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Stamina: {foodStamina:F1} -> {item.m_shared.m_foodStamina:F1} (x{num2:F2})"); } } if (item.m_shared.m_foodRegen > 0f) { float foodRegen = item.m_shared.m_foodRegen; SharedData shared3 = item.m_shared; shared3.m_foodRegen *= num3; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Regen: {foodRegen:F2} -> {item.m_shared.m_foodRegen:F2} (x{num3:F2})"); } } if (item.m_shared.m_foodEitr > 0f) { float foodEitr = item.m_shared.m_foodEitr; SharedData shared4 = item.m_shared; shared4.m_foodEitr *= num4; if (MasterCookingPlugin.LogDebugInfo.Value) { MasterCookingPlugin.Logger.LogInfo((object)$"Eitr: {foodEitr:F1} -> {item.m_shared.m_foodEitr:F1} (x{num4:F2})"); } } } } }