using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
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.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: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("PasswordLock")]
[assembly: AssemblyTitle("PasswordLock")]
[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 Omniscye.RepoPasswordLock
{
[BepInPlugin("Omniscye.RepoPasswordLock", "RepoPasswordLock", "1.0.0")]
public class RepoPasswordLock : BaseUnityPlugin
{
[HarmonyPatch(typeof(SplashScreen), "Awake")]
private static class SplashScreen_Awake_Patch
{
private static void Postfix()
{
try
{
PasswordGate.SpawnOrWake();
}
catch (Exception arg)
{
Logger.LogError((object)$"Failed to spawn PasswordGate: {arg}");
}
}
}
public const string PluginGuid = "Omniscye.RepoPasswordLock";
public const string PluginName = "RepoPasswordLock";
public const string PluginVersion = "1.0.0";
internal static ConfigEntry<string> PasswordHash;
internal static ConfigEntry<string> PasswordSalt;
internal static RepoPasswordLock Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
private void Awake()
{
Instance = this;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
PasswordHash = ((BaseUnityPlugin)this).Config.Bind<string>("Security", "PasswordHash", string.Empty, "SHA256(salt+password). Stored as hex.");
PasswordSalt = ((BaseUnityPlugin)this).Config.Bind<string>("Security", "Salt", string.Empty, "Random 16-byte salt (hex).");
Patch();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded.");
}
internal void Patch()
{
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Expected O, but got Unknown
//IL_0026: Expected O, but got Unknown
if (Harmony == null)
{
Harmony val = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony val2 = val;
Harmony = val;
}
Harmony.PatchAll();
}
internal void Unpatch()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
}
internal static string ComputeHash(string saltHex, string password)
{
string saltHex2 = saltHex;
if (string.IsNullOrEmpty(saltHex2))
{
return string.Empty;
}
byte[] array = (from i in Enumerable.Range(0, saltHex2.Length / 2)
select Convert.ToByte(saltHex2.Substring(i * 2, 2), 16)).ToArray();
using SHA256 sHA = SHA256.Create();
byte[] array2 = new byte[array.Length + Encoding.UTF8.GetByteCount(password)];
Buffer.BlockCopy(array, 0, array2, 0, array.Length);
Encoding.UTF8.GetBytes(password, 0, password.Length, array2, array.Length);
byte[] array3 = sHA.ComputeHash(array2);
StringBuilder stringBuilder = new StringBuilder(array3.Length * 2);
byte[] array4 = array3;
foreach (byte b in array4)
{
stringBuilder.Append(b.ToString("x2"));
}
return stringBuilder.ToString();
}
internal static string NewSalt()
{
byte[] array = new byte[16];
RandomNumberGenerator.Fill(array);
StringBuilder stringBuilder = new StringBuilder(array.Length * 2);
byte[] array2 = array;
foreach (byte b in array2)
{
stringBuilder.Append(b.ToString("x2"));
}
return stringBuilder.ToString();
}
}
internal class PasswordGate : MonoBehaviour
{
private enum Phase
{
Hello,
Create,
Confirm,
Enter,
Done
}
[CompilerGenerated]
private sealed class <FadeCanvas>d__34 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float target;
public float duration;
public PasswordGate <>4__this;
private float <start>5__1;
private float <t>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeCanvas>d__34(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<start>5__1 = <>4__this._group.alpha;
<t>5__2 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__2 < duration)
{
<t>5__2 += Time.unscaledDeltaTime;
<>4__this._group.alpha = Mathf.Lerp(<start>5__1, target, Mathf.SmoothStep(0f, 1f, <t>5__2 / duration));
<>2__current = null;
<>1__state = 1;
return true;
}
<>4__this._group.alpha = target;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <FadeGrid>d__33 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float target;
public float duration;
public PasswordGate <>4__this;
private float <start>5__1;
private Graphic[] <imgs>5__2;
private float <t>5__3;
private float <a>5__4;
private Graphic[] <>s__5;
private int <>s__6;
private Graphic <g>5__7;
private Graphic[] <>s__8;
private int <>s__9;
private Graphic <g>5__10;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeGrid>d__33(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<imgs>5__2 = null;
<>s__5 = null;
<g>5__7 = null;
<>s__8 = null;
<g>5__10 = null;
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<start>5__1 = 1f;
<imgs>5__2 = ((Component)<>4__this._grid).GetComponentsInChildren<Graphic>(true);
<start>5__1 = ((<imgs>5__2.Length != 0) ? <imgs>5__2[0].canvasRenderer.GetAlpha() : 1f);
<t>5__3 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__3 < duration)
{
<t>5__3 += Time.unscaledDeltaTime;
<a>5__4 = Mathf.Lerp(<start>5__1, target, Mathf.SmoothStep(0f, 1f, <t>5__3 / duration));
<>s__5 = <imgs>5__2;
for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
{
<g>5__7 = <>s__5[<>s__6];
<g>5__7.canvasRenderer.SetAlpha(<a>5__4);
<g>5__7 = null;
}
<>s__5 = null;
<>2__current = null;
<>1__state = 1;
return true;
}
<>s__8 = <imgs>5__2;
for (<>s__9 = 0; <>s__9 < <>s__8.Length; <>s__9++)
{
<g>5__10 = <>s__8[<>s__9];
<g>5__10.canvasRenderer.SetAlpha(target);
<g>5__10 = null;
}
<>s__8 = null;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <FadeTitle>d__32 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float target;
public float duration;
public PasswordGate <>4__this;
private float <start>5__1;
private float <t>5__2;
private float <a>5__3;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <FadeTitle>d__32(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<start>5__1 = <>4__this._title.alpha;
<t>5__2 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<t>5__2 < duration)
{
<t>5__2 += Time.unscaledDeltaTime;
<a>5__3 = Mathf.Lerp(<start>5__1, target, Mathf.SmoothStep(0f, 1f, <t>5__2 / duration));
<>4__this._title.alpha = <a>5__3;
<>2__current = null;
<>1__state = 1;
return true;
}
<>4__this._title.alpha = target;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <HandleFourDigits>d__30 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PasswordGate <>4__this;
private Button[] <>s__1;
private int <>s__2;
private Button <b>5__3;
private bool <ok>5__4;
private Button[] <>s__5;
private int <>s__6;
private Button <b>5__7;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <HandleFourDigits>d__30(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>s__1 = null;
<b>5__3 = null;
<>s__5 = null;
<b>5__7 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0307: Unknown result type (might be due to invalid IL or missing references)
//IL_042e: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>s__1 = <>4__this._digitButtons;
for (<>s__2 = 0; <>s__2 < <>s__1.Length; <>s__2++)
{
<b>5__3 = <>s__1[<>s__2];
((Selectable)<b>5__3).interactable = false;
<b>5__3 = null;
}
<>s__1 = null;
<>2__current = Hold(0.05f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
if (<>4__this._phase == Phase.Create)
{
<>4__this._firstSet = <>4__this._entry;
<>4__this._entry = string.Empty;
<>4__this._progressDots.text = string.Empty;
<>2__current = <>4__this.FadeGrid(0f, 0.25f);
<>1__state = 2;
return true;
}
if (<>4__this._phase == Phase.Confirm)
{
if (<>4__this._entry == <>4__this._firstSet)
{
if (string.IsNullOrEmpty(RepoPasswordLock.PasswordSalt.Value))
{
RepoPasswordLock.PasswordSalt.Value = RepoPasswordLock.NewSalt();
}
RepoPasswordLock.PasswordHash.Value = RepoPasswordLock.ComputeHash(RepoPasswordLock.PasswordSalt.Value, <>4__this._entry);
((BaseUnityPlugin)RepoPasswordLock.Instance).Config.Save();
<>2__current = <>4__this.FadeGrid(0f, 0.25f);
<>1__state = 5;
return true;
}
((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.TitleFlash("Mismatch. Try again", new Color(0.8f, 0.2f, 0.2f, 1f)));
<>4__this._entry = string.Empty;
<>4__this._progressDots.text = string.Empty;
}
else if (<>4__this._phase == Phase.Enter)
{
<ok>5__4 = RepoPasswordLock.ComputeHash(RepoPasswordLock.PasswordSalt.Value, <>4__this._entry) == RepoPasswordLock.PasswordHash.Value;
if (<ok>5__4)
{
<>2__current = <>4__this.FadeGrid(0f, 0.2f);
<>1__state = 7;
return true;
}
((MonoBehaviour)<>4__this).StartCoroutine(<>4__this.TitleFlash("Nope.", new Color(0.8f, 0.2f, 0.2f, 1f)));
<>4__this._entry = string.Empty;
<>4__this._progressDots.text = string.Empty;
}
break;
case 2:
<>1__state = -1;
<>4__this._title.text = "Confirm Password";
<>2__current = Hold(0.2f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
<>2__current = <>4__this.FadeGrid(1f, 0.25f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
<>4__this._phase = Phase.Confirm;
break;
case 5:
<>1__state = -1;
<>4__this._title.text = "Welcome to R.E.P.O";
<>2__current = Hold(0.6f);
<>1__state = 6;
return true;
case 6:
<>1__state = -1;
<>4__this._phase = Phase.Done;
break;
case 7:
<>1__state = -1;
<>4__this._title.text = "Welcome to R.E.P.O";
<>2__current = Hold(0.6f);
<>1__state = 8;
return true;
case 8:
<>1__state = -1;
<>4__this._phase = Phase.Done;
break;
}
<>s__5 = <>4__this._digitButtons;
for (<>s__6 = 0; <>s__6 < <>s__5.Length; <>s__6++)
{
<b>5__7 = <>s__5[<>s__6];
((Selectable)<b>5__7).interactable = true;
<b>5__7 = null;
}
<>s__5 = null;
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <Hold>d__35 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public float t;
private float <e>5__1;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Hold>d__35(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<e>5__1 = 0f;
break;
case 1:
<>1__state = -1;
break;
}
if (<e>5__1 < t)
{
<e>5__1 += Time.unscaledDeltaTime;
<>2__current = null;
<>1__state = 1;
return true;
}
return false;
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <Run>d__27 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public PasswordGate <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <Run>d__27(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>4__this._phase = Phase.Hello;
<>2__current = <>4__this.FadeCanvas(1f, 0.35f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
((Component)<>4__this._grid).gameObject.SetActive(false);
((Component)<>4__this._progressDots).gameObject.SetActive(false);
<>4__this._title.text = "Hello";
<>2__current = Hold(0.6f);
<>1__state = 2;
return true;
case 2:
<>1__state = -1;
<>2__current = <>4__this.FadeTitle(0f, 0.6f);
<>1__state = 3;
return true;
case 3:
<>1__state = -1;
if (<>4__this._hasSaved)
{
<>4__this._phase = Phase.Enter;
<>4__this._title.text = "Enter Password";
}
else
{
<>4__this._phase = Phase.Create;
<>4__this._title.text = "Create a Password";
}
<>4__this._progressDots.text = string.Empty;
((Component)<>4__this._progressDots).gameObject.SetActive(true);
((Component)<>4__this._grid).gameObject.SetActive(true);
<>2__current = <>4__this.FadeTitle(1f, 0.6f);
<>1__state = 4;
return true;
case 4:
<>1__state = -1;
goto IL_01f9;
case 5:
<>1__state = -1;
goto IL_01f9;
case 6:
{
<>1__state = -1;
<>4__this.CleanupAndClose();
return false;
}
IL_01f9:
if (<>4__this._phase != Phase.Done)
{
<>2__current = null;
<>1__state = 5;
return true;
}
<>2__current = <>4__this.FadeCanvas(0f, 0.4f);
<>1__state = 6;
return true;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <TitleFlash>d__31 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public string text;
public Color color;
public PasswordGate <>4__this;
private Color <original>5__1;
private string <originalText>5__2;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <TitleFlash>d__31(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<originalText>5__2 = null;
<>1__state = -2;
}
private bool MoveNext()
{
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<original>5__1 = ((Graphic)<>4__this._title).color;
<originalText>5__2 = <>4__this._title.text;
<>4__this._title.text = text;
((Graphic)<>4__this._title).color = color;
<>4__this.PlayClick(0.5f, 200f);
<>2__current = Hold(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this._title.text = <originalText>5__2;
((Graphic)<>4__this._title).color = <original>5__1;
return false;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
private static PasswordGate? _instance;
private Canvas _canvas = null;
private CanvasGroup _group = null;
private Image _backdrop = null;
private RectTransform _panel = null;
private TMP_Text _title = null;
private GridLayoutGroup _grid = null;
private Button[] _digitButtons = Array.Empty<Button>();
private TMP_Text _progressDots = null;
private AudioSource _audio = null;
private string _entry = string.Empty;
private string _firstSet = string.Empty;
private float _prevTimeScale;
private bool _uiBuilt = false;
private CursorLockMode _prevCursorLock;
private bool _prevCursorVisible;
private Phase _phase;
private bool _hasSaved => !string.IsNullOrEmpty(RepoPasswordLock.PasswordHash.Value);
public static void SpawnOrWake()
{
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
if ((Object)(object)_instance != (Object)null)
{
((Component)_instance).gameObject.SetActive(true);
_instance.Begin();
return;
}
GameObject val = new GameObject("RepoPasswordGate", new Type[1] { typeof(PasswordGate) });
Object.DontDestroyOnLoad((Object)(object)val);
_instance = val.GetComponent<PasswordGate>();
_instance.Begin();
}
private void Begin()
{
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (!_uiBuilt)
{
BuildUI();
}
else
{
ResetUIState();
}
_prevTimeScale = Time.timeScale;
Time.timeScale = 0f;
_prevCursorLock = Cursor.lockState;
_prevCursorVisible = Cursor.visible;
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
EventSystemEnsure();
((MonoBehaviour)this).StopAllCoroutines();
((MonoBehaviour)this).StartCoroutine(Run());
}
private void OnDestroy()
{
//IL_003a: Unknown result type (might be due to invalid IL or missing references)
if (Mathf.Approximately(Time.timeScale, 0f))
{
Time.timeScale = (Mathf.Approximately(_prevTimeScale, 0f) ? 1f : _prevTimeScale);
}
Cursor.lockState = _prevCursorLock;
Cursor.visible = _prevCursorVisible;
_instance = null;
}
private void ResetUIState()
{
_entry = string.Empty;
_firstSet = string.Empty;
if ((Object)(object)_progressDots != (Object)null)
{
_progressDots.text = string.Empty;
_progressDots.alpha = 1f;
}
if ((Object)(object)_title != (Object)null)
{
_title.alpha = 1f;
}
if ((Object)(object)_group != (Object)null)
{
_group.alpha = 0f;
}
if ((Object)(object)_grid != (Object)null)
{
((Component)_grid).gameObject.SetActive(false);
Graphic[] componentsInChildren = ((Component)_grid).GetComponentsInChildren<Graphic>(true);
foreach (Graphic val in componentsInChildren)
{
val.canvasRenderer.SetAlpha(1f);
}
}
if (_digitButtons != null)
{
Button[] digitButtons = _digitButtons;
foreach (Button val2 in digitButtons)
{
((Selectable)val2).interactable = true;
}
}
}
private void BuildUI()
{
//IL_004f: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b9: Expected O, but got Unknown
//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
//IL_010a: Unknown result type (might be due to invalid IL or missing references)
//IL_0116: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Unknown result type (might be due to invalid IL or missing references)
//IL_012e: Unknown result type (might be due to invalid IL or missing references)
//IL_013e: Unknown result type (might be due to invalid IL or missing references)
//IL_0144: Expected O, but got Unknown
//IL_0178: Unknown result type (might be due to invalid IL or missing references)
//IL_0193: Unknown result type (might be due to invalid IL or missing references)
//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
//IL_01da: Unknown result type (might be due to invalid IL or missing references)
//IL_020d: Unknown result type (might be due to invalid IL or missing references)
//IL_0217: Expected O, but got Unknown
//IL_0271: Unknown result type (might be due to invalid IL or missing references)
//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
//IL_02c7: Expected O, but got Unknown
//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0314: Unknown result type (might be due to invalid IL or missing references)
//IL_032b: Unknown result type (might be due to invalid IL or missing references)
//IL_0342: Unknown result type (might be due to invalid IL or missing references)
//IL_034f: Unknown result type (might be due to invalid IL or missing references)
//IL_036a: Unknown result type (might be due to invalid IL or missing references)
//IL_0385: Unknown result type (might be due to invalid IL or missing references)
_canvas = ((Component)this).gameObject.AddComponent<Canvas>();
_canvas.renderMode = (RenderMode)0;
_canvas.sortingOrder = 32767;
CanvasScaler val = ((Component)this).gameObject.AddComponent<CanvasScaler>();
val.uiScaleMode = (ScaleMode)1;
val.referenceResolution = new Vector2(1920f, 1080f);
val.matchWidthOrHeight = 0.5f;
((Component)this).gameObject.AddComponent<GraphicRaycaster>();
_group = ((Component)this).gameObject.AddComponent<CanvasGroup>();
_group.alpha = 0f;
_group.interactable = true;
_group.blocksRaycasts = true;
GameObject val2 = new GameObject("Backdrop");
val2.transform.SetParent(((Component)_canvas).transform, false);
_backdrop = val2.AddComponent<Image>();
((Graphic)_backdrop).color = new Color(0f, 0f, 0f, 0.98f);
RectTransform component = val2.GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.offsetMin = Vector2.zero;
component.offsetMax = Vector2.zero;
GameObject val3 = new GameObject("Panel");
val3.transform.SetParent(((Component)_canvas).transform, false);
_panel = val3.AddComponent<RectTransform>();
_panel.anchorMin = new Vector2(0.5f, 0.5f);
_panel.anchorMax = new Vector2(0.5f, 0.5f);
_panel.pivot = new Vector2(0.5f, 0.5f);
_panel.sizeDelta = new Vector2(900f, 800f);
_panel.anchoredPosition = Vector2.zero;
VerticalLayoutGroup val4 = val3.AddComponent<VerticalLayoutGroup>();
((LayoutGroup)val4).childAlignment = (TextAnchor)4;
((HorizontalOrVerticalLayoutGroup)val4).spacing = 24f;
((LayoutGroup)val4).padding = new RectOffset(20, 20, 20, 20);
((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = false;
((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = false;
((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false;
_title = MakeText(val3.transform, "Hello", 64, (FontStyles)17);
((Graphic)_title).color = new Color(0.85f, 0.85f, 0.85f, 1f);
_progressDots = MakeText(val3.transform, "", 42, (FontStyles)1);
((Graphic)_progressDots).color = new Color(0.8f, 0.8f, 0.8f, 1f);
GameObject val5 = new GameObject("DigitGrid");
val5.transform.SetParent(val3.transform, false);
_grid = val5.AddComponent<GridLayoutGroup>();
RectTransform component2 = val5.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0.5f, 0.5f);
component2.anchorMax = new Vector2(0.5f, 0.5f);
component2.pivot = new Vector2(0.5f, 0.5f);
component2.sizeDelta = new Vector2(600f, 600f);
component2.anchoredPosition = Vector2.zero;
_grid.cellSize = new Vector2(170f, 170f);
_grid.spacing = new Vector2(30f, 30f);
_grid.constraint = (Constraint)1;
_grid.constraintCount = 3;
_digitButtons = Enumerable.Range(1, 9).Select(MakeDigitButton).ToArray();
_audio = ((Component)this).gameObject.AddComponent<AudioSource>();
_audio.playOnAwake = false;
_audio.spatialBlend = 0f;
_uiBuilt = true;
}
private TMP_Text MakeText(Transform parent, string content, int size, FontStyles styles)
{
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Expected O, but got Unknown
//IL_0057: 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)
GameObject val = new GameObject("TMPText");
val.transform.SetParent(parent, false);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = content;
((TMP_Text)val2).fontSize = size;
((TMP_Text)val2).alignment = (TextAlignmentOptions)514;
((TMP_Text)val2).enableAutoSizing = false;
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
((TMP_Text)val2).fontStyle = styles;
RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
rectTransform.sizeDelta = new Vector2(1000f, (float)(size + 60));
return (TMP_Text)(object)val2;
}
private Button MakeDigitButton(int digit)
{
//IL_002a: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
//IL_0064: Unknown result type (might be due to invalid IL or missing references)
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
//IL_010c: Unknown result type (might be due to invalid IL or missing references)
//IL_012d: Unknown result type (might be due to invalid IL or missing references)
//IL_0138: Unknown result type (might be due to invalid IL or missing references)
//IL_013a: Unknown result type (might be due to invalid IL or missing references)
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
//IL_014a: Unknown result type (might be due to invalid IL or missing references)
//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
//IL_020b: Unknown result type (might be due to invalid IL or missing references)
//IL_0215: Expected O, but got Unknown
GameObject val = new GameObject($"Digit_{digit}");
val.transform.SetParent(((Component)_grid).transform, false);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(0.1f, 0.1f, 0.1f, 0.85f);
((Graphic)val2).raycastTarget = true;
Button val3 = val.AddComponent<Button>();
ColorBlock val4 = default(ColorBlock);
((ColorBlock)(ref val4)).colorMultiplier = 1f;
((ColorBlock)(ref val4)).normalColor = new Color(0.1f, 0.1f, 0.1f, 0.85f);
((ColorBlock)(ref val4)).highlightedColor = new Color(0.2f, 0.2f, 0.2f, 0.95f);
((ColorBlock)(ref val4)).pressedColor = new Color(0.6f, 0.6f, 0.1f, 1f);
((ColorBlock)(ref val4)).selectedColor = new Color(0.2f, 0.2f, 0.2f, 0.95f);
((ColorBlock)(ref val4)).disabledColor = new Color(0.05f, 0.05f, 0.05f, 0.5f);
ColorBlock colors = val4;
((Selectable)val3).colors = colors;
TextMeshProUGUI val5 = new GameObject("Label").AddComponent<TextMeshProUGUI>();
((TMP_Text)val5).transform.SetParent(val.transform, false);
((TMP_Text)val5).text = digit.ToString();
((TMP_Text)val5).alignment = (TextAlignmentOptions)514;
((TMP_Text)val5).fontSize = 64f;
((TMP_Text)val5).fontStyle = (FontStyles)1;
((Graphic)val5).color = new Color(0.85f, 0.85f, 0.85f, 1f);
RectTransform rectTransform = ((TMP_Text)val5).rectTransform;
rectTransform.anchorMin = Vector2.zero;
rectTransform.anchorMax = Vector2.one;
rectTransform.offsetMin = Vector2.zero;
rectTransform.offsetMax = Vector2.zero;
((UnityEvent)val3.onClick).AddListener((UnityAction)delegate
{
OnDigit(digit);
});
return val3;
}
[IteratorStateMachine(typeof(<Run>d__27))]
private IEnumerator Run()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Run>d__27(0)
{
<>4__this = this
};
}
private void CleanupAndClose()
{
//IL_0027: Unknown result type (might be due to invalid IL or missing references)
Time.timeScale = (Mathf.Approximately(_prevTimeScale, 0f) ? 1f : _prevTimeScale);
Cursor.lockState = _prevCursorLock;
Cursor.visible = _prevCursorVisible;
_instance = null;
Object.Destroy((Object)(object)((Component)this).gameObject);
}
private void OnDigit(int d)
{
PlayClick();
if (_phase == Phase.Create || _phase == Phase.Confirm || _phase == Phase.Enter)
{
_entry += d;
_progressDots.text = new string('•', _entry.Length);
if (_entry.Length >= 4)
{
((MonoBehaviour)this).StartCoroutine(HandleFourDigits());
}
}
}
[IteratorStateMachine(typeof(<HandleFourDigits>d__30))]
private IEnumerator HandleFourDigits()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <HandleFourDigits>d__30(0)
{
<>4__this = this
};
}
[IteratorStateMachine(typeof(<TitleFlash>d__31))]
private IEnumerator TitleFlash(string text, Color color)
{
//IL_0015: Unknown result type (might be due to invalid IL or missing references)
//IL_0016: Unknown result type (might be due to invalid IL or missing references)
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <TitleFlash>d__31(0)
{
<>4__this = this,
text = text,
color = color
};
}
[IteratorStateMachine(typeof(<FadeTitle>d__32))]
private IEnumerator FadeTitle(float target, float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeTitle>d__32(0)
{
<>4__this = this,
target = target,
duration = duration
};
}
[IteratorStateMachine(typeof(<FadeGrid>d__33))]
private IEnumerator FadeGrid(float target, float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeGrid>d__33(0)
{
<>4__this = this,
target = target,
duration = duration
};
}
[IteratorStateMachine(typeof(<FadeCanvas>d__34))]
private IEnumerator FadeCanvas(float target, float duration)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <FadeCanvas>d__34(0)
{
<>4__this = this,
target = target,
duration = duration
};
}
[IteratorStateMachine(typeof(<Hold>d__35))]
private static IEnumerator Hold(float t)
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <Hold>d__35(0)
{
t = t
};
}
private void EventSystemEnsure()
{
//IL_0037: Unknown result type (might be due to invalid IL or missing references)
//IL_003d: Expected O, but got Unknown
if (!((Object)(object)EventSystem.current != (Object)null))
{
GameObject val = new GameObject("EventSystem", new Type[2]
{
typeof(EventSystem),
typeof(StandaloneInputModule)
});
Object.DontDestroyOnLoad((Object)(object)val);
}
}
private void PlayClick(float volume = 1f, float hz = 440f)
{
int num = 22050;
float num2 = 0.06f;
int num3 = Mathf.CeilToInt((float)num * num2);
float[] array = new float[num3];
for (int i = 0; i < num3; i++)
{
float num4 = (float)i / (float)num;
float num5 = Mathf.Clamp01(Mathf.Min(num4 * 40f, (num2 - num4) * 60f));
array[i] = Mathf.Sin(MathF.PI * 2f * hz * num4) * num5 * 0.5f;
}
AudioClip val = AudioClip.Create("ui_click", num3, 1, num, false);
val.SetData(array, 0);
_audio.pitch = Random.Range(0.95f, 1.05f);
_audio.PlayOneShot(val, volume);
}
}
}