Decompiled source of AutoRestockFish UpdatedForEastTown v1.0.0

Krissy_AutoRestock.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Unity.Netcode;
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(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyInformationalVersion("0.0.3")]
[assembly: AssemblyTitle("reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("reeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6e37af03-9cef-44ca-88aa-81f436b0f0f1")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace AutoRestockFish
{
	[BepInPlugin("xuthics.autoFish", "AutoRestockFish", "0.0.3")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(Item), "BuyProductServer")]
		private class BuyProductServerPatch
		{
			private static bool Prefix(Item __instance, out bool __result)
			{
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Expected O, but got Unknown
				if (!((NetworkBehaviour)__instance).IsServer)
				{
					__result = false;
					return false;
				}
				if (__instance.amount.Value <= 0)
				{
					__result = false;
					return false;
				}
				string name = ((Object)__instance.itemSO).name;
				long itemID = __instance.itemSO.id;
				if (autoFishTypes.Contains(name))
				{
					List<Item> list = (from x in Object.FindObjectsOfType<Item>()
						where x.itemSO is ProductSO && x.amount.Value > 0 && x.IsInFreezer() && x.itemSO.id == itemID && !x.IsExpired()
						select (x)).ToList();
					if (list.Count > 0)
					{
						Item val = list.First();
						__instance.dayCounter = val.dayCounter;
						Object.Destroy((Object)((Component)val).gameObject);
					}
					else
					{
						NetworkVariable<int> amount = __instance.amount;
						amount.Value -= 1;
					}
					__result = true;
				}
				else
				{
					NetworkVariable<int> amount2 = __instance.amount;
					amount2.Value -= 1;
					__result = true;
				}
				return false;
			}
		}

		internal ManualLogSource MyLogger;

		private Harmony m_harmony = new Harmony("xuthics.autoFish");

		private static string[] autoFishTypes = new string[14]
		{
			"Regular Fish", "Brown Fish", "Grey Fish", "Green Fish", "Orange Roughy", "Carp", "Swordfish", "Octopus", "Baby Shark", "Trout",
			"Lobster", "Tuna", "Ray", "Goby"
		};

		private void Awake()
		{
			MyLogger = ((BaseUnityPlugin)this).Logger;
			MyLogger.LogInfo((object)"Plugin AutoRestockFish v0.0.3 is loaded!");
			m_harmony.PatchAll();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "AutoRestockFish";

		public const string PLUGIN_NAME = "AutoRestockFish";

		public const string PLUGIN_VERSION = "0.0.3";
	}
}
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 Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}