using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OneMoreMeal")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OneMoreMeal")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a6577b0f-52a5-4a4e-969d-e2844121e4b7")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("com.zhaila.valheim.onemoremeal", "OneMoreMeal", "0.9.1")]
public class OneMoreMealMod : BaseUnityPlugin
{
private void Awake()
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
Harmony val = new Harmony("com.zhaila.valheim.onemoremeal");
val.PatchAll();
((BaseUnityPlugin)this).Logger.LogInfo((object)"OneMoreMeal Mod Loaded!");
}
}
[HarmonyPatch(typeof(Player))]
public static class FoodLimitPatch
{
[HarmonyPatch("Awake")]
[HarmonyPostfix]
private static void Postfix(Player __instance)
{
FieldInfo field = typeof(Player).GetField("m_maxFoods", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public);
if (field != null)
{
field.SetValue(__instance, 4);
}
}
}
[HarmonyPatch(typeof(Player), "EatFood")]
public static class EatFoodPatch
{
[HarmonyTranspiler]
private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
List<CodeInstruction> list = new List<CodeInstruction>(instructions);
for (int i = 0; i < list.Count; i++)
{
if (list[i].opcode == OpCodes.Ldc_I4_3)
{
list[i].opcode = OpCodes.Ldc_I4_4;
}
}
return list;
}
}
[HarmonyPatch(typeof(Player), "CanEat")]
public static class CanEatPatch
{
[HarmonyPostfix]
private static void Postfix(Player __instance, ref bool __result, ItemData item)
{
foreach (Food food in __instance.m_foods)
{
if (food.m_item.m_shared.m_name == item.m_shared.m_name && food.CanEatAgain())
{
__result = true;
return;
}
}
__result = __instance.m_foods.Count < 4;
}
}
public static class FoodExtensions
{
public static bool CanEatAgain(this Food food)
{
return food.m_time < food.m_item.m_shared.m_foodBurnTime / 2f;
}
}
[HarmonyPatch(typeof(Player), "EatFood")]
public static class EatFoodEffectPatch
{
[HarmonyPostfix]
private static void Postfix(Player __instance, ItemData item)
{
//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0103: Unknown result type (might be due to invalid IL or missing references)
//IL_0114: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_012c: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014e: Unknown result type (might be due to invalid IL or missing references)
//IL_0161: Expected O, but got Unknown
if (__instance.m_foods.Count >= 4)
{
return;
}
bool flag = false;
foreach (Food food in __instance.m_foods)
{
if (food.m_item.m_shared.m_name == item.m_shared.m_name)
{
flag = true;
if (food.CanEatAgain())
{
food.m_time = item.m_shared.m_foodBurnTime;
food.m_health = item.m_shared.m_food;
food.m_stamina = item.m_shared.m_foodStamina;
food.m_eitr = item.m_shared.m_foodEitr;
__instance.UpdateFood(0f, true);
}
}
}
if (!flag && __instance.m_foods.Count < 4)
{
Food item2 = new Food
{
m_name = item.m_shared.m_name,
m_item = item,
m_time = item.m_shared.m_foodBurnTime,
m_health = item.m_shared.m_food,
m_stamina = item.m_shared.m_foodStamina,
m_eitr = item.m_shared.m_foodEitr
};
__instance.m_foods.Add(item2);
__instance.UpdateFood(0f, true);
}
}
}
[HarmonyPatch(typeof(Player), "UpdateFood")]
public static class UpdateFoodPatch
{
[HarmonyPostfix]
private static void Postfix(Player __instance)
{
if (__instance.m_foods.Count > 4)
{
__instance.m_foods.RemoveRange(4, __instance.m_foods.Count - 4);
}
}
}
[HarmonyPatch(typeof(Hud), "Awake")]
public static class HudPatch
{
private static void Postfix(Hud __instance)
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_012a: Unknown result type (might be due to invalid IL or missing references)
//IL_012f: Unknown result type (might be due to invalid IL or missing references)
//IL_019f: Unknown result type (might be due to invalid IL or missing references)
//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
Array.Resize(ref __instance.m_foodBars, 4);
Array.Resize(ref __instance.m_foodIcons, 4);
Array.Resize(ref __instance.m_foodTime, 4);
GameObject val = Object.Instantiate<GameObject>(((Component)__instance.m_foodBars[0]).gameObject, ((Component)__instance.m_foodBars[0]).transform.parent);
__instance.m_foodBars[3] = val.GetComponent<Image>();
val.transform.SetParent(((Component)__instance.m_foodBars[0]).transform.parent, false);
val.transform.localPosition = ((Component)__instance.m_foodBars[0]).transform.localPosition + new Vector3(0f, 138f, 0f);
GameObject val2 = Object.Instantiate<GameObject>(((Component)__instance.m_foodIcons[0]).gameObject, ((Component)__instance.m_foodIcons[0]).transform.parent);
__instance.m_foodIcons[3] = val2.GetComponent<Image>();
val2.transform.SetParent(((Component)__instance.m_foodIcons[0]).transform.parent, false);
val2.transform.localPosition = ((Component)__instance.m_foodIcons[0]).transform.localPosition + new Vector3(0f, 138f, 0f);
GameObject val3 = Object.Instantiate<GameObject>(((Component)__instance.m_foodTime[0]).gameObject, __instance.m_foodTime[0].transform.parent);
__instance.m_foodTime[3] = (TMP_Text)(object)val3.GetComponent<TextMeshProUGUI>();
val3.transform.SetParent(__instance.m_foodTime[0].transform.parent, false);
val3.transform.localPosition = __instance.m_foodTime[0].transform.localPosition + new Vector3(0f, 138f, 0f);
}
}