Decompiled source of Pyrophyte v1.0.2

plugins/Pyrophyte/bitmotte.Pyrophyte.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Decorators;
using PluginConfig.API.Fields;
using PluginConfig.API.Functionals;
using Pyrophyte;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;

[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("bitmotte.Pyrophyte")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0")]
[assembly: AssemblyProduct("Pyrophyte")]
[assembly: AssemblyTitle("bitmotte.Pyrophyte")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
public class IHATEYOUIFUCKINGHATEDIEDIEDIEPLEASEJUSTFUCKINGDIE : MonoBehaviour
{
	private void Start()
	{
		((MonoBehaviour)this).Invoke("Hasten", 1f);
	}

	public void Hasten()
	{
		Configurator.UpdateFire();
	}
}
public static class ImageLoader
{
	public static Texture2D LoadPNG(string filePath)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Expected O, but got Unknown
		Texture2D val = null;
		if (File.Exists(filePath))
		{
			byte[] array = File.ReadAllBytes(filePath);
			Plugin.Logger.LogInfo((object)"YES");
			val = new Texture2D(2, 2);
			ImageConversion.LoadImage(val, array);
			((Texture)val).filterMode = (FilterMode)0;
		}
		Plugin.Logger.LogInfo((object)val);
		return val;
	}
}
namespace Pyrophyte
{
	public static class BundleTool
	{
		public static AssetBundle Load(string fileName)
		{
			return AssetBundle.LoadFromMemory(EmbeddedAccess.AccessFile(fileName));
		}
	}
	public static class Configurator
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static PostConfigChangeEvent <0>__UpdateFire;

			public static OnClick <1>__OpenDiscord;
		}

		public static FloatSliderField height;

		public static FloatSliderField width;

		public static FloatSliderField heightOffset;

		public static ColorField color;

		public static FloatSliderField alpha;

		public static IntField frames;

		public static FloatField fps;

		public static ButtonField joinDC;

		public static PluginConfigurator CreateConfigurator()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Expected O, but got Unknown
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c9: Expected O, but got Unknown
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Expected O, but got Unknown
			PluginConfigurator val = PluginConfigurator.Create("Pyrophyte", "bitmotte.Pyrophyte");
			ConfigSpace val2 = new ConfigSpace(val.rootPanel, 32f);
			ConfigHeader val3 = new ConfigHeader(val.rootPanel, "Fire queue may not fully clear . . . If sections of fire are on older config values, it will clear out eventually .", 24);
			ConfigSpace val4 = new ConfigSpace(val.rootPanel, 8f);
			height = new FloatSliderField(val.rootPanel, "Height", "height", new Tuple<float, float>(0f, 32f), 1f);
			width = new FloatSliderField(val.rootPanel, "Width", "width", new Tuple<float, float>(0f, 32f), 2f);
			heightOffset = new FloatSliderField(val.rootPanel, "Height Offset", "height_offset", new Tuple<float, float>(-16f, 16f), -1f);
			ConfigSpace val5 = new ConfigSpace(val.rootPanel, 10f);
			ConfigSpace val6 = new ConfigSpace(val.rootPanel, 10f);
			ConfigHeader val7 = new ConfigHeader(val.rootPanel, "To add a custom fire image, replace `oce.png` in the plugin folder with your image . . . If you want it to be animated, export your video as a spritesheet . It must be in a straight line .", 24);
			ConfigSpace val8 = new ConfigSpace(val.rootPanel, 10f);
			frames = new IntField(val.rootPanel, "Frame Count", "frames", 15);
			fps = new FloatField(val.rootPanel, "Frames per second", "fps", 6f);
			ConfigSpace val9 = new ConfigSpace(val.rootPanel, 15f);
			ConfigHeader val10 = new ConfigHeader(val.rootPanel, "Join my discord for sneak peeks, devlogs, and the possibility to test my mods early ! !", 20, (TextAlignmentOptions)513);
			joinDC = new ButtonField(val.rootPanel, "Join my Discord", "joinDC");
			ConfigSpace val11 = new ConfigSpace(val.rootPanel, 15f);
			object obj = <>O.<0>__UpdateFire;
			if (obj == null)
			{
				PostConfigChangeEvent val12 = UpdateFire;
				<>O.<0>__UpdateFire = val12;
				obj = (object)val12;
			}
			val.postConfigChange += (PostConfigChangeEvent)obj;
			ButtonField obj2 = joinDC;
			object obj3 = <>O.<1>__OpenDiscord;
			if (obj3 == null)
			{
				OnClick val13 = OpenDiscord;
				<>O.<1>__OpenDiscord = val13;
				obj3 = (object)val13;
			}
			obj2.onClick += (OnClick)obj3;
			return val;
		}

		private static void OpenDiscord()
		{
			Process.Start("https://discord.gg/PjSpcEvuB7");
		}

		public static void UpdateFire()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Expected O, but got Unknown
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Expected O, but got Unknown
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			FireObjectPool instance = MonoSingleton<FireObjectPool>.Instance;
			if ((Object)(object)instance != (Object)null)
			{
				instance.firePool.Clear();
				instance.simpleFirePool.Clear();
				GameObject val;
				if ((Object)(object)instance.firePrefab.transform.GetChild(0).Find("fire anchor") == (Object)null)
				{
					val = new GameObject("fire anchor");
					val.transform.parent = instance.firePrefab.transform.GetChild(0);
					Object.Destroy((Object)(object)((Component)instance.firePrefab.transform.GetChild(0).Find("FireSprite")).gameObject);
					val.transform.localPosition = new Vector3(0f, -1.5f, 0f);
					GameObject val2 = new GameObject("custom fire sprite");
					val2.transform.parent = val.transform;
					val2.transform.localScale = new Vector3(1f, 1f, -1f);
					val2.layer = LayerMask.GetMask(new string[1] { "TransparentFX" });
					val2.transform.localPosition = new Vector3(0f, 0f, 0f);
					MeshRenderer val3 = val2.AddComponent<MeshRenderer>();
					val2.AddComponent<MeshFilter>().mesh = MeshMaker.CreatePlaneMesh();
					Material material = new Material(Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/FireMaterial.mat").WaitForCompletion());
					Texture2D mainTexture = ImageLoader.LoadPNG(Assembly.GetExecutingAssembly().Location.Replace("bitmotte.Pyrophyte.dll", "oce.png") ?? "");
					((Renderer)val3).material = material;
					((Renderer)val3).material.mainTexture = (Texture)(object)mainTexture;
					SlideSprite slideSprite = val2.AddComponent<SlideSprite>();
					slideSprite.renderer = val3;
					Object.Destroy((Object)(object)((Component)instance.firePrefab.transform.GetChild(0).Find("Glow")).gameObject);
				}
				else
				{
					val = ((Component)instance.firePrefab.transform.GetChild(0).Find("fire anchor")).gameObject;
				}
				val.transform.localScale = new Vector3(width.value, height.value, 8f);
				val.transform.localPosition = new Vector3(0f, heightOffset.value, 0f);
				SlideSprite componentInChildren = val.GetComponentInChildren<SlideSprite>();
				componentInChildren.frames = frames.value;
				componentInChildren.interval = 1f / fps.value;
				componentInChildren.Setup();
				Texture2D mainTexture2 = ImageLoader.LoadPNG(Assembly.GetExecutingAssembly().Location.Replace("bitmotte.Pyrophyte.dll", "oce.png") ?? "");
				MeshRenderer componentInChildren2 = val.GetComponentInChildren<MeshRenderer>();
				((Renderer)componentInChildren2).material.mainTexture = (Texture)(object)mainTexture2;
				instance.simpleFirePrefab = instance.firePrefab;
				Plugin.Logger.LogInfo((object)"fire changed");
			}
			Plugin.Logger.LogInfo((object)"fire change attempted");
		}
	}
	public static class EmbeddedAccess
	{
		public static byte[] AccessFile(string fileName)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			byte[] array;
			using (Stream stream = executingAssembly.GetManifestResourceStream("Pyrophyte.resources." + fileName))
			{
				if (stream == null)
				{
					return null;
				}
				array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
			}
			return array;
		}
	}
	internal static class MeshMaker
	{
		public static Mesh CreatePlaneMesh()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			Mesh val = new Mesh();
			Vector3[] vertices = (Vector3[])(object)new Vector3[4]
			{
				new Vector3(-0.5f, 0f, 0f),
				new Vector3(0.5f, 0f, 0f),
				new Vector3(-0.5f, 1f, 0f),
				new Vector3(0.5f, 1f, 0f)
			};
			int[] triangles = new int[6] { 0, 3, 1, 3, 0, 2 };
			Vector2[] uv = (Vector2[])(object)new Vector2[4]
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(0f, 1f),
				new Vector2(1f, 1f)
			};
			val.vertices = vertices;
			val.triangles = triangles;
			val.uv = uv;
			val.RecalculateNormals();
			return val;
		}
	}
	[HarmonyPatch(typeof(NewMovement), "Start")]
	public static class patcg
	{
		private static void Prefix(NewMovement __instance)
		{
			Configurator.UpdateFire();
		}
	}
	[BepInPlugin("bitmotte.Pyrophyte", "Pyrophyte", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static PluginConfigurator config;

		private void Awake()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin bitmotte.Pyrophyte is loaded!");
			Harmony val = new Harmony("bitmotte.Pyrophyte");
			val.PatchAll();
			config = Configurator.CreateConfigurator();
		}

		private void OnSceneLoad(Scene scene, LoadSceneMode mode)
		{
		}
	}
	public static class SetupResource
	{
		public static GameObject FixShader(GameObject gameObject)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			Shader shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Environment/Metal/Pattern 1/Metal Pattern 1 8.mat").WaitForCompletion().shader;
			SkinnedMeshRenderer[] componentsInChildren = gameObject.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val in componentsInChildren)
			{
				Material[] materials = ((Renderer)val).materials;
				foreach (Material val2 in materials)
				{
					if (((Object)val2.shader).name == "ULTRAKILL/Master")
					{
						val2.shader = shader;
					}
					if (((Object)val2.shader).name == "Hidden/InternalErrorShader")
					{
						val2.shader = Addressables.LoadAssetAsync<Material>((object)"Assets/Materials/Dev/FadeToWhite.mat").WaitForCompletion().shader;
					}
				}
			}
			MeshRenderer[] componentsInChildren2 = gameObject.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val3 in componentsInChildren2)
			{
				Material[] materials2 = ((Renderer)val3).materials;
				foreach (Material val4 in materials2)
				{
					val4.shader = shader;
				}
			}
			return gameObject;
		}
	}
	public class SlideSprite : MonoBehaviour
	{
		public MeshRenderer renderer;

		public int frames;

		public float interval;

		private float slideDistance;

		private float totalSlideDistance;

		private void Start()
		{
			Setup();
			((MonoBehaviour)this).Invoke("Slide", interval);
		}

		public void Setup()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			slideDistance = 1f / (float)frames;
			totalSlideDistance = 0f;
			((Renderer)renderer).material.mainTextureScale = new Vector2(slideDistance, 1f);
		}

		public void Slide()
		{
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).Invoke("Slide", interval);
			totalSlideDistance += slideDistance;
			((Renderer)renderer).material.mainTextureOffset = new Vector2(totalSlideDistance, 0f);
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "bitmotte.Pyrophyte";

		public const string PLUGIN_NAME = "Pyrophyte";

		public const string PLUGIN_VERSION = "1.1.0";
	}
}