Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of RecipeBrowser v1.0.2
plugins/RecipeBrowser.dll
Decompiled 2 days ago
The result has been truncated due to the large size, download it to view full contents!
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.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Managers; using Jotunn.Utils; using Microsoft.CodeAnalysis; using SoftReferenceableAssets; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("RecipeBrowser")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+8071511bfd02e023a0d054b957caeecd75515d8c")] [assembly: AssemblyProduct("RecipeBrowser")] [assembly: AssemblyTitle("RecipeBrowser")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [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] [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 RecipeBrowser { internal sealed class Bookmarks(string path) { private readonly List<string> keys = (File.Exists(path) ? (from l in File.ReadAllLines(path) where l.Length > 0 select l).ToList() : new List<string>()); public IReadOnlyList<string> Keys => keys; public bool Contains(string key) { return keys.Contains(key); } public void Add(string key) { if (!keys.Contains(key)) { keys.Add(key); File.WriteAllLines(path, keys); } } public void Remove(string key) { if (keys.Remove(key)) { File.WriteAllLines(path, keys); } } public void Move(string key, string target) { if (!(key == target) && keys.Contains(key)) { int num = ((target == null) ? (keys.Count - 1) : keys.IndexOf(target)); if (num >= 0) { keys.Remove(key); keys.Insert(Math.Min(num, keys.Count), key); File.WriteAllLines(path, keys); } } } } internal enum View { Recipes, Sources, Upgrades, Usages } internal enum SortMode { Progression, Name, Mod } internal sealed class Browser { private const float BarWidth = 250f; private const float BarHeight = 52f; private const float ResetWidth = 150f; private readonly RectTransform root; private readonly Tooltip tooltip; private readonly Catalog catalog; private readonly Bookmarks bookmarks; private readonly ItemPanel results; private readonly ItemPanel bookmarked; private readonly SearchBar searchBar; private readonly RecipeWindow window; private readonly GameObject resultsBar; private readonly GameObject bookmarksBar; private const float StockCheckInterval = 0.5f; private bool visible; private bool typing; private bool liveQuery; private int stockSignature; private float stockCheckedAt; public bool Alive => Object.op_Implicit((Object)(object)results.Root); public bool IsTyping => typing; public bool IsRecipeOpen => window.IsOpen; public Layout Layout { get; } public static Action<string> Log { get; set; } public Browser(Catalog catalog, Bookmarks bookmarks, RectTransform root, Layout layout) { //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0275: Unknown result type (might be due to invalid IL or missing references) Browser browser = this; this.root = root; tooltip = new Tooltip(FindTooltipPrefab(InventoryGui.instance), root); this.catalog = catalog; this.bookmarks = bookmarks; Layout = layout; Query.IsBookmarked = (Entry e) => bookmarks.Contains(e.Key); results = new ItemPanel(root, layout, inBookmarks: false, Open, delegate { browser.Toggle(UiConfig.ResultsCollapsed); }); searchBar = new SearchBar(results, catalog, Filter); results.LayoutHeader = searchBar.Layout; results.Frame.Saved = delegate(Rect r) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) UiConfig.Save(UiConfig.ResultsRect, r, root.rect); }; bookmarked = new ItemPanel(root, layout, inBookmarks: true, Open, delegate { browser.Toggle(UiConfig.BookmarksCollapsed); }, Reorder); Text title = Ui.Label(bookmarked.Header, "Bookmarks", 0f, 0f, 100f, 32f, 18, (TextAnchor)3, Ui.Orange); Button reset = Ui.Button(bookmarked.Header, "Reset layout", 0f, 0f, 150f, 32f, ResetLayout); ((Component)reset).GetComponentInChildren<Text>().fontSize = 13; Text hint = Ui.Label(bookmarked.Header, "A over an item adds / removes it · drag to reorder", 0f, 0f, 100f, 30f, 14, (TextAnchor)3, Ui.Muted); bookmarked.LayoutHeader = delegate(float inner) { Ui.Place(((Component)title).gameObject, browser.bookmarked.Header, 0f, 0f, Mathf.Max(40f, browser.bookmarked.HeaderWidth - 150f - 6f), 32f); Ui.Place(((Component)reset).gameObject, browser.bookmarked.Header, Mathf.Max(0f, browser.bookmarked.HeaderWidth - 150f), 0f, 150f, 32f); Ui.Place(((Component)hint).gameObject, browser.bookmarked.Header, 0f, 38f, inner, 30f); return 74f; }; bookmarked.Frame.Saved = delegate(Rect r) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) UiConfig.Save(UiConfig.BookmarksRect, r, root.rect); }; window = new RecipeWindow(root, catalog, layout.Window); resultsBar = CreateBar("Recipes", delegate { browser.Toggle(UiConfig.ResultsCollapsed); }); bookmarksBar = CreateBar("Bookmarks", delegate { browser.Toggle(UiConfig.BookmarksCollapsed); }); PlacePanels(); ApplyCollapsed(); Filter(); RenderBookmarks(); } private GameObject CreateBar(string title, Action expand) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) GameObject obj = GUIManager.Instance.CreateWoodpanel((Transform)(object)root, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 250f, 52f, false); Ui.Label(obj.transform, title, 12f, 10f, 100f, 32f, 18, (TextAnchor)3, Ui.Orange); Ui.Button(obj.transform, "Expand", 128f, 10f, 110f, 32f, expand); obj.SetActive(false); return obj; } private void PlacePanels() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0049: 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) Rect rect = root.rect; results.Frame.Place(UiConfig.Load(UiConfig.ResultsRect, rect, Layout.Results)); bookmarked.Frame.Place(UiConfig.Load(UiConfig.BookmarksRect, rect, Layout.Bookmarks)); PlaceBars(); } private void PlaceBars() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_0038: Expected O, but got Unknown //IL_0043: 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_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Expected O, but got Unknown RectTransform val = (RectTransform)resultsBar.transform; RectTransform obj = root; Rect rect = results.Frame.Rect; Ui.PlaceLocal(val, obj, ((Rect)(ref rect)).min, Vector2.zero); RectTransform val2 = (RectTransform)bookmarksBar.transform; RectTransform obj2 = root; rect = bookmarked.Frame.Rect; Ui.PlaceLocal(val2, obj2, ((Rect)(ref rect)).min, Vector2.zero); } public void ResetLayout() { //IL_0017: Unknown result type (might be due to invalid IL or missing references) UiConfig.ClearLayout(); PlacePanels(); window.Reset(Layout.Window); } private static GameObject FindTooltipPrefab(InventoryGui gui) { UITooltip val = ((Component)gui.m_playerGrid).GetComponentsInChildren<UITooltip>(true).Concat(gui.m_playerGrid.m_elementPrefab.GetComponentsInChildren<UITooltip>(true)).Concat(((Component)gui).GetComponentsInChildren<UITooltip>(true)) .FirstOrDefault((Func<UITooltip, bool>)((UITooltip t) => Object.op_Implicit((Object)(object)t.m_tooltipPrefab))); Log?.Invoke(Object.op_Implicit((Object)(object)val) ? ("Tooltip from " + ((Object)val).name + " (" + ((Object)val.m_tooltipPrefab).name + ")") : "Tooltip prefab not found"); if (!Object.op_Implicit((Object)(object)val)) { return null; } return val.m_tooltipPrefab; } public void SetVisible(bool value) { if (visible != value) { visible = value; if (!visible) { searchBar.Defocus(); SetTyping(value: false); tooltip.Hide(); window.Root.SetActive(false); } ApplyCollapsed(); } } private void ApplyCollapsed() { bool value = UiConfig.ResultsCollapsed.Value; bool value2 = UiConfig.BookmarksCollapsed.Value; results.Root.SetActive(visible && !value); bookmarked.Root.SetActive(visible && !value2); resultsBar.SetActive(visible && value); bookmarksBar.SetActive(visible && value2); } public void ToggleCollapsed() { bool flag = !UiConfig.ResultsCollapsed.Value || !UiConfig.BookmarksCollapsed.Value; ConfigEntry<bool> resultsCollapsed = UiConfig.ResultsCollapsed; bool value = (UiConfig.BookmarksCollapsed.Value = flag); resultsCollapsed.Value = value; Collapsed(); } private void Toggle(ConfigEntry<bool> entry) { entry.Value = !entry.Value; Collapsed(); } private void Collapsed() { if (UiConfig.ResultsCollapsed.Value) { searchBar.Defocus(); SetTyping(value: false); } PlaceBars(); ApplyCollapsed(); } public void Destroy() { SetTyping(value: false); tooltip.Hide(); Object.Destroy((Object)(object)results.Root); Object.Destroy((Object)(object)bookmarked.Root); Object.Destroy((Object)(object)window.Root); Object.Destroy((Object)(object)resultsBar); Object.Destroy((Object)(object)bookmarksBar); } public void Tick() { searchBar.Tick(); SetTyping(!UiConfig.ResultsCollapsed.Value && searchBar.IsActive); tooltip.Update(Object.op_Implicit((Object)(object)Slot.Hovered) ? Slot.Hovered.Entry : null); if (Time.time - stockCheckedAt < 0.5f) { return; } stockCheckedAt = Time.time; int num = Stock.Signature(); if (num != stockSignature) { stockSignature = num; window.Refresh(); if (liveQuery) { Filter(resetPage: false); } } } private void SetTyping(bool value) { if (typing != value) { typing = value; GUIManager.BlockInput(value); } } public void Open(Entry entry, View view) { window.Open(entry, view); } public void Back() { window.Back(); } public void Close() { window.Close(); } public void ToggleBookmark(Entry entry, bool remove) { if (remove) { bookmarks.Remove(entry.Key); } else { bookmarks.Add(entry.Key); } RenderBookmarks(); if (liveQuery) { Filter(resetPage: false); } } private void Reorder(Entry entry, Entry target) { bookmarks.Move(entry.Key, target?.Key); RenderBookmarks(); } private void Filter() { Filter(resetPage: true); } private void Filter(bool resetPage) { Query query = Query.Parse(searchBar.Text, catalog); liveQuery = query.IsLive; results.Section = ((UiConfig.BiomeSeparators.Value && searchBar.Sort == SortMode.Progression) ? ((Func<Entry, string>)((Entry e) => Progression.Name(e.Biome))) : null); results.Show(catalog.Sorted(searchBar.Sort).Where(query.Matches).ToList(), resetPage); } private void RenderBookmarks() { bookmarked.Show((from e in bookmarks.Keys.Select(catalog.Find) where e != null select e).ToList(), resetPage: false); } } internal sealed class Entry { private string tooltip; public string Tooltip => tooltip ?? (tooltip = <details>P() + "\n\n<color=#bbbbbb>" + Kind + " · " + Key + " · " + Mod + " · " + Progression.Name(Biome) + "</color>"); public string Key { get; } public string Name { get; } public Sprite Icon { get; } public string Mod { get; } public string ItemName { get; } public string Kind { get { if (ItemName != null) { return "item"; } return "piece"; } } public HashSet<string> Tags { get; } public int? Biome { get; set; } public string Subcategory { get; set; } public int StationLevel { get; set; } public string MainTag { get; set; } public (float Health, float Stamina, float Eitr)? Food { get; set; } public string CompactName { get; } public string CompactMod { get; } internal ItemDrop Drop { get; set; } internal Piece Piece { get; set; } internal bool IsFeast { get; set; } public Entry(string key, string name, Sprite icon, string mod, string itemName, Func<string> details) { <details>P = details; Key = key; Name = name; Icon = icon; Mod = mod; ItemName = itemName; Tags = new HashSet<string>(); MainTag = "misc"; CompactName = (name ?? "").Replace(" ", ""); CompactMod = (mod ?? "").Replace(" ", ""); base..ctor(); } } internal readonly struct ItemStack { public Entry Entry { get; } public int Amount { get; } public ItemStack(Entry entry, int amount) { Entry = entry; Amount = amount; } } internal enum CardKind { Craft, Build, Conversion, Grow, Production, Source } internal sealed class RecipeCard(string title, string group, bool isUpgrade, Entry station, int stationLevel, List<ItemStack> inputs, List<ItemStack> outputs, List<string> notes) { public string Title { get; } = title; public string Group { get; } = group; public bool IsUpgrade { get; } = isUpgrade; public Entry Station { get; } = station; public int StationLevel { get; } = stationLevel; public List<ItemStack> Inputs { get; } = inputs; public List<ItemStack> Outputs { get; } = outputs; public List<string> Notes { get; } = notes; public Recipe Recipe { get; set; } public int Quality { get; set; } = 1; public int? Biome { get; set; } public CardKind Kind { get; set; } public bool OnlyOneIngredient { get; set; } internal int? Seed { get; set; } internal bool Weak { get; set; } internal int ToolTier { get; set; } internal Func<DamageTypes, float> ToolDamage { get; set; } } internal sealed class Catalog { private const string Vanilla = "Valheim"; private readonly Dictionary<string, Entry> entries = new Dictionary<string, Entry>(); private readonly Dictionary<string, List<RecipeCard>> producing = new Dictionary<string, List<RecipeCard>>(); private readonly Dictionary<string, List<RecipeCard>> using_ = new Dictionary<string, List<RecipeCard>>(); private readonly Dictionary<string, List<RecipeCard>> upgrades = new Dictionary<string, List<RecipeCard>>(); private readonly Dictionary<string, List<RecipeCard>> sources = new Dictionary<string, List<RecipeCard>>(); private readonly List<RecipeCard> cards = new List<RecipeCard>(); private readonly Dictionary<Entry, string> stationNames = new Dictionary<Entry, string>(); private readonly Dictionary<SortMode, IReadOnlyList<Entry>> sorted = new Dictionary<SortMode, IReadOnlyList<Entry>>(); private readonly Dictionary<string, string> tagDescriptions = new Dictionary<string, string>(); private readonly Dictionary<string, string> mods; private readonly Filter filter = new Filter(); private readonly HashSet<string> seeds = new HashSet<string>(); private readonly HashSet<string> buildable = new HashSet<string>(); private static readonly List<RecipeCard> Empty = new List<RecipeCard>(); public IReadOnlyList<Entry> All { get; } public int SourceRecipeCount { get; } public int SourceItemCount { get; } public int ConfigVersion { get; } public long BuildMilliseconds { get; } public int SpawnSignature { get; } public int LocationVersion { get; } public IReadOnlyDictionary<string, int> TagCounts { get; } public IReadOnlyDictionary<string, int> ModCounts { get; } public bool IsStale(ObjectDB db) { if (Object.op_Implicit((Object)(object)db) && db.m_recipes.Count == SourceRecipeCount && db.m_items.Count == SourceItemCount && DataConfig.Version == ConfigVersion && Sources.SpawnSignature() == SpawnSignature) { return Locations.Version != LocationVersion; } return true; } public Catalog(ObjectDB db, ZNetScene scene) { //IL_0389: Unknown result type (might be due to invalid IL or missing references) //IL_0390: Invalid comparison between Unknown and I4 Stopwatch stopwatch = Stopwatch.StartNew(); SourceRecipeCount = db.m_recipes.Count; SourceItemCount = db.m_items.Count; ConfigVersion = DataConfig.Version; SpawnSignature = Sources.SpawnSignature(fresh: true); LocationVersion = Locations.Version; mods = ModsByPrefab(); foreach (GameObject item3 in db.m_items.Where((GameObject p) => Object.op_Implicit((Object)(object)p))) { ItemDrop drop = item3.GetComponent<ItemDrop>(); SharedData val = (Object.op_Implicit((Object)(object)drop) ? drop.m_itemData.m_shared : null); if (val == null || val.m_icons == null || val.m_icons.Length == 0) { continue; } string text = ModOf(((Object)item3).name); string text2 = filter.RejectItem(((Object)item3).name, val, text == "Valheim"); if (text2 != null) { filter.Hide(((Object)item3).name, val.m_name, text2); continue; } Add(((Object)item3).name, Filter.DisplayName(val.m_name, ((Object)item3).name), val.m_icons[0], () => drop.m_itemData.GetTooltip(-1), val.m_name).Drop = drop; } List<(string, string)> list = new List<(string, string)>(); foreach (ItemDrop item4 in from p in db.m_items where Object.op_Implicit((Object)(object)p) select p.GetComponent<ItemDrop>() into d where Object.op_Implicit((Object)(object)d) && Object.op_Implicit((Object)(object)d.m_itemData.m_shared.m_buildPieces) select d) { List<Piece> list2 = (from p in item4.m_itemData.m_shared.m_buildPieces.m_pieces where Object.op_Implicit((Object)(object)p) select p.GetComponent<Piece>() into p where Object.op_Implicit((Object)(object)p) && p.m_enabled select p).ToList(); Entry entry = Find(((Object)item4).name); if (entry != null && (list2.Any((Piece p) => Object.op_Implicit((Object)(object)((Component)p).GetComponent<Feast>())) || (int)item4.m_itemData.m_shared.m_animationState == 16)) { entry.IsFeast = true; } foreach (Piece item5 in list2) { buildable.Add(((Object)item5).name); StationExtension component = ((Component)item5).GetComponent<StationExtension>(); if (component != null && Object.op_Implicit((Object)(object)component.m_craftingStation)) { list.Add((((Object)item5).name, ((Object)component.m_craftingStation).name)); } string text3 = filter.RejectPiece(item5, ModOf(((Object)item5).name) == "Valheim"); if (text3 != null) { filter.Hide(((Object)item5).name, item5.m_name, text3); } else { AddPieceRecipe(item5, item4); } } } foreach (Recipe item6 in db.m_recipes.Where((Recipe r) => Object.op_Implicit((Object)(object)r) && r.m_enabled && Object.op_Implicit((Object)(object)r.m_item))) { AddCraftingRecipes(item6); } int num = 0; foreach (GameObject item7 in scene.m_prefabs.Where((GameObject p) => Object.op_Implicit((Object)(object)p))) { if (!AddConversions(item7)) { num++; } } Sources sources = new Sources(scene, Find, cards.Add); sources.Collect(); RemoveUnobtainable(); foreach (RecipeCard card in cards) { Register(card); } AssignTags(); Dictionary<Entry, List<Entry>> dictionary = new Dictionary<Entry, List<Entry>>(); foreach (var item8 in list) { string item = item8.Item1; string item2 = item8.Item2; Entry entry2 = Find(item); if (entry2 == null) { continue; } Entry entry3 = Find(item2); if (entry3 != null) { List<Entry> list5; if (!dictionary.TryGetValue(entry3, out var value)) { List<Entry> list3 = (dictionary[entry3] = new List<Entry>()); list5 = list3; } else { list5 = value; } list5.Add(entry2); } } Progression.Assign(entries.Values, cards, dictionary, Progression.Overrides()); foreach (Entry value3 in entries.Values) { value3.Tags.Add(Progression.Tag(value3.Biome)); } foreach (string item9 in this.sources.Keys.ToList()) { this.sources[item9] = this.sources[item9].OrderBy((RecipeCard c) => c.Biome ?? int.MaxValue).ToList(); } All = (from e in entries.Values orderby e.Mod != "Valheim", e.Mod, e.Name select e).ToList(); Dictionary<string, int> dictionary2 = new Dictionary<string, int>(); foreach (string item10 in All.SelectMany((Entry e) => e.Tags)) { dictionary2[item10] = ((!dictionary2.TryGetValue(item10, out var value2)) ? 1 : (value2 + 1)); } TagCounts = dictionary2; ModCounts = (from e in All group e by e.Mod).ToDictionary((IGrouping<string, Entry> g) => g.Key, (IGrouping<string, Entry> g) => g.Count()); BuildMilliseconds = stopwatch.ElapsedMilliseconds; DataConfig.Log.LogInfo((object)($"Catalog: {All.Count} entries, {cards.Count} cards, {BuildMilliseconds} ms. Vegetation {sources.VegetationCount}, creatures with biome {sources.CreatureCount}, " + $"unknown biome for {All.Count((Entry e) => !e.Biome.HasValue)}. Skipped {num} processing prefabs not in any piece table. " + (Locations.Done ? $"Locations: {Locations.Places.Count} prefabs." : "Locations are still loading (chests only by name for now)."))); DataConfig.Log.LogInfo((object)("Hidden: " + filter.Summary())); if (!Locations.Done) { return; } foreach (Entry item11 in All.Where((Entry e) => !e.Biome.HasValue)) { DataConfig.Log.LogInfo((object)("Unknown biome: " + item11.Key + " (" + item11.Name + ", " + item11.Mod + ") · " + Diagnose(item11))); } } private string Diagnose(Entry entry) { List<string> list = new List<string>(); foreach (RecipeCard item in Cards(entry, View.Sources)) { list.Add("source '" + item.Title + "' seed=" + (item.Seed?.ToString() ?? "-") + (item.Weak ? " weak" : "")); } foreach (RecipeCard item2 in Cards(entry, View.Recipes)) { List<string> list2 = (from i in item2.Inputs.Select((ItemStack i) => i.Entry).Append(item2.Station) where i != null && !i.Biome.HasValue select i.Key).Distinct().ToList(); list.Add($"{item2.Kind} '{item2.Title}'" + ((list2.Count > 0) ? (" needs " + string.Join("+", list2)) : ((item2.Inputs.Count == 0) ? " no inputs" : ""))); } if (list.Count != 0) { return string.Join("; ", list); } return "no cards"; } public IReadOnlyList<Entry> Sorted(SortMode mode) { if (sorted.TryGetValue(mode, out var value)) { return value; } Dictionary<SortMode, IReadOnlyList<Entry>> dictionary = sorted; return dictionary[mode] = mode switch { SortMode.Name => (from e in All orderby e.Name, e.Key select e).ToList(), SortMode.Mod => All, _ => (from e in All orderby e.Biome ?? int.MaxValue, Tags.CategoryIndex(e.MainTag), Tags.SubcategoryIndex(e.Subcategory), e.Subcategory, e.StationLevel, e.Name select e).ToList(), }; } public string TagDescription(string tag) { if (!tagDescriptions.TryGetValue(tag, out var value)) { return Tags.Describe(tag); } return value; } public string StationName(Entry station) { if (station == null || !stationNames.TryGetValue(station, out var value)) { return null; } return value; } public Entry Find(string key) { if (key == null || !entries.TryGetValue(key, out var value)) { return null; } return value; } public IReadOnlyList<RecipeCard> Cards(Entry entry, View view) { if (!(view switch { View.Recipes => producing, View.Upgrades => upgrades, View.Sources => sources, _ => using_, }).TryGetValue(entry.Key, out var value)) { return Empty; } return value; } private static Dictionary<string, string> ModsByPrefab() { Dictionary<string, string> dictionary = Chainloader.PluginInfos.Values.ToDictionary((PluginInfo p) => p.Metadata.GUID, (PluginInfo p) => Path.GetFileName(Path.GetDirectoryName(p.Location))); Dictionary<string, string> dictionary2 = new Dictionary<string, string>(); foreach (IModPrefab prefab in ModQuery.GetPrefabs()) { if (Object.op_Implicit((Object)(object)prefab.Prefab) && prefab.SourceMod != null) { string value; string text = ((dictionary.TryGetValue(prefab.SourceMod.GUID, out value) && value != "plugins") ? value : null); dictionary2[((Object)prefab.Prefab).name] = text ?? prefab.SourceMod.Name; } } return dictionary2; } private string ModOf(string prefab) { if (!mods.TryGetValue(prefab, out var value)) { return "Valheim"; } return value; } private Entry Add(string key, string name, Sprite icon, Func<string> details, string itemName = null) { if (entries.TryGetValue(key, out var value)) { return value; } return entries[key] = new Entry(key, name, icon, ModOf(key), itemName, details); } private Entry PieceEntry(Piece piece) { if (!Object.op_Implicit((Object)(object)piece)) { return null; } Entry entry = Add(((Object)piece).name, Filter.DisplayName(piece.m_name, ((Object)piece).name), piece.m_icon, () => Localization.instance.Localize(piece.m_description)); entry.Piece = piece; CraftingStation component = ((Component)piece).GetComponent<CraftingStation>(); if (component != null && Object.op_Implicit((Object)(object)component)) { stationNames[entry] = component.m_name; } return entry; } private Entry StationEntry(CraftingStation station) { if (!Object.op_Implicit((Object)(object)station)) { return null; } Entry entry = Find(((Object)station).name) ?? Add(((Object)station).name, Filter.DisplayName(station.m_name, ((Object)station).name), station.m_icon, () => ""); Entry entry2 = entry; if (entry2.Piece == null) { Piece val = (entry2.Piece = ((Component)station).GetComponent<Piece>()); } stationNames[entry] = station.m_name; return entry; } private void AddPieceRecipe(Piece piece, ItemDrop tool) { //IL_02e0: Unknown result type (might be due to invalid IL or missing references) //IL_02e5: Unknown result type (might be due to invalid IL or missing references) Entry entry = PieceEntry(piece); List<ItemStack> list = (from r in piece.m_resources where Object.op_Implicit((Object)(object)r.m_resItem) && r.m_amount > 0 select new ItemStack(Find(((Object)r.m_resItem).name), r.m_amount) into s where s.Entry != null select s).ToList(); if (list.Count == 0 && !Object.op_Implicit((Object)(object)((Component)piece).GetComponent<Plant>())) { return; } string text = Localization.instance.Localize(tool.m_itemData.m_shared.m_name); cards.Add(new RecipeCard("Build", "Build · " + text, isUpgrade: false, StationEntry(piece.m_craftingStation), 0, list, new List<ItemStack> { new ItemStack(entry, 1) }, new List<string> { "Tool: " + text }) { Kind = CardKind.Build }); Plant component = ((Component)piece).GetComponent<Plant>(); if (component == null || !Object.op_Implicit((Object)(object)component)) { return; } seeds.Add(((Object)piece).name); foreach (ItemStack item in list) { seeds.Add(item.Entry.Key); } List<ItemStack> list2 = new List<ItemStack>(); List<string> notes = new List<string> { "Plant: " + entry.Name, $"Grows in {component.m_growTime / 60f:0}–{component.m_growTimeMax / 60f:0} min" }; foreach (Pickable item2 in from g in component.m_grownPrefabs where Object.op_Implicit((Object)(object)g) select g.GetComponent<Pickable>() into p where Object.op_Implicit((Object)(object)p) select p) { if (Object.op_Implicit((Object)(object)item2.m_itemPrefab)) { Entry crop = Find(((Object)item2.m_itemPrefab).name); if (crop != null && list2.All((ItemStack c) => c.Entry != crop)) { list2.Add(new ItemStack(crop, Mathf.Max(1, item2.m_amount))); } } foreach (DropData extra in item2.m_extraDrops.m_drops.Where((DropData d) => Object.op_Implicit((Object)(object)d.m_item) && Find(((Object)d.m_item).name) != null)) { if (list2.All((ItemStack c) => c.Entry.Key != ((Object)extra.m_item).name)) { list2.Add(new ItemStack(Find(((Object)extra.m_item).name), Mathf.Max(1, extra.m_stackMax))); } } } if (list2.Count > 0 && list.Count > 0) { cards.Add(new RecipeCard("Growing", "Growing", isUpgrade: false, null, 0, list, list2, notes) { Kind = CardKind.Grow }); } } private void AddCraftingRecipes(Recipe recipe) { Entry entry = Find(((Object)recipe.m_item).name); if (entry == null) { return; } int num = Mathf.Max(1, recipe.m_item.m_itemData.m_shared.m_maxQuality); int quality; for (quality = ((!recipe.m_noCraftOnlyUpgrade) ? 1 : 2); quality <= num; quality++) { List<ItemStack> list = new List<ItemStack>(); if (quality > 1) { list.Add(new ItemStack(entry, 1)); } list.AddRange(from r in recipe.m_resources where Object.op_Implicit((Object)(object)r.m_resItem) && r.GetAmount(quality) > 0 select new ItemStack(Find(((Object)r.m_resItem).name), r.GetAmount(quality)) into s where s.Entry != null select s); List<string> list2 = new List<string>(); if (quality > 1) { list2.Add($"Input item must be level {quality - 1}"); } if (recipe.m_requireOnlyOneIngredient) { list2.Add("Any one ingredient"); } CraftingStation requiredStation = recipe.GetRequiredStation(quality); string title = ((quality == 1) ? "Crafting" : $"Upgrade to level {quality}"); Entry entry2 = StationEntry(requiredStation); cards.Add(new RecipeCard(title, entry2?.Name ?? "Hand crafting", quality > 1, entry2, Object.op_Implicit((Object)(object)requiredStation) ? recipe.GetRequiredStationLevel(quality) : 0, list, new List<ItemStack> { new ItemStack(entry, (quality != 1) ? 1 : recipe.m_amount) }, list2) { Kind = CardKind.Craft, Recipe = recipe, Quality = quality, OnlyOneIngredient = recipe.m_requireOnlyOneIngredient }); } } private bool AddConversions(GameObject prefab) { Smelter component = prefab.GetComponent<Smelter>(); Fermenter component2 = prefab.GetComponent<Fermenter>(); CookingStation component3 = prefab.GetComponent<CookingStation>(); if (!Object.op_Implicit((Object)(object)component) && !Object.op_Implicit((Object)(object)component2) && !Object.op_Implicit((Object)(object)component3)) { return true; } Entry entry = Find(((Object)prefab).name); if (entry == null) { ConfigEntry<bool> logFilter = DataConfig.LogFilter; if (logFilter != null && logFilter.Value) { DataConfig.Log.LogInfo((object)("Processing " + ((Object)prefab).name + " skipped: not in any piece table")); } return false; } if (Object.op_Implicit((Object)(object)component)) { string fuel = (Object.op_Implicit((Object)(object)component.m_fuelItem) ? $"Fuel: {component.m_fuelPerProduct}× {Find(((Object)component.m_fuelItem).name)?.Name}" : null); foreach (ItemConversion item in component.m_conversion) { AddConversion(entry, item.m_from, 1, item.m_to, 1, fuel, $"{component.m_secPerProduct:0} s each"); } } if (Object.op_Implicit((Object)(object)component2)) { foreach (ItemConversion item2 in component2.m_conversion) { AddConversion(entry, item2.m_from, 1, item2.m_to, item2.m_producedItems, null, $"{component2.m_fermentationDuration / 60f:0} min"); } } if (Object.op_Implicit((Object)(object)component3)) { string fuel2 = ((component3.m_useFuel && Object.op_Implicit((Object)(object)component3.m_fuelItem)) ? ("Fuel: " + Find(((Object)component3.m_fuelItem).name)?.Name) : null); foreach (ItemConversion item3 in component3.m_conversion) { AddConversion(entry, item3.m_from, 1, item3.m_to, 1, fuel2, $"{item3.m_cookTime:0} s"); } } return true; } private void AddConversion(Entry station, ItemDrop from, int fromAmount, ItemDrop to, int toAmount, string fuel, string time) { Entry entry = (Object.op_Implicit((Object)(object)from) ? Find(((Object)from).name) : null); Entry entry2 = (Object.op_Implicit((Object)(object)to) ? Find(((Object)to).name) : null); if (entry != null && entry2 != null) { List<string> list = new List<string> { time }; if (fuel != null) { list.Add(fuel); } cards.Add(new RecipeCard("Processing", station.Name, isUpgrade: false, station, 0, new List<ItemStack> { new ItemStack(entry, fromAmount) }, new List<ItemStack> { new ItemStack(entry2, toAmount) }, list) { Kind = CardKind.Conversion }); } } private void RemoveUnobtainable() { HashSet<Entry> removed = new HashSet<Entry>(); foreach (Entry item in stationNames.Keys.Where((Entry s) => !buildable.Contains(s.Key))) { removed.Add(item); filter.Hide(item.Key, item.Name, "station not in any piece table"); } cards.RemoveAll((RecipeCard c) => removed.Contains(c.Station)); HashSet<Entry> produced = new HashSet<Entry>(from o in cards.Where((RecipeCard c) => !c.IsUpgrade).SelectMany((RecipeCard c) => c.Outputs) select o.Entry); HashSet<Entry> consumed = new HashSet<Entry>(from e in cards.SelectMany((RecipeCard c) => c.Inputs.Select((ItemStack i) => i.Entry).Append(c.Station)) where e != null select e); HashSet<Entry> used = new HashSet<Entry>(consumed.Concat(cards.SelectMany((RecipeCard c) => c.Outputs.Select((ItemStack o) => o.Entry)))); Dictionary<string, int> overrides = Progression.Overrides(); foreach (IGrouping<string, Entry> item2 in from e in entries.Values where Object.op_Implicit((Object)(object)e.Drop) && !removed.Contains(e) group e by e.Drop.m_itemData.m_shared.m_name into g where g.Count() > 1 select g) { List<Entry> list = item2.Where((Entry e) => produced.Contains(e) || consumed.Contains(e)).ToList(); if (list.Count == 0) { list = item2.Where(used.Contains).ToList(); } if (list.Count == 0) { continue; } foreach (Entry item3 in item2.Except(list)) { removed.Add(item3); filter.Hide(item3.Key, item3.Name, "duplicate"); } } ConfigEntry<bool> hideUnobtainable = DataConfig.HideUnobtainable; if (hideUnobtainable == null || hideUnobtainable.Value) { foreach (Entry item4 in entries.Values.Where((Entry e) => !removed.Contains(e) && !used.Contains(e) && !overrides.ContainsKey(e.Key) && (!Object.op_Implicit((Object)(object)e.Drop) || !Object.op_Implicit((Object)(object)e.Drop.m_itemData.m_shared.m_buildPieces)))) { removed.Add(item4); filter.Hide(item4.Key, item4.Name, "no source or use"); } } if (removed.Count == 0) { return; } foreach (Entry item5 in removed) { entries.Remove(item5.Key); } foreach (RecipeCard item6 in cards.Where((RecipeCard c) => c.Kind == CardKind.Source)) { item6.Outputs.RemoveAll((ItemStack o) => removed.Contains(o.Entry)); } cards.RemoveAll((RecipeCard c) => c.Outputs.Count == 0 || c.Outputs.Any((ItemStack o) => removed.Contains(o.Entry)) || c.Inputs.Any((ItemStack i) => removed.Contains(i.Entry)) || removed.Contains(c.Station)); } private void AssignTags() { foreach (Entry value in entries.Values) { if (Object.op_Implicit((Object)(object)value.Drop)) { Tags.OfItem(value, value.Drop.m_itemData.m_shared, value.IsFeast); } else { Tags.OfPiece(value, value.Piece, seeds.Contains(value.Key)); } if (Object.op_Implicit((Object)(object)value.Drop) && seeds.Contains(value.Key)) { value.Tags.Add("seeds"); } List<RecipeCard> list = Cards(value, View.Recipes).Where(delegate(RecipeCard c) { CardKind kind = c.Kind; return (uint)kind <= 1u; }).ToList(); value.StationLevel = ((list.Count != 0) ? list.Min((RecipeCard c) => (c.Station != null) ? Mathf.Max(1, c.StationLevel) : 0) : 0); foreach (Entry item in (from c in Cards(value, View.Recipes) select c.Station into s where s != null select s).Distinct()) { string text = Tags.StationTag(item); value.Tags.Add(text); tagDescriptions[text] = "Crafted at: " + item.Name; } foreach (string item2 in value.Tags.Where((string t) => t.StartsWith("set:"))) { if (!tagDescriptions.ContainsKey(item2)) { tagDescriptions[item2] = "Armor set: " + value.Name; } } } } private void Register(RecipeCard card) { IEnumerable<Entry> enumerable = from e in card.Inputs.Select((ItemStack s) => s.Entry).Append(card.Station) where e != null select e; if (card.IsUpgrade) { foreach (Entry item in enumerable.Concat(card.Outputs.Select((ItemStack s) => s.Entry)).Distinct()) { ListFor(upgrades, item).Add(card); } return; } foreach (Entry item2 in card.Outputs.Select((ItemStack o) => o.Entry).Distinct()) { ListFor((card.Kind == CardKind.Source) ? sources : producing, item2).Add(card); } foreach (Entry item3 in enumerable.Distinct()) { ListFor(using_, item3).Add(card); } } private static List<RecipeCard> ListFor(Dictionary<string, List<RecipeCard>> map, Entry entry) { if (!map.TryGetValue(entry.Key, out var value)) { return map[entry.Key] = new List<RecipeCard>(); } return value; } } internal enum ContainerMode { Auto, Always, Never } internal static class DataConfig { public static ManualLogSource Log { get; } = Logger.CreateLogSource("RecipeBrowser.Data"); public static ConfigEntry<bool> HideUnobtainable { get; private set; } public static ConfigEntry<string> IgnoreList { get; private set; } public static ConfigEntry<bool> LogFilter { get; private set; } public static ConfigEntry<string> BiomeOverrides { get; private set; } public static ConfigEntry<ContainerMode> Containers { get; private set; } public static ConfigEntry<float> ContainerRange { get; private set; } public static ConfigEntry<bool> ScanLocations { get; private set; } public static int Version { get; private set; } public static void Bind(ConfigFile config) { //IL_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Expected O, but got Unknown HideUnobtainable = Rebuilds<bool>(config.Bind<bool>("Catalog", "Hide unobtainable", true, "Hides items with no source and no use (no recipe, processing, drop, pickup, trader or ingredient use).")); IgnoreList = Rebuilds<string>(config.Bind<string>("Catalog", "Ignore list", "", "Prefabs that are never shown. Comma separated: exact name, '*suffix' or 'prefix*' (e.g. 'SwordCheat, *_nochest, NPC_*').")); LogFilter = config.Bind<bool>("Catalog", "Log filter", false, "Logs every hidden entry and the reason (debugging)."); BiomeOverrides = Rebuilds<string>(config.Bind<string>("Biomes", "Biome overrides", "", "Manual biome for entries, takes precedence over the computed one. Format 'Prefab=biome', comma separated, biome as a tag (meadows, blackforest, swamp, ocean, mountains, plains, mistlands, ashlands, deepnorth).")); ScanLocations = config.Bind<bool>("Biomes", "Scan locations", true, "After entering a world, gradually loads location and dungeon prefabs (chests, altars, creatures) for more accurate biomes and Sources. Turn off if it makes the game stutter after entering a world."); Containers = config.Bind<ContainerMode>("Counts", "Nearby chests", ContainerMode.Auto, "Include nearby chests in the \"have\" counts. Auto = only when CraftFromContainers or a similar mod is running, Always = always, Never = inventory only."); ContainerRange = config.Bind<float>("Counts", "Chest range", 20f, new ConfigDescription("Chest range in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 100f), Array.Empty<object>())); } private static ConfigEntry<T> Rebuilds<T>(ConfigEntry<T> entry) { entry.SettingChanged += delegate { Version++; }; return entry; } public static Func<string, bool> Ignored() { List<string> source = (from p in (IgnoreList?.Value ?? "").Split(',', ';') select p.Trim() into p where p.Length > 0 select p).ToList(); HashSet<string> exact = new HashSet<string>(source.Where((string p) => !Enumerable.Contains(p, '*')), StringComparer.OrdinalIgnoreCase); List<string> suffixes = (from p in source where p.StartsWith("*") select p.Substring(1)).ToList(); List<string> prefixes = (from p in source where p.EndsWith("*") && !p.StartsWith("*") select p.Substring(0, p.Length - 1)).ToList(); return (string name) => exact.Contains(name) || suffixes.Any((string s) => name.EndsWith(s, StringComparison.OrdinalIgnoreCase)) || prefixes.Any((string p) => name.StartsWith(p, StringComparison.OrdinalIgnoreCase)); } } internal sealed class Filter { private static readonly Regex CheatOrTest = new Regex("(Cheat|Test)(?![a-z])"); private readonly Func<string, bool> ignored = DataConfig.Ignored(); private readonly Dictionary<string, int> counts = new Dictionary<string, int>(); private static readonly HashSet<string> UnreleasedNames = new HashSet<string> { "OrbFrostFire", "OrbThunderBlood", "HelmetCrownofValheim", "CrownJewel", "FrozenKingDrop", "Shovel", "StaffOrbofAhri", "StaffOrbofAhriUncooked", "StaffThunderBlood", "StaffThunderbloodUncooked", "KnifeVoid", "TrophyBlob_Frost", "TrophyForestTroll", "TrophyDraugrFem" }; public string RejectItem(string prefab, SharedData shared, bool vanilla) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: 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) //IL_000a: Invalid comparison between Unknown and I4 //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Invalid comparison between Unknown and I4 ItemType itemType = shared.m_itemType; object obj; if (((int)itemType != 10 && (int)itemType != 20) || 1 == 0) { obj = RejectName(prefab); if (obj == null) { obj = Dlc(shared.m_dlc); if (obj == null) { obj = ((vanilla && Missing(shared.m_name)) ? ("missing translation " + shared.m_name) : null); if (obj == null) { if (!vanilla || !Unreleased(prefab)) { return null; } return "unreleased or unused vanilla"; } } } } else { obj = "type " + ((object)Unsafe.As<ItemType, ItemType>(ref shared.m_itemType)/*cast due to .constrained prefix*/).ToString(); } return (string)obj; } private static bool Unreleased(string prefab) { if (!UnreleasedNames.Contains(prefab) && !prefab.EndsWith("_FrostFire")) { return prefab.EndsWith("_BloodLightning"); } return true; } public string RejectPiece(Piece piece, bool vanilla) { if (piece.m_repairPiece || piece.m_removePiece) { return "repair/remove tool"; } if (Object.op_Implicit((Object)(object)((Component)piece).GetComponent<Feast>())) { return "feast (treated as food)"; } if (!piece.m_resources.Any((Requirement r) => Object.op_Implicit((Object)(object)r.m_resItem) && r.m_amount > 0) && !Object.op_Implicit((Object)(object)((Component)piece).GetComponent<Plant>())) { return "no resources"; } string text = RejectName(((Object)piece).name); if (text == null) { text = Dlc(piece.m_dlc); if (text == null) { if (!vanilla || !Missing(piece.m_name)) { return null; } text = "missing translation " + piece.m_name; } } return text; } private string RejectName(string name) { if (name.StartsWith("SP_") || name.StartsWith("FW_")) { return "prefab SP_/FW_"; } string text = name.ToLowerInvariant(); if (text.EndsWith("_attach") || text.EndsWith("_nochest") || text.EndsWith("_ragdoll")) { return "technical variant"; } if (CheatOrTest.IsMatch(name) || text.Contains("_test")) { return "cheat/test"; } if (!ignored(name)) { return null; } return "ignore list"; } private static string Dlc(string dlc) { if (string.IsNullOrEmpty(dlc) || !Object.op_Implicit((Object)(object)DLCMan.instance) || DLCMan.instance.IsDLCInstalled(dlc)) { return null; } return "DLC " + dlc; } public static bool Missing(string token) { if (!string.IsNullOrEmpty(token) && token[0] == '$') { return Localization.instance.Localize(token) == "[" + token.Substring(1) + "]"; } return false; } public static string DisplayName(string token, string prefab) { if (!string.IsNullOrEmpty(token) && !Missing(token)) { return Localization.instance.Localize(token); } return CleanName(prefab); } public static string CleanName(string prefab) { return Regex.Replace(Regex.Replace(prefab.Replace('_', ' '), "(?<=[a-z])(?=[A-Z0-9])", " "), "\\s+", " ").Trim(); } public void Hide(string prefab, string name, string reason) { string key = ((reason.IndexOf(' ') > 0 && reason.StartsWith("missing")) ? "missing translation" : (reason.StartsWith("DLC") ? "DLC" : reason)); counts[key] = ((!counts.TryGetValue(key, out var value)) ? 1 : (value + 1)); ConfigEntry<bool> logFilter = DataConfig.LogFilter; if (logFilter != null && logFilter.Value) { DataConfig.Log.LogInfo((object)("Hidden " + prefab + " (" + name + "): " + reason)); } } public string Summary() { return string.Join(", ", from c in counts orderby c.Value descending select $"{c.Key} {c.Value}"); } } internal sealed class Frame(RectTransform canvas, RectTransform target, Func<Rect, Rect> fit, Vector2 step) { private const float HandleSize = 16f; public Rect Rect { get; private set; } public Action<Rect> Saved { get; set; } public void Place(Rect desired) { //IL_0006: 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) //IL_000c: 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) //IL_0018: 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_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) Rect val = fit(desired); Rect rect = canvas.rect; float num = Mathf.Clamp(((Rect)(ref val)).xMin, ((Rect)(ref rect)).xMin, Mathf.Max(((Rect)(ref rect)).xMin, ((Rect)(ref rect)).xMax - ((Rect)(ref val)).width)); float num2 = Mathf.Clamp(((Rect)(ref val)).yMin, Mathf.Min(((Rect)(ref rect)).yMin, ((Rect)(ref rect)).yMax - ((Rect)(ref val)).height), ((Rect)(ref rect)).yMax - ((Rect)(ref val)).height); Rect = new Rect(num, num2, ((Rect)(ref val)).width, ((Rect)(ref val)).height); RectTransform rect2 = target; RectTransform root = canvas; Rect rect3 = Rect; float xMin = ((Rect)(ref rect3)).xMin; rect3 = Rect; Ui.PlaceLocal(rect2, root, new Vector2(xMin, ((Rect)(ref rect3)).yMax), new Vector2(0f, 1f)); RectTransform obj = target; rect3 = Rect; obj.sizeDelta = ((Rect)(ref rect3)).size; } public void AddMoveHandle(GameObject handle) { //IL_0030: 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) if (!Object.op_Implicit((Object)(object)handle.GetComponent<Graphic>())) { ((Graphic)handle.AddComponent<Image>()).color = Color.clear; } Vector2 offset = default(Vector2); Drag drag = handle.AddComponent<Drag>(); drag.Canvas = canvas; drag.Began = delegate(Vector2 p) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: 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) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) Rect rect = Rect; float xMin = ((Rect)(ref rect)).xMin; rect = Rect; offset = new Vector2(xMin, ((Rect)(ref rect)).yMax) - p; }; drag.Moved = delegate(Vector2 p) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0049: 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_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) Frame frame = this; float num = p.x + offset.x; float num2 = p.y + offset.y; Rect rect = Rect; float num3 = num2 - ((Rect)(ref rect)).height; rect = Rect; float width = ((Rect)(ref rect)).width; rect = Rect; frame.Place(new Rect(num, num3, width, ((Rect)(ref rect)).height)); }; drag.Ended = delegate { //IL_0016: Unknown result type (might be due to invalid IL or missing references) Saved?.Invoke(Rect); }; } public void AddResizeHandle() { //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_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0050: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Resize", new Type[1] { typeof(RectTransform) }); RectTransform val2 = (RectTransform)val.transform; ((Transform)val2).SetParent((Transform)(object)target, false); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(1f, 0f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; val2.anchoredPosition = new Vector2(-3f, 3f); val2.sizeDelta = new Vector2(16f, 16f); ((Graphic)val.AddComponent<Image>()).color = new Color(Ui.Orange.r, Ui.Orange.g, Ui.Orange.b, 0.55f); Drag drag = val.AddComponent<Drag>(); drag.Canvas = canvas; drag.Moved = delegate(Vector2 p) { //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) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) Rect rect = Rect; float xMin = ((Rect)(ref rect)).xMin; float num = p.y - step.y / 2f; float num2 = p.x + step.x / 2f; rect = Rect; Place(Rect.MinMaxRect(xMin, num, num2, ((Rect)(ref rect)).yMax)); }; drag.Ended = delegate { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Saved?.Invoke(Rect); }; } } internal sealed class Drag : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { public RectTransform Canvas; public Action<Vector2> Began; public Action<Vector2> Moved; public Action Ended; private Vector2 Local(PointerEventData e) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) return Ui.ScreenToLocal(Canvas, e.position); } public void OnBeginDrag(PointerEventData e) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Began?.Invoke(Local(e)); } public void OnDrag(PointerEventData e) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) Moved?.Invoke(Local(e)); } public void OnEndDrag(PointerEventData e) { Ended?.Invoke(); } } internal sealed class Clicks : MonoBehaviour, IPointerClickHandler, IEventSystemHandler { public Action Left; public Action Right; public void OnPointerClick(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Invalid comparison between Unknown and I4 if ((int)e.button == 0) { Left?.Invoke(); } else if ((int)e.button == 1) { Right?.Invoke(); } } } internal sealed class Press : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IPointerEnterHandler, IPointerExitHandler { public Action Pressed; public bool Hovered { get; private set; } public void OnPointerDown(PointerEventData e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) if ((int)e.button == 0) { Pressed?.Invoke(); } } public void OnPointerEnter(PointerEventData e) { Hovered = true; } public void OnPointerExit(PointerEventData e) { Hovered = false; } private void OnDisable() { Hovered = false; } } internal sealed class ItemPanel { public const float Pad = 10f; public const float HeaderHeight = 76f; public const float PagerWidth = 140f; public const float RowHeight = 32f; private const float MinInner = 480f; private const float CollapseWidth = 32f; private const int MaxCells = 40; private readonly Layout layout; private readonly bool inBookmarks; private readonly Action<Entry, View> open; private readonly Action<Entry, Entry> reorder; private readonly RectTransform header; private readonly RectTransform grid; private readonly Button previous; private readonly Button next; private readonly Button collapse; private readonly Text pageLabel; private readonly List<Slot> slots = new List<Slot>(); private readonly List<Text> headings = new List<Text>(); private readonly List<(int Start, int Count, string Heading)> lines = new List<(int, int, string)>(); private List<Entry> entries = new List<Entry>(); private int columns; private int rows; private int first; private int linedFor = -1; private (int, int) built; public GameObject Root { get; } public Transform Header => (Transform)(object)header; public float HeaderWidth { get; private set; } public Frame Frame { get; } public Func<float, float> LayoutHeader { get; set; } = (float _) => 38f; public Func<Entry, string> Section { get; set; } public static float Height(int rows, float cell) { return 96f + (float)rows * cell; } public ItemPanel(RectTransform canvas, Layout layout, bool inBookmarks, Action<Entry, View> open, Action onCollapse, Action<Entry, Entry> reorder = null) { //IL_008d: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: 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_00cc: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Expected O, but got Unknown //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0243: Unknown result type (might be due to invalid IL or missing references) //IL_024d: Expected O, but got Unknown //IL_025d: Unknown result type (might be due to invalid IL or missing references) this.layout = layout; this.inBookmarks = inBookmarks; this.open = open; this.reorder = reorder; Root = GUIManager.Instance.CreateWoodpanel((Transform)(object)canvas, new Vector2(0.5f, 0.5f), new Vector2(0.5f, 0.5f), Vector2.zero, 400f, 200f, false); RectTransform target = (RectTransform)Root.transform; Frame = new Frame(canvas, target, Fit, new Vector2(layout.Cell, layout.Cell)); header = (RectTransform)Ui.Rect("Header", Root.transform, 10f, 10f, 100f, 76f).transform; Frame.AddMoveHandle(((Component)header).gameObject); previous = Ui.Button((Transform)(object)header, "<", 0f, 0f, 32f, 32f, delegate { Scroll(-rows); }); pageLabel = Ui.Label((Transform)(object)header, "", 0f, 0f, 72f, 32f, 14, (TextAnchor)4, Ui.Muted); next = Ui.Button((Transform)(object)header, ">", 0f, 0f, 32f, 32f, delegate { Scroll(rows); }); collapse = Ui.Button((Transform)(object)header, "–", 0f, 0f, 32f, 32f, onCollapse); grid = (RectTransform)Ui.Rect("Grid", Root.transform, 10f, 86f, 100f, 100f).transform; ((Graphic)((Component)grid).gameObject.AddComponent<Image>()).color = Color.clear; ((Component)grid).gameObject.AddComponent<ScrollArea>().Scrolled = Scroll; Frame.AddResizeHandle(); } private Rect Fit(Rect desired) { //IL_01f2: Unknown result type (might be due to invalid IL or missing references) float cell = layout.Cell; columns = Mathf.Clamp(Mathf.FloorToInt((((Rect)(ref desired)).width - 20f) / cell + 0.01f), Mathf.CeilToInt(480f / cell), 40); float num = (float)columns * cell; HeaderWidth = num - 140f - 32f - 12f; float num2 = LayoutHeader(num); rows = Mathf.Clamp(Mathf.FloorToInt((((Rect)(ref desired)).height - 20f - num2) / cell + 0.01f), 1, 40); Ui.Place(((Component)header).gameObject, Root.transform, 10f, 10f, num, num2); float num3 = num - 32f - 6f - 140f; Ui.Place(((Component)previous).gameObject, (Transform)(object)header, num3, 0f, 32f, 32f); Ui.Place(((Component)pageLabel).gameObject, (Transform)(object)header, num3 + 34f, 0f, 72f, 32f); Ui.Place(((Component)next).gameObject, (Transform)(object)header, num3 + 140f - 32f, 0f, 32f, 32f); Ui.Place(((Component)collapse).gameObject, (Transform)(object)header, num - 32f, 0f, 32f, 32f); Ui.Place(((Component)grid).gameObject, Root.transform, 10f, 10f + num2, num, (float)rows * cell); BuildSlots(); float num4 = num + 20f; float num5 = 20f + num2 + (float)rows * cell; return new Rect(((Rect)(ref desired)).xMin, ((Rect)(ref desired)).yMax - num5, num4, num5); } private void BuildSlots() { //IL_0179: Unknown result type (might be due to invalid IL or missing references) (int, int) tuple = built; int num = columns; int num2 = rows; if (tuple.Item1 == num && tuple.Item2 == num2) { Refresh(); return; } built = (columns, rows); foreach (Slot slot in slots) { Object.Destroy((Object)(object)((Component)slot).gameObject); } foreach (Text heading in headings) { Object.Destroy((Object)(object)((Component)heading).gameObject); } slots.Clear(); headings.Clear(); float cell = layout.Cell; float num3 = (cell - layout.SlotSize) / 2f; for (int i = 0; i < rows; i++) { for (int j = 0; j < columns; j++) { slots.Add(Slot.Create((Transform)(object)grid, (float)j * cell + num3, (float)i * cell + num3, layout.SlotSize, inBookmarks, open, reorder)); } headings.Add(Ui.Label((Transform)(object)grid, "", num3, (float)i * cell, (float)columns * cell - num3 * 2f, cell, 16, (TextAnchor)6, Ui.Orange)); } Refresh(); } public void Show(List<Entry> list, bool resetPage) { entries = list; linedFor = -1; if (resetPage) { first = 0; } Refresh(); } private void Scroll(int deltaRows) { first += deltaRows; Refresh(); } private void BuildLines() { if (linedFor == columns) { return; } linedFor = columns; lines.Clear(); string text = null; int i = 0; while (i < entries.Count) { if (Section != null && (lines.Count == 0 || (Section(entries[i]) ?? "") != text)) { List<(int Start, int Count, string Heading)> list = lines; string obj = Section(entries[i]) ?? ""; text = obj; list.Add((0, 0, obj)); } int num; for (num = i; i < entries.Count && i - num < columns && (Section == null || (Section(entries[i]) ?? "") == text); i++) { } lines.Add((num, i - num, null)); } } private void Refresh() { if (slots.Count == 0) { return; } BuildLines(); first = Mathf.Clamp(first, 0, Mathf.Max(0, lines.Count - rows)); for (int i = 0; i < rows; i++) { (int, int, string) tuple = ((first + i < lines.Count) ? lines[first + i] : (0, 0, null)); headings[i].text = tuple.Item3 ?? ""; ((Component)headings[i]).gameObject.SetActive(tuple.Item3 != null); for (int j = 0; j < columns; j++) { slots[i * columns + j].Show((j < tuple.Item2) ? entries[tuple.Item1 + j] : null); } } int num = Mathf.Max(1, Mathf.CeilToInt((float)lines.Count / (float)rows)); int num2 = ((first + rows >= lines.Count) ? num : (first / rows + 1)); pageLabel.text = $"{num2}/{num}"; } } internal sealed record Layout(float Cell, float SlotSize, int Rows, Rect Results, Rect Bookmarks, Rect Window) { private const float Margin = 12f; private const float ResultsShare = 0.62f; private const float MaxWindowHeight = 1300f; private const float WindowWidth = 680f; public static Layout Fit(InventoryGui gui, RectTransform root, int rows) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //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_0047: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_013a: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) float num = LocalSize(gui.m_playerGrid.m_gridRoot, root); float cell = gui.m_playerGrid.m_elementSpace * num; Rect rect = ((RectTransform)gui.m_playerGrid.m_elementPrefab.transform).rect; float slotSize = ((Rect)(ref rect)).width * num; Rect rect2 = root.rect; float num2 = ItemPanel.Height(rows, cell); float num3 = ((Rect)(ref rect2)).xMin + 12f + (((Rect)(ref rect2)).width - 24f) * 0.62f; Rect results = Rect.MinMaxRect(((Rect)(ref rect2)).xMin + 12f, ((Rect)(ref rect2)).yMin + 12f, num3 - 6f, ((Rect)(ref rect2)).yMin + 12f + num2); Rect bookmarks = Rect.MinMaxRect(num3 + 6f, ((Rect)(ref rect2)).yMin + 12f, ((Rect)(ref rect2)).xMax - 12f, ((Rect)(ref rect2)).yMin + 12f + num2); float num4 = ((Rect)(ref results)).yMax + 12f; Rect window = Rect.MinMaxRect(((Rect)(ref rect2)).center.x - 340f, num4, ((Rect)(ref rect2)).center.x + 340f, Mathf.Min(((Rect)(ref rect2)).yMax - 12f, num4 + 1300f)); return new Layout(cell, slotSize, rows, results, bookmarks, window); } private static float LocalSize(RectTransform vanilla, RectTransform root) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0026: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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) Camera val = Ui.CameraOf((Transform)(object)vanilla); Vector2 val2 = Ui.ScreenToLocal(root, RectTransformUtility.WorldToScreenPoint(val, ((Transform)vanilla).TransformPoint(Vector3.zero))); Vector2 val3 = Ui.ScreenToLocal(root, RectTransformUtility.WorldToScreenPoint(val, ((Transform)vanilla).TransformPoint(Vector3.right))); return Vector2.Distance(val2, val3); } [CompilerGenerated] private Layout(Layout original) { //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0049: Unknown result type (might be due to invalid IL or missing references) Cell = original.Cell; SlotSize = original.SlotSize; Rows = original.Rows; Results = original.Results; Bookmarks = original.Bookmarks; Window = original.Window; } } internal static class Locations { private const int Batch = 8; private const float LoadTimeout = 30f; private static ZoneSystem scannedFor; private static Dictionary<string, SortedSet<int>> places = new Dictionary<string, SortedSet<int>>(); private static Dictionary<string, SortedSet<int>> creatures = new Dictionary<string, SortedSet<int>>(); public static int Version { get; private set; } public static bool Done { get; private set; } public static IReadOnlyDictionary<string, SortedSet<int>> Places => places; public static IReadOnlyDictionary<string, SortedSet<int>> Creatures => creatures; private static string CachePath => Path.Combine(Paths.CachePath, "PetyM.RecipeBrowser.locations.txt"); public static void EnsureStarted(MonoBehaviour host) { ZoneSystem instance = ZoneSystem.instance; if (Object.op_Implicit((Object)(object)instance) && !((Object)(object)scannedFor == (Object)(object)instance)) { scannedFor = instance; places = new Dictionary<string, SortedSet<int>>(); creatures = new Dictionary<string, SortedSet<int>>(); Done = false; string key = CacheKey(instance); if (!LoadCache(key)) { host.StartCoroutine(Scan(instance, key)); } } } private static string CacheKey(ZoneSystem zone) { IOrderedEnumerable<string> values = Chainloader.PluginInfos.Values.Select((PluginInfo p) => $"{p.Metadata.GUID}@{p.Metadata.Version}").OrderBy<string, string>((string p) => p, StringComparer.Ordinal); IOrderedEnumerable<string> values2 = (from l in zone.m_locations where l != null && l.m_enable && l.m_prefab.IsValid select $"{l.m_prefab.Name}:{(int)l.m_biome}").OrderBy<string, string>((string l) => l, StringComparer.Ordinal); string s = Version.GetVersionString(false) + "|" + string.Join(",", values) + "|" + string.Join(",", values2); using SHA1 sHA = SHA1.Create(); return BitConverter.ToString(sHA.ComputeHash(Encoding.UTF8.GetBytes(s))).Replace("-", ""); } private static bool LoadCache(string key) { try { if (!File.Exists(CachePath)) { return false; } string[] array = File.ReadAllLines(CachePath); if (array.Length == 0 || array[0] != "key\t" + key) { return false; } Dictionary<string, SortedSet<int>> dictionary = new Dictionary<string, SortedSet<int>>(); Dictionary<string, SortedSet<int>> dictionary2 = new Dictionary<string, SortedSet<int>>(); foreach (string item in array.Skip(1)) { string[] array2 = item.Split(new char[1] { '\t' }); if (array2.Length == 3) { ((array2[0] == "P") ? dictionary : ((array2[0] == "C") ? dictionary2 : null))?.Add(array2[1], new SortedSet<int>(array2[2].Split(new char[1] { ',' }).Select(int.Parse))); } } Publish(dictionary, dictionary2); DataConfig.Log.LogInfo((object)$"Locations: loaded from cache, {places.Count} prefabs, {creatures.Count} creatures."); return true; } catch (Exception ex) { DataConfig.Log.LogWarning((object)("Location cache unreadable, rescanning: " + ex.Message)); return false; } } private static void SaveCache(string key) { try { List<string> list = new List<string> { "key\t" + key }; list.AddRange(places.Select((KeyValuePair<string, SortedSet<int>> p) => "P\t" + p.Key + "\t" + string.Join(",", p.Value))); list.AddRange(creatures.Select((KeyValuePair<string, SortedSet<int>> c) => "C\t" + c.Key + "\t" + string.Join(",", c.Value))); Directory.CreateDirectory(Path.GetDirectoryName(CachePath)); File.WriteAllLines(CachePath, list); } catch (Exception ex) { DataConfig.Log.LogWarning((object)("Location cache not saved: " + ex.Message)); } } private static void Publish(Dictionary<string, SortedSet<int>> newPlaces, Dictionary<string, SortedSet<int>> newCreatures) { places = newPlaces; creatures = newCreatures; Done = true; Version++; } private unsafe static IEnumerator Scan(ZoneSystem zone, string key) { Stopwatch watch = Stopwatch.StartNew(); Dictionary<string, SortedSet<int>> foundPlaces = new Dictionary<string, SortedSet<int>>(); Dictionary<string, SortedSet<int>> foundCreatures = new Dictionary<string, SortedSet<int>>(); List<(Theme themes, List<int> ranks)> dungeons = new List<(Theme, List<int>)>(); List<(SoftReference<GameObject> asset, List<int> ranks)> locations = (from l in zone.m_locations where l != null && l.m_enable && l.m_prefab.IsValid select (asset: l.m_prefab, ranks: Progression.RanksOf(l.m_biome).ToList()) into l where l.ranks.Count > 0 select l).ToList(); IEnumerator step = Load(locations, delegate(GameObject go, List<int> ranks) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) ScanPrefab(go, ranks); DungeonGenerator[] componentsInChildren = go.GetComponentsInChildren<DungeonGenerator>(true); foreach (DungeonGenerator val in componentsInChildren) { dungeons.Add((val.m_themes, ranks)); } }); while (step.MoveNext()) { yield return step.Current; } int roomCount = 0; if (Object.op_Implicit((Object)(object)DungeonDB.instance) && dungeons.Count > 0) { List<(SoftReference<GameObject>, List<int>)> list = (from r in DungeonDB.GetRooms() where r != null && r.m_enabled && r.m_prefab.IsValid select (asset: r.m_prefab, ranks: dungeons.Where(((Theme themes, List<int> ranks) d) => (d.themes & r.m_theme) > 0).SelectMany(((Theme themes, List<int> ranks) d) => d.ranks).Distinct() .ToList()) into r where r.ranks.Count > 0 select r).ToList(); roomCount = list.Count; step = Load(list, ScanPrefab); while (step.MoveNext()) { yield return step.Current; } } if (!((Object)(object)scannedFor != (Object)(object)zone)) { Publish(foundPlaces, foundCreatures); SaveCache(key); DataConfig.Log.LogInfo((object)("Locations: dungeon themes " + string.Join(", ", dungeons.Select(((Theme themes, List<int> ranks) d) => ((object)(*(Theme*)(&d.themes))/*cast due to .constrained prefix*/).ToString()).Distinct()) + $"; all rooms {DungeonDB.GetRooms()?.Count ?? 0}, room themes " + string.Join(", ", from r in DungeonDB.GetRooms() ?? new List<RoomData>() where r != null group r by r.m_theme into g select $"{g.Key} {g.Count()}"))); DataConfig.Log.LogInfo((object)$"Locations: {locations.Count} locations, {roomCount} dungeon rooms, {places.Count} prefabs, {creatures.Count} creatures, {watch.ElapsedMilliseconds} ms (cached for next start)."); } void ScanPrefab(GameObject go, List<int> ranks) { Locations.ScanPrefab(go, ranks, foundPlaces, foundCreatures); } } private static IEnumerator Load(List<(SoftReference<GameObject> asset, List<int> ranks)> list, Action<GameObject, List<int>> scan) { for (int i = 0; i < list.Count; i += 8) { if (!Object.op_Implicit((Object)(object)scannedFor)) { break; } List<(SoftReference<GameObject> asset, List<int> ranks)> batch = list.Skip(i).Take(8).ToList(); foreach (var (val, _) in batch) { val.LoadAsync(); } float deadline = Time.realtimeSinceStartup + 30f; while (batch.Any(((SoftReference<GameObject> asset, List<int> ranks) b) => b.asset.IsLoading) && Time.realtimeSinceStartup < deadline) { yield return null; } foreach (var item in batch) { try { SoftReference<GameObject> val; (val, _) = item; if (val.IsLoaded) { val = item.asset; GameObject asset = val.Asset; if (asset != null) { scan(asset, item.ranks); } } } catch (Exception ex) { ManualLogSource log = DataConfig.Log; var (val, _) = item; log.LogWarning((object)("Location " + val.Name + " skipped: " + ex.Message)); } finally { var (val, _) = item; val.Release(); } } } } private static void ScanPrefab(GameObject go, List<int> ranks, Dictionary<string, SortedSet<int>> places, Dictionary<string, SortedSet<int>> creatures) { ZNetView[] componentsInChildren = go.GetComponentsInChildren<ZNetView>(true); foreach (ZNetView val in componentsInChildren) { Mark(places, PrefabName(((Object)((Component)val).gameObject).name), ranks); if (Object.op_Implicit((Object)(object)((Component)val).GetComponent<Character>())) { Mark(creatures, PrefabName(((Object)((Component)val).gameObject).name), ranks); } } foreach (CreatureSpawner item in from s in go.GetComponentsInChildren<CreatureSpawner>(true) where Object.op_Implicit((Object)(object)s.m_creaturePrefab) select s) { Mark(creatures, ((Object)item.m_creaturePrefab).name, ranks); } SpawnArea[] componentsInChildren2 = go.GetComponentsInChildren<SpawnArea>(true); for (int i = 0; i < componentsInChildren2.Length; i++) { foreach (SpawnData item2 in componentsInChildren2[i].m_prefabs.Where((SpawnData p) => Object.op_Implicit((Object)(object)p.m_prefab))) { Mark(creatures, ((Object)item2.m_prefab).name, ranks); } } foreach (OfferingBowl item3 in from b in go.GetComponentsInChildren<OfferingBowl>(true) where Object.op_Implicit((Object)(object)b.m_bossPrefab) select b) { Mark(creatures, ((Object)item3.m_bossPrefab).name, ranks); } } private static void Mark(Dictionary<string, SortedSet<int>> map, string name, List<int> ranks) { if (!string.IsNullOrEmpty(name)) { if (!map.TryGetValue(name, out var value)) { value = (map[name] = new SortedSet<int>()); } value.UnionWith(ranks); } } private static string PrefabName(string name) { int num = name.IndexOf(" (", StringComparison.Ordinal); if (num <= 0) { return name; } return name.Substring(0, num); } } [BepInPlugin("PetyM.RecipeBrowser", "RecipeBrowser", "1.0.2")] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { [HarmonyPatch(typeof(ZInput), "GetKeyDown", new Type[] { typeof(KeyCode), typeof(bool) })] private static class EscapeClosesRecipeFirst { private static void Postfix(KeyCode key, ref bool __result) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 if (__result && (int)key == 27 && (recipeOpen || escapeConsumedFrame == Time.frameCount)) { __result = false; } } } [HarmonyPatch(typeof(ZInput), "GetButton", new Type[] { typeof(string) })] private static class SuppressMovementWhileActing { private static readonly string[] Movement = new string[4] { "Forward", "Backward", "Left", "Right" }; private static void Postfix(string name, ref bool __result) { if (__result && hoveredEntry != null && ((IEnumerable<KeyCode>)actionKeys).Any((Func<KeyCode, bool>)Input.GetKey) && Movement.Contains(name)) { __result = false; } } } private ConfigEntry<KeyboardShortcut> recipesKey; private ConfigEntry<KeyboardShortcut> usagesKey; private ConfigEntry<KeyboardShortcut> bookmarkKey; private ConfigEntry<KeyboardShortcut> backKey; private ConfigEntry<KeyboardShortcut> collapseKey; private ConfigEntry<int> rows; private Bookmarks bookmarks; private Catalog catalog; private ObjectDB catalogSource; private Browser browser; private const float SettleDelay = 0.15f; private const float RetryDelay = 10f; private float retryAt; private float openedAt = -1f; private Layout layout; private static Entry hoveredEntry; private static bool recipeOpen; private static int escapeConsumedFrame = -1; private static KeyCode[] actionKeys = (KeyCode[])(object)new KeyCode[0]; private void Awake() { //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0075: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Expected O, but got Unknown //IL_012a: Unknown result type (might be due to invalid IL or missing references) ModQuery.Enable(); recipesKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Recipes", new KeyboardShortcut((KeyCode)114, Array.Empty<KeyCode>()), "Recipes for the item under the cursor."); usagesKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Usages", new KeyboardShortcut((KeyCode)117, Array.Empty<KeyCode>()), "Where the item under the cursor is used."); bookmarkKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Bookmark", new KeyboardShortcut((KeyCode)97, Array.Empty<KeyCode>()), "Bookmarks the item under the cursor; in the bookmarks panel removes it."); backKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Back", new KeyboardShortcut((KeyCode)8, Array.Empty<KeyCode>()), (ConfigDescription)null); collapseKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Keys", "Collapse", new KeyboardShortcut((KeyCode)121, Array.Empty<KeyCode>()), "Collapses or expands the panels (only with the inventory open)."); DataConfig.Bind(((BaseUnityPlugin)this).Config); UiConfig.Bind(((BaseUnityPlugin)this).Config); rows = ((BaseUnityPlugin)this).Config.Bind<int>("Display", "Rows", 5, new ConfigDescription("Number of rows in the bottom panels.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(2, 10), Array.Empty<object>())); new Harmony("PetyM.RecipeBrowser").PatchAll(); Browser.Log = ((BaseUnityPlugin)this).Logger.LogInfo; bookmarks = new Bookmarks(Path.Combine(Paths.ConfigPath, "PetyM.RecipeBrowser.bookmarks.txt")); } private void Update() { //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Expected O, but got Unknown //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Unknown result type (might be due to invalid IL or missing references) //IL_0287: Unknown result type (might be due to invalid IL or missing references) //IL_028c: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0329: Unknown result type (might be due to invalid IL or missing references) //IL_032e: 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) if (DataConfig.ScanLocations.Value && Object.op_Implicit((Object)(object)Player.m_localPlayer) && Object.op_Implicit((Object)(object)ZoneSystem.instance)) { Locations.EnsureStarted((MonoBehaviour)(object)this); } if (!Object.op_Implicit((Object)(object)Player.m_localPlayer) || !InventoryGui.IsVisible() || !Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront)) { hoveredEntry = null; recipeOpen = false; openedAt = -1f; layout = null; if (browser != null && browser.Alive) { browser.SetVisible(value: false); } return; } ObjectDB instance = ObjectDB.instance; if (!Object.op_Implicit((Object)(object)instance) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { return; } if ((catalog == null || (Object)(object)catalogSource != (Object)(object)instance || catalog.IsStale(instance)) && Time.time >= retryAt) { RebuildCatalog(instance); } if (catalog == null) { return; } if (openedAt < 0f) { openedAt = Time.time; } if (layout == null) { if (Time.time - openedAt < 0.15f) { return; } RectTransform root = (RectTransform)GUIManager.CustomGUIFront.transform; layout = Layout.Fit(InventoryGui.instance, root, rows.Value); if (browser != null && browser.Alive && browser.Layout != layout) { browser.Destroy(); browser = null; } if (browser == null || !browser.Alive) { browser = new Browser(catalog, bookmarks, root, layout); } } if (browser == null || !browser.Alive) { layout = null; return; } if (UiConfig.ResetLayout.Value) { browser.ResetLayout(); } browser.SetVisible(value: true); browser.Tick(); if (browser.IsRecipeOpen && Input.GetKeyDown((KeyCode)27)) { escapeConsumedFrame = Time.frameCount; browser.Close(); } recipeOpen = browser.IsRecipeOpen; if (browser.IsTyping || OtherTextInputFocused()) { hoveredEntry = null; return; } KeyboardShortcut value = backKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { browser.Back(); } value = collapseKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { browser.ToggleCollapsed(); } Entry entry = (hoveredEntry = HoveredEntry()); actionKeys = new ConfigEntry<KeyboardShortcut>[3] { recipesKey, usagesKey, bookmarkKey }.Select(delegate(ConfigEntry<KeyboardShortcut> k) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) KeyboardShortcut value2 = k.Value; return ((KeyboardShortcut)(ref value2)).MainKey; }).ToArray(); if (entry != null) { value = recipesKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { browser.Open(entry, View.Recipes); } value = usagesKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { browser.Open(entry, View.Usages); } value = bookmarkKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { browser.ToggleBookmark(entry, Object.op_Implicit((Object)(object)Slot.Hovered) && Slot.Hovered.InBookmarks); } } } private void RebuildCatalog(ObjectDB db) { try { catalog = new Catalog(db, ZNetScene.instance); } catch (Exception arg) { ((BaseUnityPlugin)this).Logger.LogError((object)$"Catalog build failed: {arg}"); retryAt = Time.time + 10f; return; } catalogSource = db; Stock.Invalidate(); if (browser != null && browser.Alive) { browser.Destroy(); } browser = null; } private Entry HoveredEntry() { //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006b: 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) //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Expected O, but got Unknown if (Object.op_Implicit((Object)(object)Slot.Hovered)) { return Slot.Hovered.Entry; } InventoryGui instance = InventoryGui.instance; InventoryGrid[] array = (InventoryGrid[])(object)new InventoryGrid[2] { instance.m_playerGrid, instance.m_containerGrid }; foreach (InventoryGrid val in array) { InventoryElement val2 = (Object.op_Implicit((Object)(object)val) ? val.GetHoveredElement() : null); if (!((Object)(object)val2 == (Object)null) && val.m_inventory != null) { Vector2i elementPos = val.GetElementPos(val2); ItemData itemAt = val.m_inventory.GetItemAt(elementPos.x, elementPos.y); if (Object.op_Implicit((Object)(object)itemAt?.m_dropPrefab)) { return catalog.Find(((Object)itemAt.m_dropPrefab).name); } } } foreach (RecipeDataPair availableRecipe in instance.m_availableRecipes) { RecipeDataPair current = availableRecipe; if (Object.op_Implicit((Object)(object)((RecipeDataPair)(ref current)).InterfaceElement) && Object.op_Implicit((Object)(object)((RecipeDataPair)(ref current)).Recipe) && Object.op_Implicit((Object)(object)((RecipeDataPair)(ref current)).Recipe.m_item) && IsPointerOver((RectTransform)((RecipeDataPair)(ref current)).InterfaceElement.transform)) { return catalog.Find(((Object)((RecipeDataPair)(ref current)).Recipe.m_item).name); } } return null; } private static bool OtherTextInputFocused() { GameObject val = (Object.op_Implicit((Object)(object)EventSystem.current) ? EventSystem.current.currentSelectedGameObject : null); if (Object.op_Implicit((Object)(object)val)) { TMP_InputField component = val.GetComponent<TMP_InputField>(); if (Object.op_Implicit((Object)(object)component) && component.isFocused) { return true; } InputField component2 = val.GetComponent<InputField>(); if (Object.op_Implicit((Object)(object)component2) && component2.isFocused) { return true; } } if ((!Object.op_Implicit((Object)(object)Chat.instance) || !Chat.instance.HasFocus()) && !Console.IsVisible()) { return TextInput.IsVisible(); } return true; } private static bool IsPointerOver(RectTransform rect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) Rect rect2 = rect.rect; return ((Rect)(ref rect2)).Contains(((Transform)rect).InverseTransformPoint(ZInput.pointerPosition)); } } internal static class Progression { public const int Meadows = 0; public const int BlackForest = 1; public const int Swamp = 2; public const int Ocean = 3; public const int Mountain = 4; public const int Plains = 5; public const int Mistlands = 6; public const int AshLands = 7; public const int DeepNorth = 8; public const string UnknownName = "Unknown"; public const string UnknownTag = "unknown"; private static readonly string[] Names = new string[9] { "Meadows", "Black Forest", "Swamp", "Ocean", "Mountains", "Plains", "Mistlands", "Ashlands", "Deep North" }; private static readonly string[] TagNames = new string[9] { "meadows", "blackforest", "swamp", "ocean", "mountains", "plains", "mistlands", "ashlands", "deepnorth" }; private static readonly (Biome biome, int rank)[] Bits = new(Biome, int)[9] { ((Biome)1, 0), ((Biome)8, 1), ((Biome)2, 2), ((Biome)256, 3), ((Biome)4, 4), ((Biome)16, 5), ((Biome)512, 6), ((Biome)32, 7), ((Biome)64, 8) }; private static readonly Dictionary<string, int> BossKeys = new Dictionary<string, int> { ["defeated_eikthyr"] = 0, ["defeated_gdking"] = 1, ["defeated_bonemass"] = 2, ["defeated_dragon"] = 4, ["defeated_goblinking"] = 5, ["defeated_queen"] = 6, ["defeated_fader"] = 7 }; private static readonly string[] BossNames = new string[7] { "Eikthyr", "The Elder", "Bonemass", "Moder", "Yagluth", "The Queen", "Fader" }; private static readonly Dictionary<string, int> VanillaOverrides = new Dictionary<string, int> { ["Chitin"] = 3, ["SerpentMeat"] = 3, ["SerpentScale"] = 3, ["TrophySerpent"] = 3, ["Coins"] = 0, ["Amber"] = 0, ["AmberPearl"] = 1, ["Ruby"] = 1, ["YmirRemains"] = 1, ["TrophyEikthyr"] = 0, ["HardAntler"] = 0, ["TrophyTheElder"] = 1, ["CryptKey"] = 1, ["TrophyBonemass"] = 2, ["Wishbone"] = 2, ["DragonEgg"] = 4, ["TrophyDragonQueen"] = 4, ["DragonTear"] = 4, ["TrophyGoblinKing"] = 5, ["YagluthDrop"] = 5, ["TrophySeekerQueen"] = 6, ["QueenDrop"] = 6, ["TrophyFader"] = 7, ["FaderDrop"] = 7, ["Wisp"] = 6, ["MushroomBlue"] = 4, ["DvergrKeyFragment"] = 6, ["WolfClaw"] = 4, ["FaderEmber"] = 7, ["ChickenMeat"] = 5, ["TrophyGoblinBruteBrosShaman"] = 5, ["chest_hildir3"] = 5 }; public static int Count => Names.Length; public static IReadOnlyList<string> Tags => TagNames; public static string Name(int rank) { if (rank < 0 || rank >= Names.Length) { return "Unknown"; } return Names[rank]; } public static string Name(int? rank) { if (!rank.HasValue) { return "Unknown"; } return Name(rank.Value); } public static string Tag(int? rank) { switch (rank) { default: return "unknown"; case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: return TagNames[rank.Value]; } } public static int? FromMask(Biome mask) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) foreach (var (val, value) in Bits.OrderBy(((Biome biome, int rank) b) => b.rank)) { if ((mask & val) != 0) { return value; } } return null; } public static IEnumerable<int> RanksOf(Biome mask) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) return from b in Bits where (mask & b.biome) > 0 select b.rank into r orderby r select r; } public static int? FromKey(string key) { if (string.IsNullOrEmpty(key) || !BossKeys.TryGetValue(key.ToLowerInvariant(), out var value)) { return null; } return value; } public static string KeyLabel(string key) { int? num = FromKey(key); if (num.HasValue) { int valueOrDefault = num.GetValueOrDefault(); return "after defeating " + BossNames[(valueOrDefault > 3) ? (valueOrDefault - 1) : valueOrDefault]; } return "key: " + key; } public static int? Max(int? a, int? b) { if (!a.HasValue || !b.HasValue) { return a ?? b; } return Math.Max(a.Value, b.Value); } public static int? GuessFromName(string name) { string text = name.ToLowerInvariant(); if (text.Contains("meadow")) { return 0; } if (text.Contains("blackforest") || text.Contains("forestcrypt") || text.Contains("trollcave")) { return 1; } if (text.Contains("swamp") || text.Contains("sunkencrypt")) { return 2; } if (text.Contains("mountain") || text.Contains("frostcave")) { return 4; } if (text.Contains("plains") || text.Contains("heath") || text.Contains("goblin")) { return 5; } if (text.Contains("mistland") || text.Contains("dvergr")) { return 6; } if (text.Contains("ashland") || text.Contains("charred")) { return 7; } return null; } public static int? ParseRank(string text) { text = text.Trim().ToLowerInvariant(); if (int.TryParse(text, out var result)) { if (result < 0 || result >= Names.Length) { return null; } return result; } for (int i = 0; i < Names.Length; i++) { if (TagNames[i] == text || Names[i].ToLowerInvariant() == text) { return i; } } return null; } public static Dictionary<string, int> Overrides() { Dictionary<string, int> dictionary = new Dictionary<string, int>(VanillaOverrides); string[] array = (DataConfig.BiomeOverrides?.Value ?? "").Split(',', ';'); foreach (string text in array) { string[] array2 = text.Split(new char[1] { '=' }); if (array2.Length == 2 && array2[0].Trim().Length != 0) { int? num = ParseRank(array2[1]); if (num.HasValue) { int valueOrDefault = num.GetValueOrDefault(); dictionary[array2[0].Trim()] = valueOrDefault; } else { DataConfig.Log.LogWarning((object)("Unknown biome in override: " + text)); } } } return dictionary; } public static void Assign(ICollection<Entry> entries, IReadOnlyList<RecipeCard> cards, Dictionary<Entry, List<Entry>> extensions, Dictionary<string, int> overrides) { Dictionary<Entry, int> biome = new Dictionary<Entry, int>(); HashSet<Entry> fixedEntries = new HashSet<Entry>(); foreach (Entry entry in entries) { if (overrides.TryGetValue(entry.Key, out var value)) { biome[entry] = value; fixedEntries.Add(entry); } } List<Entry> tools = entries.Where((Entry e) => Object.op_Implicit((Object)(object)e.Drop) && e.Drop.m_itemData.m_shared.m_toolTier > 0).ToList(); List<RecipeCard> list = cards.Where((RecipeCard c) => !c.IsUpgrade && !c.Weak).ToList(); Run(list, null); HashSet<Entry> seeded = new HashSet<Entry>(biome.Keys); Run(cards.Where((RecipeCard c) => c.Weak && c.Outputs.Any((ItemStack o) => !seeded.Contains(o.Entry))).Concat(list).ToList(), seeded); foreach (Entry entry2 in entries) { entry2.Biome = (biome.TryGetValue(entry2, out var value2) ? new int?(value2) : ((int?)null)); } foreach (RecipeCard card in cards) { card.Biome = Cost(card); } int? Cost(RecipeCard card) { int? num = ((card.Kind == CardKind.Source) ? card.Seed : ((int?)nul