Decompiled source of UltraFumos v1.4.0

UltraFumos.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using PluginConfig.API;
using PluginConfig.API.Fields;
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("UltraFumos")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Replaces various Ultrakill things with fumos")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: AssemblyInformationalVersion("1.4.0+f49811a2dc54841db87b908c4bf0d8d6ee75c863")]
[assembly: AssemblyProduct("Ultrafumos")]
[assembly: AssemblyTitle("UltraFumos")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.4.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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 FumoSkull
{
	public enum Fumo
	{
		Cirno,
		Reimu,
		Yuyuko,
		Koishi,
		Sakuya,
		Youmu,
		Mokou,
		Patchouli
	}
	public static class FumoExtensions
	{
		public static string GameObjectName(this Fumo fumo)
		{
			if (fumo == Fumo.Yuyuko)
			{
				return "YuYuGO";
			}
			return $"{fumo}GO";
		}
	}
	public class FumoConfig
	{
		private PluginConfigurator config;

		private BoolField cirno;

		private BoolField reimu;

		private BoolField yuyuko;

		private BoolField koishi;

		private BoolField sakuya;

		private BoolField youmu;

		private BoolField mokou;

		private BoolField patchouli;

		public bool IsCirnoDisabled => !cirno.value;

		public bool IsReimuDisabled => !reimu.value;

		public bool IsYuyukoDisabled => !yuyuko.value;

		public bool IsKoishiDisabled => !koishi.value;

		public bool IsSakuyaDisabled => !sakuya.value;

		public bool IsYoumuDisabled => !youmu.value;

		public bool IsMokouDisabled => !mokou.value;

		public bool IsPatchouliDisabled => !patchouli.value;

		public void Awake()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Expected O, but got Unknown
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Expected O, but got Unknown
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Expected O, but got Unknown
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Expected O, but got Unknown
			config = PluginConfigurator.Create("Ultrafumos", "UltraFumos");
			Texture2D val = FumoSkulls.FumoBundle.LoadAsset<Texture2D>("icon.png");
			config.image = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
			cirno = new BoolField(config.rootPanel, "Replace blue skulls with Cirno", "skull.blue.cirno", true);
			reimu = new BoolField(config.rootPanel, "Replace red skulls with Reimu", "skull.red.reimu", true);
			yuyuko = new BoolField(config.rootPanel, "Replace torches with Yuyuko", "torch.yuyuko", true);
			koishi = new BoolField(config.rootPanel, "Replace soap with Koishi", "soap.koishi", true);
			sakuya = new BoolField(config.rootPanel, "Replace rockets with Sakuya", "grenade.rocket.sakuya", true);
			youmu = new BoolField(config.rootPanel, "Replace mines with Youmu", "mine.youmu", true);
			mokou = new BoolField(config.rootPanel, "Replace core eject with Mokou", "grenade.core_eject.mokou", true);
			patchouli = new BoolField(config.rootPanel, "Replace books and tablets with Patchouli", "book.patchouli", true);
		}
	}
	[BepInPlugin("UltraFumos", "Ultrafumos", "1.4.0")]
	public class FumoSkulls : BaseUnityPlugin
	{
		private static readonly Dictionary<Fumo, GameObject> allFumos = new Dictionary<Fumo, GameObject>();

		public static readonly FumoConfig Config = new FumoConfig();

		private Harmony harmony;

		public static AssetBundle FumoBundle;

		public void Awake()
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			FumoBundle = AssetBundle.LoadFromStream(typeof(FumoSkulls).Assembly.GetManifestResourceStream("fumoskulls"));
			FumoBundle.LoadAllAssets();
			Config.Awake();
			harmony = new Harmony("UltraFumos");
			harmony.PatchAll();
			foreach (Fumo value in Enum.GetValues(typeof(Fumo)))
			{
				allFumos.Add(value, FumoBundle.LoadAsset<GameObject>(value.GameObjectName()));
			}
		}

		public static void CreateFumo(Fumo fumoType, Transform masterSkull, Vector3 position, Quaternion rotation, Vector3 scale, Shader shader)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)("Swapping " + ((Object)masterSkull).name + " to " + fumoType));
			GameObject obj = Object.Instantiate<GameObject>(allFumos[fumoType], masterSkull);
			obj.SetActive(true);
			obj.transform.localRotation = rotation;
			obj.transform.localPosition = position;
			obj.transform.localScale = scale;
			Renderer[] componentsInChildren = obj.GetComponentsInChildren<Renderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Material[] materials = componentsInChildren[i].materials;
				for (int j = 0; j < materials.Length; j++)
				{
					materials[j].shader = shader;
				}
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UltraFumos";

		public const string PLUGIN_NAME = "Ultrafumos";

		public const string PLUGIN_VERSION = "1.4.0";
	}
}
namespace FumoSkull.Patches
{
	[HarmonyPatch(typeof(Landmine), "Start")]
	internal static class FumofiyLandmine
	{
		private static void Postfix(Landmine __instance)
		{
			//IL_0060: 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_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (!FumoSkulls.Config.IsYoumuDisabled)
			{
				MeshRenderer componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
				GameObject value = Traverse.Create((object)__instance).Field<GameObject>("lightCylinder").Value;
				((Renderer)value.GetComponentInChildren<MeshRenderer>()).enabled = false;
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					((Renderer)componentInChildren).enabled = false;
					FumoSkulls.CreateFumo(Fumo.Youmu, value.transform, new Vector3(0f, 0f, 0f), Quaternion.Euler(0f, 270f, 0f), new Vector3(1f, 1f, 1f) * 0.001f, ((Renderer)componentInChildren).material.shader);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Grenade), "Awake")]
	internal static class FumofiyRocket
	{
		private static void Postfix(Grenade __instance)
		{
			if (__instance.rocket)
			{
				PatchRocket(__instance);
			}
			else
			{
				PatchCoreEject(__instance);
			}
		}

		private static void PatchRocket(Grenade grenade)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			if (FumoSkulls.Config.IsSakuyaDisabled)
			{
				return;
			}
			Renderer[] componentsInChildren = (Renderer[])(object)((Component)grenade).gameObject.GetComponentsInChildren<MeshRenderer>();
			Renderer[] array = componentsInChildren;
			if (array.Length != 0)
			{
				for (int i = 0; i < array.Length; i++)
				{
					array[i].enabled = false;
				}
				FumoSkulls.CreateFumo(Fumo.Sakuya, ((Component)grenade).transform, new Vector3(0f, 0f, 2f), Quaternion.Euler(0f, 0f, 90f), new Vector3(10f, 10f, 10f), array[0].material.shader);
			}
		}

		private static void PatchCoreEject(Grenade grenade)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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)
			if (FumoSkulls.Config.IsMokouDisabled)
			{
				return;
			}
			Renderer[] componentsInChildren = (Renderer[])(object)((Component)grenade).gameObject.GetComponentsInChildren<MeshRenderer>();
			Renderer[] array = componentsInChildren;
			if (array.Length != 0)
			{
				for (int i = 0; i < array.Length; i++)
				{
					array[i].enabled = false;
				}
				FumoSkulls.CreateFumo(Fumo.Mokou, ((Component)grenade).transform, new Vector3(0f, -0.5f, 2f), Quaternion.Euler(0f, 0f, 90f), new Vector3(3.5f, 3.5f, 3.5f), array[0].material.shader);
			}
		}
	}
	[HarmonyPatch(typeof(Skull), "Awake")]
	internal static class FumofiySkull
	{
		private static void Postfix(Skull __instance)
		{
			//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_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Invalid comparison between Unknown and I4
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Invalid comparison between Unknown and I4
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: 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)
			ItemType itemType = ((Component)__instance).GetComponent<ItemIdentifier>().itemType;
			if ((int)itemType != 1)
			{
				if ((int)itemType != 2 || FumoSkulls.Config.IsReimuDisabled)
				{
					return;
				}
			}
			else if (FumoSkulls.Config.IsCirnoDisabled)
			{
				return;
			}
			ModifyMaterial value;
			try
			{
				value = Traverse.Create((object)__instance).Field<ModifyMaterial>("mod").Value;
			}
			catch (Exception ex)
			{
				Debug.LogError((object)$"Failed to get `mod` field of skull: {ex.GetType()} {ex.Message}");
				return;
			}
			Renderer value2;
			try
			{
				Traverse obj = Traverse.Create((object)value);
				obj.Method("SetValues", Array.Empty<object>()).GetValue();
				value2 = obj.Field<Renderer>("rend").Value;
			}
			catch (Exception ex2)
			{
				Debug.LogError((object)$"Failed to get `rend` field of modifyMaterial: {ex2.GetType()} {ex2.Message}");
				return;
			}
			if (Object.op_Implicit((Object)(object)value2))
			{
				Fumo fumoType;
				Vector3 position = default(Vector3);
				if ((int)itemType != 1)
				{
					if ((int)itemType != 2)
					{
						return;
					}
					fumoType = Fumo.Reimu;
					((Vector3)(ref position))..ctor(-0.015f, 0f, 0.15f);
				}
				else
				{
					fumoType = Fumo.Cirno;
					((Vector3)(ref position))..ctor(0.05f, 0.03f, 0.1f);
				}
				value2.enabled = false;
				FumoSkulls.CreateFumo(fumoType, ((Component)value2).transform, position, Quaternion.Euler(15f, 0f, 270f), new Vector3(0.8f, 0.8f, 0.8f), value2.material.shader);
			}
			else
			{
				Debug.LogWarning((object)"renderer was null");
			}
		}
	}
	[HarmonyPatch(typeof(Soap), "Start")]
	internal static class FumofiySoap
	{
		private static void Prefix(Soap __instance)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (!FumoSkulls.Config.IsKoishiDisabled)
			{
				Renderer componentInChildren = (Renderer)(object)((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					componentInChildren.enabled = false;
					FumoSkulls.CreateFumo(Fumo.Koishi, ((Component)((Component)componentInChildren).transform.parent).transform, new Vector3(0f, 0.1f, 0f), Quaternion.Euler(270f, 270f, 0f), new Vector3(1f, 1f, 1f) * 2.75f, componentInChildren.material.shader);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Torch), "Start")]
	internal static class FumofiyTorch
	{
		private static void Prefix(Torch __instance)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			if (!FumoSkulls.Config.IsYuyukoDisabled)
			{
				Renderer componentInChildren = (Renderer)(object)((Component)__instance).gameObject.GetComponentInChildren<MeshRenderer>();
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					componentInChildren.enabled = false;
					FumoSkulls.CreateFumo(Fumo.Yuyuko, ((Component)((Component)componentInChildren).transform.parent).transform, new Vector3(0f, 0.1f, 0f), Quaternion.Euler(270f, 270f, 0f), new Vector3(1f, 1f, 1f) * 2.75f, componentInChildren.material.shader);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Readable), "Awake")]
	internal class FumofiyBook
	{
		private static void Prefix(Readable __instance)
		{
			if (!FumoSkulls.Config.IsPatchouliDisabled)
			{
				ItemIdentifier componentInChildren = ((Component)__instance).gameObject.GetComponentInChildren<ItemIdentifier>();
				if (((Object)componentInChildren).name == "Book")
				{
					ReplaceBook(__instance);
				}
				else if (((Object)componentInChildren).name == "BookTablet")
				{
					ReplaceTablet(__instance);
				}
			}
		}

		private static void ReplaceBook(Readable readable)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			Renderer componentInChildren = (Renderer)(object)((Component)readable).gameObject.GetComponentInChildren<MeshRenderer>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.enabled = false;
				FumoSkulls.CreateFumo(Fumo.Patchouli, ((Component)componentInChildren).transform, new Vector3(1.75f, -0.1f, -1.5f), Quaternion.Euler(0f, 180f, 0f), new Vector3(1f, 1f, 1f) * 2.5f, componentInChildren.material.shader);
			}
		}

		private static void ReplaceTablet(Readable readable)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			Renderer componentInChildren = (Renderer)(object)((Component)((Component)readable).gameObject.transform.GetChild(0)).gameObject.GetComponentInChildren<MeshRenderer>();
			if (Object.op_Implicit((Object)(object)componentInChildren))
			{
				componentInChildren.enabled = false;
				FumoSkulls.CreateFumo(Fumo.Patchouli, ((Component)componentInChildren).transform, new Vector3(1f, -0.1f, -1f), Quaternion.Euler(0f, 180f, 0f), new Vector3(1f, 1f, 1f) * 2.5f, componentInChildren.material.shader);
			}
		}
	}
}