Decompiled source of Outline Patch v1.0.0

OutlinePatch.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OutlinePatch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("GeeztJeez")]
[assembly: AssemblyProduct("OutlinePatch")]
[assembly: AssemblyCopyright("Copyright © Geezt Lifetime")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("7acfaef0-7669-4401-8bff-5a9a02e18c75")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace OutlinePatch;

[BepInPlugin("GeeztJeez.OutlinePatch", "OutlinePatch", "1.0.0")]
internal class Loader : BaseUnityPlugin
{
	public static bool enableDebug;

	public AssetBundle assetBundle;

	public AssetBundle sceneBundle;

	public static string modName;

	private void ApplyHarmony()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			new Harmony(modName).PatchAll(Assembly.GetExecutingAssembly());
			Log("Harmony patched successfully!");
		}
		catch (Exception ex)
		{
			LogError("Harmony patch failed: " + ex);
			LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation...");
		}
	}

	private void Awake()
	{
		try
		{
			ApplyHarmony();
		}
		catch (Exception ex)
		{
			LogError("Fatal error, mod loading failed: " + ex);
			LogWarning("Please contact Geezt Jeez or try reloading the game for proper installation...");
		}
	}

	public static void Log(string message)
	{
		if (enableDebug)
		{
			Debug.Log((object)(modName + " [Log] : " + message));
		}
	}

	public static void LogWarning(string message)
	{
		if (enableDebug)
		{
			Debug.LogWarning((object)(modName + " [Warn] : " + message));
		}
	}

	public static void LogError(string message)
	{
		if (enableDebug)
		{
			Debug.LogError((object)(modName + " [Error] :" + message));
		}
	}

	static Loader()
	{
		modName = "OutlinePatch";
	}
}
[HarmonyPatch(typeof(Outline))]
public static class OutlineRendererPatch
{
	private static void CleanRenderers(Outline __instance)
	{
		if ((Object)(object)__instance == (Object)null)
		{
			return;
		}
		Renderer[] value = Traverse.Create((object)__instance).Field("renderers").GetValue<Renderer[]>();
		if (value != null)
		{
			Renderer[] array = value.Where((Renderer r) => (Object)(object)r != (Object)null).ToArray();
			if (array.Length != value.Length)
			{
				Traverse.Create((object)__instance).Field("renderers").SetValue((object)array);
			}
		}
	}

	[HarmonyPatch("OnEnable")]
	[HarmonyPrefix]
	private static void OnEnablePrefix(Outline __instance)
	{
		CleanRenderers(__instance);
	}

	[HarmonyPatch("OnDisable")]
	[HarmonyPrefix]
	private static void OnDisablePrefix(Outline __instance)
	{
		CleanRenderers(__instance);
	}
}