Decompiled source of DontPauseMe v1.0.0

BepInEx/Plugins/DontPauseMe/DontPauseMe.dll

Decompiled a week 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.Logging;
using BepInEx.Unity.IL2CPP;
using ConfigGarden;
using ConfigGarden.Interfaces;
using DontPauseMe.Config;
using DontPauseMe.Helpers;
using FeluciaConfigWrapper;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TTTT;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Localization.Components;
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(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DontPauseMe")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+400ffa85cf734ddb77cc86b7d3473c8fb993d7f8")]
[assembly: AssemblyProduct("Stop Terry from pausing the game when it loses focus.")]
[assembly: AssemblyTitle("DontPauseMe")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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 DontPauseMe
{
	[BepInPlugin("FeluciaPS.TTTT.DontPauseMe", "DontPauseMe", "1.0.0")]
	public class DontPauseMe : BasePlugin
	{
		internal static ManualLogSource Log;

		internal static ILogger Logger = (ILogger)(object)new Logger();

		internal static ConfigHelper<DontPauseMeConfig> config;

		internal static GameObject toggle;

		internal static void SetBackgroundActive(bool value)
		{
			Application.runInBackground = !value;
			config.Data.PauseOnFocusLoss = value;
			config.Save();
		}

		public override void Load()
		{
			Log = ((BasePlugin)this).Log;
			config = ConfigWrapper.Create<DontPauseMeConfig>((IModInfo)(object)new ModInfo(), "config", Logger);
			Application.runInBackground = !config.Data.PauseOnFocusLoss;
			PatchLoader.LoadPatches();
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "DontPauseMe";

		public const string PLUGIN_NAME = "Stop Terry from pausing the game when it loses focus.";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace DontPauseMe.Patches
{
	internal class GameLoadPatches
	{
		[HarmonyPatch(typeof(ControlLockManager))]
		[HarmonyPatch("ForceUnlockAll")]
		internal class ForceUnlockControlsPatch
		{
			internal static bool loaded;

			internal static void LoadExtraSettings()
			{
				if (loaded)
				{
					return;
				}
				GameObject val = GameObject.Find("Pause Canvas");
				object obj;
				if (val == null)
				{
					obj = null;
				}
				else
				{
					Transform obj2 = val.transform.Find("Settings - Graphics");
					if (obj2 == null)
					{
						obj = null;
					}
					else
					{
						Transform obj3 = obj2.Find("Toggles");
						obj = ((obj3 != null) ? ((Component)obj3).gameObject : null);
					}
				}
				GameObject val2 = (GameObject)obj;
				GameObject gameObject = ((Component)val2.transform.Find("Container Toggle - Fullscreen")).gameObject;
				DontPauseMe.toggle = Object.Instantiate<GameObject>(gameObject, val2.transform);
				Toggle componentInChildren = DontPauseMe.toggle.GetComponentInChildren<Toggle>();
				componentInChildren.isOn = DontPauseMe.config.Data.PauseOnFocusLoss;
				((UnityEventBase)componentInChildren.onValueChanged).RemoveAllListeners();
				((UnityEvent<bool>)(object)componentInChildren.onValueChanged).AddListener(UnityAction<bool>.op_Implicit((Action<bool>)DontPauseMe.SetBackgroundActive));
				TextMeshProUGUI componentInChildren2 = DontPauseMe.toggle.GetComponentInChildren<TextMeshProUGUI>();
				LocalizeStringEvent component = ((Component)componentInChildren2).GetComponent<LocalizeStringEvent>();
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				((TMP_Text)componentInChildren2).text = "Pause On Focus Loss";
				((Component)val2.transform.Find("Dark Filler (1)")).gameObject.SetActive(false);
				loaded = true;
			}

			internal static void Prefix()
			{
				LoadExtraSettings();
			}
		}
	}
}
namespace DontPauseMe.Helpers
{
	internal class Logger : ILogger
	{
		internal static void Info(object message)
		{
			DontPauseMe.Log.LogInfo(message);
		}

		internal static void Message(object message)
		{
			DontPauseMe.Log.LogMessage(message);
		}

		internal static void Warn(object message)
		{
			DontPauseMe.Log.LogWarning(message);
		}

		internal static void Error(object message)
		{
			DontPauseMe.Log.LogError(message);
		}

		public void Info(string message)
		{
			Info((object)message);
		}

		public void Message(string message)
		{
			Message((object)message);
		}

		public void Warn(string message)
		{
			Warn((object)message);
		}

		public void Error(string message)
		{
			Error((object)message);
		}
	}
	internal class PatchLoader
	{
		internal static Harmony harmony;

		internal static void LoadPatches()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			harmony = new Harmony("FeluciaPS.TTTT.DontPauseMe");
			harmony.PatchAll(Assembly.GetExecutingAssembly());
			Logger.Info((object)"FeluciaPS.TTTT.DontPauseMe loaded!");
		}
	}
}
namespace DontPauseMe.Config
{
	internal class DontPauseMeConfig
	{
		public bool PauseOnFocusLoss { get; set; } = false;
	}
	internal class ModInfo : IModInfo
	{
		internal const string PLUGIN_GUID = "FeluciaPS.TTTT.DontPauseMe";

		internal const string PLUGIN_NAME = "DontPauseMe";

		internal const string PLUGIN_VERSION = "1.0.0";

		internal const string GAME = "Tiny Terry's Turbo Trip";

		internal const string AUTHOR = "FeluciaPS";

		public string GAME_NAME => "Tiny Terry's Turbo Trip";

		public string AUTHOR_NAME => "FeluciaPS";

		public string MOD_NAME => "DontPauseMe";
	}
}

BepInEx/Plugins/DontPauseMe/FeluciaConfigWrapper.dll

Decompiled a week ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using ConfigGarden;
using ConfigGarden.Interfaces;
using Microsoft.CodeAnalysis;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("FeluciaConfigWrapper")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("FeluciaConfigWrapper")]
[assembly: AssemblyTitle("FeluciaConfigWrapper")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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]
	[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]
	[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 FeluciaConfigWrapper
{
	public static class ConfigWrapper
	{
		public static string ResolvePath(string root, IModInfo info)
		{
			return Path.Combine(root, "Felucia Mods", info.GAME_NAME, info.MOD_NAME);
		}

		public static ConfigHelper<T> Create<T>(IModInfo info, string fileName = "config", ILogger? logger = null) where T : class, new()
		{
			return new ConfigHelper<T>(info, fileName, logger, (Func<string, IModInfo, string>)ResolvePath);
		}
	}
}