Decompiled source of Inverse Coilhead v0.1.0

InverseCoilhead.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
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 HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("InverseCoilhead")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("A mod which changes the coilhead's behavior so that it moves only when a player is looking at it")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("InverseCoilhead")]
[assembly: AssemblyTitle("InverseCoilhead")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 InverseCoil
{
	[BepInPlugin("InverseCoilhead", "InverseCoilhead", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(SpringManAI))]
		[HarmonyPatch("Update")]
		public static class InverseCoilPatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				foreach (CodeInstruction instruction in instructions)
				{
					if (instruction.opcode == OpCodes.Ldfld && instruction.operand.Equals(typeof(SpringManAI).GetField("currentChaseSpeed", BindingFlags.Instance | BindingFlags.NonPublic)))
					{
						yield return new CodeInstruction(OpCodes.Pop, (object)null);
						yield return new CodeInstruction(OpCodes.Ldc_R4, (object)14f);
					}
					else
					{
						yield return instruction;
					}
					if (instruction.opcode == OpCodes.Blt)
					{
						yield return new CodeInstruction(OpCodes.Ldloc_1, (object)null);
						yield return new CodeInstruction(OpCodes.Ldc_I4_0, (object)null);
						yield return new CodeInstruction(OpCodes.Ceq, (object)null);
						yield return new CodeInstruction(OpCodes.Stloc_1, (object)null);
					}
				}
			}
		}

		public static Plugin Instance;

		private Harmony harmony = new Harmony("InverseCoilhead");

		private void Awake()
		{
			Instance = this;
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Inverse Coil active!");
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "InverseCoilhead";

		public const string PLUGIN_NAME = "InverseCoilhead";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}