Decompiled source of CustomGameOverText v1.0.0

Tomatobird.CustomGameOverText.dll

Decompiled 20 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Tomatobird.CustomGameOverText")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+2e9a3ecde27629e22080ebb4005c88d21d95dc70")]
[assembly: AssemblyProduct("CustomGameOverText")]
[assembly: AssemblyTitle("Tomatobird.CustomGameOverText")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 CustomGameOverText
{
	[BepInPlugin("Tomatobird.CustomGameOverText", "CustomGameOverText", "1.0.0")]
	public class CustomGameOverText : BaseUnityPlugin
	{
		public static ConfigEntry<string> titleText;

		public static ConfigEntry<float> titleTextSize;

		public static ConfigEntry<string> subTitleText;

		public static ConfigEntry<float> subTitleTextSize;

		public static CustomGameOverText Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		internal static Harmony? Harmony { get; set; }

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Instance = this;
			titleText = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GameOverText", "YOU ARE FIRED.", "Enter custom title text.");
			titleTextSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GameOverTextSize", 80f, "Enter font size of the title.");
			subTitleText = ((BaseUnityPlugin)this).Config.Bind<string>("General", "GameOverSubTitle", "You did not meet the profit quota before the deadline.", "Enter custom subtitle text.");
			subTitleTextSize = ((BaseUnityPlugin)this).Config.Bind<float>("General", "GameOverSubTitleSize", 23f, "Enter font size of the subtitle.");
			Patch();
			Logger.LogInfo((object)"Tomatobird.CustomGameOverText v1.0.0 has loaded!");
		}

		internal static void Patch()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (Harmony == null)
			{
				Harmony = new Harmony("Tomatobird.CustomGameOverText");
			}
			Logger.LogDebug((object)"Patching...");
			Harmony.PatchAll();
			Logger.LogDebug((object)"Finished patching!");
		}

		internal static void Unpatch()
		{
			Logger.LogDebug((object)"Unpatching...");
			Harmony? harmony = Harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
			Logger.LogDebug((object)"Finished unpatching!");
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "Tomatobird.CustomGameOverText";

		public const string PLUGIN_NAME = "CustomGameOverText";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace CustomGameOverText.Patches
{
	[HarmonyPatch(typeof(HUDManager))]
	public class GameOverTextPatch
	{
		[HarmonyPatch("Start")]
		[HarmonyPostfix]
		private static void CustomGameOverTextPatch(HUDManager __instance)
		{
			GameObject val = GameObject.Find("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText");
			if ((Object)(object)val != (Object)null)
			{
				TextMeshProUGUI component = val.GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component != (Object)null)
				{
					if (!(CustomGameOverText.titleText.Value == ""))
					{
						((TMP_Text)component).text = CustomGameOverText.titleText.Value;
					}
					((TMP_Text)component).fontSize = CustomGameOverText.titleTextSize.Value;
				}
				else
				{
					CustomGameOverText.Logger.LogError((object)"Failed to find TextMeshProUGUI Component in gameobject Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText. Cannot patch custom gameover text.");
				}
			}
			else
			{
				CustomGameOverText.Logger.LogError((object)"Failed to find Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText. Cannot patch custom gameover text.");
			}
			GameObject val2 = GameObject.Find("Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText (1)");
			if ((Object)(object)val2 != (Object)null)
			{
				TextMeshProUGUI component2 = val2.GetComponent<TextMeshProUGUI>();
				if ((Object)(object)component2 != (Object)null)
				{
					if (!(CustomGameOverText.subTitleText.Value == ""))
					{
						((TMP_Text)component2).text = CustomGameOverText.subTitleText.Value;
					}
					((TMP_Text)component2).fontSize = CustomGameOverText.subTitleTextSize.Value;
				}
				else
				{
					CustomGameOverText.Logger.LogError((object)"Failed to find TextMeshProUGUI Component in gameobject Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText (1). Cannot patch custom gameover text.");
				}
			}
			else
			{
				CustomGameOverText.Logger.LogError((object)"Failed to find Systems/UI/Canvas/GameOverScreen/MaskImage/HeaderText (1). Cannot patch custom gameover text.");
			}
		}
	}
}