Decompiled source of SocialExperimentPlugin v1.0.0

SocialExperimentPlugin.dll

Decompiled 5 months ago
using System;
using System.Collections;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using TMPro;
using UnityEngine;
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: AssemblyTitle("SocialExperimentPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SocialExperimentPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("SocialExperimentPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.socialexperiment", "Social Experiment Plugin", "1.0.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class TemplatePlugin : BaseUnityPlugin
{
	public static class Utility
	{
		public static void PostOnMainPage(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		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 const string Name = "Social Experiment Plugin";

	public const string Guid = "org.lordashes.plugins.socialexperiment";

	public const string Version = "1.0.0.0";

	public const string Author = "Lord Ashes";

	public static float progress = -5f;

	public static Texture2D backgroundTexture1 = Image.LoadTexture("SocialExperimentBackground1.png", (CacheType)999);

	public static Texture2D backgroundTexture2 = Image.LoadTexture("SocialExperimentBackground2.png", (CacheType)999);

	public static Texture2D progressTexture = Image.LoadTexture("SocialExperimentBackgroundProgressBar.png", (CacheType)999);

	private void Awake()
	{
		Debug.Log((object)"Social Experiment Plugin: Active.");
		((MonoBehaviour)this).StartCoroutine(IncreaseProgress());
		Utility.PostOnMainPage(((object)this).GetType());
	}

	private void OnGUI()
	{
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		if (progress >= 0f)
		{
			float num = Math.Min(progress, 100f) * 1186f / 100f;
			GUI.DrawTexture(new Rect((float)(Screen.width / 2 - 600), (float)(Screen.height / 2 - 130), 1200f, 110f), (Texture)(object)backgroundTexture1, (ScaleMode)2);
			GUI.DrawTexture(new Rect((float)(Screen.width / 2 - 600 + 7), (float)(Screen.height / 2 - 90), num, 25f), (Texture)(object)progressTexture);
			GUI.DrawTexture(new Rect((float)(Screen.width / 2 - 600), (float)(Screen.height / 2 - 130), 1200f, 110f), (Texture)(object)backgroundTexture2, (ScaleMode)2);
		}
	}

	private IEnumerator IncreaseProgress()
	{
		while (true)
		{
			yield return (object)new WaitForSeconds(1f);
			if (progress < 100f)
			{
				progress += 1f;
			}
		}
	}
}