Decompiled source of FarmingCompat v1.0.0

Cjayride.FarmingCompat.dll

Decompiled 3 days ago
using System;
using System.Diagnostics;
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 UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("assembly_valheim")]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyCompany("Cjayride.FarmingCompat")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Cjayride.FarmingCompat")]
[assembly: AssemblyTitle("Cjayride.FarmingCompat")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 Cjayride.FarmingCompat
{
	[BepInPlugin("cjayride.FarmingCompat", "FarmingCompat", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string PluginGuid = "cjayride.FarmingCompat";

		public const string PluginName = "FarmingCompat";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log;

		private void Awake()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			Type type = AccessTools.TypeByName("Farming.MassHarvest+HarvestNearbyPickables");
			if (type == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[FarmingCompat] Farming.MassHarvest+HarvestNearbyPickables not found; skip.");
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(type, "isFarmingPickable", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"[FarmingCompat] isFarmingPickable not found; skip.");
				return;
			}
			new Harmony("cjayride.FarmingCompat").Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(FarmingPickableGuard), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"[FarmingCompat] Patched Farming isFarmingPickable (null ZDO guard).");
		}
	}
	internal static class FarmingPickableGuard
	{
		public static bool Prefix(Pickable pickable, ref bool __result)
		{
			if ((Object)(object)pickable == (Object)null || (Object)(object)pickable.m_nview == (Object)null)
			{
				__result = false;
				return false;
			}
			if (pickable.m_nview.GetZDO() == null)
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}