Decompiled source of NIRMATA v1.0.16

plugins/NIRMATA/NIRMATA.dll

Decompiled 9 months 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 NIRMATA.Utils;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: AssemblyCompany("NIRMATA")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("NIRMATA")]
[assembly: AssemblyTitle("NIRMATA")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 NIRMATA
{
	public static class PluginInformation
	{
		public const string PLUGIN_NAME = "NIRMATA";

		public const string PLUGIN_VERSION = "1.0.0";

		public const string PLUGIN_GUID = "lc.NIRMATA";
	}
	[BepInPlugin("lc.NIRMATA", "NIRMATA", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static Texture2D mainLogo;

		public static ManualLogSource StaticLogger;

		private Harmony harmony;

		private void Awake()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("lc.NIRMATA");
			harmony.PatchAll();
			AssetBundle obj = BundleUtilities.LoadBundleFromInternalAssembly("NIRMATA.assets", Assembly.GetExecutingAssembly());
			mainLogo = obj.LoadPersistentAsset<Texture2D>("assets/logo.png");
			obj.Unload(false);
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "NIRMATA";

		public const string PLUGIN_NAME = "NIRMATA";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace NIRMATA.Patches
{
	[HarmonyPatch(typeof(MenuManager), "Awake")]
	public static class LogoPatch
	{
		[HarmonyPriority(0)]
		public static void Postfix(MenuManager __instance)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject gameObject = ((Component)((Component)((Component)__instance).transform.parent).gameObject.transform.Find("MenuContainer")).gameObject;
				Scene scene = gameObject.scene;
				if (!(((Scene)(ref scene)).name != "MainMenu"))
				{
					((Component)gameObject.transform.Find("MainButtons").Find("HeaderImage")).gameObject.GetComponent<Image>().sprite = Sprite.Create(Plugin.mainLogo, new Rect(0f, 0f, (float)((Texture)Plugin.mainLogo).width, (float)((Texture)Plugin.mainLogo).height), new Vector2(0.5f, 0.5f));
					((Component)gameObject.transform.Find("LoadingScreen").Find("Image")).gameObject.GetComponent<Image>().sprite = Sprite.Create(Plugin.mainLogo, new Rect(0f, 0f, (float)((Texture)Plugin.mainLogo).width, (float)((Texture)Plugin.mainLogo).height), new Vector2(0.5f, 0.5f));
				}
			}
			catch (Exception ex)
			{
				Plugin.StaticLogger.LogError((object)ex.Message);
			}
		}

		private static void Traverse(GameObject obj)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Plugin.StaticLogger.LogInfo((object)((Object)obj).name);
			foreach (Transform item in obj.transform)
			{
				Traverse(((Component)item).gameObject);
			}
			Plugin.StaticLogger.LogInfo((object)"-----------");
		}
	}
}
namespace NIRMATA.Utils
{
	public class BundleUtilities
	{
		public static byte[] GetResourceBytes(string filename, Assembly assembly)
		{
			string[] manifestResourceNames = assembly.GetManifestResourceNames();
			foreach (string text in manifestResourceNames)
			{
				if (!text.Contains(filename))
				{
					continue;
				}
				using Stream stream = assembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return null;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				return array;
			}
			return null;
		}

		public static AssetBundle LoadBundleFromInternalAssembly(string filename, Assembly assembly)
		{
			return AssetBundle.LoadFromMemory(GetResourceBytes(filename, assembly));
		}
	}
	public static class AssetBundleExtension
	{
		public static T LoadPersistentAsset<T>(this AssetBundle bundle, string name) where T : Object
		{
			Object val = bundle.LoadAsset(name);
			if (val != (Object)null)
			{
				val.hideFlags = (HideFlags)32;
				return (T)(object)val;
			}
			return default(T);
		}
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}