using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("FullAutoFeed")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("FullAutoFeed")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("D8D5471F-1880-41C5-BA83-FB86191E4BDD")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("com.lan.FullAutoFeed", "全自动喂食", "1.0.0")]
public class FullAutoFeed : 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.lan.FullAutoFeed");
val.PatchAll();
Debug.LogWarning((object)"全自动喂食 --作者:她说缝上都不给我");
}
}
[HarmonyPatch(typeof(BlockAnimal))]
public class BlockAnimalPatch
{
private static readonly FieldInfo _isFed = AccessTools.Field(typeof(BlockAnimal), "isFed");
[HarmonyPrefix]
[HarmonyPatch("OnNetworkSpawn")]
private static bool Prefix(BlockAnimal __instance)
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer)
{
return true;
}
GameManager val = Object.FindObjectOfType<GameManager>();
if ((Object)(object)val != (Object)null)
{
NetworkVariable<bool> val2 = (NetworkVariable<bool>)_isFed.GetValue(__instance);
val2.Value = true;
string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Translations"), TableEntryReference.op_Implicit(((ItemSO)((Block)__instance).blockSO).itemName), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
val.IncrementCoinsServer(-10, (TransactionType)6, "成功喂食了一个" + localizedString);
}
else
{
Debug.LogError((object)"GameManager 未找到!");
}
return true;
}
[HarmonyPrefix]
[HarmonyPatch("OnDayChanged")]
private static bool PrefixOnDayChanged(BlockAnimal __instance)
{
//IL_007b: Unknown result type (might be due to invalid IL or missing references)
//IL_008b: Unknown result type (might be due to invalid IL or missing references)
if (!((NetworkBehaviour)__instance).IsServer)
{
return true;
}
NetworkVariable<bool> val = (NetworkVariable<bool>)_isFed.GetValue(__instance);
if (((NetworkBehaviour)__instance).IsServer && val.Value)
{
NetworkVariable<int> dayCounter = __instance.dayCounter;
int value = dayCounter.Value + 1;
dayCounter.Value = value;
}
GameManager val2 = Object.FindObjectOfType<GameManager>();
if ((Object)(object)val2 != (Object)null)
{
val.Value = true;
string localizedString = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("Translations"), TableEntryReference.op_Implicit(((ItemSO)((Block)__instance).blockSO).itemName), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
val2.IncrementCoinsServer(-10, (TransactionType)6, "成功喂食了一个" + localizedString);
}
else
{
Debug.LogError((object)"GameManager 未找到!");
}
return false;
}
}