using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.SceneManagement; using UnityEngine.UI; [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("UltraUnlock")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("ULTRAKILL-styled launcher UI for UltraUnlock.")] [assembly: AssemblyFileVersion("2.0.1.0")] [assembly: AssemblyInformationalVersion("2.0.1")] [assembly: AssemblyProduct("UltraUnlock")] [assembly: AssemblyTitle("UltraUnlock")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("2.0.1.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 SilentSmilee.ULTRAKILL.UltraUnlock { [BepInPlugin("com.silentsmilee.ultraunlock", "UltraUnlock", "2.0.1")] [BepInProcess("ULTRAKILL.exe")] public sealed class UltraUnlock : BaseUnityPlugin { private enum Screen { Home, SaveSlot, BackupPrompt, BackupBrowser, MassBackupContents, RestoreConfirmation, DeleteBackupConfirmation, BackupResult, Unlock, Advanced, UnlockConfirmation, DontUnlockConfirmation, CalibrationConfirmation, Result } [HarmonyPatch(typeof(SceneHelper), "LoadScene")] private static class SceneLoadPatch { [HarmonyPrefix] private static bool Prefix(string __0) { if (!_modActive) { return true; } _pendingScene = __0; return false; } } public const string PluginGuid = "com.silentsmilee.ultraunlock"; public const string PluginName = "UltraUnlock"; public const string PluginVersion = "2.0.1"; private static bool _modActive; private static string _pendingScene; private Harmony _harmony; private ConfigEntry _showOnStartup; private GameObject _overlayRoot; private GameObject _optionsStartupToggle; private GameObject _optionsReenabledPrompt; private RectTransform _content; private TMP_FontAsset _font; private Sprite _borderLarge; private Sprite _fillLarge; private Sprite _pausePanelFill; private Sprite _borderSmall; private Sprite _checkmark; private Sprite _folderIcon; private Texture2D _circuitTexture; private RawImage _circuitBackground; private bool _built; private bool _initialPanelAnimationPending = true; private int _selectedSlot = -1; private bool _selectedSlotExists; private UltraUnlockBackupInfo _selectedBackup; private UltraUnlockMassBackupInfo _selectedMassBackup; private bool _backupResultSucceeded; private string _backupResultMessage = string.Empty; private string _backupResultTitle = "BACKUP"; private Screen _backupResultReturnScreen; private Screen _backupResultSuccessScreen; private Screen _restoreReturnScreen = Screen.BackupBrowser; private string _unlockNotice = string.Empty; private int _backedUpSlotIndex = -1; private UltraUnlockRequest _pendingUnlockRequest; private Screen _pendingUnlockReturnScreen = Screen.Unlock; private bool _bestiary; private bool _collectables; private bool _weapons; private bool _arms; private bool _sandbox; private bool _pRankAll; private bool _cyberGrind; private int _cyberGrindScore; private bool _lastUnlockSucceeded; private string _lastUnlockMessage = string.Empty; private Screen _resultReturnScreen = Screen.Unlock; private static readonly Color PausePanelColor = new Color(0f, 0f, 0f, 40f / 51f); private static readonly Color PauseFrameColor = new Color(0f, 0f, 0f, 0.78039217f); private static readonly Color ButtonHighlight = new Color(26f / 51f, 26f / 51f, 26f / 51f, 1f); private static readonly Color ButtonPressed = Color.red; private static readonly Color ButtonDisabled = new Color(40f / 51f, 40f / 51f, 40f / 51f, 0.5019608f); private const float UiPixelsPerUnitMultiplier = 5.4f; private const float InitialPanelAnimationDelay = 1.1f; private const float InitialPanelAnimationSpeed = 14f; private void Awake() { //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Expected O, but got Unknown _modActive = false; UltraUnlockCyberGrindSafety.Initialize(((BaseUnityPlugin)this).Logger); _showOnStartup = ((BaseUnityPlugin)this).Config.Bind("Startup", "ShowUltraUnlock", true, "Show the UltraUnlock when ULTRAKILL starts. This can also be changed in the Options menu."); SceneManager.sceneLoaded += OnSceneLoaded; _harmony = new Harmony("com.silentsmilee.ultraunlock"); _harmony.PatchAll(typeof(UltraUnlock).Assembly); if (_showOnStartup.Value) { _modActive = true; Time.timeScale = 0f; AudioListener.pause = true; Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; } } private void Start() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) UltraUnlockCyberGrindSafety.OnSceneLoaded(SceneManager.GetActiveScene()); ((MonoBehaviour)this).StartCoroutine(InstallOptionsStartupToggle(SceneManager.GetActiveScene())); if (_modActive) { BuildOverlayIfNeeded(); } } private void OnDestroy() { SceneManager.sceneLoaded -= OnSceneLoaded; Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) if (!_modActive) { return; } Cursor.visible = true; Cursor.lockState = (CursorLockMode)0; if ((Object)(object)_circuitBackground != (Object)null) { Rect uvRect = _circuitBackground.uvRect; ((Rect)(ref uvRect)).y = ((Rect)(ref uvRect)).y - 0.1f * Time.unscaledDeltaTime; if (((Rect)(ref uvRect)).y <= -1f) { ((Rect)(ref uvRect)).y = ((Rect)(ref uvRect)).y + 1f; } _circuitBackground.uvRect = uvRect; } } private void OnSceneLoaded(Scene scene, LoadSceneMode mode) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) UltraUnlockCyberGrindSafety.OnSceneLoaded(scene); ((MonoBehaviour)this).StartCoroutine(InstallOptionsStartupToggle(scene)); if (_modActive) { BuildOverlayIfNeeded(); } } private void BuildOverlayIfNeeded() { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) if (!_built) { LoadThemeAssets(); EnsureEventSystem(); _overlayRoot = new GameObject("UltraUnlock_Overlay"); Object.DontDestroyOnLoad((Object)(object)_overlayRoot); Canvas obj = _overlayRoot.AddComponent(); obj.renderMode = (RenderMode)0; obj.sortingOrder = 32767; CanvasScaler obj2 = _overlayRoot.AddComponent(); obj2.uiScaleMode = (ScaleMode)1; obj2.referenceResolution = new Vector2(1920f, 1080f); obj2.matchWidthOrHeight = 0.5f; _overlayRoot.AddComponent(); RectTransform val = MakeRect(_overlayRoot.transform, "Backdrop"); Stretch(val); ((Graphic)AddImage(((Component)val).gameObject, null, Color.black, sliced: false)).raycastTarget = false; RectTransform val2 = MakeRect((Transform)(object)val, "CircuitBackground"); Stretch(val2); _circuitBackground = ((Component)val2).gameObject.AddComponent(); _circuitBackground.texture = (Texture)(object)_circuitTexture; ((Graphic)_circuitBackground).color = new Color(0.25f, 0.25f, 0.25f, 1f); _circuitBackground.uvRect = new Rect(0f, 0f, 3f, 3f); ((Graphic)_circuitBackground).raycastTarget = false; _content = MakeRect((Transform)(object)val, "Content"); Stretch(_content); _built = true; ShowScreen(Screen.Home); } } private void LoadThemeAssets() { _borderLarge = LoadSprite("UltraUnlock.Assets.Round_BorderLarge.png", "Round_BorderLarge", 41f); _fillLarge = LoadSprite("UltraUnlock.Assets.Round_FillLarge.png", "Round_FillLarge", 37f); _pausePanelFill = LoadSprite("UltraUnlock.Assets.Round_VertHandle_Invert_1.png", "Round_VertHandle_Invert 1", 117f); _borderSmall = LoadSprite("UltraUnlock.Assets.Round_BorderSmall.png", "Round_BorderSmall", 29f); _checkmark = LoadSprite("UltraUnlock.Assets.Check.png", "Check", 0f); _folderIcon = LoadSprite("UltraUnlock.Assets.SmileOsFolder.png", "smileOS 2 folder", 0f); _circuitTexture = LoadTexture("UltraUnlock.Assets.TextmodeCircuit.png", "TextmodeCircuit", repeat: true); TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll(); foreach (TMP_FontAsset val in array) { if ((Object)(object)val != (Object)null && ((Object)val).name == "VCR_OSD_MONO_1") { _font = val; break; } } if ((Object)(object)_font == (Object)null) { array = Resources.FindObjectsOfTypeAll(); foreach (TMP_FontAsset val2 in array) { if ((Object)(object)val2 != (Object)null && ((Object)val2).name.Contains("VCR_OSD")) { _font = val2; break; } } } if ((Object)(object)_font == (Object)null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"UltraUnlock could not find VCR_OSD_MONO_1; TextMesh Pro will use its current default font."); } } private Sprite LoadSprite(string resourceName, string spriteName, float border) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) Texture2D val = LoadTexture(resourceName, spriteName, repeat: false); Vector4 val2 = default(Vector4); ((Vector4)(ref val2))..ctor(border, border, border, border); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, val2); ((Object)obj).name = spriteName; return obj; } private static Texture2D LoadTexture(string resourceName, string textureName, bool repeat) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(resourceName); if (stream == null) { throw new InvalidOperationException("Missing embedded UI asset: " + resourceName); } using MemoryStream memoryStream = new MemoryStream(); stream.CopyTo(memoryStream); Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false); if (!ImageConversion.LoadImage(val, memoryStream.ToArray(), false)) { throw new InvalidOperationException("Could not decode embedded UI asset: " + resourceName); } ((Object)val).name = textureName; ((Texture)val).wrapMode = (TextureWrapMode)(!repeat); ((Texture)val).filterMode = (FilterMode)1; return val; } private static void EnsureEventSystem() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_001e: Unknown result type (might be due to invalid IL or missing references) if (!((Object)(object)Object.FindObjectOfType() != (Object)null)) { GameObject val = new GameObject("UltraUnlock_EventSystem"); Object.DontDestroyOnLoad((Object)val); val.AddComponent(); val.AddComponent(); } } private IEnumerator InstallOptionsStartupToggle(Scene scene) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (_showOnStartup == null || _showOnStartup.Value) { yield break; } yield return null; for (int attempt = 0; attempt < 90; attempt++) { if ((Object)(object)_optionsStartupToggle != (Object)null) { break; } Transform navigationRail = FindOptionsNavigationRail(scene); if ((Object)(object)navigationRail == (Object)null) { yield return null; continue; } Button val = FindPluginConfiguratorButton(navigationRail); if ((Object)(object)val == (Object)null && attempt < 10) { yield return null; continue; } Button val2 = val ?? FindNavigationButtonTemplate(navigationRail); if ((Object)(object)val2 == (Object)null) { yield return null; continue; } _optionsStartupToggle = Object.Instantiate(((Component)val2).gameObject, navigationRail, false); ((Object)_optionsStartupToggle).name = "UltraUnlockStartupToggle"; _optionsStartupToggle.SetActive(true); Button component = _optionsStartupToggle.GetComponent