using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
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: AssemblyCompany("Omniscye")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d6b9a17f444632a047419185c533d1083cae6463")]
[assembly: AssemblyProduct("ModuleManager")]
[assembly: AssemblyTitle("ModuleManager")]
[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 Empress.ModuleBrowser
{
[BepInPlugin("Empress.ModuleBrowser", "Module Manager", "1.1.3")]
public class ModuleBrowser : BaseUnityPlugin
{
private struct LevelOption
{
public string Name;
public object Ref;
}
private struct ModuleEntry
{
public string Display;
public string Key;
public string ResourcePath;
public int Difficulty;
public int TypeKey;
public object PrefabRef;
public object LevelRef;
public string LevelName;
}
[CompilerGenerated]
private sealed class <>c__DisplayClass72_0
{
public string levelName;
internal bool <DiscoverRoutine>b__1(LevelOption l)
{
return string.Equals(l.Name, levelName, StringComparison.OrdinalIgnoreCase);
}
}
[CompilerGenerated]
private sealed class <DiscoverRoutine>d__72 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ModuleBrowser <>4__this;
private Type <rmType>5__1;
private FieldInfo <rm>5__2;
private object <inst>5__3;
private IEnumerable <levelsEnum>5__4;
private (int typeKey, int diff, string field)[] <map>5__5;
private int <totalFound>5__6;
private IEnumerator <>s__7;
private object <level>5__8;
private <>c__DisplayClass72_0 <>8__9;
private Type <levelType>5__10;
private int <foundForLevel>5__11;
private (int typeKey, int diff, string field)[] <>s__12;
private int <>s__13;
private int <typeKey>5__14;
private int <diff>5__15;
private string <field>5__16;
private FieldInfo <fi>5__17;
private IEnumerable <listObj>5__18;
private IEnumerator <>s__19;
private object <pref>5__20;
private string <name>5__21;
private string <resPath>5__22;
private string <display>5__23;
private string <key>5__24;
private ModuleEntry <entry>5__25;
private List<ModuleEntry> <bucket>5__26;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <DiscoverRoutine>d__72(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
int num = <>1__state;
if (num == -3 || num == 1)
{
try
{
}
finally
{
<>m__Finally1();
}
}
<rmType>5__1 = null;
<rm>5__2 = null;
<inst>5__3 = null;
<levelsEnum>5__4 = null;
<map>5__5 = null;
<>s__7 = null;
<level>5__8 = null;
<>8__9 = null;
<levelType>5__10 = null;
<>s__12 = null;
<field>5__16 = null;
<fi>5__17 = null;
<listObj>5__18 = null;
<>s__19 = null;
<pref>5__20 = null;
<name>5__21 = null;
<resPath>5__22 = null;
<display>5__23 = null;
<key>5__24 = null;
<entry>5__25 = default(ModuleEntry);
<bucket>5__26 = null;
<>1__state = -2;
}
private bool MoveNext()
{
try
{
int num = <>1__state;
if (num != 0)
{
if (num != 1)
{
return false;
}
<>1__state = -3;
<fi>5__17 = null;
<listObj>5__18 = null;
<field>5__16 = null;
goto IL_068d;
}
<>1__state = -1;
<>4__this._entries.Clear();
<>4__this._entriesByType.Clear();
<>4__this._moduleByKey.Clear();
<>4__this._levels.Clear();
<rmType>5__1 = FindTypeBySimpleName("RunManager");
<rm>5__2 = <rmType>5__1?.GetField("levels", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
<inst>5__3 = <rmType>5__1?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
if (<inst>5__3 == null)
{
Logger.LogWarning((object)"RunManager.instance not found — open a save / be in-game.");
return false;
}
<levelsEnum>5__4 = <rm>5__2?.GetValue(<inst>5__3) as IEnumerable;
if (<levelsEnum>5__4 == null)
{
Logger.LogWarning((object)"RunManager.levels is null.");
return false;
}
<map>5__5 = new(int, int, string)[12]
{
(0, 1, "ModulesNormal1"),
(0, 2, "ModulesNormal2"),
(0, 3, "ModulesNormal3"),
(1, 1, "ModulesPassage1"),
(1, 2, "ModulesPassage2"),
(1, 3, "ModulesPassage3"),
(2, 1, "ModulesDeadEnd1"),
(2, 2, "ModulesDeadEnd2"),
(2, 3, "ModulesDeadEnd3"),
(3, 1, "ModulesExtraction1"),
(3, 2, "ModulesExtraction2"),
(3, 3, "ModulesExtraction3")
};
<totalFound>5__6 = 0;
<>s__7 = <levelsEnum>5__4.GetEnumerator();
<>1__state = -3;
goto IL_0740;
IL_0740:
do
{
if (<>s__7.MoveNext())
{
<level>5__8 = <>s__7.Current;
<>8__9 = new <>c__DisplayClass72_0();
continue;
}
<>m__Finally1();
<>s__7 = null;
<>4__this._levels.Sort((LevelOption a, LevelOption b) => string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase));
<>4__this.UpdateLevelButtonText();
Logger.LogInfo((object)$"Discovered {<totalFound>5__6} modules across all levels.");
if (_uiVisible)
{
<>4__this.RefreshCurrentTab();
}
return false;
}
while (<level>5__8 == null);
<levelType>5__10 = <level>5__8.GetType();
<>8__9.levelName = TryGetString(<level>5__8, "NarrativeName") ?? "(Unnamed Level)";
<foundForLevel>5__11 = 0;
<>s__12 = <map>5__5;
<>s__13 = 0;
goto IL_069b;
IL_068d:
<>s__13++;
goto IL_069b;
IL_069b:
if (<>s__13 < <>s__12.Length)
{
(int, int, string) tuple = <>s__12[<>s__13];
<typeKey>5__14 = tuple.Item1;
<diff>5__15 = tuple.Item2;
<field>5__16 = tuple.Item3;
<fi>5__17 = <levelType>5__10.GetField(<field>5__16, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
<listObj>5__18 = <fi>5__17?.GetValue(<level>5__8) as IEnumerable;
if (<listObj>5__18 == null)
{
goto IL_068d;
}
<>s__19 = <listObj>5__18.GetEnumerator();
try
{
while (<>s__19.MoveNext())
{
<pref>5__20 = <>s__19.Current;
if (<pref>5__20 == null)
{
continue;
}
<name>5__21 = TryGetString(<pref>5__20, "PrefabName");
<resPath>5__22 = TryGetString(<pref>5__20, "ResourcePath");
if (string.IsNullOrWhiteSpace(<name>5__21) && string.IsNullOrWhiteSpace(<resPath>5__22))
{
continue;
}
<display>5__23 = ((!string.IsNullOrWhiteSpace(<name>5__21)) ? <name>5__21 : Path.GetFileName(<resPath>5__22));
<display>5__23 = <>4__this.RxModuleTrim.Replace(<display>5__23 ?? "", "").Trim();
<key>5__24 = ((!string.IsNullOrWhiteSpace(<name>5__21)) ? <name>5__21 : <resPath>5__22)?.ToLowerInvariant();
if (!string.IsNullOrEmpty(<key>5__24))
{
<entry>5__25 = new ModuleEntry
{
Display = <display>5__23,
Key = ((!string.IsNullOrWhiteSpace(<name>5__21)) ? <name>5__21 : <resPath>5__22),
ResourcePath = <resPath>5__22,
Difficulty = <diff>5__15,
TypeKey = <typeKey>5__14,
PrefabRef = <pref>5__20,
LevelRef = <level>5__8,
LevelName = <>8__9.levelName
};
if (!<>4__this._entriesByType.TryGetValue(<typeKey>5__14, out <bucket>5__26))
{
<bucket>5__26 = new List<ModuleEntry>();
<>4__this._entriesByType[<typeKey>5__14] = <bucket>5__26;
}
<bucket>5__26.Add(<entry>5__25);
<>4__this._entries.Add(<entry>5__25);
if (!<>4__this._moduleByKey.ContainsKey(<key>5__24))
{
<>4__this._moduleByKey[<key>5__24] = <pref>5__20;
}
<totalFound>5__6++;
<foundForLevel>5__11++;
<name>5__21 = null;
<resPath>5__22 = null;
<display>5__23 = null;
<key>5__24 = null;
<entry>5__25 = default(ModuleEntry);
<bucket>5__26 = null;
<pref>5__20 = null;
}
}
}
finally
{
if (<>s__19 is IDisposable disposable)
{
disposable.Dispose();
}
}
<>s__19 = null;
<>2__current = null;
<>1__state = 1;
return true;
}
<>s__12 = null;
if (<foundForLevel>5__11 > 0 && !<>4__this._levels.Any((LevelOption l) => string.Equals(l.Name, <>8__9.levelName, StringComparison.OrdinalIgnoreCase)))
{
<>4__this._levels.Add(new LevelOption
{
Name = <>8__9.levelName,
Ref = <level>5__8
});
}
<>8__9 = null;
<levelType>5__10 = null;
<level>5__8 = null;
goto IL_0740;
}
catch
{
//try-fault
((IDisposable)this).Dispose();
throw;
}
}
bool IEnumerator.MoveNext()
{
//ILSpy generated this explicit interface implementation from .override directive in MoveNext
return this.MoveNext();
}
private void <>m__Finally1()
{
<>1__state = -1;
if (<>s__7 is IDisposable disposable)
{
disposable.Dispose();
}
}
[DebuggerHidden]
void IEnumerator.Reset()
{
throw new NotSupportedException();
}
}
[CompilerGenerated]
private sealed class <InitializeCanvasDelayed>d__52 : IEnumerator<object>, IEnumerator, IDisposable
{
private int <>1__state;
private object <>2__current;
public ModuleBrowser <>4__this;
object IEnumerator<object>.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
object IEnumerator.Current
{
[DebuggerHidden]
get
{
return <>2__current;
}
}
[DebuggerHidden]
public <InitializeCanvasDelayed>d__52(int <>1__state)
{
this.<>1__state = <>1__state;
}
[DebuggerHidden]
void IDisposable.Dispose()
{
<>1__state = -2;
}
private bool MoveNext()
{
//IL_0026: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Expected O, but got Unknown
switch (<>1__state)
{
default:
return false;
case 0:
<>1__state = -1;
<>2__current = (object)new WaitForSeconds(0.5f);
<>1__state = 1;
return true;
case 1:
<>1__state = -1;
<>4__this.BuildCanvas();
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 bool _uiVisible;
private int _tabIndex = 0;
private readonly Regex RxModuleTrim = new Regex("^Module\\s*", RegexOptions.IgnoreCase | RegexOptions.Compiled);
private readonly List<ModuleEntry> _entries = new List<ModuleEntry>();
private readonly Dictionary<int, List<ModuleEntry>> _entriesByType = new Dictionary<int, List<ModuleEntry>>();
private readonly Dictionary<string, object> _moduleByKey = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase);
private readonly HashSet<string> _disabled = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
private readonly List<LevelOption> _levels = new List<LevelOption>();
private object _selectedLevelRef = null;
private string _selectedLevelName = "All";
private GameObject _canvasRoot;
private Canvas _canvas;
private GameObject _panelRoot;
private ScrollRect _scrollRect;
private Transform _contentContainer;
private TextMeshProUGUI _titleText;
private TextMeshProUGUI _statusText;
private TextMeshProUGUI _countText;
private Button _refreshButton;
private Button[] _tabButtons = (Button[])(object)new Button[4];
private GameObject _itemRowPrefab;
private Button _allOnBtn;
private Button _allOffBtn;
private Button _levelBtn;
private TextMeshProUGUI _levelBtnText;
private GameObject _levelMenu;
private ConfigEntry<KeyCode> _toggleKey;
private ConfigEntry<float> _scrollSpeed;
private ConfigEntry<string> _disabledCsv;
private Color _bg = new Color(0.05f, 0.05f, 0.06f, 0.92f);
private Color _bg2 = new Color(0.03f, 0.03f, 0.035f, 0.98f);
private Color _fg = new Color(0.86f, 0.86f, 0.88f, 1f);
private Color _mutedCol = new Color(0.75f, 0.75f, 0.8f, 0.75f);
private Color _accentRed = new Color(0.85f, 0.15f, 0.15f, 1f);
private Color _accentGreen = new Color(0.18f, 0.7f, 0.25f, 1f);
private CursorLockMode _prevLock;
private bool _prevVisible;
internal static ModuleBrowser Instance { get; private set; }
internal static ManualLogSource Logger => Instance._logger;
private ManualLogSource _logger => ((BaseUnityPlugin)this).Logger;
internal Harmony? Harmony { get; set; }
internal static bool UIActive => _uiVisible;
private void Awake()
{
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_013d: Unknown result type (might be due to invalid IL or missing references)
Instance = this;
((Component)this).gameObject.transform.parent = null;
((Object)((Component)this).gameObject).hideFlags = (HideFlags)61;
Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Input", "ToggleKey", (KeyCode)277, "Key to toggle the Module Manager UI.");
_scrollSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("UI", "ScrollSpeed", 35f, "Mouse wheel scroll sensitivity for the Module Manager list.");
_disabledCsv = ((BaseUnityPlugin)this).Config.Bind<string>("Modules", "DisabledModuleKeys", "", "CSV of disabled modules (PrefabName preferred; ResourcePath allowed).");
foreach (string item in SplitCsv(_disabledCsv.Value))
{
_disabled.Add(item);
}
Harmony = new Harmony(((BaseUnityPlugin)this).Info.Metadata.GUID);
Harmony.PatchAll();
Logger.LogInfo((object)$"{((BaseUnityPlugin)this).Info.Metadata.GUID} v{((BaseUnityPlugin)this).Info.Metadata.Version} loaded. Press {_toggleKey.Value} to open/close the module manager.");
((MonoBehaviour)this).StartCoroutine(InitializeCanvasDelayed());
}
[IteratorStateMachine(typeof(<InitializeCanvasDelayed>d__52))]
private IEnumerator InitializeCanvasDelayed()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <InitializeCanvasDelayed>d__52(0)
{
<>4__this = this
};
}
private void OnDestroy()
{
Harmony? harmony = Harmony;
if (harmony != null)
{
harmony.UnpatchSelf();
}
if (_uiVisible)
{
RestoreCursor();
}
if (Object.op_Implicit((Object)(object)_canvasRoot))
{
Object.Destroy((Object)(object)_canvasRoot);
}
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(_toggleKey.Value))
{
_uiVisible = !_uiVisible;
if (_uiVisible)
{
TakeCursor();
if (_entries.Count == 0)
{
((MonoBehaviour)this).StartCoroutine(DiscoverRoutine());
}
ShowCanvas();
}
else
{
RestoreCursor();
HideCanvas();
}
}
if (_uiVisible)
{
KeepCursorFree();
}
if ((Object)(object)_scrollRect != (Object)null && _scrollRect.scrollSensitivity != _scrollSpeed.Value)
{
_scrollRect.scrollSensitivity = _scrollSpeed.Value;
}
}
private void BuildCanvas()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_011b: Unknown result type (might be due to invalid IL or missing references)
//IL_0131: Unknown result type (might be due to invalid IL or missing references)
//IL_0147: Unknown result type (might be due to invalid IL or missing references)
//IL_015d: Unknown result type (might be due to invalid IL or missing references)
//IL_0176: Unknown result type (might be due to invalid IL or missing references)
//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
//IL_01c3: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
//IL_0208: Unknown result type (might be due to invalid IL or missing references)
//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
//IL_0377: Unknown result type (might be due to invalid IL or missing references)
//IL_0381: Expected O, but got Unknown
//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
//IL_03e7: Expected O, but got Unknown
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_044d: Expected O, but got Unknown
//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
//IL_04b3: Expected O, but got Unknown
//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
//IL_00cf: Expected O, but got Unknown
//IL_051b: Unknown result type (might be due to invalid IL or missing references)
//IL_0532: Unknown result type (might be due to invalid IL or missing references)
//IL_0549: Unknown result type (might be due to invalid IL or missing references)
//IL_0560: Unknown result type (might be due to invalid IL or missing references)
//IL_0577: Unknown result type (might be due to invalid IL or missing references)
//IL_0624: Unknown result type (might be due to invalid IL or missing references)
//IL_0655: Unknown result type (might be due to invalid IL or missing references)
//IL_065f: Expected O, but got Unknown
//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
//IL_06fe: Unknown result type (might be due to invalid IL or missing references)
//IL_0715: Unknown result type (might be due to invalid IL or missing references)
//IL_0758: Unknown result type (might be due to invalid IL or missing references)
//IL_07a1: Unknown result type (might be due to invalid IL or missing references)
//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
//IL_07e6: Unknown result type (might be due to invalid IL or missing references)
//IL_084e: Unknown result type (might be due to invalid IL or missing references)
//IL_085b: Unknown result type (might be due to invalid IL or missing references)
//IL_0868: Unknown result type (might be due to invalid IL or missing references)
//IL_08b2: Unknown result type (might be due to invalid IL or missing references)
//IL_08c9: Unknown result type (might be due to invalid IL or missing references)
//IL_08e0: Unknown result type (might be due to invalid IL or missing references)
//IL_08f7: Unknown result type (might be due to invalid IL or missing references)
//IL_0980: Unknown result type (might be due to invalid IL or missing references)
//IL_0997: Unknown result type (might be due to invalid IL or missing references)
//IL_09ae: Unknown result type (might be due to invalid IL or missing references)
//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
//IL_09dc: Unknown result type (might be due to invalid IL or missing references)
//IL_0a0c: Unknown result type (might be due to invalid IL or missing references)
//IL_0a5d: Unknown result type (might be due to invalid IL or missing references)
//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
//IL_0a8b: Unknown result type (might be due to invalid IL or missing references)
//IL_0aa2: Unknown result type (might be due to invalid IL or missing references)
//IL_0ab9: Unknown result type (might be due to invalid IL or missing references)
//IL_0ae7: Unknown result type (might be due to invalid IL or missing references)
//IL_0b17: Unknown result type (might be due to invalid IL or missing references)
//IL_0b21: Expected O, but got Unknown
_canvasRoot = new GameObject("ModuleManagerCanvas_EMPRESS");
Object.DontDestroyOnLoad((Object)(object)_canvasRoot);
_canvasRoot.layer = LayerMask.NameToLayer("UI");
_canvas = _canvasRoot.AddComponent<Canvas>();
_canvas.renderMode = (RenderMode)0;
_canvas.sortingOrder = 32767;
_canvas.overrideSorting = true;
CanvasScaler val = _canvasRoot.AddComponent<CanvasScaler>();
val.uiScaleMode = (ScaleMode)1;
val.referenceResolution = new Vector2(1920f, 1080f);
val.matchWidthOrHeight = 1f;
_canvasRoot.AddComponent<GraphicRaycaster>();
if ((Object)(object)EventSystem.current == (Object)null)
{
GameObject val2 = new GameObject("EventSystem_EMPRESS");
Object.DontDestroyOnLoad((Object)(object)val2);
val2.AddComponent<EventSystem>();
val2.AddComponent<StandaloneInputModule>();
}
_panelRoot = CreateUIElement("Panel", _canvasRoot.transform);
RectTransform component = _panelRoot.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0.5f, 0.5f);
component.anchorMax = new Vector2(0.5f, 0.5f);
component.pivot = new Vector2(0.5f, 0.5f);
component.sizeDelta = new Vector2(640f, 720f);
Image val3 = _panelRoot.AddComponent<Image>();
((Graphic)val3).color = _bg;
GameObject val4 = CreateUIElement("Header", _panelRoot.transform);
RectTransform component2 = val4.GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 1f);
component2.anchorMax = new Vector2(1f, 1f);
component2.pivot = new Vector2(0.5f, 1f);
component2.sizeDelta = new Vector2(-28f, 60f);
component2.anchoredPosition = new Vector2(0f, -14f);
HorizontalLayoutGroup val5 = val4.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val5).childControlWidth = true;
((HorizontalOrVerticalLayoutGroup)val5).childControlHeight = true;
((HorizontalOrVerticalLayoutGroup)val5).childForceExpandWidth = false;
((HorizontalOrVerticalLayoutGroup)val5).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)val5).spacing = 10f;
GameObject val6 = CreateUIElement("Title", val4.transform);
LayoutElement val7 = val6.AddComponent<LayoutElement>();
val7.flexibleWidth = 1f;
val7.minWidth = 200f;
_titleText = val6.AddComponent<TextMeshProUGUI>();
((TMP_Text)_titleText).text = "<b>▣ Module Manager</b> <color=#BBBBBB>— Empress</color>";
((TMP_Text)_titleText).fontSize = 18f;
((TMP_Text)_titleText).fontStyle = (FontStyles)1;
((Graphic)_titleText).color = _fg;
((TMP_Text)_titleText).alignment = (TextAlignmentOptions)4097;
GameObject val8 = CreateUIElement("Controls", val4.transform);
HorizontalLayoutGroup val9 = val8.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val9).spacing = 8f;
((HorizontalOrVerticalLayoutGroup)val9).childForceExpandHeight = false;
((HorizontalOrVerticalLayoutGroup)val9).childForceExpandWidth = false;
GameObject val10 = CreateButton("AllOnBtn", val8.transform, "Enable All");
_allOnBtn = val10.GetComponent<Button>();
LayoutElement val11 = val10.AddComponent<LayoutElement>();
val11.preferredWidth = 110f;
val11.preferredHeight = 26f;
((UnityEvent)_allOnBtn.onClick).AddListener((UnityAction)delegate
{
ToggleAllInCurrentTab(enable: true);
});
GameObject val12 = CreateButton("AllOffBtn", val8.transform, "Disable All");
_allOffBtn = val12.GetComponent<Button>();
LayoutElement val13 = val12.AddComponent<LayoutElement>();
val13.preferredWidth = 110f;
val13.preferredHeight = 26f;
((UnityEvent)_allOffBtn.onClick).AddListener((UnityAction)delegate
{
ToggleAllInCurrentTab(enable: false);
});
GameObject val14 = CreateButton("RefreshBtn", val8.transform, "Refresh");
LayoutElement val15 = val14.AddComponent<LayoutElement>();
val15.preferredWidth = 90f;
val15.preferredHeight = 26f;
_refreshButton = val14.GetComponent<Button>();
((UnityEvent)_refreshButton.onClick).AddListener((UnityAction)delegate
{
((MonoBehaviour)this).StartCoroutine(DiscoverRoutine());
});
GameObject val16 = CreateButton("LevelBtn", val8.transform, "Level: All");
LayoutElement val17 = val16.AddComponent<LayoutElement>();
val17.preferredWidth = 180f;
val17.preferredHeight = 26f;
_levelBtn = val16.GetComponent<Button>();
((UnityEvent)_levelBtn.onClick).AddListener(new UnityAction(ToggleLevelMenu));
Transform obj = val16.transform.Find("Text");
_levelBtnText = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
DrawDivider(_panelRoot.transform, -80f);
GameObject val18 = CreateUIElement("TabBar", _panelRoot.transform);
RectTransform component3 = val18.GetComponent<RectTransform>();
component3.anchorMin = new Vector2(0f, 1f);
component3.anchorMax = new Vector2(1f, 1f);
component3.pivot = new Vector2(0.5f, 1f);
component3.sizeDelta = new Vector2(-28f, 34f);
component3.anchoredPosition = new Vector2(0f, -88f);
HorizontalLayoutGroup val19 = val18.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val19).spacing = 10f;
((HorizontalOrVerticalLayoutGroup)val19).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val19).childForceExpandHeight = true;
string[] array = new string[4] { "NORMAL", "PASSAGE", "DEAD END", "EXTRACTION" };
for (int i = 0; i < 4; i++)
{
int index = i;
GameObject val20 = CreateButton($"Tab{i}", val18.transform, array[i]);
Image component4 = val20.GetComponent<Image>();
((Graphic)component4).color = _bg2;
_tabButtons[i] = val20.GetComponent<Button>();
((UnityEvent)_tabButtons[i].onClick).AddListener((UnityAction)delegate
{
SwitchTab(index);
});
}
DrawDivider(_panelRoot.transform, -128f);
GameObject val21 = CreateUIElement("Status", _panelRoot.transform);
RectTransform component5 = val21.GetComponent<RectTransform>();
component5.anchorMin = new Vector2(0f, 1f);
component5.anchorMax = new Vector2(1f, 1f);
component5.pivot = new Vector2(0.5f, 1f);
component5.sizeDelta = new Vector2(-28f, 30f);
component5.anchoredPosition = new Vector2(0f, -134f);
_statusText = val21.AddComponent<TextMeshProUGUI>();
((TMP_Text)_statusText).fontSize = 11f;
((Graphic)_statusText).color = new Color(0.95f, 0.75f, 0.3f, 1f);
((TMP_Text)_statusText).alignment = (TextAlignmentOptions)514;
GameObject val22 = CreateUIElement("ScrollView", _panelRoot.transform);
RectTransform component6 = val22.GetComponent<RectTransform>();
component6.anchorMin = new Vector2(0f, 0f);
component6.anchorMax = new Vector2(1f, 1f);
component6.offsetMin = new Vector2(14f, 50f);
component6.offsetMax = new Vector2(-14f, -212f);
_scrollRect = val22.AddComponent<ScrollRect>();
_scrollRect.horizontal = false;
_scrollRect.vertical = true;
_scrollRect.scrollSensitivity = _scrollSpeed.Value;
GameObject val23 = CreateUIElement("Viewport", val22.transform);
RectTransform component7 = val23.GetComponent<RectTransform>();
component7.anchorMin = Vector2.zero;
component7.anchorMax = Vector2.one;
component7.sizeDelta = Vector2.zero;
val23.AddComponent<RectMask2D>();
_scrollRect.viewport = component7;
GameObject val24 = CreateUIElement("Content", val23.transform);
RectTransform component8 = val24.GetComponent<RectTransform>();
component8.anchorMin = new Vector2(0f, 1f);
component8.anchorMax = new Vector2(1f, 1f);
component8.pivot = new Vector2(0.5f, 1f);
component8.sizeDelta = new Vector2(0f, 500f);
VerticalLayoutGroup val25 = val24.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val25).spacing = 2f;
((HorizontalOrVerticalLayoutGroup)val25).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val25).childForceExpandHeight = false;
val24.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
_scrollRect.content = component8;
_contentContainer = val24.transform;
GameObject val26 = CreateUIElement("Count", _panelRoot.transform);
RectTransform component9 = val26.GetComponent<RectTransform>();
component9.anchorMin = new Vector2(0f, 0f);
component9.anchorMax = new Vector2(1f, 0f);
component9.pivot = new Vector2(0.5f, 0f);
component9.sizeDelta = new Vector2(-28f, 30f);
component9.anchoredPosition = new Vector2(0f, 12f);
_countText = val26.AddComponent<TextMeshProUGUI>();
((TMP_Text)_countText).fontSize = 12f;
((Graphic)_countText).color = _mutedCol;
((TMP_Text)_countText).alignment = (TextAlignmentOptions)514;
_levelMenu = CreateUIElement("LevelDropdown", _panelRoot.transform);
RectTransform component10 = _levelMenu.GetComponent<RectTransform>();
component10.anchorMin = new Vector2(1f, 1f);
component10.anchorMax = new Vector2(1f, 1f);
component10.pivot = new Vector2(1f, 1f);
component10.sizeDelta = new Vector2(240f, 10f);
component10.anchoredPosition = new Vector2(-20f, -74f);
Image val27 = _levelMenu.AddComponent<Image>();
((Graphic)val27).color = new Color(0f, 0f, 0f, 0.9f);
VerticalLayoutGroup val28 = _levelMenu.AddComponent<VerticalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val28).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val28).childForceExpandHeight = false;
((LayoutGroup)val28).padding = new RectOffset(6, 6, 6, 6);
((HorizontalOrVerticalLayoutGroup)val28).spacing = 4f;
_levelMenu.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2;
_levelMenu.SetActive(false);
CreateItemRowPrefab();
_canvasRoot.SetActive(false);
UpdateTabVisuals();
}
private void CreateItemRowPrefab()
{
//IL_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0090: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e3: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
//IL_0154: Unknown result type (might be due to invalid IL or missing references)
_itemRowPrefab = CreateUIElement("ItemRowPrefab", _panelRoot.transform);
_itemRowPrefab.SetActive(false);
RectTransform component = _itemRowPrefab.GetComponent<RectTransform>();
component.sizeDelta = new Vector2(0f, 34f);
HorizontalLayoutGroup val = _itemRowPrefab.AddComponent<HorizontalLayoutGroup>();
((HorizontalOrVerticalLayoutGroup)val).childForceExpandWidth = true;
((HorizontalOrVerticalLayoutGroup)val).childForceExpandHeight = true;
((HorizontalOrVerticalLayoutGroup)val).spacing = 8f;
TextMeshProUGUI val2 = CreateTextMeshPro("Label", _itemRowPrefab.transform, "", 13f, _fg, (TextAlignmentOptions)4097);
LayoutElement val3 = ((Component)val2).gameObject.AddComponent<LayoutElement>();
val3.flexibleWidth = 1f;
RectTransform component2 = ((Component)val2).GetComponent<RectTransform>();
component2.anchorMin = new Vector2(0f, 0f);
component2.anchorMax = new Vector2(1f, 1f);
component2.offsetMin = Vector2.zero;
component2.offsetMax = Vector2.zero;
GameObject val4 = CreateButton("ToggleBtn", _itemRowPrefab.transform, "ENABLED");
LayoutElement val5 = val4.AddComponent<LayoutElement>();
val5.preferredWidth = 110f;
val5.preferredHeight = 26f;
Image component3 = val4.GetComponent<Image>();
((Graphic)component3).color = _accentGreen;
}
private GameObject CreateUIElement(string name, Transform parent)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
GameObject val = new GameObject(name);
val.transform.SetParent(parent, false);
val.AddComponent<RectTransform>();
return val;
}
private GameObject CreateButton(string name, Transform parent, string text)
{
//IL_0013: Unknown result type (might be due to invalid IL or missing references)
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: 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_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0078: Unknown result type (might be due to invalid IL or missing references)
//IL_0085: 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)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
//IL_00fe: 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_0118: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateUIElement(name, parent);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = _bg2;
Button val3 = val.AddComponent<Button>();
((Selectable)val3).targetGraphic = (Graphic)(object)val2;
ColorBlock colors = ((Selectable)val3).colors;
((ColorBlock)(ref colors)).normalColor = Color.white;
((ColorBlock)(ref colors)).highlightedColor = new Color(1f, 1f, 1f, 0.95f);
((ColorBlock)(ref colors)).pressedColor = new Color(1f, 1f, 1f, 0.85f);
((ColorBlock)(ref colors)).selectedColor = Color.white;
((ColorBlock)(ref colors)).disabledColor = new Color(1f, 1f, 1f, 0.5f);
((Selectable)val3).colors = colors;
TextMeshProUGUI val4 = CreateTextMeshPro("Text", val.transform, text, 13f, _fg, (TextAlignmentOptions)514);
TextMeshProUGUI val5 = val4;
((TMP_Text)val5).enableWordWrapping = false;
((TMP_Text)val5).overflowMode = (TextOverflowModes)1;
RectTransform component = ((Component)val4).GetComponent<RectTransform>();
component.anchorMin = Vector2.zero;
component.anchorMax = Vector2.one;
component.sizeDelta = Vector2.zero;
return val;
}
private TextMeshProUGUI CreateTextMeshPro(string name, Transform parent, string text, float fontSize, Color color, TextAlignmentOptions alignment)
{
//IL_0023: 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)
GameObject val = CreateUIElement(name, parent);
TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
((TMP_Text)val2).text = text;
((TMP_Text)val2).fontSize = fontSize;
((Graphic)val2).color = color;
((TMP_Text)val2).alignment = alignment;
((TMP_Text)val2).enableWordWrapping = false;
((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
return val2;
}
private void DrawDivider(Transform parent, float yPos)
{
//IL_0020: 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_004c: 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_0074: Unknown result type (might be due to invalid IL or missing references)
//IL_009b: Unknown result type (might be due to invalid IL or missing references)
GameObject val = CreateUIElement("Divider", parent);
RectTransform component = val.GetComponent<RectTransform>();
component.anchorMin = new Vector2(0f, 1f);
component.anchorMax = new Vector2(1f, 1f);
component.pivot = new Vector2(0.5f, 1f);
component.sizeDelta = new Vector2(-28f, 1f);
component.anchoredPosition = new Vector2(0f, yPos);
Image val2 = val.AddComponent<Image>();
((Graphic)val2).color = new Color(1f, 1f, 1f, 0.12f);
}
private void ShowCanvas()
{
if (Object.op_Implicit((Object)(object)_canvasRoot))
{
_canvasRoot.SetActive(true);
}
RefreshCurrentTab();
}
private void HideCanvas()
{
if (Object.op_Implicit((Object)(object)_canvasRoot))
{
_canvasRoot.SetActive(false);
}
}
private void SwitchTab(int index)
{
_tabIndex = index;
UpdateTabVisuals();
RefreshCurrentTab();
}
private void UpdateTabVisuals()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0033: Unknown result type (might be due to invalid IL or missing references)
for (int i = 0; i < _tabButtons.Length; i++)
{
if (!((Object)(object)_tabButtons[i] == (Object)null))
{
Image component = ((Component)_tabButtons[i]).GetComponent<Image>();
((Graphic)component).color = (Color)((_tabIndex == i) ? new Color(0.12f, 0.12f, 0.14f, 1f) : _bg2);
}
}
}
private void RefreshCurrentTab()
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
//IL_02b3: Expected O, but got Unknown
if ((Object)(object)_contentContainer == (Object)null)
{
return;
}
if ((Object)(object)_itemRowPrefab == (Object)null)
{
CreateItemRowPrefab();
}
foreach (Transform item in _contentContainer)
{
Transform val = item;
Object.Destroy((Object)(object)((Component)val).gameObject);
}
bool flag = HostControls();
((TMP_Text)_statusText).text = (flag ? "Host controls module availability. Clients view-only." : "⚠ Host only — toggles are disabled for clients.");
List<ModuleEntry> value;
List<ModuleEntry> source = (_entriesByType.TryGetValue(_tabIndex, out value) ? value : new List<ModuleEntry>());
if (_selectedLevelRef != null)
{
source = source.Where((ModuleEntry e) => e.LevelRef == _selectedLevelRef).ToList();
}
List<ModuleEntry> list = source.OrderBy((ModuleEntry e) => e.Difficulty).ThenBy<ModuleEntry, string>((ModuleEntry e) => e.Display, StringComparer.OrdinalIgnoreCase).ToList();
foreach (ModuleEntry item2 in list)
{
GameObject val2 = Object.Instantiate<GameObject>(_itemRowPrefab, _contentContainer);
val2.SetActive(true);
Transform obj = val2.transform.Find("Label");
TextMeshProUGUI val3 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
if (Object.op_Implicit((Object)(object)val3))
{
((TMP_Text)val3).text = $"{item2.Display} <color=#888888>[d{item2.Difficulty}]</color>";
}
Transform obj2 = val2.transform.Find("ToggleBtn");
Button val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<Button>() : null);
if (Object.op_Implicit((Object)(object)val4))
{
bool enabled = !IsDisabledKey(item2.Key) && !IsDisabledKey(item2.ResourcePath);
Image btnImage = ((Component)val4).GetComponent<Image>();
Transform obj3 = ((Component)val4).transform.Find("Text");
TextMeshProUGUI btnText = ((obj3 != null) ? ((Component)obj3).GetComponent<TextMeshProUGUI>() : null);
UpdateToggleButtonVisual(btnImage, btnText, enabled);
((Selectable)val4).interactable = flag;
string key = item2.Key;
string alt = item2.ResourcePath;
((UnityEventBase)val4.onClick).RemoveAllListeners();
((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
{
bool flag2 = !IsDisabledKey(key) && !IsDisabledKey(alt);
bool flag3 = !flag2;
SetModuleEnabled(key, alt, flag3);
UpdateToggleButtonVisual(btnImage, btnText, flag3);
RefreshCounts();
});
}
}
RefreshCounts();
}
private void RefreshCounts()
{
List<ModuleEntry> value;
List<ModuleEntry> list = (_entriesByType.TryGetValue(_tabIndex, out value) ? value : new List<ModuleEntry>());
if (_selectedLevelRef != null)
{
list = list.Where((ModuleEntry e) => e.LevelRef == _selectedLevelRef).ToList();
}
int count = list.Count;
int num = list.Count((ModuleEntry e) => !IsDisabledKey(e.Key) && !IsDisabledKey(e.ResourcePath));
int tabIndex = _tabIndex;
if (1 == 0)
{
}
string text = tabIndex switch
{
0 => "normal",
1 => "passage",
2 => "dead-end",
3 => "extraction",
_ => "modules",
};
if (1 == 0)
{
}
string arg = text;
((TMP_Text)_countText).text = $"{num}/{count} {arg} enabled";
List<string> list2 = new List<string>();
int d;
for (d = 1; d <= 3; d++)
{
if (list.Count((ModuleEntry e) => e.Difficulty == d && !IsDisabledKey(e.Key) && !IsDisabledKey(e.ResourcePath)) == 0)
{
list2.Add($"d{d} pool empty → fail-safe will ignore filters");
}
}
if (list2.Count > 0)
{
((TMP_Text)_statusText).text = "⚠ " + string.Join(" · ", list2);
}
}
private void UpdateToggleButtonVisual(Image img, TextMeshProUGUI txt, bool enabled)
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
if (Object.op_Implicit((Object)(object)img))
{
((Graphic)img).color = (enabled ? _accentGreen : _accentRed);
}
if (Object.op_Implicit((Object)(object)txt))
{
((TMP_Text)txt).text = (enabled ? "ENABLED" : "DISABLED");
}
}
private void ToggleAllInCurrentTab(bool enable)
{
if (!_entriesByType.TryGetValue(_tabIndex, out List<ModuleEntry> value))
{
return;
}
IEnumerable<ModuleEntry> enumerable = value;
if (_selectedLevelRef != null)
{
enumerable = enumerable.Where((ModuleEntry e) => e.LevelRef == _selectedLevelRef);
}
foreach (ModuleEntry item in enumerable)
{
SetModuleEnabled(item.Key, item.ResourcePath, enable);
}
RefreshCurrentTab();
}
private void SetModuleEnabled(string keyName, string altResourcePath, bool enable)
{
string text = ((!string.IsNullOrEmpty(keyName)) ? keyName : altResourcePath);
if (string.IsNullOrEmpty(text))
{
return;
}
if (!HostControls())
{
Logger.LogWarning((object)"Client cannot change module filters. Only the host controls module pools.");
return;
}
if (!enable)
{
_disabled.Add(text);
}
else
{
_disabled.Remove(text);
}
List<string> values = _disabled.ToList();
if (!string.IsNullOrEmpty(altResourcePath))
{
if (enable)
{
_disabled.Remove(altResourcePath);
}
else
{
_disabled.Add(altResourcePath);
}
values = _disabled.Distinct<string>(StringComparer.OrdinalIgnoreCase).ToList();
}
_disabledCsv.Value = string.Join(",", values);
((BaseUnityPlugin)this).Config.Save();
}
private static IEnumerable<string> SplitCsv(string csv)
{
IEnumerable<string> result;
if (!string.IsNullOrWhiteSpace(csv))
{
result = from s in csv.Split(new char[1] { ',' }, StringSplitOptions.RemoveEmptyEntries)
select s.Trim() into s
where !string.IsNullOrEmpty(s)
select s;
}
else
{
IEnumerable<string> enumerable = Enumerable.Empty<string>();
result = enumerable;
}
return result;
}
private bool IsDisabledKey(string key)
{
return !string.IsNullOrEmpty(key) && _disabled.Contains(key);
}
[IteratorStateMachine(typeof(<DiscoverRoutine>d__72))]
private IEnumerator DiscoverRoutine()
{
//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
return new <DiscoverRoutine>d__72(0)
{
<>4__this = this
};
}
private void UpdateLevelButtonText()
{
if (Object.op_Implicit((Object)(object)_levelBtnText))
{
((TMP_Text)_levelBtnText).text = "Level: " + _selectedLevelName;
}
}
private void ToggleLevelMenu()
{
if (!((Object)(object)_levelMenu == (Object)null))
{
bool flag = !_levelMenu.activeSelf;
if (flag)
{
BuildLevelMenu();
}
_levelMenu.SetActive(flag);
}
}
private void StyleMenuItem(GameObject go)
{
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
if (!((Object)(object)go == (Object)null))
{
LayoutElement val = go.GetComponent<LayoutElement>() ?? go.AddComponent<LayoutElement>();
val.preferredHeight = 26f;
val.minHeight = 26f;
val.flexibleWidth = 1f;
Transform obj = go.transform.Find("Text");
TextMeshProUGUI val2 = ((obj != null) ? ((Component)obj).GetComponent<TextMeshProUGUI>() : null);
if (Object.op_Implicit((Object)(object)val2))
{
((TMP_Text)val2).alignment = (TextAlignmentOptions)4097;
((TMP_Text)val2).margin = new Vector4(8f, 0f, 8f, 0f);
}
}
}
private void BuildLevelMenu()
{
//IL_0079: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00a8: Expected O, but got Unknown
//IL_0108: Unknown result type (might be due to invalid IL or missing references)
//IL_0139: Unknown result type (might be due to invalid IL or missing references)
//IL_0143: Expected O, but got Unknown
if ((Object)(object)_levelMenu == (Object)null)
{
return;
}
for (int num = _levelMenu.transform.childCount - 1; num >= 0; num--)
{
Object.Destroy((Object)(object)((Component)_levelMenu.transform.GetChild(num)).gameObject);
}
GameObject val = CreateButton("AllLevels", _levelMenu.transform, "All Levels");
((Graphic)val.GetComponent<Image>()).color = _bg2;
StyleMenuItem(val);
((UnityEvent)val.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
_selectedLevelRef = null;
_selectedLevelName = "All";
UpdateLevelButtonText();
_levelMenu.SetActive(false);
RefreshCurrentTab();
});
foreach (LevelOption level in _levels)
{
GameObject val2 = CreateButton("Level_" + level.Name, _levelMenu.transform, level.Name);
((Graphic)val2.GetComponent<Image>()).color = _bg2;
StyleMenuItem(val2);
LevelOption cap = level;
((UnityEvent)val2.GetComponent<Button>().onClick).AddListener((UnityAction)delegate
{
_selectedLevelRef = cap.Ref;
_selectedLevelName = cap.Name;
UpdateLevelButtonText();
_levelMenu.SetActive(false);
RefreshCurrentTab();
});
}
}
private void TakeCursor()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
_prevLock = Cursor.lockState;
_prevVisible = Cursor.visible;
try
{
Type type = FindTypeBySimpleName("CursorManager");
object obj = type?.GetField("instance", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
type?.GetMethod("Unlock", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(obj, new object[1] { 9999f });
}
catch
{
}
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
private void KeepCursorFree()
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Invalid comparison between Unknown and I4
if ((int)Cursor.lockState > 0)
{
Cursor.lockState = (CursorLockMode)0;
}
if (!Cursor.visible)
{
Cursor.visible = true;
}
}
private void RestoreCursor()
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
Cursor.lockState = _prevLock;
Cursor.visible = _prevVisible;
if (Object.op_Implicit((Object)(object)_levelMenu))
{
_levelMenu.SetActive(false);
}
}
internal static Type? FindTypeBySimpleName(string simpleName)
{
string simpleName2 = simpleName;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type = null;
try
{
type = assembly.GetTypes().FirstOrDefault((Type x) => x.Name == simpleName2 || (x.FullName?.EndsWith("." + simpleName2) ?? false));
}
catch
{
}
if (type != null)
{
return type;
}
}
return null;
}
private static string TryGetString(object target, string memberName)
{
if (target == null || string.IsNullOrEmpty(memberName))
{
return null;
}
Type type = target.GetType();
try
{
PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
return property.GetValue(target, null)?.ToString();
}
}
catch
{
}
try
{
FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field.GetValue(target)?.ToString();
}
}
catch
{
}
return null;
}
internal static bool HostControls()
{
try
{
if (!PhotonNetwork.InRoom)
{
return true;
}
return PhotonNetwork.IsMasterClient;
}
catch
{
return true;
}
}
}
[HarmonyPatch]
internal static class Patch_LevelGenerator_PickModule
{
private static MethodBase TargetMethod()
{
Type type = ModuleBrowser.FindTypeBySimpleName("LevelGenerator");
if (type == null)
{
return null;
}
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (!(methodInfo.Name != "PickModule"))
{
return methodInfo;
}
}
return null;
}
private static void Prefix(object __instance, object _list1, object _list2, object _list3)
{
if (!ModuleBrowser.HostControls())
{
return;
}
try
{
FilterOne(_list1);
FilterOne(_list2);
FilterOne(_list3);
}
catch (Exception ex)
{
ModuleBrowser.Logger.LogWarning((object)("PickModule filter failed: " + ex.Message));
}
}
private static void FilterOne(object listObj)
{
if (listObj == null)
{
return;
}
Type type = listObj.GetType();
object[] array = ((listObj is IEnumerable source) ? source.Cast<object>().ToArray() : null);
if (array == null || array.Length == 0)
{
return;
}
List<object> list = new List<object>(array.Length);
object[] array2 = array;
foreach (object obj in array2)
{
string text = TryGetString(obj, "PrefabName");
string text2 = TryGetString(obj, "ResourcePath");
if ((string.IsNullOrEmpty(text) || !IsDisabled(text)) && (string.IsNullOrEmpty(text2) || !IsDisabled(text2)))
{
list.Add(obj);
}
}
if (list.Count == 0)
{
return;
}
MethodInfo method = type.GetMethod("Clear", BindingFlags.Instance | BindingFlags.Public);
MethodInfo method2 = type.GetMethod("Add", BindingFlags.Instance | BindingFlags.Public);
method?.Invoke(listObj, null);
foreach (object item in list)
{
method2?.Invoke(listObj, new object[1] { item });
}
}
private static bool IsDisabled(string key)
{
ModuleBrowser instance = ModuleBrowser.Instance;
if ((Object)(object)instance == (Object)null)
{
return false;
}
return ((object)instance).GetType().GetField("_disabled", BindingFlags.Instance | BindingFlags.NonPublic)?.GetValue(instance) is IEnumerable source && source.Cast<string>().Contains<string>(key, StringComparer.OrdinalIgnoreCase);
}
private static string TryGetString(object target, string memberName)
{
if (target == null || string.IsNullOrEmpty(memberName))
{
return null;
}
Type type = target.GetType();
try
{
PropertyInfo property = type.GetProperty(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
return property.GetValue(target, null)?.ToString();
}
}
catch
{
}
try
{
FieldInfo field = type.GetField(memberName, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field.GetValue(target)?.ToString();
}
}
catch
{
}
return null;
}
}
[HarmonyPatch]
internal static class Patch_CameraAim_Update
{
private static MethodBase TargetMethod()
{
return ModuleBrowser.FindTypeBySimpleName("CameraAim")?.GetMethod("Update", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic) ?? null;
}
private static bool Prefix()
{
return !ModuleBrowser.UIActive;
}
}
[HarmonyPatch(typeof(CursorManager))]
internal static class Patch_CursorManager_Unlock
{
private static MethodBase TargetMethod()
{
return AccessTools.Method(typeof(CursorManager), "Unlock", (Type[])null, (Type[])null);
}
private static void Postfix()
{
if (ModuleBrowser.UIActive)
{
Cursor.lockState = (CursorLockMode)0;
Cursor.visible = true;
}
}
}
}