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.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.NET.Common; using BepInExResoniteShim; using BepisResoniteWrapper; using Elements.Core; using FrooxEngine; using FrooxEngine.ProtoFlux; using FrooxEngine.UIX; using HarmonyLib; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(/*Could not decode attribute arguments.*/)] [assembly: TargetFramework(".NETCoreApp,Version=v10.0", FrameworkDisplayName = ".NET 10.0")] [assembly: AssemblyCompany("yosh, NepuShiro")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.3.0.0")] [assembly: AssemblyInformationalVersion("1.3.0+ee766c013aabf7e08456619a0aa5425062599113")] [assembly: AssemblyProduct("YAP")] [assembly: AssemblyTitle("ResoniteYAP")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/NepuShiro/ResoniteYAP")] [assembly: AssemblyVersion("1.3.0.0")] [module: RefSafetyRules(11)] namespace YAP; internal enum MatchAlgo { CherryPick, Fzy } public static class FzyMatcher { private const float SCORE_CONSEC = 0.7f; private const float SCORE_UPPER = 0.7f; private const float SCORE_GAP_LEADING = -0.2f; private const float SCORE_GAP_INNER = -0.05f; private const float SCORE_GAP_TRAILING = -0.05f; private const float MAX_SCORE = 1f / 0f; private const float MIN_SCORE = -1f / 0f; private const int MAX_LEN = 64; private static float[] BEST_MATCH = new float[64]; private static float[] BEST = new float[64]; public unsafe static bool HasMatch(global::System.ReadOnlySpan haystack, global::System.ReadOnlySpan needle) { if (haystack.Length < needle.Length) { return false; } global::System.ReadOnlySpan readOnlySpan = haystack; for (int i = 0; i < needle.Length; i++) { int num = MemoryExtensions.IndexOf(readOnlySpan, *(char*)needle[i]); if (num == -1) { return false; } readOnlySpan = readOnlySpan.Slice(num + 1); } return true; } public unsafe static float Score(global::System.ReadOnlySpan haystack, global::System.ReadOnlySpan haystack_lower, global::System.ReadOnlySpan needle, global::System.ReadOnlySpan needle_lower) { if (haystack.Length == needle.Length) { return 1f / 0f; } float num = -1f / 0f; float num2 = -1f / 0f; float num3 = -1f / 0f; for (int i = 0; i < needle.Length; i++) { float num4 = ((i == needle.Length - 1) ? (-0.05f) : (-0.05f)); for (int j = 0; j < haystack.Length; j++) { if (*(ushort*)needle_lower[i] == *(ushort*)haystack_lower[j]) { float num5 = -1f / 0f; float num6 = (char.IsUpper(*(char*)haystack[j]) ? 0.7f : 0f); if (i == 0) { num5 = (float)j * -0.2f + num6; } else if (j > 0) { num5 = Math.Max(num2 + num6, num + 0.7f); } num = BEST_MATCH[j]; num2 = BEST[j]; BEST_MATCH[j] = num5; num3 = Math.Max(num5, num3 + num4); } else { num = BEST_MATCH[j]; num2 = BEST[j]; BEST_MATCH[j] = -1f / 0f; num3 += num4; } BEST[j] = num3; } } return BEST[haystack.Length - 1]; } } [HarmonyPatch(typeof(ComponentSelector))] public static class PatchComponentSelector { private static readonly ConditionalWeakTable Pickers = new ConditionalWeakTable(); [HarmonyPatch("OnOpenCategoryPressed")] [HarmonyPostfix] public static void OnOpenCategoryPressed_Postfix(SyncRef ____uiRoot) { ResetPicker(____uiRoot); } [HarmonyPatch("OpenGroupPressed")] [HarmonyPostfix] public static void OpenGroupPressed_Postfix(SyncRef ____uiRoot) { ResetPicker(____uiRoot); } private static void ResetPicker(SyncRef uiRoot) { object obj; if (uiRoot == null) { obj = null; } else { Slot target = uiRoot.Target; obj = ((target != null) ? target.GetComponentInParents((Predicate)null, true, false) : null); } ComponentSelector val = (ComponentSelector)obj; Picker picker = default(Picker); if (val != null && Pickers.TryGetValue(val, ref picker)) { TextEditor val2 = Enumerable.FirstOrDefault((global::System.Collections.Generic.IEnumerable)((Component)val).Slot.GetComponentsInChildren((Predicate)null, false, false, (Predicate)null)); if (val2 != null && !FocusManagerExtensions.HasLocalFocus((IFocusable)(object)val2)) { picker?.SwitchToNorm(); } } } [HarmonyPatch("SetupUI")] [HarmonyPrefix] public static bool SetupUI_Prefix(ComponentSelector __instance, SyncRef ____uiRoot, Sync ____rootPath, SyncType ____genericType) { //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01d7: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.Enabled.Value) { return true; } MethodInfo method = ((object)__instance).GetType().GetMethod("OnAddComponentPressed", (BindingFlags)36); ButtonEventHandler val = ((method != null) ? method.CreateDelegate(typeof(ButtonEventHandler), (object)__instance) : null) as ButtonEventHandler; MethodInfo method2 = ((object)__instance).GetType().GetMethod("OpenGenericTypesPressed", (BindingFlags)36); ButtonEventHandler val2 = ((method2 != null) ? method2.CreateDelegate(typeof(ButtonEventHandler), (object)__instance) : null) as ButtonEventHandler; if (val == null || val2 == null) { Plugin.Log.LogError((object)"Can't find methods for opening components/types!"); return true; } UIBuilder val3 = RadiantUI_Panel.SetupPanel(((Component)__instance).Slot, LocaleHelper.AsLocaleKey(Plugin.SelectorTitle.Value, (string)null, true, (Dictionary)null), Plugin.SelectorSize.Value, true, true); RadiantUI_Constants.SetupEditorStyle(val3, true); val3.Style.TextAlignment = (Alignment)3; val3.Style.ForceExpandHeight = false; val3.VerticalLayout(8f, 8f, (Alignment?)null, (bool?)null, (bool?)null); val3.HorizontalLayout(8f, 0f, (Alignment?)null); DestroyOnUserLeaveExtensions.DestroyWhenUserLeaves(val3.Root, ((Worker)__instance).LocalUser); val3.Root.PersistentSelf = false; val3.Style.MinHeight = Plugin.SearchSize.Value; val3.Style.FlexibleWidth = 1f; TextField val4 = val3.TextField((string)null, false, (string)null, false, LocaleString.op_Implicit("Search...")); ((SyncField)(object)val4.Editor.Target.FinishHandling).Value = (FinishAction)2; val3.Style.FlexibleWidth = -1f; val3.Style.MinWidth = 64f; LocaleString val5 = LocaleString.op_Implicit("∅"); ((ContainerWorker)(object)((Component)val3.Button(ref val5)).Slot).AttachComponent>(true, (Action>)null).TargetValue.Target = (IField)(object)val4.Text.Content; val3.Style.MinWidth = -1f; val3.Style.MinHeight = -1f; val3.NestOut(); val3.Style.FlexibleHeight = 1f; val3.OverlappingLayout(0f, (Alignment?)null); ScrollRect scrollRect = val3.ScrollArea((Alignment?)null); Slot root = val3.Root; val3.VerticalLayout(8f, 0f, (Alignment?)null, (bool?)null, (bool?)null); val3.FitContent((SizeFit)0, (SizeFit)1); root.ActiveSelf = false; val3.NestOut(); val3.ScrollArea((Alignment?)null); val3.VerticalLayout(8f, 0f, (Alignment?)null, (bool?)null, (bool?)null); val3.FitContent((SizeFit)0, (SizeFit)1); ____uiRoot.Target = val3.Root; __instance.BuildUI((string)null, false, (string)null, false); Picker picker = new Picker(SyncRef.op_Implicit(____uiRoot), root, val4, val, val2); ((SyncField)(object)____rootPath).OnValueChange += picker.RootPathValueChanged; ((SyncField)(object)val4.Text.CaretPosition).OnValueChange += picker.CaretPositionChanged; ((SyncField)(object)val4.Text.Content).OnValueChange += picker.SearchTermChanged; Action val6 = default(Action); ((SyncElement)val4.Text.Content).Changed += delegate { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Expected O, but got Unknown //IL_0029: Expected O, but got Unknown World world = ((Worker)__instance).World; Action obj = val6; if (obj == null) { Action val7 = delegate { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) ((SyncField)(object)scrollRect.NormalizedPosition).Value = default(float2); }; Action val8 = val7; val6 = val7; obj = val8; } world.RunSynchronously(obj, false, (IUpdatable)null, false); }; ((SyncField)(object)____genericType).OnValueChange += picker.GenericTypeChanged; Pickers.AddOrUpdate(__instance, picker); return false; } } public class Picker { private readonly Slot _normRoot; private readonly Slot _searchRoot; private Util.MatchType _matchType; private readonly UIBuilder _searchUi; private readonly TextField _searchField; private readonly FontCollection _fontCollection; private readonly ButtonEventHandler _onAddPressed; private readonly ButtonEventHandler _onGenericPressed; public Picker(Slot normRoot, Slot searchRoot, TextField searchField, ButtonEventHandler onAddPressed, ButtonEventHandler onGenericPressed) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Expected O, but got Unknown //IL_0054: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) _normRoot = normRoot; _searchRoot = searchRoot; _searchField = searchField; _onAddPressed = onAddPressed; _onGenericPressed = onGenericPressed; _searchUi = new UIBuilder(searchRoot, (Slot)null); RadiantUI_Constants.SetupEditorStyle(_searchUi, true); _searchUi.Style.TextAlignment = Plugin.TextAlignment.Value; _searchUi.Style.ButtonTextAlignment = Plugin.TextAlignment.Value; _searchUi.Style.MinHeight = (Plugin.UseCustomResultSize.Value ? Plugin.ResultSize.Value : (Plugin.ShowPath.Value ? 64f : 32f)); BooleanValueDriver obj = ((ContainerWorker)(object)searchRoot.Parent.Parent).AttachComponent>(true, (Action>)null); ValueCopyExtensions.DriveFrom((IField)(object)obj.State, (IField)(object)searchRoot.ActiveSelf_Field, false, false, true); ((SyncRef>)(object)obj.TargetField).Target = (IField)(object)normRoot.ActiveSelf_Field; ((SyncField)(object)obj.FalseValue).Value = true; _fontCollection = ((ContainerWorker)(object)searchRoot.Parent.Parent).AttachComponent(true, (Action)null); DynamicSpriteFont val = ((ContainerWorker)(object)searchRoot.Parent.Parent).AttachComponent(true, (Action)null); val.AddSprite("circle", Black_Border.Circle_10pc, 1.25f); _fontCollection.FontSets.Add((IAssetProvider)(object)((ContainerWorker)(object)((Worker)searchRoot).World.RootSlot).GetComponent((Predicate)null, false)); _fontCollection.FontSets.Add((IAssetProvider)(object)val); } public void SwitchToNorm() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown ((Worker)_searchRoot).World.RunSynchronously((Action)([CompilerGenerated] () => { _searchRoot.ActiveSelf = false; }), false, (IUpdatable)null, false); } public void SwitchToSearch() { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Expected O, but got Unknown ((Worker)_searchRoot).World.RunSynchronously((Action)([CompilerGenerated] () => { _searchRoot.ActiveSelf = true; }), false, (IUpdatable)null, false); } public void SearchTermChanged(SyncField stringField) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Expected O, but got Unknown ((Worker)_searchRoot).World.RunSynchronously((Action)delegate { //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_015e: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) //IL_034d: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_046c: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) _searchRoot.DestroyChildren(false, true, false, (Predicate)null); string value = stringField.Value; if (value == null) { SwitchToNorm(); return; } value = ((Plugin.SpaceGeneric.Value && Plugin.MatchAlgorithm.Value == MatchAlgo.Fzy) ? value.Replace(' ', '<') : value); value = string.Concat(Enumerable.Where((global::System.Collections.Generic.IEnumerable)value, (Func)((char c) => !char.IsWhiteSpace(c)))); value += new string('>', Math.Max(0, Enumerable.Aggregate((global::System.Collections.Generic.IEnumerable)value, 0, (Func)((int d, char c) => d + c switch { '<' => 1, '>' => -1, _ => 0, })))); string text = null; int num = value.IndexOf('<', (StringComparison)4); if (num != -1) { string text2 = value; int num2 = num; text = text2.Substring(num2, text2.Length - num2); value = value.Substring(0, num); if (text == "<>") { text = ""; } } float num3 = (Plugin.SingleClick.Value ? 0f : 0.35f); global::System.Collections.Generic.IEnumerator enumerator = Util.AlgorithmDelegate.Invoke(value, _matchType, Plugin.SearchLimit.Value).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { Util.TypeInfo current = enumerator.Current; bool isGenericTypeDefinition = current.Type.IsGenericTypeDefinition; colorX val = (isGenericTypeDefinition ? Sub.GREEN : Sub.CYAN); ButtonEventHandler val2 = (isGenericTypeDefinition ? _onGenericPressed : _onAddPressed); string text3 = (isGenericTypeDefinition ? ReflectionExtensions.GetNiceName(current.Type, "<", ">", "+") : ((MemberInfo)current.Type).Name); long orderOffset = 0L; string text4 = ((_matchType == Util.MatchType.ProtoFlux) ? current.Category.Replace("ProtoFlux/Runtimes/Execution/Nodes/", "") : current.Category); global::System.Type type = null; string text5; if (isGenericTypeDefinition) { if (current.Category == null || current.Type.AssemblyQualifiedName == null) { continue; } text5 = Path.Combine(current.Category, current.Type.AssemblyQualifiedName); if (text != null) { global::System.Type type2 = Util.ParseGenericReal(current.Type, text, ((Worker)_normRoot).World); if (type2 != (global::System.Type)null) { val = Sub.PURPLE; val2 = _onAddPressed; text5 = ((Worker)_normRoot).World.Types.EncodeType(type2); text3 = ((MemberInfo)current.Type).Name.Substring(0, ((MemberInfo)current.Type).Name.IndexOf('`')) + text; orderOffset = -1024L; type = type2.GetGenericArguments()[0]; } } } else { text5 = ((Worker)_normRoot).World.Types.EncodeType(current.Type); } string text6 = $"{text3}"; colorX val3; if (Plugin.ShowCircle.Value) { val3 = DatatypeColorHelper.GetTypeColor(type ?? current.Type); string text7 = ((colorX)(ref val3)).ToHexString(false, "#"); text6 = "" + text6; } if (Plugin.ShowPath.Value) { string text8 = (Plugin.PathNewLine.Value ? "
" : " "); val3 = ((colorX)(ref val)).SetValue(1f); string text9 = ((colorX)(ref val3)).ToHexString(false, "#"); text6 = $"{text6}{text8}[{text4}]"; } UIBuilder searchUi = _searchUi; LocaleString val4 = LocaleString.op_Implicit(text6); colorX? val5 = val; Button val6 = searchUi.Button(ref val4, ref val5, val2, text5, num3); ((Component)val6).Slot.OrderOffset = orderOffset; if (Plugin.ShowPath.Value) { Text val7 = (Text)((IWorldElement)val6.LabelTextField).Parent; ((SyncRef>)(object)val7.Font).Target = (IAssetProvider)(object)_fontCollection; ((SyncField)(object)val7.Size).Value = 24.44582f; } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } }, false, (IUpdatable)null, false); } public void CaretPositionChanged(SyncField intField) { if (intField.Value == -1 && string.IsNullOrWhiteSpace(Sync.op_Implicit(_searchField.Text.Content))) { SwitchToNorm(); } else if (!_searchRoot.ActiveSelf) { SwitchToSearch(); } } public void GenericTypeChanged(SyncField typeField) { if (typeField.Value != (global::System.Type)null) { SwitchToNorm(); } } public void RootPathValueChanged(SyncField stringField) { string value = stringField.Value; _matchType = ((value != null && value.StartsWith("ProtoFlux/Runtimes/")) ? Util.MatchType.ProtoFlux : Util.MatchType.Components); } } [ResonitePlugin("NepuShiro.ResoniteYAP", "YAP", "1.3.0", "yosh, NepuShiro", "https://github.com/NepuShiro/ResoniteYAP")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BasePlugin { [CompilerGenerated] private static class <>O { public static Func> <0>__FindMatchesCherryPick; public static Func> <1>__FindMatchesFzy; public static Action <2>__InitLibrary; } [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static EventHandler <>9__15_0; internal void b__15_0(object? _, EventArgs _) { Func> algorithmDelegate = ((MatchAlgorithm.Value != MatchAlgo.CherryPick) ? new Func>(Util.FindMatchesFzy) : new Func>(Util.FindMatchesCherryPick)); Util.AlgorithmDelegate = algorithmDelegate; } } internal static ManualLogSource Log; internal static ConfigEntry? Enabled; internal static ConfigEntry? SingleClick; internal static ConfigEntry? SearchLimit; internal static ConfigEntry? MatchAlgorithm; internal static ConfigEntry? SpaceGeneric; internal static ConfigEntry? SelectorTitle; internal static ConfigEntry? SelectorSize; internal static ConfigEntry? TextAlignment; internal static ConfigEntry? SearchSize; internal static ConfigEntry? UseCustomResultSize; internal static ConfigEntry? ResultSize; internal static ConfigEntry? ShowCircle; internal static ConfigEntry? ShowPath; internal static ConfigEntry? PathNewLine; public override void Load() { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Expected O, but got Unknown //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_0239: Unknown result type (might be due to invalid IL or missing references) //IL_023f: Expected O, but got Unknown Log = ((BasePlugin)this).Log; Enabled = ((BasePlugin)this).Config.Bind("General", "Enabled", true, "Enable the search in the component selector."); SingleClick = ((BasePlugin)this).Config.Bind("General", "Single Click", false, "Use single click instead of double click for search results."); SearchLimit = ((BasePlugin)this).Config.Bind("General", "Search Limit", 50, new ConfigDescription("Amount of search results to show (5-200)", (AcceptableValueBase)(object)new AcceptableValueRange(5, 200), global::System.Array.Empty())); MatchAlgorithm = ((BasePlugin)this).Config.Bind("General", "Algorithm", MatchAlgo.Fzy, "Algorithm to use for matching search terms."); SpaceGeneric = ((BasePlugin)this).Config.Bind("General", "Space Generic", false, "Use space for opening generics (Fzy only)"); SelectorTitle = ((BasePlugin)this).Config.Bind("General", "Selector Title", "ComponentSelector.Title", "Title of the component selector."); SelectorSize = ((BasePlugin)this).Config.Bind("Layout", "Selector Size", new float2(640f, 1200f), "Size of the component selector."); TextAlignment = ((BasePlugin)this).Config.Bind("Layout", "Text Alignment", (Alignment)3, "Text alignment for search results."); SearchSize = ((BasePlugin)this).Config.Bind("Layout", "Search Size", 64f, "Size of the search bar."); UseCustomResultSize = ((BasePlugin)this).Config.Bind("Layout", "Use Custom Result Size", false, "Use custom result size instead of the default."); ResultSize = ((BasePlugin)this).Config.Bind("Layout", "Custom Result Size", 64f, "Size of the search results."); ShowCircle = ((BasePlugin)this).Config.Bind("Display", "Show Circle", false, "Show a circle colored by the component type in the search results."); ShowPath = ((BasePlugin)this).Config.Bind("Display", "Show Path", false, "Show the path to the selected component."); PathNewLine = ((BasePlugin)this).Config.Bind("Display", "Path Newline", true, "Use a newline for the path."); ConfigEntry? matchAlgorithm = MatchAlgorithm; object obj = <>c.<>9__15_0; if (obj == null) { EventHandler val = delegate { Func> algorithmDelegate = ((MatchAlgorithm.Value != MatchAlgo.CherryPick) ? new Func>(Util.FindMatchesFzy) : new Func>(Util.FindMatchesCherryPick)); Util.AlgorithmDelegate = algorithmDelegate; }; <>c.<>9__15_0 = val; obj = (object)val; } matchAlgorithm.SettingChanged += (EventHandler)obj; object obj2 = <>O.<2>__InitLibrary; if (obj2 == null) { Action val2 = Util.InitLibrary; <>O.<2>__InitLibrary = val2; obj2 = (object)val2; } ResoniteHooks.OnEngineReady += (Action)obj2; ((BasePlugin)this).HarmonyInstance.PatchAll(); ManualLogSource log = Log; bool flag = default(bool); BepInExInfoLogInterpolatedStringHandler val3 = new BepInExInfoLogInterpolatedStringHandler(18, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Plugin "); ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted("NepuShiro.ResoniteYAP"); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral(" is loaded!"); } log.LogInfo(val3); } } public static class Util { public enum MatchType { Components, ProtoFlux } public record struct TypeInfo(global::System.Type Type, string NameLower, string Category) { [CompilerGenerated] public override readonly string ToString() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Expected O, but got Unknown StringBuilder val = new StringBuilder(); val.Append("TypeInfo"); val.Append(" { "); if (PrintMembers(val)) { val.Append(' '); } val.Append('}'); return ((object)val).ToString(); } [CompilerGenerated] private readonly bool PrintMembers(StringBuilder builder) { builder.Append("Type = "); builder.Append((object)Type); builder.Append(", NameLower = "); builder.Append((object)NameLower); builder.Append(", Category = "); builder.Append((object)Category); return true; } } internal static Func> AlgorithmDelegate = FindMatchesFzy; private static readonly Dictionary> Library = new Dictionary>(); public static void InitLibrary() { //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_015c: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) global::System.DateTime utcNow = global::System.DateTime.UtcNow; List val = new List(); global::System.Collections.Generic.IEnumerator enumerator = ((global::System.Collections.Generic.IEnumerable)GlobalTypeRegistry.CoreAssemblies).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator).MoveNext()) { global::System.Collections.Generic.IEnumerator enumerator2 = ((global::System.Collections.Generic.IEnumerable)enumerator.Current.Types).GetEnumerator(); try { while (((global::System.Collections.IEnumerator)enumerator2).MoveNext()) { global::System.Type current = enumerator2.Current; if (current.IsSubclassOf(typeof(Component)) && !current.IsAbstract) { CategoryAttribute customAttribute = CustomAttributeExtensions.GetCustomAttribute((MemberInfo)(object)current, true); string category = ((customAttribute != null) ? Enumerable.FirstOrDefault((global::System.Collections.Generic.IEnumerable)customAttribute.Paths) : null) ?? "Uncategorized"; val.Add(new TypeInfo { Type = current, NameLower = ((MemberInfo)current).Name.ToLowerInvariant(), Category = category }); } } } finally { ((global::System.IDisposable)enumerator2)?.Dispose(); } } } finally { ((global::System.IDisposable)enumerator)?.Dispose(); } ILookup val2 = Enumerable.ToLookup((global::System.Collections.Generic.IEnumerable)val, (Func)((TypeInfo x) => x.Type.IsSubclassOf(typeof(ProtoFluxNode)))); Library[MatchType.Components] = new HashSet(val2[false]); Library[MatchType.ProtoFlux] = new HashSet(val2[true]); ManualLogSource log = Plugin.Log; bool flag = default(bool); BepInExDebugLogInterpolatedStringHandler val3 = new BepInExDebugLogInterpolatedStringHandler(27, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("Time to enumerate types: "); TimeSpan val4 = global::System.DateTime.UtcNow - utcNow; ((BepInExLogInterpolatedStringHandler)val3).AppendFormatted(((TimeSpan)(ref val4)).TotalMilliseconds); ((BepInExLogInterpolatedStringHandler)val3).AppendLiteral("ms"); } log.LogDebug(val3); } public static global::System.Type? ParseGenericReal(global::System.Type type, string generic, World world) { string text = type.FullName.Substring(0, type.FullName.IndexOf('`')) + generic; global::System.Type type2 = world.Types.ParseNiceType(text, true); if (type2 == (global::System.Type)null || !type2.IsConstructedGenericType) { return null; } PropertyInfo property = type2.GetProperty("IsValidGenericType", (BindingFlags)88); if (property != (PropertyInfo)null && !(bool)property.GetValue((object)null)) { return null; } return type2; } public static float StringScoreCherry(string s, string[] q) { float num = 0f; for (int i = 0; i < q.Length; i++) { if (!s.Contains(q[i], (StringComparison)4)) { return 0f; } num += (float)q[i].Length / ((float)(s.Length + i) + 1f); } return num; } public static global::System.Collections.Generic.IEnumerable FindMatchesCherryPick(string query, MatchType matchType, int limit) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: 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) string[] q = query.Split(' ', (StringSplitOptions)3); List> val = new List>(); Enumerator enumerator = Library[matchType].GetEnumerator(); try { while (enumerator.MoveNext()) { TypeInfo current = enumerator.Current; float num = StringScoreCherry(((MemberInfo)current.Type).Name, q); if (num > 0f) { val.Add(new ValueTuple(current, num)); } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return Enumerable.Select, TypeInfo>(Enumerable.Take>((global::System.Collections.Generic.IEnumerable>)Enumerable.OrderByDescending, float>((global::System.Collections.Generic.IEnumerable>)val, (Func, float>)((ValueTuple s) => s.Item2)), limit), (Func, TypeInfo>)((ValueTuple s) => s.Item1)); } public static global::System.Collections.Generic.IEnumerable FindMatchesFzy(string query, MatchType matchType, int limit) { //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) //IL_007e: Unknown result type (might be due to invalid IL or missing references) string text = query.ToLowerInvariant(); List> val = new List>(); Enumerator enumerator = Library[matchType].GetEnumerator(); try { while (enumerator.MoveNext()) { TypeInfo current = enumerator.Current; if (FzyMatcher.HasMatch(MemoryExtensions.AsSpan(current.NameLower), MemoryExtensions.AsSpan(text))) { float num = FzyMatcher.Score(MemoryExtensions.AsSpan(((MemberInfo)current.Type).Name), MemoryExtensions.AsSpan(current.NameLower), MemoryExtensions.AsSpan(query), MemoryExtensions.AsSpan(text)); if (num > 0f) { val.Add(new ValueTuple(current, num)); } } } } finally { ((global::System.IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose(); } return Enumerable.Select, TypeInfo>(Enumerable.Take>((global::System.Collections.Generic.IEnumerable>)Enumerable.OrderByDescending, float>((global::System.Collections.Generic.IEnumerable>)val, (Func, float>)((ValueTuple s) => s.Item2)), limit), (Func, TypeInfo>)((ValueTuple s) => s.Item1)); } } public static class PluginMetadata { public const string GUID = "NepuShiro.ResoniteYAP"; public const string NAME = "YAP"; public const string VERSION = "1.3.0"; public const string AUTHORS = "yosh, NepuShiro"; public const string REPOSITORY_URL = "https://github.com/NepuShiro/ResoniteYAP"; }