Decompiled source of WeedKillerFixes v1.1.0

WeedKillerFixes.dll

Decompiled 3 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
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: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("WeedKillerFixes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Fixes some major issues with weed killer")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+6460b95f64a34da825901c137ae0f252bcb89b13")]
[assembly: AssemblyProduct("WeedKillerFixes")]
[assembly: AssemblyTitle("WeedKillerFixes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.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 WeedKillerFixes
{
	[BepInPlugin("butterystancakes.lethalcompany.weedkillerfixes", "Weed Killer Fixes", "1.1.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string PLUGIN_GUID = "butterystancakes.lethalcompany.weedkillerfixes";

		private const string PLUGIN_NAME = "Weed Killer Fixes";

		private const string PLUGIN_VERSION = "1.1.0";

		internal static ManualLogSource Logger;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			Logger = ((BaseUnityPlugin)this).Logger;
			new Harmony("butterystancakes.lethalcompany.weedkillerfixes").PatchAll();
			Logger.LogInfo((object)"Weed Killer Fixes v1.1.0 loaded");
		}
	}
	[HarmonyPatch]
	internal class WeedKillerFixesPatches
	{
		[HarmonyPatch(typeof(SprayPaintItem), "TrySprayingWeedKillerBottle")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> TransTrySprayingWeedKillerBottle(IEnumerable<CodeInstruction> instructions)
		{
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			MethodInfo methodInfo = AccessTools.Method(typeof(GameObject), "CompareTag", (Type[])null, (Type[])null);
			MethodInfo methodInfo2 = AccessTools.DeclaredPropertyGetter(typeof(Time), "deltaTime");
			for (int i = 2; i < list.Count - 1; i++)
			{
				if (list[i].opcode == OpCodes.Call)
				{
					if (list[i].operand.ToString().Contains("Raycast") && list[i - 2].opcode == OpCodes.Ldc_I4)
					{
						list[i - 2].operand = (int)list[i - 2].operand & ~(1 << LayerMask.NameToLayer("Room"));
						Plugin.Logger.LogDebug((object)"Transpiler: Simplify layer mask");
					}
					else if ((MethodInfo)list[i].operand == methodInfo2)
					{
						list[i].opcode = OpCodes.Ldfld;
						list[i].operand = AccessTools.Field(typeof(SprayPaintItem), "sprayIntervalSpeed");
						list.Insert(i, new CodeInstruction(OpCodes.Ldarg_0, (object)null));
						Plugin.Logger.LogDebug((object)"Transpiler: Fix addVehicleHPInterval time");
					}
				}
				else if (list[i].opcode == OpCodes.Ldstr && (string)list[i].operand == "MoldSporeCollider" && list[i + 1].opcode == OpCodes.Callvirt && (MethodInfo)list[i + 1].operand == methodInfo)
				{
					list[i].operand = "MoldSpore";
					Plugin.Logger.LogDebug((object)"Transpiler: Fix wrong tag being checked");
				}
			}
			return list;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "WeedKillerFixes";

		public const string PLUGIN_NAME = "WeedKillerFixes";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}