Hyw.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
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 TMPro;
using UnityEngine;
using UnityEngine.Events;
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")]
[assembly: AssemblyCompany("Hyw")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+9ab16c278e306c9122c8b64617a567463590b0c5")]
[assembly: AssemblyProduct("Hyw")]
[assembly: AssemblyTitle("Hyw")]
[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.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Hyw
{
	public class AssetLoader
	{
		private const string fontPath = "Hyw.asset.7000.bundle";

		public static AssetBundle assetBundle;

		public static TMP_FontAsset regularNoto;

		public static TMP_FontAsset boldNoto;

		public static TMP_FontAsset mediumNoto;

		public static void Initialize()
		{
			assetBundle = LoadAssetBundle("Hyw.asset.7000.bundle");
			regularNoto = assetBundle.LoadAsset<TMP_FontAsset>("NotoSansSC-Regular SDF");
			boldNoto = assetBundle.LoadAsset<TMP_FontAsset>("NotoSansSC-Bold SDF");
			mediumNoto = assetBundle.LoadAsset<TMP_FontAsset>("NotoSansSC-Medium SDF");
			Object[] array = assetBundle.LoadAllAssets();
			foreach (Object val in array)
			{
				Plugin.Logger.LogInfo((object)(val.name + ": " + ((object)val).GetType().Name));
			}
		}

		public static AssetBundle LoadAssetBundle(string assetBundlePath)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			using Stream stream = executingAssembly.GetManifestResourceStream(assetBundlePath);
			if (stream != null)
			{
				Plugin.Logger.LogInfo((object)("Loading asset bundle " + assetBundlePath));
			}
			return AssetBundle.LoadFromStream(stream);
		}
	}
	[HarmonyPatch(typeof(OptionsMenuToManager))]
	public static class InstantiatePatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("SetPauseMenu")]
		public static void Prefix(OptionsMenuToManager __instance)
		{
			PauseMenuChecker.CheckPauseMenu(__instance);
		}
	}
	public static class PauseMenuChecker
	{
		public static GameObject _zpPauseMenu;

		public static void CheckPauseMenu(OptionsMenuToManager __instance)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			if ((Object)(object)__instance.pauseMenu != (Object)null && ((Object)__instance.pauseMenu).name == "PauseMenu")
			{
				if ((Object)(object)_zpPauseMenu == (Object)null)
				{
					_zpPauseMenu = new GameObject("ZpPauseMenu");
					_zpPauseMenu.transform.SetParent(__instance.pauseMenu.transform.parent, false);
					_zpPauseMenu.AddComponent<ZpPauseMenu>();
					_zpPauseMenu.transform.SetSiblingIndex(__instance.pauseMenu.transform.GetSiblingIndex());
				}
				__instance.pauseMenu = _zpPauseMenu;
				_zpPauseMenu.SetActive(false);
				Plugin.Logger.LogInfo((object)"HYW");
			}
		}
	}
	public abstract class PauseMenuTemplate : MonoBehaviour
	{
		protected Button resumeBtn;

		protected Button checkpointBtn;

		protected Button optionsBtn;

		protected Button restartBtn;

		protected Button quitBtn;

		protected List<Button> buttons = new List<Button>();

		protected PauseMenu pauseMenuScript;

		protected RectTransform buttonsContainer;

		protected GamepadObjectSelector gamepadObjectSelector;

		protected TMP_FontAsset tmpAsset;

		protected virtual void Awake()
		{
			OnPreSetup();
			EnsureFullScreen();
			SetUpLayout();
			BuildFixedContent();
			SetupCustomContent();
			SetExplicitNavigation();
			OnPostSetup();
		}

		protected virtual void OnEnable()
		{
			PauseMenuScript();
		}

		private void EnsureFullScreen()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform val = ((Component)this).GetComponent<RectTransform>();
			if ((Object)(object)val == (Object)null)
			{
				val = ((Component)this).gameObject.AddComponent<RectTransform>();
			}
			val.anchorMin = Vector2.zero;
			val.anchorMax = Vector2.one;
			val.offsetMin = Vector2.zero;
			val.offsetMax = Vector2.zero;
			((Transform)val).localScale = Vector3.one;
			((Transform)val).localPosition = Vector3.zero;
		}

		private void BuildFixedContent()
		{
			CreateButton();
		}

		private void CreateButton()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			resumeBtn = AddButton("RESUME", new UnityAction(OnResumeClicked));
			checkpointBtn = AddButton("CHECKPOINT", new UnityAction(OnCheckpointClicked));
			restartBtn = AddButton("RESTART MISSION", new UnityAction(OnRestartClicked));
			optionsBtn = AddButton("OPTIONS", new UnityAction(OnOptionsClicked));
			quitBtn = AddButton("QUIT", new UnityAction(OnQuitClicked));
			gamepadObjectSelector = ((Component)this).gameObject.AddComponent<GamepadObjectSelector>();
			gamepadObjectSelector.mainTarget = ((Component)resumeBtn).gameObject;
		}

		private void SetExplicitNavigation()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < buttons.Count; i++)
			{
				Navigation navigation = default(Navigation);
				((Navigation)(ref navigation)).mode = (Mode)4;
				((Navigation)(ref navigation)).selectOnRight = (Selectable)(object)buttons[(i + 1) % buttons.Count];
				((Navigation)(ref navigation)).selectOnLeft = (Selectable)(object)buttons[(i - 1 + buttons.Count) % buttons.Count];
				((Navigation)(ref navigation)).selectOnDown = ((Navigation)(ref navigation)).selectOnRight;
				((Navigation)(ref navigation)).selectOnUp = ((Navigation)(ref navigation)).selectOnLeft;
				((Selectable)buttons[i]).navigation = navigation;
			}
		}

		protected virtual void OnResumeClicked()
		{
			MonoSingleton<OptionsMenuToManager>.Instance.UnPause();
		}

		protected virtual void OnCheckpointClicked()
		{
			MonoSingleton<OptionsMenuToManager>.Instance.RestartCheckpoint();
		}

		protected virtual void OnOptionsClicked()
		{
			MonoSingleton<OptionsMenuToManager>.Instance.OpenOptions();
		}

		protected virtual void OnRestartClicked()
		{
			MonoSingleton<OptionsMenuToManager>.Instance.RestartMission();
		}

		protected virtual void OnQuitClicked()
		{
			MonoSingleton<OptionsMenuToManager>.Instance.QuitMission();
		}

		protected virtual void OnPreSetup()
		{
		}

		protected virtual void SetupCustomContent()
		{
		}

		protected virtual void OnPostSetup()
		{
		}

		public Button AddButton(string label, UnityAction onClick)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(label + "Button");
			val.transform.SetParent((Transform)(object)buttonsContainer, false);
			RectTransform val2 = val.AddComponent<RectTransform>();
			val2.sizeDelta = new Vector2(150f, 30f);
			val.AddComponent<CanvasRenderer>();
			Image val3 = val.AddComponent<Image>();
			((Graphic)val3).color = new Color(1f, 1f, 1f, 0.95f);
			Button val4 = val.AddComponent<Button>();
			((UnityEvent)val4.onClick).AddListener(onClick);
			GameObject val5 = new GameObject("Text");
			val5.transform.SetParent(val.transform, false);
			TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val6).text = label;
			((TMP_Text)val6).alignment = (TextAlignmentOptions)514;
			((TMP_Text)val6).fontSize = 14f;
			((Graphic)val6).color = new Color(0f, 0f, 0f, 1f);
			RectTransform rectTransform = ((TMP_Text)val6).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			Vector2 offsetMin = (rectTransform.offsetMax = Vector2.zero);
			rectTransform.offsetMin = offsetMin;
			if ((Object)(object)tmpAsset != (Object)null)
			{
				((TMP_Text)val6).font = tmpAsset;
			}
			buttons.Add(val4);
			return val4;
		}

		private void SetUpLayout()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Expected O, but got Unknown
			GameObject val = new GameObject("ButtonsContainer");
			val.transform.SetParent(((Component)this).transform, false);
			buttonsContainer = val.AddComponent<RectTransform>();
			buttonsContainer.anchorMin = new Vector2(0f, 1f);
			buttonsContainer.anchorMax = new Vector2(1f, 1f);
			buttonsContainer.offsetMin = new Vector2(0f, 0f);
			buttonsContainer.offsetMax = new Vector2(0f, 0f);
			HorizontalLayoutGroup val2 = val.AddComponent<HorizontalLayoutGroup>();
			((LayoutGroup)val2).childAlignment = (TextAnchor)4;
			((LayoutGroup)val2).padding = new RectOffset(25, 25, 50, 10);
			((HorizontalOrVerticalLayoutGroup)val2).spacing = 10f;
			((HorizontalOrVerticalLayoutGroup)val2).childControlHeight = false;
			((HorizontalOrVerticalLayoutGroup)val2).childControlWidth = false;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandHeight = false;
			((HorizontalOrVerticalLayoutGroup)val2).childForceExpandWidth = false;
		}

		private void PauseMenuScript()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			MapInfoBase instance = MapInfoBase.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				((Selectable)checkpointBtn).interactable = false;
			}
			else if (instance.replaceCheckpointButtonWithSkip)
			{
				((Component)checkpointBtn).GetComponentInChildren<TMP_Text>().text = "SKIP";
				((Selectable)checkpointBtn).interactable = true;
				((UnityEventBase)checkpointBtn.onClick).RemoveAllListeners();
				((UnityEvent)checkpointBtn.onClick).AddListener(new UnityAction(OnCheckpointButton));
			}
			else
			{
				bool interactable = (Object)(object)MonoSingleton<StatsManager>.Instance.currentCheckPoint != (Object)null;
				((Selectable)checkpointBtn).interactable = interactable;
			}
		}

		private void OnCheckpointButton()
		{
			StockMapInfo instance = StockMapInfo.Instance;
			if (!((Object)(object)instance == (Object)null))
			{
				string nextSceneName = instance.nextSceneName;
				if (!string.IsNullOrEmpty(nextSceneName))
				{
					MonoSingleton<OptionsMenuToManager>.Instance.ChangeLevel(nextSceneName);
				}
			}
		}
	}
	[BepInPlugin("greycsont.ultrakill.hyw", "Hyw", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger { get; private set; }

		private void Awake()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"Plugin greycsont.ultrakill.hyw is loaded!");
			((Object)((Component)this).gameObject).hideFlags = (HideFlags)4;
			AssetLoader.Initialize();
			Harmony val = new Harmony("greycsont.ultrakill.hyw");
			val.PatchAll();
		}
	}
	public static class CNBtnState
	{
		public static bool isActive;

		public static string currentSymbol => isActive ? "-" : "+";
	}
	public class ZpPauseMenu : PauseMenuTemplate
	{
		private GameObject titleObject;

		private GameObject title_EN;

		private GameObject title_CN;

		private Button showTitleCNBtn;

		protected override void OnPreSetup()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			tmpAsset = AssetLoader.mediumNoto;
			titleObject = new GameObject("TitleObject");
			titleObject.transform.SetParent(((Component)this).transform, false);
			titleObject.transform.localPosition = Vector3.zero;
			titleObject.transform.localScale = Vector3.one * 0.9f;
		}

		protected override void OnPostSetup()
		{
			AddBackgroundImage();
			AddPausedText();
			AddPausedTextCN();
			title_CN.SetActive(CNBtnState.isActive);
		}

		protected override void SetupCustomContent()
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			showTitleCNBtn = AddButton(CNBtnState.currentSymbol, new UnityAction(OnShowTitileCNClicked));
			((Component)showTitleCNBtn).GetComponent<RectTransform>().sizeDelta = new Vector2(30f, 30f);
		}

		private void OnShowTitileCNClicked()
		{
			CNBtnState.isActive = !CNBtnState.isActive;
			title_CN.SetActive(CNBtnState.isActive);
			((TMP_Text)((Component)showTitleCNBtn).GetComponentInChildren<TextMeshProUGUI>()).text = CNBtnState.currentSymbol;
		}

		private void AddBackgroundImage()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("BackgroundImage");
			val.transform.SetParent(((Component)this).transform, false);
			Image val2 = val.AddComponent<Image>();
			((Graphic)val2).color = new Color(0f, 0f, 0f, 0.7f);
			((Graphic)val2).raycastTarget = false;
			RectTransform rectTransform = ((Graphic)val2).rectTransform;
			rectTransform.anchorMin = Vector2.zero;
			rectTransform.anchorMax = Vector2.one;
			rectTransform.offsetMin = Vector2.zero;
			rectTransform.offsetMax = Vector2.zero;
			val.transform.SetAsFirstSibling();
		}

		private void AddPausedText()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			title_EN = new GameObject("Title_EN");
			title_EN.transform.SetParent(titleObject.transform, false);
			TextMeshProUGUI val = title_EN.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val).text = "PAUSE";
			((TMP_Text)val).fontSize = 100f;
			((TMP_Text)val).alignment = (TextAlignmentOptions)514;
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).font = AssetLoader.mediumNoto;
			((TMP_Text)val).enableKerning = false;
			((TMP_Text)val).characterSpacing = -2f;
			RectTransform rectTransform = ((TMP_Text)val).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
			rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.anchoredPosition = Vector2.zero;
			rectTransform.sizeDelta = new Vector2(500f, 100f);
		}

		private void AddPausedTextCN()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			title_CN = new GameObject("Title_CN");
			title_CN.transform.SetParent(titleObject.transform, false);
			TextMeshProUGUI val = title_CN.AddComponent<TextMeshProUGUI>();
			((TMP_Text)val).text = "----暂停中----";
			((TMP_Text)val).fontSize = 30f;
			((TMP_Text)val).alignment = (TextAlignmentOptions)514;
			((Graphic)val).raycastTarget = false;
			((TMP_Text)val).font = AssetLoader.mediumNoto;
			((TMP_Text)val).enableKerning = false;
			((TMP_Text)val).characterSpacing = -1f;
			Plugin.Logger.LogError((object)((TMP_Text)val).characterSpacing);
			RectTransform rectTransform = ((TMP_Text)val).rectTransform;
			rectTransform.anchorMin = new Vector2(0.5f, 0.5f);
			rectTransform.anchorMax = new Vector2(0.5f, 0.5f);
			rectTransform.pivot = new Vector2(0.5f, 0.5f);
			rectTransform.anchoredPosition = new Vector2(0f, -75f);
			rectTransform.sizeDelta = new Vector2(500f, 100f);
		}
	}
	internal static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "greycsont.ultrakill.hyw";

		public const string PLUGIN_NAME = "Hyw";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		internal IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}