Decompiled source of AutoEat v1.2.0

gaakrin.autoeat/AutoEat.dll

Decompiled 2 weeks ago
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("AutoEat")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("AutoEat")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c5a5e412-54df-4af1-aabd-09a17d5cc70d")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("gaakrin.autoeat", "AutoEat", "1.2.0")]
public class AutoEat : BaseUnityPlugin
{
	private ConfigEntry<bool> enableAutoEat;

	private float[] autoEatCountdowns = new float[8];

	private bool[] hasShown = new bool[8];

	private void Awake()
	{
		enableAutoEat = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "EnableAutoEat", true, "Enable/disable AutoEat");
	}

	private void Update()
	{
		if (!enableAutoEat.Value)
		{
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null)
		{
			return;
		}
		List<Food> foods = localPlayer.GetFoods();
		for (int i = 0; i < foods.Count; i++)
		{
			Food val = foods[i];
			Inventory inventory = ((Humanoid)localPlayer).GetInventory();
			ItemData item = inventory.GetItem(val.m_item.m_shared.m_name, -1, false);
			if (item != null && val.CanEatAgain())
			{
				if (!hasShown[i])
				{
					MessageHud.instance.ShowMessage((MessageType)2, "Auto eating " + val.m_item.m_shared.m_name + " in 5 mins", 0, (Sprite)null, false);
					hasShown[i] = true;
				}
				autoEatCountdowns[i] += Time.deltaTime;
				if (autoEatCountdowns[i] >= 290f)
				{
					((Humanoid)localPlayer).ConsumeItem(inventory, item, false);
					autoEatCountdowns[i] = 0f;
					hasShown[i] = false;
				}
			}
		}
	}
}