Decompiled source of Trypophobia v1.0.0

BepInEx/plugins/Trypophobia.dll

Decompiled 11 months ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Trypophobia.Patches;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Trypophobia")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Trypophobia")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("96b0a3f7-a1c3-489f-b993-5909273abd70")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Trypophobia
{
	[BepInPlugin("Baba.Trypophobia", "Trypophobia", "1.0.0")]
	public class TPModBase : BaseUnityPlugin
	{
		public const string modGUID = "Baba.Trypophobia";

		public const string modName = "Trypophobia";

		public const string modVersion = "1.0.0";

		private readonly Harmony harmony = new Harmony("Baba.Trypophobia");

		public static ManualLogSource mls;

		public static Texture2D texture;

		private void Awake()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			mls = ((BaseUnityPlugin)this).Logger;
			try
			{
				string path = Path.Combine(Paths.PluginPath, "Trypophobia".ToLower(), "hive.png");
				texture = new Texture2D(2, 2);
				ImageConversion.LoadImage(texture, File.ReadAllBytes(path));
			}
			catch (Exception ex)
			{
				mls.LogError((object)("Failed to load hive.png texture with exception error " + ex.Message));
			}
			new Harmony("Baba.Trypophobia").PatchAll(typeof(BeeHivePatch));
			new Harmony("Baba.Trypophobia").PatchAll(typeof(ScrapPatch));
			mls.LogInfo((object)"Trypophobia successfully loaded!");
		}
	}
}
namespace Trypophobia.Patches
{
	[HarmonyPatch(typeof(GrabbableObject), "SetScrapValue")]
	internal class ScrapPatch
	{
		private static void Postfix(GrabbableObject __instance)
		{
			if (__instance.itemProperties.itemName == "Hive")
			{
				Renderer component = ((Component)__instance).GetComponent<Renderer>();
				component.material.EnableKeyword("_NORMALMAP");
				component.material.SetTexture("_NormalMap", (Texture)null);
				component.material.mainTexture = (Texture)(object)TPModBase.texture;
			}
		}
	}
	[HarmonyPatch(typeof(RedLocustBees), "Start")]
	internal class BeeHivePatch
	{
		private static void Postfix(RedLocustBees __instance)
		{
			Renderer component = ((Component)__instance.hive).GetComponent<Renderer>();
			component.material.EnableKeyword("_NORMALMAP");
			component.material.SetTexture("_NormalMap", (Texture)null);
			component.material.mainTexture = (Texture)(object)TPModBase.texture;
		}
	}
}