Decompiled source of SetInjectionFlagPlugin v2.6.0

SetInjectionFlagPlugin.dll

Decompiled 5 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using JetBrains.Annotations;
using ModdingTales;
using PluginUtilities;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Set Injection Flag Plugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Set Injection Flag Plugin")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("4e4deb5e-97f9-4901-bf67-6748a9c1229a")]
[assembly: AssemblyFileVersion("2.6.0.0")]
[assembly: AssemblyInformationalVersion("2.6.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("2.6.0.0")]
namespace PluginUtilities
{
	[BepInPlugin("org.generic.plugins.setinjectionflag", "Set Injection Flag Plugin", "2.6.0.0")]
	public class SetInjectionFlag : BaseUnityPlugin
	{
		public const string Guid = "org.generic.plugins.setinjectionflag";

		public const string Name = "Set Injection Flag Plugin";

		public const string Version = "2.6.0.0";

		internal static ManualLogSource PluginLogger;

		[UsedImplicitly]
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogDebug((object)"Awake Triggered");
			PluginLogger = ((BaseUnityPlugin)this).Logger;
			AppStateManager.UsingCodeInjection = true;
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded, You're now good to start modding!");
			ModdingUtils.AddPluginToMenuList((BaseUnityPlugin)(object)this);
			SceneManager.sceneLoaded += ModdingUtils.OnSceneLoaded;
		}
	}
}
namespace ModdingTales
{
	public static class ModdingUtils
	{
		private static readonly HashSet<(BaseUnityPlugin, string)> ParentPlugins = new HashSet<(BaseUnityPlugin, string)>();

		private static readonly ManualLogSource Logger = SetInjectionFlag.PluginLogger;

		private static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}

		public static void AddPluginToMenuList(BaseUnityPlugin parentPlugin)
		{
			AddPluginToMenuList(parentPlugin, string.Empty);
		}

		public static void AddPluginToMenuList(BaseUnityPlugin parentPlugin, string author)
		{
			ParentPlugins.Add((parentPlugin, author));
		}

		[Obsolete("See AddPluginToMenuList")]
		public static void Initialize(BaseUnityPlugin parentPlugin, ManualLogSource logger, string author, bool startSocket = false)
		{
			AddPluginToMenuList(parentPlugin, author);
		}

		[Obsolete("See AddPluginToMenuList")]
		public static void Initialize(BaseUnityPlugin parentPlugin, ManualLogSource logger, bool startSocket = false)
		{
			AddPluginToMenuList(parentPlugin, "");
		}

		internal static void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			Logger.LogDebug((object)("Loading Scene: " + ((Scene)(ref scene)).name));
			TextMeshProUGUI uITextByName = GetUITextByName("Panel_BetaWarning");
			if (!Object.op_Implicit((Object)(object)uITextByName))
			{
				return;
			}
			Logger.LogDebug((object)("Found TextMeshProUGUI in Scene: " + ((Scene)(ref scene)).name));
			if (((TMP_Text)uITextByName).text.EndsWith("</size>"))
			{
				((TMP_Text)uITextByName).text = ((TMP_Text)uITextByName).text + "\n\nMods Currently Installed:\n";
			}
			foreach (var parentPlugin in ParentPlugins)
			{
				try
				{
					BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(((object)parentPlugin.Item1).GetType(), typeof(BepInPlugin));
					((TMP_Text)uITextByName).text = ((TMP_Text)uITextByName).text + (string.IsNullOrWhiteSpace(parentPlugin.Item2) ? $"\n{val.Name} - {val.Version}" : $"\n{parentPlugin.Item2} {val.Name} - {val.Version}");
					Logger.LogDebug((object)("Added Mod to List: " + val.Name));
				}
				catch (Exception ex)
				{
					Logger.LogError((object)("Error adding mod to list: " + ex.Message));
				}
			}
		}
	}
}