Decompiled source of MajoraHauntedMask v1.3.1

MajorasMask.dll

Decompiled 8 months ago
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.Configuration;
using BepInEx.Logging;
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("MajorasMask")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MajorasMask")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("302d6ed6-4d7a-4f7d-b0ab-240c5c024d2e")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace MajorasMask
{
	[BepInPlugin("MajorasMask", "MajorasMask", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static PluginLogger logger = new PluginLogger();

		public static Plugin Instance;

		private static AssetBundle Bundle;

		public static GameObject MajorasMesh;

		private void Awake()
		{
			Instance = this;
			ConfigEntry<bool> val = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Logging", true, (ConfigDescription)null);
			logger.EnableLogging(val.Value);
			logger.LogInfo("Plugin is awake!");
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "MajorasMask");
			Bundle = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "majorasmask"));
			if ((Object)(object)Bundle == (Object)null)
			{
				logger.LogError("Could not find asset bundle!");
				return;
			}
			logger.LogInfo("Successfully loaded asset bundle");
			MajorasMesh = Bundle.LoadAsset<GameObject>("Assets/MajoraMask/MajoraMask.prefab");
		}
	}
	public class PluginInfo
	{
		public const string PLUGIN_GUID = "MajorasMask";

		public const string PLUGIN_NAME = "MajorasMask";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	public class PluginLogger
	{
		private static ManualLogSource mls = Logger.CreateLogSource("MajorasMask");

		private static bool ShouldLog = true;

		public void EnableLogging(bool status)
		{
			ShouldLog = status;
		}

		public void LogInfo(object data)
		{
			if (ShouldLog)
			{
				mls.LogInfo(data);
			}
		}

		public void LogWarning(object data)
		{
			if (ShouldLog)
			{
				mls.LogWarning(data);
			}
		}

		public void LogError(object data)
		{
			if (ShouldLog)
			{
				mls.LogError(data);
			}
		}
	}
}
namespace MajorasMask.Patches
{
	[HarmonyPatch(typeof(HauntedMaskItem), "Update")]
	internal class HauntedMaskItemPatch
	{
		public static void Postfix(ref HauntedMaskItem __instance)
		{
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.maskEyesFilled == (Object)null)
			{
				return;
			}
			__instance.headMaskPrefab = Plugin.MajorasMesh;
			Renderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (((Object)((Component)val).gameObject).name == "MaskMesh")
				{
					GameObject val2 = Object.Instantiate<GameObject>(Plugin.MajorasMesh, Vector3.zero, Quaternion.identity, ((Component)val).transform.parent);
					val2.transform.localPosition = Vector3.zero;
					val2.transform.localScale = Vector3.one;
					((Component)val).gameObject.SetActive(false);
				}
			}
		}
	}
	[HarmonyPatch(typeof(MaskedPlayerEnemy), "Start")]
	internal class MaskedPlayerEnemyPatch
	{
		public static void Postfix(ref MaskedPlayerEnemy __instance)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			Renderer[] componentsInChildren = ((Component)__instance).gameObject.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				if (((Object)((Component)val).gameObject).name == "Mesh")
				{
					GameObject val2 = Object.Instantiate<GameObject>(Plugin.MajorasMesh, Vector3.zero, Quaternion.identity, ((Component)val).transform.parent);
					val2.transform.localRotation = Quaternion.Euler(270f, 270f, 270f);
					val2.transform.localPosition = new Vector3(0f, 1.5f, 0f);
					val2.transform.localScale = Vector3.one;
				}
			}
		}
	}
}