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.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: AssemblyCompany("AutoRestockFish")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("0.0.2.0")]
[assembly: AssemblyInformationalVersion("0.0.2")]
[assembly: AssemblyProduct("AutoRestockFish")]
[assembly: AssemblyTitle("AutoRestockFish")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.2.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 AutoRestockFish
{
[BepInPlugin("xuthics.autoFish", "AutoRestockFish", "0.0.2")]
public class Plugin : BaseUnityPlugin
{
[HarmonyPatch(typeof(Item), "BuyProductServer")]
private class BuyProductServerPatch
{
private static bool Prefix(Item __instance, out bool __result)
{
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
select (x)).ToList();
if (list.Count > 0)
{
Item val = list.First();
ItemSO itemSO = __instance.itemSO;
ref int maxDays = ref ((ProductSO)((itemSO is ProductSO) ? itemSO : null)).maxDays;
ItemSO itemSO2 = val.itemSO;
maxDays = ((ProductSO)((itemSO2 is ProductSO) ? itemSO2 : null)).maxDays;
Object.Destroy((Object)(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 static ManualLogSource Logger;
private Harmony m_harmony = new Harmony("xuthics.autoFish");
private static string[] autoFishTypes = new string[11]
{
"Regular Fish", "Brown Fish", "Grey Fish", "Green Fish", "Orange Roughy", "Carp", "Swordfish", "Octopus", "Baby Shark", "Trout",
"Lobster"
};
private void Awake()
{
Logger = ((BaseUnityPlugin)this).Logger;
Logger.LogInfo((object)"Plugin AutoRestockFish v0.0.2 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.2";
}
}