Decompiled source of MiscFixes v1.0.0

MiscFixes.dll

Decompiled 5 hours 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 EntityStates;
using EntityStates.LunarExploderMonster;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
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("MiscFixes")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d499e3e7f47576ef7dda072463273a315406e375")]
[assembly: AssemblyProduct("MiscFixes")]
[assembly: AssemblyTitle("MiscFixes")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
[module: UnverifiableCode]
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 MiscFixes
{
	[HarmonyPatch]
	public class FixVanilla
	{
		[HarmonyPatch(typeof(FlickerLight), "Update")]
		[HarmonyPrefix]
		public static bool FixFlicker(FlickerLight __instance)
		{
			return Object.op_Implicit((Object)(object)__instance.light);
		}

		[HarmonyPatch(typeof(Indicator), "SetVisibleInternal")]
		[HarmonyILManipulator]
		public static void FixIndicator(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Renderer>(x, "set_enabled")
			}))
			{
				return;
			}
			val.Remove();
			val.EmitDelegate<Action<Renderer, bool>>((Action<Renderer, bool>)delegate(Renderer renderer, bool newVisible)
			{
				if (Object.op_Implicit((Object)(object)renderer))
				{
					renderer.enabled = newVisible;
				}
			});
		}

		[HarmonyPatch(typeof(DeathState), "FixedUpdate")]
		[HarmonyILManipulator]
		public static void FixExplode(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILCursor[] array = Array.Empty<ILCursor>();
			if (!val.TryFindNext(ref array, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DeathState>(x, "FireExplosion"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "SetActive")
			}))
			{
				return;
			}
			ILCursor obj = array[0];
			ILCursor val2 = array[1];
			int index = obj.Index;
			obj.Index = index + 1;
			obj.MoveAfterLabels();
			index = val2.Index;
			val2.Index = index + 1;
			obj.Emit(OpCodes.Br, (object)val2.MarkLabel());
			val2.Emit(OpCodes.Ldarg_0);
			val2.EmitDelegate<Action<DeathState>>((Action<DeathState>)delegate(DeathState self)
			{
				if (Object.op_Implicit((Object)(object)((EntityState)self).modelLocator) && Object.op_Implicit((Object)(object)((EntityState)self).modelLocator.modelTransform))
				{
					((Component)((EntityState)self).modelLocator.modelTransform).gameObject.SetActive(false);
				}
			});
		}
	}
	[BepInPlugin("com.score.MiscFixes", "MiscFixes", "1.0.0")]
	public class MiscFixesPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.score.MiscFixes";

		public const string PluginAuthor = "score";

		public const string PluginName = "MiscFixes";

		public const string PluginVersion = "1.0.0";

		public static InteractableSpawnCard prefab;

		public static MiscFixesPlugin Instance { get; private set; }

		public void Awake()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			new Harmony("com.score.MiscFixes").PatchAll(Assembly.GetExecutingAssembly());
		}
	}
}