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.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CrewBoom;
using CrewBoom.Data;
using CrewBoomMono;
using Reptile;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SkinSearch")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SkinSearch")]
[assembly: AssemblyCopyright("Copyright © 2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("18b1ae4b-dea5-497b-b560-b7750c5c9075")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace SkinSearch;
[BepInPlugin("chimp.brc.skinsearch", "Skin Search", "1.3.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SkinSearchPlugin : BaseUnityPlugin
{
internal enum SortMode
{
Name,
Recent
}
public const string PluginGuid = "chimp.brc.skinsearch";
public const string PluginName = "Skin Search";
public const string PluginVersion = "1.3.1";
internal static ManualLogSource Log;
private static SkinSearchPlugin _instance;
private ConfigEntry<KeyCode> _toggleKey;
internal static ConfigEntry<SortMode> SortConfig;
internal static ConfigEntry<bool> ShowThumbnails;
internal static ConfigEntry<int> PageSize;
internal static ConfigEntry<bool> BlockGameInput;
private readonly List<ListTab> _tabs = new List<ListTab>();
private int _activeTab;
private bool _open;
private bool _focusSearchField;
private bool _prevCursorVisible;
private CursorLockMode _prevCursorLock;
private Rect _windowRect = new Rect(40f, 40f, 520f, 580f);
internal const float RowHeight = 44f;
private GUIStyle _rowStyle;
private GUIStyle _rowStyleSelected;
private GUIStyle _starStyle;
private GUIStyle _tabStyle;
private GUIStyle _tabStyleActive;
private ListTab Tab => _tabs[_activeTab];
private void Awake()
{
//IL_00be: Unknown result type (might be due to invalid IL or missing references)
//IL_00c8: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
_instance = this;
_toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "ToggleKey", (KeyCode)288, "Opens/closes the search window.");
ShowThumbnails = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "ShowThumbnails", true, "Show each skin's graffiti as a thumbnail.");
SortConfig = ((BaseUnityPlugin)this).Config.Bind<SortMode>("General", "SortMode", SortMode.Name, "How lists are sorted (favorites always stay on top).");
BlockGameInput = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "BlockGameInput", true, "While the window is open, the game ignores keyboard and mouse (no accidental tricks when clicking).");
PageSize = ((BaseUnityPlugin)this).Config.Bind<int>("General", "SkinsPerPage", 25, new ConfigDescription("How many entries are shown per page.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(5, 200), Array.Empty<object>()));
_tabs.Add(new SkinTab(((BaseUnityPlugin)this).Config));
if (BoEBridge.Installed)
{
_tabs.Add(new EmoteTab(((BaseUnityPlugin)this).Config));
}
else
{
Log.LogInfo((object)"Bunch of Emotes not installed - Emotes tab disabled.");
}
_tabs.Add(new MapTab(((BaseUnityPlugin)this).Config));
ExternalTab externalTab = GamblingBridge.CreateTab();
if (externalTab != null)
{
_tabs.Add(externalTab);
}
}
internal static void RequestClose()
{
_instance?.Close();
}
public static void ToggleTab(string title)
{
SkinSearchPlugin instance = _instance;
if ((Object)(object)instance == (Object)null)
{
return;
}
int num = instance._tabs.FindIndex((ListTab t) => t.Title == title);
if (num >= 0)
{
if (instance._open && instance._activeTab == num)
{
instance.Close();
}
else if (!instance._open)
{
instance._activeTab = num;
instance.Open();
}
else
{
instance.SwitchTab(num);
}
}
}
private void Update()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
if (Input.GetKeyDown(_toggleKey.Value))
{
if (_open)
{
Close();
}
else
{
Open();
}
}
}
private void Open()
{
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
if (Tab.NeedsRefresh)
{
Tab.Refresh();
}
Tab.OnOpen();
_open = true;
_focusSearchField = true;
Tab.MarkDirty();
_prevCursorVisible = Cursor.visible;
_prevCursorLock = Cursor.lockState;
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
if (BlockGameInput.Value)
{
InputBlocker.Block();
}
}
private void LateUpdate()
{
InputBlocker.Tick();
}
private void OnDestroy()
{
InputBlocker.Release();
}
private void Close()
{
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
GUI.FocusControl((string)null);
_open = false;
InputBlocker.Release();
Cursor.visible = _prevCursorVisible;
Cursor.lockState = _prevCursorLock;
}
private void SwitchTab(int index)
{
if (index != _activeTab)
{
GUI.FocusControl((string)null);
_activeTab = index;
if (Tab.NeedsRefresh)
{
Tab.Refresh();
}
Tab.OnOpen();
Tab.MarkDirty();
_focusSearchField = !Tab.CustomDraw;
}
}
private void OnGUI()
{
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Expected O, but got Unknown
//IL_0072: Unknown result type (might be due to invalid IL or missing references)
//IL_0077: Unknown result type (might be due to invalid IL or missing references)
if (!_open)
{
return;
}
InitStyles();
HandleKeyboard(Event.current);
if (_open)
{
if (!Tab.CustomDraw)
{
Tab.UpdateResults();
}
_windowRect = GUILayout.Window(23578, _windowRect, new WindowFunction(DrawWindow), "Skin Search", Array.Empty<GUILayoutOption>());
ClampWindowToScreen();
}
}
private void ClampWindowToScreen()
{
((Rect)(ref _windowRect)).width = Mathf.Min(((Rect)(ref _windowRect)).width, (float)Screen.width);
((Rect)(ref _windowRect)).height = Mathf.Min(((Rect)(ref _windowRect)).height, (float)Screen.height);
((Rect)(ref _windowRect)).x = Mathf.Clamp(((Rect)(ref _windowRect)).x, 0f, (float)Screen.width - ((Rect)(ref _windowRect)).width);
((Rect)(ref _windowRect)).y = Mathf.Clamp(((Rect)(ref _windowRect)).y, 0f, (float)Screen.height - ((Rect)(ref _windowRect)).height);
}
private void InitStyles()
{
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: Expected O, but got Unknown
//IL_0043: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Expected O, but got Unknown
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_006e: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
//IL_0089: Unknown result type (might be due to invalid IL or missing references)
//IL_0092: 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_00af: Expected O, but got Unknown
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
//IL_00d0: Expected O, but got Unknown
//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
//IL_00e9: Expected O, but got Unknown
//IL_00f4: 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)
if (_rowStyle == null)
{
_rowStyle = new GUIStyle(GUI.skin.button)
{
alignment = (TextAnchor)3,
fixedHeight = 44f
};
_rowStyleSelected = new GUIStyle(_rowStyle);
_rowStyleSelected.normal.textColor = Color.yellow;
_rowStyleSelected.hover.textColor = Color.yellow;
_starStyle = new GUIStyle(GUI.skin.button)
{
fontSize = 18,
fixedHeight = 44f,
fixedWidth = 32f
};
_tabStyle = new GUIStyle(GUI.skin.button)
{
fixedHeight = 26f
};
_tabStyleActive = new GUIStyle(_tabStyle)
{
fontStyle = (FontStyle)1
};
_tabStyleActive.normal.textColor = Color.yellow;
_tabStyleActive.hover.textColor = Color.yellow;
}
}
private void HandleKeyboard(Event e)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_004c: Unknown result type (might be due to invalid IL or missing references)
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0053: Unknown result type (might be due to invalid IL or missing references)
//IL_0055: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Unknown result type (might be due to invalid IL or missing references)
//IL_005b: Invalid comparison between Unknown and I4
//IL_0029: Unknown result type (might be due to invalid IL or missing references)
//IL_0030: Invalid comparison between Unknown and I4
//IL_0062: Unknown result type (might be due to invalid IL or missing references)
//IL_0066: Invalid comparison between Unknown and I4
//IL_006d: 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_008a: Expected I4, but got Unknown
if ((int)e.type != 4)
{
return;
}
ListTab tab = Tab;
if (tab.CustomDraw)
{
if ((int)e.keyCode == 27)
{
Close();
e.Use();
}
return;
}
KeyCode keyCode = e.keyCode;
KeyCode val = keyCode;
if ((int)val != 13)
{
if ((int)val == 27)
{
Close();
e.Use();
return;
}
switch (val - 271)
{
default:
return;
case 3:
tab.Selected = Math.Min(tab.Selected + 1, tab.Results.Count - 1);
tab.SetPage(tab.Selected / PageSize.Value);
e.Use();
return;
case 2:
tab.Selected = Math.Max(tab.Selected - 1, 0);
tab.SetPage(tab.Selected / PageSize.Value);
e.Use();
return;
case 0:
break;
case 1:
return;
}
}
if (tab.Selected >= 0 && tab.Selected < tab.Results.Count)
{
tab.Apply(tab.Results[tab.Selected]);
}
e.Use();
}
private void DrawWindow(int id)
{
//IL_0341: Unknown result type (might be due to invalid IL or missing references)
//IL_034b: Unknown result type (might be due to invalid IL or missing references)
//IL_0350: Unknown result type (might be due to invalid IL or missing references)
//IL_0443: Unknown result type (might be due to invalid IL or missing references)
//IL_0448: Unknown result type (might be due to invalid IL or missing references)
//IL_0465: Unknown result type (might be due to invalid IL or missing references)
//IL_0458: Unknown result type (might be due to invalid IL or missing references)
if (_tabs.Count > 1)
{
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
for (int i = 0; i < _tabs.Count; i++)
{
if (GUILayout.Button(_tabs[i].Title, (i == _activeTab) ? _tabStyleActive : _tabStyle, Array.Empty<GUILayoutOption>()))
{
SwitchTab(i);
}
}
if (Tab.CustomDraw && GUILayout.Button("X", _tabStyle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
{
Close();
}
GUILayout.EndHorizontal();
}
ListTab tab = Tab;
if (tab.CustomDraw)
{
tab.Draw();
GUI.DragWindow();
return;
}
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUI.SetNextControlName("SkinSearchField");
tab.Query = GUILayout.TextField(tab.Query, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
if (GUILayout.Button("Refresh", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(70f) }))
{
tab.Refresh();
}
if (GUILayout.Button("X", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(28f) }))
{
Close();
}
GUILayout.EndHorizontal();
if (_focusSearchField)
{
GUI.FocusControl("SkinSearchField");
_focusSearchField = false;
}
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
string text = ((SortConfig.Value == SortMode.Recent) ? "Sort: Recent" : "Sort: A-Z");
if (GUILayout.Button(text, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) }))
{
SortConfig.Value = ((SortConfig.Value != SortMode.Recent) ? SortMode.Recent : SortMode.Name);
foreach (ListTab tab2 in _tabs)
{
tab2.MarkDirty();
}
tab.SetPage(0);
}
if (tab.SupportsThumbnails)
{
ShowThumbnails.Value = GUILayout.Toggle(ShowThumbnails.Value, " Thumbnails", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) });
}
GUILayout.FlexibleSpace();
GUILayout.Label($"{tab.Results.Count} / {tab.All.Count} ★ {tab.Favorites.Count}", Array.Empty<GUILayoutOption>());
GUILayout.EndHorizontal();
int num = tab.Page * PageSize.Value;
int num2 = Math.Min(num + PageSize.Value, tab.Results.Count);
bool flag = tab.SupportsThumbnails && ShowThumbnails.Value;
string text2 = ((tab.Recent.Count > 0) ? tab.Recent[0] : null);
tab.Scroll = GUILayout.BeginScrollView(tab.Scroll, Array.Empty<GUILayoutOption>());
if (tab.All.Count == 0)
{
GUILayout.Label(tab.EmptyMessage, Array.Empty<GUILayoutOption>());
}
else if (tab.Results.Count == 0)
{
GUILayout.Label("No matches.", Array.Empty<GUILayoutOption>());
}
for (int j = num; j < num2; j++)
{
ListEntry listEntry = tab.Results[j];
bool flag2 = tab.Favorites.Contains(listEntry.Key);
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
if (GUILayout.Button(flag2 ? "★" : "☆", _starStyle, Array.Empty<GUILayoutOption>()))
{
tab.ToggleFavorite(listEntry);
}
if (flag)
{
Texture thumbnail = tab.GetThumbnail(listEntry);
Rect rect = GUILayoutUtility.GetRect(44f, 44f, (GUILayoutOption[])(object)new GUILayoutOption[2]
{
GUILayout.Width(44f),
GUILayout.Height(44f)
});
if ((Object)(object)thumbnail != (Object)null)
{
GUI.DrawTexture(rect, thumbnail, (ScaleMode)2);
}
else
{
GUI.Box(rect, "?");
}
}
string text3 = ((listEntry.Key == text2) ? (" • " + tab.LastUsedLabel) : "");
if (GUILayout.Button(listEntry.DisplayName + tab.Tag(listEntry) + text3, (j == tab.Selected) ? _rowStyleSelected : _rowStyle, Array.Empty<GUILayoutOption>()))
{
tab.Selected = j;
tab.Apply(listEntry);
}
GUILayout.EndHorizontal();
}
GUILayout.EndScrollView();
GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
GUI.enabled = tab.Page > 0;
if (GUILayout.Button("<<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }))
{
tab.SetPage(0);
}
if (GUILayout.Button("<", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }))
{
tab.SetPage(tab.Page - 1);
}
GUI.enabled = true;
GUILayout.FlexibleSpace();
GUILayout.Label($"Page {tab.Page + 1} / {tab.PageCount}", Array.Empty<GUILayoutOption>());
GUILayout.FlexibleSpace();
GUI.enabled = tab.Page < tab.PageCount - 1;
if (GUILayout.Button(">", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }))
{
tab.SetPage(tab.Page + 1);
}
if (GUILayout.Button(">>", (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(40f) }))
{
tab.SetPage(tab.PageCount - 1);
}
GUI.enabled = true;
GUILayout.EndHorizontal();
GUI.DragWindow();
}
}
internal abstract class ListTab
{
public readonly List<ListEntry> All = new List<ListEntry>();
public List<ListEntry> Results = new List<ListEntry>();
public readonly HashSet<string> Favorites = new HashSet<string>();
public readonly List<string> Recent = new List<string>();
public string Query = "";
public int Page;
public int Selected;
public Vector2 Scroll;
public bool Built;
private string _lastQuery;
private bool _dirty = true;
private readonly ConfigEntry<string> _favoritesConfig;
private readonly ConfigEntry<string> _recentConfig;
private const int MaxRecent = 20;
public abstract string Title { get; }
public virtual bool SupportsThumbnails => false;
public virtual bool CustomDraw => false;
public virtual bool NeedsRefresh => !Built || All.Count == 0;
public virtual string EmptyMessage => "Nothing found.";
public virtual string LastUsedLabel => "last used";
public int PageCount
{
get
{
int value = SkinSearchPlugin.PageSize.Value;
return Math.Max(1, (Results.Count + value - 1) / value);
}
}
public virtual void Draw()
{
}
protected ListTab()
{
}
protected ListTab(ConfigFile config, string dataSection)
{
_favoritesConfig = config.Bind<string>(dataSection, "Favorites", "", "Favorites, comma-separated. Managed in-game.");
_recentConfig = config.Bind<string>(dataSection, "Recent", "", "Recently used, newest first. Managed in-game.");
foreach (string item in SplitKeys(_favoritesConfig.Value))
{
Favorites.Add(item);
}
Recent.AddRange(SplitKeys(_recentConfig.Value));
}
protected abstract void Load();
protected abstract bool ApplyEntry(ListEntry entry);
public virtual Texture GetThumbnail(ListEntry entry)
{
return null;
}
public virtual string Tag(ListEntry entry)
{
return "";
}
public virtual void OnOpen()
{
}
public void Refresh()
{
All.Clear();
try
{
Load();
}
catch (Exception arg)
{
SkinSearchPlugin.Log.LogError((object)$"Couldn't load {Title}: {arg}");
}
Built = true;
MarkDirty();
SkinSearchPlugin.Log.LogInfo((object)$"Loaded {All.Count} {Title.ToLowerInvariant()}.");
}
public void Apply(ListEntry entry)
{
try
{
if (ApplyEntry(entry))
{
AddRecent(entry.Key);
}
}
catch (Exception arg)
{
SkinSearchPlugin.Log.LogError((object)$"Failed to use {entry.DisplayName} ({entry.Key}): {arg}");
}
}
public void MarkDirty()
{
_dirty = true;
}
public void UpdateResults()
{
if (!_dirty && Query == _lastQuery)
{
return;
}
if (Query != _lastQuery)
{
Page = 0;
}
_dirty = false;
_lastQuery = Query;
string q = Query.Trim();
string[] words = q.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
var source = from e in All
select new
{
Entry = e,
Score = ((q.Length == 0) ? 1 : MatchScore(e, q, words))
} into x
where x.Score > 0
select x;
var source2 = source.OrderByDescending(x => Favorites.Contains(x.Entry.Key));
if (SkinSearchPlugin.SortConfig.Value == SkinSearchPlugin.SortMode.Recent)
{
source2 = source2.ThenBy(x => RecentRank(x.Entry.Key));
}
if (q.Length > 0)
{
source2 = source2.ThenByDescending(x => x.Score);
}
Results = (from x in source2.ThenBy(x => x.Entry.DisplayName, StringComparer.OrdinalIgnoreCase)
select x.Entry).ToList();
Selected = Mathf.Clamp(Selected, 0, Math.Max(0, Results.Count - 1));
Page = Mathf.Clamp(Page, 0, PageCount - 1);
}
public void SetPage(int page)
{
//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)
int num = Mathf.Clamp(page, 0, PageCount - 1);
if (num != Page)
{
Page = num;
Scroll = Vector2.zero;
}
}
private int RecentRank(string key)
{
int num = Recent.IndexOf(key);
return (num < 0) ? int.MaxValue : num;
}
private static int MatchScore(ListEntry e, string q, string[] words)
{
return Math.Max(Score(e.DisplayName, q, words), Math.Max(Score(e.FileName, q, words) - 5, Score(e.Category, q, words) - 20));
}
private static int Score(string name, string query, string[] words)
{
if (string.IsNullOrEmpty(name))
{
return 0;
}
StringComparison cmp = StringComparison.OrdinalIgnoreCase;
if (name.Equals(query, cmp))
{
return 100;
}
if (name.StartsWith(query, cmp))
{
return 75;
}
int num = name.IndexOf(query, cmp);
if (num >= 0)
{
return 50 - Math.Min(num, 40);
}
if (words.All((string w) => name.IndexOf(w, cmp) >= 0))
{
return 25;
}
return 0;
}
public void ToggleFavorite(ListEntry entry)
{
if (_favoritesConfig != null)
{
if (!Favorites.Remove(entry.Key))
{
Favorites.Add(entry.Key);
}
_favoritesConfig.Value = string.Join(",", Favorites.ToArray());
MarkDirty();
}
}
private void AddRecent(string key)
{
if (_recentConfig != null)
{
Recent.Remove(key);
Recent.Insert(0, key);
if (Recent.Count > 20)
{
Recent.RemoveRange(20, Recent.Count - 20);
}
_recentConfig.Value = string.Join(",", Recent.ToArray());
MarkDirty();
}
}
private static IEnumerable<string> SplitKeys(string raw)
{
if (string.IsNullOrEmpty(raw))
{
yield break;
}
string[] array = raw.Split(new char[1] { ',' });
foreach (string part in array)
{
string k = part.Trim();
if (k.Length > 0)
{
yield return k;
}
}
}
}
internal class ListEntry
{
public string Key;
public string DisplayName;
public string FileName;
public string Category;
public Texture Thumbnail;
public bool ThumbnailTried;
}
internal class SkinEntry : ListEntry
{
public Guid Guid;
public Characters Slot;
public bool IsReplacement;
public bool HiddenFromCypher;
public bool IsVanilla;
public unsafe string SlotName
{
get
{
//IL_0018: Unknown result type (might be due to invalid IL or missing references)
//IL_001d: Unknown result type (might be due to invalid IL or missing references)
object result;
if (!IsReplacement && !IsVanilla)
{
result = "";
}
else
{
BrcCharacter slot = (BrcCharacter)Slot;
result = ((object)(*(BrcCharacter*)(&slot))/*cast due to .constrained prefix*/).ToString();
}
return (string)result;
}
}
}
internal class SkinTab : ListTab
{
private const int MaxVanillaSlot = 26;
private ConfigFile _crewBoomConfig;
private const string CrewBoomOff = "OFF";
private const BindingFlags AnyInstance = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public override string Title => "Skins";
public override bool SupportsThumbnails => true;
public override string LastUsedLabel => "current";
public override string EmptyMessage => "No characters found. Load into a stage, then press Refresh.";
public SkinTab(ConfigFile config)
: base(config, "Data")
{
}
public override string Tag(ListEntry entry)
{
SkinEntry skinEntry = (SkinEntry)entry;
if (skinEntry.IsVanilla)
{
return " [vanilla]";
}
return skinEntry.IsReplacement ? (" [replaces " + skinEntry.SlotName + "]") : "";
}
public override void OnOpen()
{
foreach (ListEntry item in All)
{
if ((Object)(object)item.Thumbnail == (Object)null)
{
item.ThumbnailTried = false;
}
}
}
protected override void Load()
{
LoadVanilla();
LoadCrewBoom();
}
private void LoadVanilla()
{
//IL_0046: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Unknown result type (might be due to invalid IL or missing references)
//IL_0059: Unknown result type (might be due to invalid IL or missing references)
//IL_0093: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
Core instance = Core.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
SaveManager saveManager = instance.SaveManager;
obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
}
SaveSlotData val = (SaveSlotData)obj;
if (val == null)
{
SkinSearchPlugin.Log.LogWarning((object)"No save loaded yet - vanilla characters will show after Refresh in a stage.");
return;
}
for (int i = 0; i < 26; i++)
{
Characters slot = (Characters)i;
if (IsVanillaAvailable(slot))
{
string text = ((object)(BrcCharacter)i/*cast due to .constrained prefix*/).ToString();
All.Add(new SkinEntry
{
Guid = Guid.Empty,
Key = "vanilla:" + text,
DisplayName = VanillaName(slot),
FileName = text,
Category = "Vanilla",
Slot = slot,
IsVanilla = true
});
}
}
}
private static bool IsVanillaAvailable(Characters slot)
{
//IL_008a: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Invalid comparison between Unknown and I4
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_000a: Invalid comparison between Unknown and I4
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0026: Invalid comparison between Unknown and I4
//IL_0028: Unknown result type (might be due to invalid IL or missing references)
//IL_002b: Invalid comparison between Unknown and I4
//IL_0049: Unknown result type (might be due to invalid IL or missing references)
try
{
if ((int)slot == 17 || (int)slot == 18)
{
return OwnsCharacterDlc();
}
if ((int)slot == 12 || (int)slot == 23 || (int)slot == 24)
{
return true;
}
CharacterProgress characterProgress = Core.Instance.SaveManager.CurrentSaveSlot.GetCharacterProgress(slot);
bool flag = default(bool);
int num;
if (characterProgress != null)
{
object member = GetMember(characterProgress, "unlocked");
if (member is bool)
{
flag = (bool)member;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogDebug((object)$"Couldn't check whether {slot} is unlocked: {ex.Message}");
return false;
}
}
private static bool OwnsCharacterDlc()
{
object instance = Core.Instance;
object member = GetMember(GetMember(instance, "platform"), "DownloadableContent");
object member2 = GetMember(GetMember(instance, "baseModule"), "characterDownloadableContent");
if (member == null || member2 == null)
{
return false;
}
MethodInfo method = member.GetType().GetMethod("IsDownloadableContentUnlocked", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
bool flag = default(bool);
int num;
if (method != null)
{
object obj = method.Invoke(member, new object[1] { member2 });
if (obj is bool)
{
flag = (bool)obj;
num = 1;
}
else
{
num = 0;
}
}
else
{
num = 0;
}
return (byte)((uint)num & (flag ? 1u : 0u)) != 0;
}
private unsafe static string VanillaName(Characters slot)
{
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0003: Unknown result type (might be due to invalid IL or missing references)
//IL_0004: Unknown result type (might be due to invalid IL or missing references)
//IL_0005: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Invalid comparison between Unknown and I4
//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
//IL_0017: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Invalid comparison between Unknown and I4
//IL_000a: Unknown result type (might be due to invalid IL or missing references)
//IL_000c: Invalid comparison between Unknown and I4
//IL_010e: Unknown result type (might be due to invalid IL or missing references)
//IL_010f: Unknown result type (might be due to invalid IL or missing references)
//IL_001e: Unknown result type (might be due to invalid IL or missing references)
//IL_0021: Invalid comparison between Unknown and I4
//IL_0010: Unknown result type (might be due to invalid IL or missing references)
//IL_0013: Invalid comparison between Unknown and I4
//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
if ((int)slot <= 9)
{
if ((int)slot == 7)
{
return "DOT EXE";
}
if ((int)slot == 9)
{
return "DJ Cyber";
}
}
else
{
if ((int)slot == 23)
{
return "Faux (No Boost Pack)";
}
if ((int)slot == 24)
{
return "DOT EXE (Leader)";
}
}
try
{
object member = GetMember(Core.Instance, "Localizer");
if ((member?.GetType().GetMethod("GetCharacterName", new Type[1] { typeof(Characters) }))?.Invoke(member, new object[1] { slot }) is string { Length: >0 } text)
{
return CultureInfo.InvariantCulture.TextInfo.ToTitleCase(text.ToLowerInvariant());
}
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogDebug((object)$"No localized name for {slot}: {ex.Message}");
}
BrcCharacter val = (BrcCharacter)slot;
return ((object)(*(BrcCharacter*)(&val))/*cast due to .constrained prefix*/).ToString();
}
private void LoadCrewBoom()
{
//IL_0110: Unknown result type (might be due to invalid IL or missing references)
//IL_0112: Unknown result type (might be due to invalid IL or missing references)
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_011c: Invalid comparison between Unknown and I4
if (!(typeof(CharacterDatabase).GetField("_characterBundlePaths", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null) is Dictionary<Guid, string> dictionary))
{
SkinSearchPlugin.Log.LogWarning((object)"CrewBoom database isn't initialized yet - try again once you're in a stage.");
return;
}
Characters val = default(Characters);
CustomCharacter val2 = default(CustomCharacter);
foreach (KeyValuePair<Guid, string> item in dictionary)
{
Guid key = item.Key;
string value = item.Value;
if (CharacterDatabase.GetCharacterValueFromGuid(key, ref val))
{
string displayName = Path.GetFileNameWithoutExtension(value);
if (CharacterDatabase.GetCharacter(key, ref val2) && ((val2 != null) ? val2.StreamData : null) != null && !string.IsNullOrEmpty(val2.StreamData.Name))
{
displayName = val2.StreamData.Name;
}
SkinEntry skinEntry = new SkinEntry
{
Guid = key,
Key = key.ToString(),
FileName = Path.GetFileNameWithoutExtension(value),
DisplayName = displayName,
Slot = val,
IsReplacement = ((int)val <= 26),
HiddenFromCypher = value.Replace('\\', '/').Contains("/no_cypher/")
};
skinEntry.Category = skinEntry.SlotName;
All.Add(skinEntry);
}
}
}
protected override bool ApplyEntry(ListEntry entry)
{
//IL_0048: 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_008e: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: 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_0111: Unknown result type (might be due to invalid IL or missing references)
SkinEntry skinEntry = (SkinEntry)entry;
WorldHandler instance = WorldHandler.instance;
Player val = ((instance != null) ? instance.GetCurrentPlayer() : null);
if ((Object)(object)val == (Object)null)
{
SkinSearchPlugin.Log.LogWarning((object)"No player found - are you in a stage?");
return false;
}
if (skinEntry.IsReplacement && !SetReplacementOverride(skinEntry.Slot, skinEntry.Guid.ToString()))
{
return false;
}
if (skinEntry.IsVanilla && CharacterDatabase.HasCharacter(skinEntry.Slot) && !SetReplacementOverride(skinEntry.Slot, "OFF"))
{
return false;
}
int savedOutfit = GetSavedOutfit(skinEntry);
SwitchCharacter(val, skinEntry.Slot, savedOutfit);
if ((Object)(object)skinEntry.Thumbnail == (Object)null)
{
skinEntry.ThumbnailTried = false;
}
SkinSearchPlugin.Log.LogInfo((object)(skinEntry.IsVanilla ? $"Applied vanilla {skinEntry.DisplayName} (slot {skinEntry.Slot}), outfit {savedOutfit}" : $"Applied {skinEntry.DisplayName} ({skinEntry.Guid}) to slot {skinEntry.Slot}, outfit {savedOutfit}"));
return true;
}
public override Texture GetThumbnail(ListEntry entry)
{
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
SkinEntry skinEntry = (SkinEntry)entry;
if ((Object)(object)skinEntry.Thumbnail != (Object)null || skinEntry.ThumbnailTried)
{
return skinEntry.Thumbnail;
}
skinEntry.ThumbnailTried = true;
try
{
if (skinEntry.IsVanilla)
{
return skinEntry.Thumbnail = VanillaGraffiti(skinEntry.Slot);
}
CustomCharacter val = default(CustomCharacter);
if (!CharacterDatabase.GetCharacter(skinEntry.Guid, ref val) || val == null)
{
return null;
}
object member = GetMember(val, "Graffiti");
if (member == null)
{
return null;
}
object member2 = GetMember(member, "graffitiMaterial");
Material val2 = (Material)((member2 is Material) ? member2 : null);
if (val2 != null && (Object)(object)val2.mainTexture != (Object)null)
{
return skinEntry.Thumbnail = val2.mainTexture;
}
FieldInfo[] fields = member.GetType().GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
object value = fieldInfo.GetValue(member);
Texture val3 = (Texture)((value is Texture) ? value : null);
if (val3 != null)
{
return skinEntry.Thumbnail = val3;
}
Material val4 = (Material)((value is Material) ? value : null);
if (val4 != null && (Object)(object)val4.mainTexture != (Object)null)
{
return skinEntry.Thumbnail = val4.mainTexture;
}
}
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogDebug((object)("No thumbnail for " + skinEntry.DisplayName + ": " + ex.Message));
}
return null;
}
private static void SwitchCharacter(Player player, Characters slot, int outfit)
{
//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)
//IL_003b: 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_0055: Unknown result type (might be due to invalid IL or missing references)
FieldInfo field = typeof(Player).GetField("character", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null && field.GetValue(player) is Characters val && val == slot)
{
field.SetValue(player, (object)(Characters)(-1));
}
player.SetCharacter(slot, outfit);
MethodInfo method = typeof(Player).GetMethod("InitVisual", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, Type.EmptyTypes, null);
if (method != null)
{
method.Invoke(player, null);
}
else
{
SkinSearchPlugin.Log.LogWarning((object)"Couldn't find Player.InitVisual - the character may not display correctly.");
}
}
private static Texture VanillaGraffiti(Characters slot)
{
//IL_004b: Unknown result type (might be due to invalid IL or missing references)
object member = GetMember(WorldHandler.instance, "graffitiArtInfo");
object obj = (member?.GetType().GetMethod("FindByCharacter", new Type[1] { typeof(Characters) }))?.Invoke(member, new object[1] { slot });
object member2 = GetMember(obj, "graffitiMaterial");
object obj2 = ((member2 is Material) ? member2 : null);
return (obj2 != null) ? ((Material)obj2).mainTexture : null;
}
private static object GetMember(object obj, string name)
{
if (obj == null)
{
return null;
}
Type type = obj.GetType();
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null)
{
return property.GetValue(obj);
}
return type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
}
private static int GetSavedOutfit(SkinEntry skin)
{
//IL_0067: Unknown result type (might be due to invalid IL or missing references)
int num = 0;
try
{
if (!skin.IsReplacement && !skin.IsVanilla)
{
CharacterProgress val = default(CharacterProgress);
if (CharacterSaveSlots.GetCharacterData(skin.Guid, ref val) && val != null)
{
num = val.outfit;
}
}
else
{
Core instance = Core.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
SaveManager saveManager = instance.SaveManager;
if (saveManager == null)
{
obj = null;
}
else
{
SaveSlotData currentSaveSlot = saveManager.CurrentSaveSlot;
obj = ((currentSaveSlot != null) ? currentSaveSlot.GetCharacterProgress(skin.Slot) : null);
}
}
CharacterProgress val2 = (CharacterProgress)obj;
if (val2 != null)
{
num = val2.outfit;
}
}
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogWarning((object)("Couldn't read saved outfit for " + skin.DisplayName + ": " + ex.Message));
}
return Mathf.Clamp(num, 0, 3);
}
private unsafe bool SetReplacementOverride(Characters slot, string value)
{
//IL_008d: Unknown result type (might be due to invalid IL or missing references)
//IL_008e: Unknown result type (might be due to invalid IL or missing references)
if (_crewBoomConfig == null)
{
Assembly crewBoomAsm = typeof(CharacterDatabase).Assembly;
PluginInfo val = ((IEnumerable<PluginInfo>)Chainloader.PluginInfos.Values).FirstOrDefault((Func<PluginInfo, bool>)((PluginInfo p) => (Object)(object)p.Instance != (Object)null && ((object)p.Instance).GetType().Assembly == crewBoomAsm));
object crewBoomConfig;
if (val == null)
{
crewBoomConfig = null;
}
else
{
BaseUnityPlugin instance = val.Instance;
crewBoomConfig = ((instance != null) ? instance.Config : null);
}
_crewBoomConfig = (ConfigFile)crewBoomConfig;
}
if (_crewBoomConfig == null)
{
SkinSearchPlugin.Log.LogWarning((object)"Couldn't find CrewBoom's config.");
return false;
}
BrcCharacter val2 = (BrcCharacter)slot;
string text = ((object)(*(BrcCharacter*)(&val2))/*cast due to .constrained prefix*/).ToString();
ConfigEntry<string> val3 = default(ConfigEntry<string>);
if (!_crewBoomConfig.TryGetEntry<string>("Replacement IDs", text, ref val3))
{
SkinSearchPlugin.Log.LogWarning((object)("No CrewBoom 'Replacement IDs' entry for " + text + "."));
return false;
}
val3.Value = value;
return true;
}
}
internal class MapEntry : ListEntry
{
public int StageId;
}
internal class MapTab : ListTab
{
private static readonly string[][] Vanilla = new string[7][]
{
new string[2] { "hideout", "Hideout" },
new string[2] { "downhill", "Versum Hill" },
new string[2] { "square", "Millennium Square" },
new string[2] { "tower", "Brink Terminal" },
new string[2] { "Mall", "Millennium Mall" },
new string[2] { "pyramid", "Pyramid Island" },
new string[2] { "osaka", "Mataan" }
};
public override string Title => "Maps";
public override string LastUsedLabel => "last visited";
public override string EmptyMessage => "No maps found. Load into a stage, then press Refresh.";
public MapTab(ConfigFile config)
: base(config, "Maps Data")
{
}
public override string Tag(ListEntry entry)
{
MapEntry mapEntry = (MapEntry)entry;
string text = ((mapEntry.StageId == MapTravel.CurrentStageId()) ? " (here)" : "");
return (string.IsNullOrEmpty(mapEntry.Category) ? "" : (" [" + mapEntry.Category + "]")) + text;
}
protected override void Load()
{
//IL_0063: Unknown result type (might be due to invalid IL or missing references)
//IL_0069: Expected I4, but got Unknown
string[][] vanilla = Vanilla;
foreach (string[] array in vanilla)
{
if (Enum.TryParse<Stage>(array[0], ignoreCase: true, out Stage result))
{
All.Add(new MapEntry
{
Key = "stage:" + array[0],
DisplayName = array[1],
FileName = array[0],
Category = "Vanilla",
StageId = (int)result
});
}
}
foreach (MapEntry item in MapStationBridge.CustomMaps())
{
All.Add(item);
}
}
protected override bool ApplyEntry(ListEntry entry)
{
MapEntry mapEntry = (MapEntry)entry;
if (mapEntry.StageId == MapTravel.CurrentStageId())
{
SkinSearchPlugin.Log.LogInfo((object)("Already in " + mapEntry.DisplayName + "."));
return false;
}
if (!MapTravel.TravelTo(mapEntry.StageId))
{
return false;
}
SkinSearchPlugin.Log.LogInfo((object)("Travelling to " + mapEntry.DisplayName));
SkinSearchPlugin.RequestClose();
return true;
}
}
internal static class MapTravel
{
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
public static bool TravelTo(int stageId)
{
try
{
object obj = Get(Core.Instance, "BaseModule");
object obj2 = Get(obj, "StageManager");
MethodInfo methodInfo = obj2?.GetType().GetMethods(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).FirstOrDefault((MethodInfo m) => m.Name == "ExitCurrentStage" && m.GetParameters().Length >= 1 && m.GetParameters()[0].ParameterType == typeof(Stage));
if (methodInfo == null)
{
SkinSearchPlugin.Log.LogWarning((object)"Couldn't find the game's StageManager.ExitCurrentStage - can't travel.");
return false;
}
ParameterInfo[] parameters = methodInfo.GetParameters();
object[] array = new object[parameters.Length];
array[0] = (object)(Stage)stageId;
for (int num = 1; num < parameters.Length; num++)
{
array[num] = (parameters[num].HasDefaultValue ? parameters[num].DefaultValue : (parameters[num].ParameterType.IsValueType ? Activator.CreateInstance(parameters[num].ParameterType) : null));
}
methodInfo.Invoke(obj2, array);
return true;
}
catch (Exception arg)
{
SkinSearchPlugin.Log.LogError((object)$"Travel failed: {arg}");
return false;
}
}
public static int CurrentStageId()
{
//IL_003f: Unknown result type (might be due to invalid IL or missing references)
//IL_0044: Unknown result type (might be due to invalid IL or missing references)
//IL_004e: Unknown result type (might be due to invalid IL or missing references)
try
{
Core instance = Core.Instance;
object obj;
if (instance == null)
{
obj = null;
}
else
{
SaveManager saveManager = instance.SaveManager;
obj = ((saveManager != null) ? saveManager.CurrentSaveSlot : null);
}
object obj2 = Get(obj, "currentStageProgress");
return (!(Get(obj2, "stageID") is Stage val)) ? int.MinValue : ((int)val);
}
catch (Exception)
{
return int.MinValue;
}
}
private static object Get(object obj, string name)
{
if (obj == null)
{
return null;
}
Type type = obj.GetType();
PropertyInfo property = type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (property != null && property.GetIndexParameters().Length == 0)
{
return property.GetValue(obj, null);
}
return type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj);
}
}
internal static class MapStationBridge
{
public static IEnumerable<MapEntry> CustomMaps()
{
List<MapEntry> list = new List<MapEntry>();
try
{
Type type = null;
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
if ((type = assembly.GetType("MapStation.API.APIManager", throwOnError: false)) != null)
{
break;
}
}
if (type == null)
{
return list;
}
object obj = type.GetField("API", BindingFlags.Static | BindingFlags.Public)?.GetValue(null);
if (!(obj?.GetType().GetProperty("CustomStages")?.GetValue(obj, null) is IEnumerable enumerable))
{
return list;
}
foreach (object item in enumerable)
{
Type type2 = item.GetType();
string text = type2.GetProperty("DisplayName")?.GetValue(item, null) as string;
string text2 = type2.GetProperty("InternalName")?.GetValue(item, null) as string;
string text3 = type2.GetProperty("AuthorName")?.GetValue(item, null) as string;
if (type2.GetProperty("StageID")?.GetValue(item, null) is int stageId)
{
list.Add(new MapEntry
{
Key = "map:" + (text2 ?? stageId.ToString()).Replace(",", ""),
DisplayName = (string.IsNullOrEmpty(text) ? text2 : text),
FileName = text3,
Category = (string.IsNullOrEmpty(text3) ? "MapStation" : ("by " + text3)),
StageId = stageId
});
}
}
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogWarning((object)("Couldn't read MapStation's maps: " + ex.Message));
}
return list;
}
}
internal class ExternalTab : ListTab
{
private readonly string _title;
private readonly Action _draw;
private readonly Action _onShown;
private bool _reported;
public override string Title => _title;
public override bool CustomDraw => true;
public override bool NeedsRefresh => false;
public ExternalTab(string title, Action draw, Action onShown)
{
_title = title;
_draw = draw;
_onShown = onShown;
Built = true;
}
public override void OnOpen()
{
_onShown?.Invoke();
}
public override void Draw()
{
try
{
_draw();
}
catch (Exception arg)
{
GUILayout.Label("The " + _title + " tab failed to draw - see the log.", Array.Empty<GUILayoutOption>());
if (!_reported)
{
SkinSearchPlugin.Log.LogError((object)$"{_title} tab failed: {arg}");
}
_reported = true;
}
}
protected override void Load()
{
}
protected override bool ApplyEntry(ListEntry entry)
{
return false;
}
}
internal static class GamblingBridge
{
public const string Guid = "com.chimp.brcgambling";
public static ExternalTab CreateTab()
{
if (!Chainloader.PluginInfos.TryGetValue("com.chimp.brcgambling", out var value) || (Object)(object)value.Instance == (Object)null)
{
SkinSearchPlugin.Log.LogInfo((object)"AMT Casino not installed - Effects tab disabled.");
return null;
}
try
{
Type type = ((object)value.Instance).GetType().Assembly.GetType("BRCGambling.InventoryPanel");
MethodInfo methodInfo = type?.GetMethod("DrawPanel", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
MethodInfo methodInfo2 = type?.GetMethod("OnShown", BindingFlags.Static | BindingFlags.Public, null, Type.EmptyTypes, null);
if (methodInfo == null)
{
SkinSearchPlugin.Log.LogInfo((object)"This AMT Casino version has no inventory panel - Effects tab disabled.");
return null;
}
string title = (type.GetField("Title", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) as string) ?? "Effects";
Action draw = (Action)Delegate.CreateDelegate(typeof(Action), methodInfo);
Action onShown = ((methodInfo2 != null) ? ((Action)Delegate.CreateDelegate(typeof(Action), methodInfo2)) : null);
return new ExternalTab(title, draw, onShown);
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogWarning((object)("Couldn't set up the Effects tab: " + ex.Message));
return null;
}
}
}
internal class EmoteEntry : ListEntry
{
public int Hash;
}
internal class EmoteTab : ListTab
{
public override string Title => "Emotes";
public override string EmptyMessage => "No emotes found. Load into a stage, then press Refresh.";
public EmoteTab(ConfigFile config)
: base(config, "Emotes Data")
{
}
public override string Tag(ListEntry entry)
{
return string.IsNullOrEmpty(entry.Category) ? "" : (" [" + entry.Category + "]");
}
protected override void Load()
{
All.AddRange(BoEBridge.GetEmotes().Cast<ListEntry>());
}
protected override bool ApplyEntry(ListEntry entry)
{
return BoEBridge.Play((EmoteEntry)entry);
}
}
internal static class BoEBridge
{
public const string Guid = "com.Dragsun.BunchOfEmotes";
private const BindingFlags StaticFlags = BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private const BindingFlags InstanceFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
private static readonly string[][] KnownLists = new string[3][]
{
new string[2] { "myCustomAnims2", "Custom" },
new string[2] { "myCustomAnims", "Game" },
new string[2] { "myCustomAnimsInject", "BoE favourites" }
};
private static Type _pluginType;
public static bool Installed => Chainloader.PluginInfos.ContainsKey("com.Dragsun.BunchOfEmotes");
private static Type PluginType
{
get
{
if (_pluginType == null && Chainloader.PluginInfos.TryGetValue("com.Dragsun.BunchOfEmotes", out var value) && (Object)(object)value.Instance != (Object)null)
{
_pluginType = ((object)value.Instance).GetType();
}
return _pluginType;
}
}
private static Dictionary<int, string> GameEmotes(Type type)
{
FieldInfo field = type.GetField("myCustomAnims", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
FieldInfo field2 = type.GetField("customMenu", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
MethodInfo method = type.GetMethod("initEmotes", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
Dictionary<int, string> result = field?.GetValue(null) as Dictionary<int, string>;
if (field2 == null || method == null || !(field2.GetValue(null) is bool flag) || !flag)
{
return result;
}
if (type.GetProperty("player", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null) == null)
{
return result;
}
FieldInfo field3 = type.GetField("myAnimationKey", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
object value = field3?.GetValue(null);
try
{
field2.SetValue(null, false);
method.Invoke(null, null);
return field.GetValue(null) as Dictionary<int, string>;
}
catch (Exception ex)
{
SkinSearchPlugin.Log.LogWarning((object)("Couldn't read BoE's game emotes: " + ex.Message));
return result;
}
finally
{
try
{
field2.SetValue(null, true);
method.Invoke(null, null);
if (field3 != null)
{
field3.SetValue(null, value);
}
}
catch
{
}
}
}
private static object GetInstanceMember(object obj, string name)
{
Type type = obj.GetType();
FieldInfo field = type.GetField(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field.GetValue(obj);
}
return type.GetProperty(name, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(obj, null);
}
public static List<EmoteEntry> GetEmotes()
{
List<EmoteEntry> list = new List<EmoteEntry>();
Type pluginType = PluginType;
if (pluginType == null)
{
return list;
}
EnsureInitialized(pluginType);
HashSet<int> seen = new HashSet<int>();
string[][] knownLists = KnownLists;
foreach (string[] array in knownLists)
{
Dictionary<int, string> dict = ((array[0] == "myCustomAnims") ? GameEmotes(pluginType) : (pluginType.GetField(array[0], BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) as Dictionary<int, string>));
AddFrom(dict, array[1], list, seen);
}
FieldInfo[] fields = pluginType.GetFields(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo f in fields)
{
if (f.FieldType == typeof(Dictionary<int, string>) && !KnownLists.Any((string[] k) => k[0] == f.Name))
{
AddFrom(f.GetValue(null) as Dictionary<int, string>, f.Name, list, seen);
}
}
return list;
}
private static void EnsureInitialized(Type type)
{
Dictionary<int, string> dictionary = type.GetField("myCustomAnims", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) as Dictionary<int, string>;
object? obj = type.GetField("myAnim", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null);
Object val = (Object)((obj is Object) ? obj : null);
if (dictionary != null && dictionary.Count <= 0 && !(val == (Object)null))
{
string text = type.GetField("BunchOfEmotesPath", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null) as string;
type.GetMethod("AddAnimationClipToController", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, new object[2]
{
val,
text + "/bunchofemotes"
});
type.GetMethod("initEmotes", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.Invoke(null, null);
}
}
private static void AddFrom(Dictionary<int, string> dict, string category, List<EmoteEntry> list, HashSet<int> seen)
{
if (dict == null)
{
return;
}
foreach (KeyValuePair<int, string> item in dict)
{
if (!string.IsNullOrEmpty(item.Value) && seen.Add(item.Key))
{
list.Add(new EmoteEntry
{
Hash = item.Key,
Key = (category + "/" + item.Value).Replace(",", ""),
DisplayName = item.Value,
Category = category
});
}
}
}
public static bool Play(EmoteEntry emote)
{
Type pluginType = PluginType;
if (pluginType == null)
{
return false;
}
object? obj = pluginType.GetProperty("player", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(null, null);
Player val = (Player)((obj is Player) ? obj : null);
if ((Object)(object)val == (Object)null)
{
WorldHandler instance = WorldHandler.instance;
val = ((instance != null) ? instance.GetCurrentPlayer() : null);
}
if ((Object)(object)val == (Object)null)
{
SkinSearchPlugin.Log.LogWarning((object)"No player found - are you in a stage?");
return false;
}
object instanceMember = GetInstanceMember(val, "sitAbility");
Ability val2 = (Ability)((instanceMember is Ability) ? instanceMember : null);
if (val2 == null)
{
SkinSearchPlugin.Log.LogWarning((object)"Couldn't find the player's sit ability.");
return false;
}
pluginType.GetField("inAnimation", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)?.SetValue(null, true);
val.ActivateAbility(val2);
val.PlayAnim(emote.Hash, false, false, -1f);
object instanceMember2 = GetInstanceMember(val, "ui");
instanceMember2?.GetType().GetMethod("TurnOn", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null)?.Invoke(instanceMember2, new object[1] { true });
SkinSearchPlugin.Log.LogInfo((object)("Played emote " + emote.DisplayName + " (" + emote.Category + ")"));
return true;
}
}
internal static class InputBlocker
{
private const BindingFlags Any = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;
private static bool _blocked;
private static bool _reported;
private static bool _prevMouse = true;
private static bool _prevKeyboard = true;
private static bool _setFailed;
public static bool Blocked => _blocked;
public static void Block()
{
if (!_blocked)
{
object obj = Controllers(!_reported);
_reported = true;
if (obj != null)
{
_prevMouse = GetEnabled(obj, "Mouse") ?? true;
_prevKeyboard = GetEnabled(obj, "Keyboard") ?? true;
}
_blocked = true;
Tick();
}
}
public static void Release()
{
if (_blocked)
{
_blocked = false;
object obj = Controllers();
if (obj != null)
{
SetEnabled(obj, "Mouse", _prevMouse);
SetEnabled(obj, "Keyboard", _prevKeyboard);
}
}
}
public static void Tick()
{
if (_blocked)
{
object obj = Controllers();
if (obj != null)
{
SetEnabled(obj, "Mouse", value: false);
SetEnabled(obj, "Keyboard", value: false);
}
Cursor.visible = true;
Cursor.lockState = (CursorLockMode)0;
}
}
private static object Controllers(bool log = false)
{
try
{
object instance = Core.Instance;
object obj = Get(instance, "GameInput") ?? Get(instance, "gameInput");
object obj2 = Get(obj, "rewiredMappingHandler");
object obj3 = RewiredPlayer(obj2);
object obj4 = Get(obj3, "controllers");
if (log)
{
Debug.Log((object)("[InputBlocker] core=" + Name(instance) + " gameInput=" + Name(obj) + " handler=" + Name(obj2) + " player=" + Name(obj3) + " controllers=" + Name(obj4) + " mouse=" + Name(Get(obj4, "Mouse")) + " keyboard=" + Name(Get(obj4, "Keyboard"))));
}
return obj4;
}
catch (Exception arg)
{
if (log)
{
Debug.LogWarning((object)$"[InputBlocker] Couldn't reach the game's input: {arg}");
}
return null;
}
}
private static object RewiredPlayer(object handler)
{
if (handler != null)
{
Type type = handler.GetType();
MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (MethodInfo methodInfo in methods)
{
if (!(methodInfo.Name != "GetRewiredPlayer"))
{
ParameterInfo[] parameters = methodInfo.GetParameters();
object obj = null;
if (parameters.Length == 0)
{
obj = methodInfo.Invoke(handler, null);
}
else if (parameters.Length == 1 && parameters[0].ParameterType == typeof(int))
{
obj = methodInfo.Invoke(handler, new object[1] { 0 });
}
if (obj != null)
{
return obj;
}
}
}
Type type2 = type;
while (type2 != null)
{
FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (FieldInfo fieldInfo in fields)
{
if (fieldInfo.FieldType.FullName == "Rewired.Player")
{
object value = fieldInfo.GetValue(fieldInfo.IsStatic ? null : handler);
if (value != null)
{
return value;
}
}
}
PropertyInfo[] properties = type2.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.PropertyType.FullName == "Rewired.Player" && propertyInfo.GetIndexParameters().Length == 0)
{
object value2 = propertyInfo.GetValue(handler, null);
if (value2 != null)
{
return value2;
}
}
}
type2 = type2.BaseType;
}
}
object obj2 = FindType("Rewired.ReInput")?.GetProperty("players", BindingFlags.Static | BindingFlags.Public)?.GetValue(null, null);
return (obj2?.GetType().GetMethod("GetPlayer", new Type[1] { typeof(int) }))?.Invoke(obj2, new object[1] { 0 });
}
private static Type FindType(string fullName)
{
Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
foreach (Assembly assembly in assemblies)
{
Type type = assembly.GetType(fullName, throwOnError: false);
if (type != null)
{
return type;
}
}
return null;
}
private static string Name(object o)
{
return (o == null) ? "MISSING" : o.GetType().Name;
}
private static bool? GetEnabled(object controllers, string which)
{
object obj = Get(controllers, which);
return (obj == null) ? ((bool?)null) : (Get(obj, "enabled") as bool?);
}
private static void SetEnabled(object controllers, string which, bool value)
{
try
{
object obj = Get(controllers, which);
if (obj != null)
{
PropertyInfo propertyInfo = FindProperty(obj.GetType(), "enabled");
if (propertyInfo != null && propertyInfo.CanWrite)
{
propertyInfo.SetValue(obj, value, null);
}
else
{
FindField(obj.GetType(), "enabled")?.SetValue(obj, value);
}
}
}
catch (Exception arg)
{
if (!_setFailed)
{
Debug.LogWarning((object)$"[InputBlocker] Couldn't switch {which} input: {arg}");
}
_setFailed = true;
}
}
private static object Get(object obj, string name)
{
if (obj == null)
{
return null;
}
Type type = obj.GetType();
PropertyInfo propertyInfo = FindProperty(type, name);
if (propertyInfo != null)
{
return propertyInfo.GetValue(obj, null);
}
return FindField(type, name)?.GetValue(obj);
}
private static PropertyInfo FindProperty(Type t, string name)
{
while (t != null)
{
PropertyInfo[] properties = t.GetProperties(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
foreach (PropertyInfo propertyInfo in properties)
{
if (propertyInfo.Name == name && propertyInfo.GetIndexParameters().Length == 0)
{
return propertyInfo;
}
}
t = t.BaseType;
}
return null;
}
private static FieldInfo FindField(Type t, string name)
{
while (t != null)
{
FieldInfo field = t.GetField(name, BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
if (field != null)
{
return field;
}
t = t.BaseType;
}
return null;
}
}