Decompiled source of HideTips v1.0.3

HideTips.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HideTips")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("DSP MOD - HideTips")]
[assembly: AssemblyFileVersion("1.0.3.0")]
[assembly: AssemblyInformationalVersion("1.0.3")]
[assembly: AssemblyProduct("HideTips")]
[assembly: AssemblyTitle("HideTips")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.3.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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace HideTips
{
	[BepInPlugin("org.soardev.hidetips", "HideTips", "1.0.3")]
	public class HideTips : BaseUnityPlugin
	{
		private static readonly ManualLogSource Logger = Logger.CreateLogSource("HideTips");

		private bool _cfgEnabled = true;

		private static bool _noRandomReminderTips = true;

		private static bool _noTutorialTips = true;

		private static bool _noAchievementCardPopups;

		private static bool _noMilestoneCardPopups = true;

		private static bool _noResearchCompletionPopups = true;

		private static bool _noResearchCompletionTips;

		private static bool _skipPrologue = true;

		private static bool _hideMenuDemo;

		private static Harmony _patch;

		private void Awake()
		{
			_cfgEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", _cfgEnabled, "enable/disable this plugin").Value;
			_noRandomReminderTips = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoRandomReminderTips", _noRandomReminderTips, "Disable Random Reminder Tips").Value;
			_noTutorialTips = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoTutorialTips", _noTutorialTips, "Disable Tutorial Tips").Value;
			_noAchievementCardPopups = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoAchievementCardPopups", _noAchievementCardPopups, "Disable Achievement Card Popups").Value;
			_noMilestoneCardPopups = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoMilestoneCardPopups", _noMilestoneCardPopups, "Disable Milestone Card Popups").Value;
			_noResearchCompletionPopups = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoResearchCompletionPopups", _noResearchCompletionPopups, "Disable Research Completion Popup Windows").Value;
			_noResearchCompletionTips = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NoResearchCompletionTips", _noResearchCompletionTips, "Disable Research Completion Tips").Value;
			_skipPrologue = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "SkipPrologue", _skipPrologue, "Skip prologue for new game").Value;
			_hideMenuDemo = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "HideMenuDemo", _hideMenuDemo, "Disable title screen demo scene loading").Value;
			if (_cfgEnabled)
			{
				Harmony.CreateAndPatchAll(typeof(HideTips), (string)null);
				if (_hideMenuDemo)
				{
					_patch = Harmony.CreateAndPatchAll(typeof(HideMenuDemo), (string)null);
				}
			}
		}

		private void OnDestroy()
		{
			Harmony patch = _patch;
			if (patch != null)
			{
				patch.UnpatchSelf();
			}
			_patch = null;
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIBuildMenu), "_OnCreate")]
		private static void ClearRandReminderTips(UIBuildMenu __instance)
		{
			if (!_noRandomReminderTips)
			{
				return;
			}
			UIRandomTip[] randRemindTips = __instance.randRemindTips;
			foreach (UIRandomTip val in randRemindTips)
			{
				if ((Object)(object)val != (Object)null)
				{
					((ManualBehaviour)val)._Free();
				}
			}
			__instance.randRemindTips = Array.Empty<UIRandomTip>();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(UIGameMenu), "_OnCreate")]
		private static void UIGameMenu__OnCreate_Postfix(UIGameMenu __instance)
		{
			__instance.randTipButton0.pop = __instance.randTipButton0.popCount;
			__instance.randTipButton1.pop = __instance.randTipButton1.popCount;
			__instance.randTipButton2.pop = __instance.randTipButton2.popCount;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UITutorialTip), "PopupTutorialTip")]
		private static bool UITutorialTip_PopupTutorialTip_Prefix()
		{
			return !_noTutorialTips;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateAchievementPopupCard")]
		private static bool UIVariousPopupGroup_CreateAchievementPopupCard_Prefix()
		{
			return !_noAchievementCardPopups;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIVariousPopupGroup), "CreateMilestonePopupCard")]
		private static bool UIVariousPopupGroup_CreateMilestonePopupCard_Prefix()
		{
			return !_noMilestoneCardPopups;
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(UIResearchResultWindow), "SetTechId")]
		private static bool UIResearchResultWindow_SetTechId_Prefix()
		{
			return !_noResearchCompletionPopups;
		}

		[HarmonyTranspiler]
		[HarmonyPatch(typeof(UIGeneralTips), "OnTechUnlocked")]
		private static IEnumerable<CodeInstruction> UIGeneralTips_OnTechUnlocked_Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Expected O, but got Unknown
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			val.MatchForward(false, (CodeMatch[])(object)new CodeMatch[3]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldfld, (object)AccessTools.Field(typeof(UIGeneralTips), "researchCompleteTip"), (string)null),
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)null, (string)null)
			});
			List<Label> labels = val.Labels;
			Label label = generator.DefineLabel();
			val.Labels = new List<Label>();
			val.InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[2]
			{
				CodeInstructionExtensions.WithLabels(new CodeInstruction(OpCodes.Ldsfld, (object)AccessTools.Field(typeof(HideTips), "_noResearchCompletionTips")), (IEnumerable<Label>)labels),
				new CodeInstruction(OpCodes.Brtrue, (object)label)
			}).MatchForward(false, (CodeMatch[])(object)new CodeMatch[2]
			{
				new CodeMatch((OpCode?)OpCodes.Callvirt, (object)AccessTools.Method(typeof(Animation), "Play", (Type[])null, (Type[])null), (string)null),
				new CodeMatch((OpCode?)OpCodes.Pop, (object)null, (string)null)
			}).Advance(2)
				.Labels.Add(label);
			return val.InstructionEnumeration();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(DSPGame), "StartGame", new Type[] { typeof(GameDesc) })]
		private static bool DSPGame_StartGame_Prefix(GameDesc _gameDesc)
		{
			if (!_skipPrologue)
			{
				return true;
			}
			DSPGame.StartGameSkipPrologue(_gameDesc);
			return false;
		}
	}
	[HarmonyPatch]
	internal class HideMenuDemo
	{
		[HarmonyPriority(800)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(DSPGame), "StartDemoGame", new Type[] { typeof(int) })]
		private static bool DSPGame_StartDemoGame_Prefix()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)DSPGame.Game != (Object)null)
			{
				DSPGame.EndGame();
			}
			DSPGame.IsMenuDemo = true;
			DSPGame.CreateGameMainObject();
			DSPGame.Game.isMenuDemo = true;
			DSPGame.Game.CreateIconSet();
			GameMain.data = new GameData();
			GameMain.data.mainPlayer = Player.Create(GameMain.data, 1);
			GameMain.data.galaxy = new GalaxyData
			{
				starCount = 0
			};
			if ((Object)(object)GameMain.universeSimulator != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)GameMain.universeSimulator).gameObject);
			}
			GameMain.universeSimulator = Object.Instantiate<UniverseSimulator>(Configs.builtin.universeSimulatorPrefab);
			UniverseSimulator universeSimulator = GameMain.universeSimulator;
			GameObject val = new GameObject("Space Audio");
			val.transform.parent = ((Component)GameMain.universeSimulator).transform;
			universeSimulator.spaceAudio = val.AddComponent<SpaceAudio>();
			GameMain.Begin();
			return false;
		}

		[HarmonyPriority(800)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(VFPreload), "IsMenuDemoLoaded")]
		private static bool VFPreload_IsMenuDemoLoaded_Prefix(ref bool __result)
		{
			__result = true;
			return false;
		}

		[HarmonyPriority(800)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(DSPGame), "LateUpdate")]
		[HarmonyPatch(typeof(GameMain), "LateUpdate")]
		[HarmonyPatch(typeof(GameMain), "FixedUpdate")]
		[HarmonyPatch(typeof(GameMain), "Update")]
		[HarmonyPatch(typeof(GameCamera), "LateUpdate")]
		private static bool DSPGame_LateUpdate_Prefix()
		{
			return !DSPGame.IsMenuDemo;
		}

		[HarmonyPriority(800)]
		[HarmonyPrefix]
		[HarmonyPatch(typeof(GameMain), "Begin")]
		private static bool GameMain_Begin_Prefix()
		{
			if (!DSPGame.IsMenuDemo)
			{
				return true;
			}
			DSPGame.Game._loading = false;
			DSPGame.Game._running = true;
			return false;
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "org.soardev.hidetips";

		public const string PLUGIN_NAME = "HideTips";

		public const string PLUGIN_VERSION = "1.0.3";
	}
}