Decompiled source of PauseInSinglePlayer v1.0.0

PauseInSinglePlayer.dll

Decompiled 2 weeks 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;
using UnityEngine.UI;

[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: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: AssemblyCompany("khalliv")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PauseInSinglePlayer")]
[assembly: AssemblyTitle("PauseInSinglePlayer")]
[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 PauseInSinglePlayer
{
	[BepInPlugin("khalliv.PauseInSinglePlayer", "PauseInSinglePlayer", "1.0.0")]
	public class PauseInSinglePlayer : BaseUnityPlugin
	{
		private ConfigEntry<KeyCode> PauseKey;

		private ConfigEntry<float> PauseTextPositionX;

		private ConfigEntry<float> PauseTextPositionY;

		private bool paused = false;

		private TextMeshProUGUI pauseText;

		private TextMeshProUGUI pauseTextBindInfo;

		internal static PauseInSinglePlayer Instance { get; private set; }

		internal static ManualLogSource Logger => Instance._logger;

		private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;

		internal Harmony? Harmony { get; set; }

		private void Awake()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Expected O, but got Unknown
			Instance = this;
			((Component)this).gameObject.transform.parent = null;
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
			PauseKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "PauseKey", (KeyCode)287, new ConfigDescription("Key to pause the game. Works in single-player only", (AcceptableValueBase)null, Array.Empty<object>()));
			PauseTextPositionX = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PauseTextPositionX", 0f, new ConfigDescription("X position of the pause text", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4000f, 4000f), Array.Empty<object>()));
			PauseTextPositionY = ((BaseUnityPlugin)this).Config.Bind<float>("General", "PauseTextPositionY", 27.5f, new ConfigDescription("Y position of the pause text", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-4000f, 4000f), Array.Empty<object>()));
			Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} has loaded!");
		}

		private void Update()
		{
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.IsMultiplayer())
			{
				return;
			}
			if ((Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelMainMenu || (Object)(object)RunManager.instance.levelCurrent == (Object)(object)RunManager.instance.levelLobbyMenu)
			{
				if (paused)
				{
					paused = false;
					Time.timeScale = 1f;
					TogglePauseText();
				}
			}
			else if (Input.GetKeyDown(PauseKey.Value))
			{
				paused = !paused;
				Time.timeScale = ((!paused) ? 1 : 0);
				TogglePauseText();
			}
		}

		private void TogglePauseText()
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)pauseText == (Object)null)
			{
				CreatePauseText();
			}
			((Component)pauseText).gameObject.SetActive(paused);
			((TMP_Text)pauseTextBindInfo).text = $"Press {PauseKey.Value} to unpause";
		}

		private void CreatePauseText()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("pauseText");
			val.transform.SetParent(((Component)HUD.instance).transform.GetChild(0).GetChild(0));
			pauseText = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)pauseText).rectTransform.pivot = new Vector2(0.5f, 0.5f);
			((TMP_Text)pauseText).rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
			((TMP_Text)pauseText).rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
			((TMP_Text)pauseText).rectTransform.anchoredPosition = new Vector2(PauseTextPositionX.Value, PauseTextPositionY.Value);
			((TMP_Text)pauseText).font = ((TMP_Text)BigMessageUI.instance.Text).font;
			((TMP_Text)pauseText).fontMaterial = ((TMP_Text)BigMessageUI.instance.Text).fontMaterial;
			((TMP_Text)pauseText).fontSize = ((TMP_Text)BigMessageUI.instance.Text).fontSize;
			((TMP_Text)pauseText).alignment = (TextAlignmentOptions)514;
			((TMP_Text)pauseText).characterSpacing = ((TMP_Text)BigMessageUI.instance.Text).characterSpacing;
			((TMP_Text)pauseText).fontSize = 50f;
			((TMP_Text)pauseText).fontStyle = (FontStyles)5;
			((TMP_Text)pauseText).outlineColor = Color32.op_Implicit(Color.black);
			((TMP_Text)pauseText).outlineWidth = 0.075f;
			((TMP_Text)pauseText).text = "PAUSED";
			val = new GameObject("pauseTextBindInfo");
			val.transform.SetParent(((TMP_Text)pauseText).transform);
			pauseTextBindInfo = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)pauseTextBindInfo).rectTransform.pivot = new Vector2(0.5f, 1f);
			((TMP_Text)pauseTextBindInfo).rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
			((TMP_Text)pauseTextBindInfo).rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
			((TMP_Text)pauseTextBindInfo).rectTransform.anchoredPosition = new Vector2(0f, -15f);
			((TMP_Text)pauseTextBindInfo).font = ((TMP_Text)BigMessageUI.instance.Text).font;
			((TMP_Text)pauseTextBindInfo).fontMaterial = ((TMP_Text)BigMessageUI.instance.Text).fontMaterial;
			((TMP_Text)pauseTextBindInfo).alignment = (TextAlignmentOptions)514;
			((TMP_Text)pauseTextBindInfo).characterSpacing = ((TMP_Text)BigMessageUI.instance.Text).characterSpacing;
			((TMP_Text)pauseTextBindInfo).fontSize = 20f;
			((Graphic)pauseTextBindInfo).color = new Color(1f, 1f, 1f, 0.5f);
			((TMP_Text)pauseTextBindInfo).outlineColor = Color32.op_Implicit(Color.black);
			((TMP_Text)pauseTextBindInfo).outlineWidth = 0.1f;
			((TMP_Text)pauseTextBindInfo).text = $"Press {PauseKey.Value} to unpause";
		}
	}
}