Decompiled source of Decay IRF NRE Fix v1.0.0

plugins/DecayIRFNREFix.dll

Decompiled 3 weeks ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Core.Logging.Interpolation;
using BepInEx.Logging;
using BepInEx.Unity.IL2CPP;
using Enemies;
using GameData;
using HarmonyLib;
using IRF;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DecayIRFNREFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyProduct("DecayIRFNREFix")]
[assembly: AssemblyTitle("DecayIRFNREFix")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace DecayIRFNREFix;

[HarmonyPatch(typeof(EnemyPrefabManager), "BuildEnemyPrefab")]
public static class EnemyPrefabManagerPatch
{
	public static void Postfix(EnemyDataBlock data, ref GameObject __result)
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Expected O, but got Unknown
		bool flag = default(bool);
		foreach (InstancedRenderFeature componentsInChild in __result.GetComponentsInChildren<InstancedRenderFeature>(true))
		{
			if (!((Object)(object)componentsInChild.Descriptor != (Object)null))
			{
				ManualLogSource l = Plugin.L;
				BepInExDebugLogInterpolatedStringHandler val = new BepInExDebugLogInterpolatedStringHandler(51, 2, ref flag);
				if (flag)
				{
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Found invalid IRF on enemy '");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>(((GameDataBlockBase<EnemyDataBlock>)(object)data).name);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("' (pID: ");
					((BepInExLogInterpolatedStringHandler)val).AppendFormatted<uint>(((GameDataBlockBase<EnemyDataBlock>)(object)data).persistentID);
					((BepInExLogInterpolatedStringHandler)val).AppendLiteral("), removing ...");
				}
				l.LogDebug(val);
				Object.Destroy((Object)(object)componentsInChild);
			}
		}
	}
}
[BepInPlugin("dev.aurirex.gtfo.DecayIRFNREFix", "DecayIRFNREFix", "1.0.0")]
public class Plugin : BasePlugin
{
	public const string GUID = "dev.aurirex.gtfo.DecayIRFNREFix";

	public const string MOD_NAME = "DecayIRFNREFix";

	public const string VERSION_STRING = "1.0.0";

	private static Harmony _harmony;

	internal static ManualLogSource L;

	public override void Load()
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Expected O, but got Unknown
		L = ((BasePlugin)this).Log;
		_harmony = new Harmony("dev.aurirex.gtfo.DecayIRFNREFix");
		_harmony.PatchAll(Assembly.GetExecutingAssembly());
	}
}