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 WaitWhat v1.0.2
WaitWhat.dll
Decompiled 3 days agousing System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("WaitWhat")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("WaitWhat")] [assembly: AssemblyTitle("WaitWhat")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] namespace WaitWhat; internal sealed class IngredientBiomeFile { public readonly List<string> Biomes = new List<string>(); private readonly Dictionary<string, string> _biomeByPrefab = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); public string GetBiome(string prefabName) { if (!_biomeByPrefab.TryGetValue(prefabName, out var value)) { return null; } return value; } public static IngredientBiomeFile Load(string path, ManualLogSource logger) { IngredientBiomeFile ingredientBiomeFile = new IngredientBiomeFile(); if (!File.Exists(path)) { logger.LogWarning((object)("Ingredient biome file not found: " + path + ". Biome groups are unavailable.")); return ingredientBiomeFile; } string[] array; try { array = File.ReadAllLines(path); } catch (Exception ex) when (ex is IOException || ex is UnauthorizedAccessException) { logger.LogWarning((object)("Ingredient biome file could not be read: " + path + " (" + ex.Message + "). Biome groups are unavailable.")); return ingredientBiomeFile; } string text = null; string[] array2 = array; for (int i = 0; i < array2.Length; i++) { string text2 = array2[i].Trim(); if (text2.Length == 0 || text2.StartsWith("#")) { continue; } if (text2.StartsWith("[") && text2.EndsWith("]")) { text = text2.Substring(1, text2.Length - 2).Trim(); if (text.Length == 0) { text = null; } else if (!ingredientBiomeFile.Biomes.Contains(text)) { ingredientBiomeFile.Biomes.Add(text); } } else if (text != null && !ingredientBiomeFile._biomeByPrefab.ContainsKey(text2)) { ingredientBiomeFile._biomeByPrefab.Add(text2, text); } } return ingredientBiomeFile; } } internal static class InputBlockPatches { [HarmonyPatch(typeof(Menu), "IsVisible")] private static class MenuIsVisible { private static void Postfix(ref bool __result) { if (Blocking) { __result = true; } } } [HarmonyPatch(typeof(TextInput), "IsVisible")] private static class TextInputIsVisible { private static void Postfix(ref bool __result) { if (Blocking) { __result = true; } } } private static int _blockUntilFrame = -1; private static bool _open; public static Func<bool> ShortcutActive = () => false; private static bool _bypass; private static bool Blocking { get { if (!_bypass) { if (!_open && Time.frameCount > _blockUntilFrame) { return ShortcutActive(); } return true; } return false; } } public static void SetOpen(bool open) { _open = open; if (!open) { _blockUntilFrame = Time.frameCount; } } public static bool Unblocked(Func<bool> check) { _bypass = true; try { return check(); } finally { _bypass = false; } } } internal sealed class KnownIngredient { public string Key; public string PrefabName; public string DisplayName; public string Biome; public string SearchText; public Sprite Icon; public bool HasKnownUses; public bool SharesKnowledge; public bool Matches(string lowerQuery) { if (lowerQuery.Length != 0) { return SearchText.Contains(lowerQuery); } return true; } } internal sealed class LostRecipe { public string Key; public string DisplayName; public Sprite Icon; public HashSet<string> IngredientKeys; } internal static class Knowledge { private sealed class Unlock { public string Key; public Sprite Icon; public Requirement[] Resources; public Recipe Recipe; public Piece Piece; } public static List<KnownIngredient> CollectIngredients(Player player, IngredientBiomeFile biomes) { List<Unlock> list = AllUnlocks(); Dictionary<string, bool> dictionary = new Dictionary<string, bool>(); foreach (Unlock item in list) { if (!IsDiscoverable(player, item)) { continue; } bool flag = player.m_knownRecipes.Contains(item.Key); Requirement[] resources = item.Resources; foreach (Requirement val in resources) { if (IsIngredient(val)) { string name = val.m_resItem.m_itemData.m_shared.m_name; if (player.m_knownMaterial.Contains(name)) { dictionary.TryGetValue(name, out var value); dictionary[name] = value || flag; } } } } Dictionary<string, KnownIngredient> dictionary2 = new Dictionary<string, KnownIngredient>(StringComparer.OrdinalIgnoreCase); foreach (Unlock item2 in list) { Requirement[] resources = item2.Resources; foreach (Requirement val2 in resources) { if (!IsIngredient(val2)) { continue; } string name2 = val2.m_resItem.m_itemData.m_shared.m_name; if (dictionary.TryGetValue(name2, out var value2)) { string name3 = ((Object)val2.m_resItem).name; if (!dictionary2.ContainsKey(name3)) { string text = Localization.instance.Localize(name2); dictionary2.Add(name3, new KnownIngredient { Key = name2, PrefabName = name3, DisplayName = text, Biome = biomes.GetBiome(name3), SearchText = (text + "\n" + name2 + "\n" + name3).ToLowerInvariant(), Icon = val2.m_resItem.m_itemData.GetIcon(), HasKnownUses = value2 }); } } } } foreach (IGrouping<string, KnownIngredient> item3 in from knownIngredient in dictionary2.Values group knownIngredient by knownIngredient.Key into g where g.Count() > 1 select g) { foreach (KnownIngredient item4 in item3) { item4.SharesKnowledge = true; item4.DisplayName = item4.DisplayName + " (" + item4.PrefabName + ")"; } } return (from knownIngredient in dictionary2.Values orderby knownIngredient.DisplayName, knownIngredient.PrefabName select knownIngredient).ToList(); } public static List<LostRecipe> RecipesLostWithout(Player player, ICollection<string> ingredientKeys) { List<LostRecipe> list = new List<LostRecipe>(); if (ingredientKeys.Count == 0) { return list; } Dictionary<string, List<Unlock>> dictionary = new Dictionary<string, List<Unlock>>(); foreach (Unlock item in AllUnlocks()) { if (player.m_knownRecipes.Contains(item.Key)) { if (!dictionary.TryGetValue(item.Key, out var value)) { dictionary.Add(item.Key, value = new List<Unlock>()); } value.Add(item); } } List<string> list2 = ingredientKeys.Distinct().Where(player.m_knownMaterial.Contains).ToList(); Dictionary<Unlock, bool> discoverableBefore = new Dictionary<Unlock, bool>(); foreach (List<Unlock> value2 in dictionary.Values) { foreach (Unlock item2 in value2) { discoverableBefore[item2] = IsDiscoverable(player, item2); } } foreach (string item3 in list2) { player.m_knownMaterial.Remove(item3); } try { foreach (KeyValuePair<string, List<Unlock>> item4 in dictionary) { HashSet<string> hashSet = new HashSet<string>((from q in item4.Value.SelectMany((Unlock u) => u.Resources).Where(IsIngredient) select q.m_resItem.m_itemData.m_shared.m_name).Where(ingredientKeys.Contains)); if (hashSet.Count != 0) { bool num = item4.Value.Any((Unlock u) => discoverableBefore[u]); bool flag = item4.Value.Any((Unlock u) => IsDiscoverable(player, u)); if (num && !flag) { list.Add(new LostRecipe { Key = item4.Key, DisplayName = Localization.instance.Localize(item4.Key), Icon = item4.Value[0].Icon, IngredientKeys = hashSet }); } } } return list; } finally { foreach (string item5 in list2) { player.m_knownMaterial.Add(item5); } } } public static void Forget(Player player, ICollection<string> ingredientKeys) { List<LostRecipe> list = RecipesLostWithout(player, ingredientKeys); foreach (string item in ingredientKeys.Distinct()) { player.m_knownMaterial.Remove(item); } foreach (LostRecipe item2 in list) { player.m_knownRecipes.Remove(item2.Key); } player.UpdateAvailablePiecesList(); } public static HashSet<string> CarriedItemKeys(Player player) { return new HashSet<string>(from i in ((Humanoid)player).GetInventory().GetAllItems() select i.m_shared.m_name); } private static List<Unlock> AllUnlocks() { List<Unlock> list = new List<Unlock>(); foreach (Recipe recipe in ObjectDB.instance.m_recipes) { if (Object.op_Implicit((Object)(object)recipe) && Object.op_Implicit((Object)(object)recipe.m_item) && recipe.m_resources != null) { ItemData itemData = recipe.m_item.m_itemData; list.Add(new Unlock { Key = itemData.m_shared.m_name, Icon = itemData.GetIcon(), Resources = recipe.m_resources, Recipe = recipe }); } } HashSet<Piece> hashSet = new HashSet<Piece>(); foreach (GameObject item in ObjectDB.instance.m_items) { ItemDrop val = (Object.op_Implicit((Object)(object)item) ? item.GetComponent<ItemDrop>() : null); PieceTable val2 = (Object.op_Implicit((Object)(object)val) ? val.m_itemData.m_shared.m_buildPieces : null); if (!Object.op_Implicit((Object)(object)val2)) { continue; } foreach (GameObject piece in val2.m_pieces) { Piece val3 = (Object.op_Implicit((Object)(object)piece) ? piece.GetComponent<Piece>() : null); if (Object.op_Implicit((Object)(object)val3) && val3.m_resources != null && hashSet.Add(val3)) { list.Add(new Unlock { Key = val3.m_name, Icon = val3.m_icon, Resources = val3.m_resources, Piece = val3 }); } } } return list; } private static bool IsIngredient(Requirement requirement) { if (Object.op_Implicit((Object)(object)requirement.m_resItem) && requirement.m_amount > 0) { return !requirement.m_upgraderResource; } return false; } private static bool IsDiscoverable(Player player, Unlock unlock) { if (!Object.op_Implicit((Object)(object)unlock.Recipe)) { return player.HaveRequirements(unlock.Piece, (RequirementMode)1); } return player.HaveRequirements(unlock.Recipe, true, 0, 1); } } internal sealed class RecipeWindow { private sealed class PreviewRow { public KnownIngredient Ingredient; public string Header; public List<LostRecipe> Recipes; } private const int WindowId = 358935; private const float ReferenceHeight = 1080f; private const float Width = 620f; private const float Height = 700f; private const float TitleGap = 18f; private const float IconSize = 24f; private const float IngredientGap = 18f; private readonly string _ingredientFile; private readonly ManualLogSource _logger; private IngredientBiomeFile _biomes; private List<KnownIngredient> _ingredients = new List<KnownIngredient>(); private readonly HashSet<string> _selectedKeys = new HashSet<string>(); private readonly HashSet<string> _selectedBiomes = new HashSet<string>(); private readonly HashSet<string> _biomeSelectedKeys = new HashSet<string>(); private bool _selectAll; private string _search = ""; private Vector2 _scroll; private bool _confirming; private List<KnownIngredient> _affected = new List<KnownIngredient>(); private List<LostRecipe> _lost = new List<LostRecipe>(); private Vector2 _confirmScroll; private List<PreviewRow> _preview = new List<PreviewRow>(); private string _carriedSummary; private GUIStyle _window; private GUIStyle _label; private GUIStyle _header; private GUIStyle _toggle; private GUIStyle _headerToggle; private GUIStyle _button; private GUIStyle _textField; private GUIStyle _placeholder; private Texture2D _background; public bool IsOpen { get; private set; } public RecipeWindow(string ingredientFile, ManualLogSource logger) { _ingredientFile = ingredientFile; _logger = logger; } public void Open() { //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) _biomes = IngredientBiomeFile.Load(_ingredientFile, _logger); _selectedKeys.Clear(); _selectedBiomes.Clear(); _selectAll = false; _search = ""; _scroll = Vector2.zero; _confirming = false; Refresh(); IsOpen = true; InputBlockPatches.SetOpen(open: true); } public void Close() { IsOpen = false; _confirming = false; InputBlockPatches.SetOpen(open: false); } private void Refresh() { _ingredients = Knowledge.CollectIngredients(Player.m_localPlayer, _biomes); UpdateSelection(); } private void UpdateSelection() { _biomeSelectedKeys.Clear(); foreach (KnownIngredient ingredient in _ingredients) { if (ingredient.HasKnownUses && IsBiomeSelected(ingredient.Biome)) { _biomeSelectedKeys.Add(ingredient.Key); } } _affected = _ingredients.Where(IsSelected).ToList(); _lost = Knowledge.RecipesLostWithout(Player.m_localPlayer, _affected.Select((KnownIngredient i) => i.Key).Distinct().ToList()); } private bool IsSelected(KnownIngredient i) { if (i.HasKnownUses) { if (!_selectAll && !_selectedKeys.Contains(i.Key)) { return _biomeSelectedKeys.Contains(i.Key); } return true; } return false; } private bool IsBiomeSelected(string biome) { if (!_selectAll) { if (biome != null) { return _selectedBiomes.Contains(biome); } return false; } return true; } public void Draw() { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Invalid comparison between Unknown and I4 //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: 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_00de: Expected O, but got Unknown //IL_00d9: 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_0028: Invalid comparison between Unknown and I4 if (!IsOpen) { return; } EnsureStyles(); if ((int)Event.current.type == 4 && (int)Event.current.keyCode == 27) { Event.current.Use(); if (!_confirming) { Close(); return; } _confirming = false; } float num = Mathf.Max(0.5f, (float)Screen.height / 1080f); Matrix4x4 matrix = GUI.matrix; GUI.matrix = Matrix4x4.Scale(new Vector3(num, num, 1f)); Rect val = default(Rect); ((Rect)(ref val))..ctor(((float)Screen.width / num - 620f) / 2f, ((float)Screen.height / num - 700f) / 2f, 620f, 700f); GUILayout.Window(358935, val, new WindowFunction(DrawWindow), "Wait what?", _window, Array.Empty<GUILayoutOption>()); GUI.matrix = matrix; } private void DrawWindow(int id) { //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_01b3: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) GUILayout.Space(18f); if (_confirming) { DrawConfirm(); return; } if (GUILayout.Toggle(_selectAll, " " + Texts.ForgetAll, _headerToggle, Array.Empty<GUILayoutOption>()) != _selectAll) { _selectAll = !_selectAll; UpdateSelection(); } GUILayout.Space(8f); GUILayout.Label(Texts.Intro, _label, Array.Empty<GUILayoutOption>()); GUILayout.Space(8f); GUILayout.Label(Texts.Biomes, _header, Array.Empty<GUILayoutOption>()); DrawBiomes(); GUILayout.Space(8f); GUILayout.Label(Texts.Ingredients, _header, Array.Empty<GUILayoutOption>()); _search = GUILayout.TextField(_search, _textField, Array.Empty<GUILayoutOption>()); if (_search.Length == 0) { GUI.Label(GUILayoutUtility.GetLastRect(), Texts.SearchPlaceholder, _placeholder); } if (_ingredients.Any((KnownIngredient i) => i.SharesKnowledge)) { GUILayout.Label(Texts.SharedIngredientKnowledge, _label, Array.Empty<GUILayoutOption>()); } DrawIngredientList(); GUILayout.Space(8f); GUILayout.Label(Texts.Selection(_affected.Count, _lost.Count), _label, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUI.enabled = _affected.Count > 0; if (GUILayout.Button(Texts.PreviewSelection, _button, Array.Empty<GUILayoutOption>())) { BuildPreview(); _confirmScroll = Vector2.zero; _confirming = true; } GUI.enabled = true; GUILayout.FlexibleSpace(); if (GUILayout.Button(Texts.Close, _button, Array.Empty<GUILayoutOption>())) { Close(); } GUILayout.EndHorizontal(); } private void DrawBiomes() { Dictionary<string, int> dictionary = (from i in _ingredients where i.Biome != null && i.HasKnownUses group i by i.Biome).ToDictionary((IGrouping<string, KnownIngredient> g) => g.Key, (IGrouping<string, KnownIngredient> g) => g.Count()); List<string> list = _biomes.Biomes.Where(dictionary.ContainsKey).ToList(); if (list.Count == 0) { GUILayout.Label(Texts.NoBiomeIngredients, _label, Array.Empty<GUILayoutOption>()); return; } for (int num = 0; num < list.Count; num += 3) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); foreach (string item in list.Skip(num).Take(3)) { bool flag = IsBiomeSelected(item); GUI.enabled = !_selectAll; bool num2 = GUILayout.Toggle(flag, $" {Texts.Biome(item)} ({dictionary[item]})", _toggle, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(193.33333f) }) != flag; GUI.enabled = true; if (num2 && !_selectAll) { if (flag) { _selectedBiomes.Remove(item); } else { _selectedBiomes.Add(item); } UpdateSelection(); } } GUILayout.EndHorizontal(); } } private void DrawIngredientList() { //IL_0013: 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) string lowerQuery = _search.Trim().ToLowerInvariant(); _scroll = GUILayout.BeginScrollView(_scroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); int num = 0; foreach (KnownIngredient ingredient in _ingredients) { if (!ingredient.Matches(lowerQuery)) { continue; } num++; bool num2 = _selectAll || _biomeSelectedKeys.Contains(ingredient.Key); bool flag = IsSelected(ingredient); bool flag2 = num2 || !ingredient.HasKnownUses; GUI.enabled = !flag2; if (GUILayout.Toggle(flag, " " + ingredient.DisplayName, _toggle, Array.Empty<GUILayoutOption>()) != flag && !flag2) { if (flag) { _selectedKeys.Remove(ingredient.Key); } else { _selectedKeys.Add(ingredient.Key); } UpdateSelection(); } GUI.enabled = true; } if (num == 0) { GUILayout.Label((_ingredients.Count == 0) ? Texts.NoIngredients : Texts.NoMatches, _label, Array.Empty<GUILayoutOption>()); } GUILayout.EndScrollView(); } private void BuildPreview() { HashSet<string> carried = Knowledge.CarriedItemKeys(Player.m_localPlayer); _preview = (from i in _affected orderby !carried.Contains(i.Key) select new PreviewRow { Ingredient = i, Header = (carried.Contains(i.Key) ? ("<color=#ff5a4a>" + i.DisplayName + "</color> " + Texts.InInventory) : i.DisplayName) + ":", Recipes = (from r in _lost where r.IngredientKeys.Contains(i.Key) orderby r.DisplayName select r).ToList() }).ToList(); List<string> list = (from i in _affected where carried.Contains(i.Key) select i.DisplayName).ToList(); _carriedSummary = ((list.Count > 0) ? ("<color=#ff5a4a>" + Texts.CarriedSummary + ": " + string.Join(", ", list) + "</color>") : null); } private void DrawConfirm() { //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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) //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) GUILayout.Label(Texts.ConfirmQuestion(_affected.Count, _lost.Count), _header, Array.Empty<GUILayoutOption>()); if (_affected.Any((KnownIngredient i) => i.SharesKnowledge)) { GUILayout.Label(Texts.SharedIngredientKnowledge, _label, Array.Empty<GUILayoutOption>()); } if (_carriedSummary != null) { GUILayout.Label(_carriedSummary, _header, Array.Empty<GUILayoutOption>()); } GUILayout.Space(8f); _confirmScroll = GUILayout.BeginScrollView(_confirmScroll, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandHeight(true) }); foreach (PreviewRow item in _preview) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawSprite(GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }), item.Ingredient.Icon); GUILayout.Label(item.Header, _header, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); if (item.Recipes.Count == 0) { GUILayout.Label(Texts.NoKnownRecipes, _label, Array.Empty<GUILayoutOption>()); } foreach (LostRecipe recipe in item.Recipes) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); DrawSprite(GUILayoutUtility.GetRect(24f, 24f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(24f), GUILayout.Height(24f) }), recipe.Icon); GUILayout.Label(recipe.DisplayName, _label, Array.Empty<GUILayoutOption>()); GUILayout.EndHorizontal(); } GUILayout.Space(18f); } GUILayout.EndScrollView(); GUILayout.Space(8f); GUILayout.Label(Texts.Relearn, _label, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button(Texts.ForgetRecipes(_lost.Count), _button, Array.Empty<GUILayoutOption>())) { Knowledge.Forget(Player.m_localPlayer, _affected.Select((KnownIngredient i) => i.Key).Distinct().ToList()); _selectedKeys.Clear(); _selectedBiomes.Clear(); _selectAll = false; _confirming = false; Refresh(); } GUILayout.FlexibleSpace(); if (GUILayout.Button(Texts.Back, _button, Array.Empty<GUILayoutOption>())) { _confirming = false; } GUILayout.EndHorizontal(); } private static void DrawSprite(Rect rect, Sprite sprite) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)sprite) && Object.op_Implicit((Object)(object)sprite.texture)) { Texture2D texture = sprite.texture; Rect textureRect = sprite.textureRect; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height); GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val); } } private void EnsureStyles() { //IL_007a: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Expected O, but got Unknown //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Expected O, but got Unknown //IL_00ec: Expected O, but got Unknown //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0134: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Unknown result type (might be due to invalid IL or missing references) //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Expected O, but got Unknown //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_0189: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0195: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Expected O, but got Unknown //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_0213: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Unknown result type (might be due to invalid IL or missing references) //IL_0216: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0235: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_027c: Unknown result type (might be due to invalid IL or missing references) //IL_027d: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0285: 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_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Unknown result type (might be due to invalid IL or missing references) //IL_0291: Unknown result type (might be due to invalid IL or missing references) //IL_0292: Unknown result type (might be due to invalid IL or missing references) //IL_0299: Unknown result type (might be due to invalid IL or missing references) //IL_02ab: Unknown result type (might be due to invalid IL or missing references) //IL_02b0: Unknown result type (might be due to invalid IL or missing references) //IL_02b7: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c6: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Expected O, but got Unknown //IL_02d5: Expected O, but got Unknown //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) //IL_02ec: Unknown result type (might be due to invalid IL or missing references) //IL_02f9: Expected O, but got Unknown //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Expected O, but got Unknown //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_032c: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_033d: Unknown result type (might be due to invalid IL or missing references) if (_window == null) { Color val = default(Color); ((Color)(ref val))..ctor(0.93f, 0.87f, 0.75f); Color val2 = default(Color); ((Color)(ref val2))..ctor(1f, 0.78f, 0.38f); Font val3 = ((IEnumerable<Font>)Resources.FindObjectsOfTypeAll<Font>()).FirstOrDefault((Func<Font, bool>)((Font f) => ((Object)f).name == "AveriaSerifLibre-Bold")); if (!Object.op_Implicit((Object)(object)val3)) { _logger.LogInfo((object)"Valheim font AveriaSerifLibre-Bold not found, using the default font."); } _background = new Texture2D(1, 1); _background.SetPixel(0, 0, new Color(0.11f, 0.08f, 0.06f, 0.95f)); _background.Apply(); _window = new GUIStyle(GUI.skin.window) { font = val3, fontSize = 22, padding = new RectOffset(16, 16, 40, 16) }; GUIStyleState normal = _window.normal; Texture2D background = (_window.onNormal.background = _background); normal.background = background; GUIStyleState normal2 = _window.normal; Color textColor = (_window.onNormal.textColor = val2); normal2.textColor = textColor; _header = new GUIStyle(GUI.skin.label) { font = val3, fontSize = 18, wordWrap = true, richText = true }; _header.normal.textColor = val2; _label = new GUIStyle(GUI.skin.label) { font = val3, fontSize = 16, wordWrap = true }; _label.normal.textColor = val; _toggle = new GUIStyle(GUI.skin.toggle) { font = val3, fontSize = 16 }; GUIStyleState normal3 = _toggle.normal; GUIStyleState onNormal = _toggle.onNormal; GUIStyleState hover = _toggle.hover; Color val5 = (_toggle.onHover.textColor = val); Color val7 = (hover.textColor = val5); textColor = (onNormal.textColor = val7); normal3.textColor = textColor; _headerToggle = new GUIStyle(_toggle) { fontSize = _header.fontSize }; GUIStyleState normal4 = _headerToggle.normal; GUIStyleState onNormal2 = _headerToggle.onNormal; GUIStyleState hover2 = _headerToggle.hover; val5 = (_headerToggle.onHover.textColor = val2); val7 = (hover2.textColor = val5); textColor = (onNormal2.textColor = val7); normal4.textColor = textColor; _button = new GUIStyle(GUI.skin.button) { font = val3, fontSize = 16, padding = new RectOffset(14, 14, 6, 6) }; _textField = new GUIStyle(GUI.skin.textField) { font = val3, fontSize = 16 }; _placeholder = new GUIStyle(_textField); _placeholder.normal.background = null; _placeholder.normal.textColor = new Color(val.r, val.g, val.b, 0.45f); } } } internal static class Texts { private static bool German => Localization.instance.GetSelectedLanguage() == "German"; public static string Intro => T("Check biomes below to forget all recipes with crafting ingredients from this biome, or search for single ingredients to forget their recipes.", "Biome unten ankreuzen, um alle Rezepte mit Zutaten aus diesem Biom zu vergessen, oder einzelne Zutaten suchen, um deren Rezepte zu vergessen."); public static string ForgetAll => T("Forget all known recipes", "Alle bekannten Rezepte vergessen"); public static string CarriedSummary => T("In inventory, would be instantly relearned", "Im Inventar, würde sofort neu gelernt"); public static string Biomes => T("Forget all from biome", "Alles aus Biom vergessen"); public static string Ingredients => T("Forget all with ingredient", "Alles mit Zutat vergessen"); public static string SearchPlaceholder => T("Search ingredients", "Zutaten suchen"); public static string NoBiomeIngredients => T("No known ingredients assigned to a biome.", "Keine bekannten Zutaten einem Biom zugeordnet."); public static string NoIngredients => T("This character knows no ingredients.", "Dieser Charakter kennt keine Zutaten."); public static string NoMatches => T("No matching ingredients.", "Keine passenden Zutaten."); public static string PreviewSelection => T("Preview selection", "Auswahl ansehen"); public static string Close => T("Close", "Schließen"); public static string Back => T("Back", "Zurück"); public static string Relearn => T("Picking up a forgotten ingredient again discovers its recipes the normal way.", "Wird eine vergessene Zutat wieder aufgehoben, werden ihre Rezepte auf normalem Weg neu entdeckt."); public static string InInventory => T("(in inventory)", "(im Inventar)"); public static string NoKnownRecipes => T("(no known recipes)", "(keine bekannten Rezepte)"); public static string SharedIngredientKnowledge => T("Items marked with their prefab names share knowledge: selecting or forgetting one also affects the others with the same game name.", "Einträge mit Prefab-Namen teilen ihr Wissen: Auswahl und Vergessen betreffen auch die anderen Einträge mit dem gleichen Spielnamen."); private static string T(string en, string de) { if (!German) { return en; } return de; } public static string Selection(int ingredients, int recipes) { if (!German) { return "Selected " + Count(ingredients, "ingredient", "ingredients") + " -> forget " + Count(recipes, "known recipe", "known recipes") + " " + ((ingredients == 1) ? "with this ingredient" : "with these ingredients"); } return Count(ingredients, "Zutat", "Zutaten") + " ausgewählt -> " + Count(recipes, "bekanntes Rezept", "bekannte Rezepte") + " " + ((ingredients == 1) ? "mit dieser Zutat vergessen" : "mit diesen Zutaten vergessen"); } public static string ForgetRecipes(int recipes) { if (!German) { return "Forget " + Count(recipes, "recipe", "recipes"); } return Count(recipes, "Rezept", "Rezepte") + " vergessen"; } public static string ConfirmQuestion(int ingredients, int recipes) { if (!German) { return "Forget " + Count(ingredients, "ingredient", "ingredients") + " and " + Count(recipes, "recipe", "recipes") + "?"; } return Count(ingredients, "Zutat", "Zutaten") + " und " + Count(recipes, "Rezept", "Rezepte") + " vergessen?"; } public static string Biome(string fileName) { string text = "$biome_" + fileName.Replace(" ", "").ToLowerInvariant(); string text2 = Localization.instance.Localize(text); if (!text2.StartsWith("[") && !(text2 == text)) { return text2; } return fileName; } private static string Count(int count, string singular, string plural) { return $"{count} {((count == 1) ? singular : plural)}"; } } [BepInPlugin("de.evabs.valheim.waitwhat", "Wait What?", "1.0.2")] public class WaitWhatPlugin : BaseUnityPlugin { public const string PluginGuid = "de.evabs.valheim.waitwhat"; public const string PluginName = "Wait What?"; public const string PluginVersion = "1.0.2"; private const string IngredientFileName = "WaitWhat.ingredients.txt"; private ConfigEntry<KeyboardShortcut> _toggleKey; private Harmony _harmony; private RecipeWindow _window; private void Awake() { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown _toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "ToggleKey", new KeyboardShortcut((KeyCode)102, (KeyCode[])(object)new KeyCode[2] { (KeyCode)306, (KeyCode)308 }), "Opens and closes the Wait What? window."); string ingredientFile = Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), "WaitWhat.ingredients.txt"); _window = new RecipeWindow(ingredientFile, ((BaseUnityPlugin)this).Logger); InputBlockPatches.ShortcutActive = delegate { //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) KeyboardShortcut value = _toggleKey.Value; return ((KeyboardShortcut)(ref value)).IsDown() || ((KeyboardShortcut)(ref value)).IsPressed() || ((KeyboardShortcut)(ref value)).IsUp(); }; _harmony = new Harmony("de.evabs.valheim.waitwhat"); _harmony.PatchAll(typeof(WaitWhatPlugin).Assembly); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } } private void Update() { //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) if (_window.IsOpen && !CanStayOpen()) { _window.Close(); return; } KeyboardShortcut value = _toggleKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { if (_window.IsOpen) { _window.Close(); } else if (CanOpen()) { _window.Open(); } } } private void LateUpdate() { if (_window.IsOpen) { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } private void OnGUI() { _window.Draw(); } private static bool CanStayOpen() { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return !((Character)Player.m_localPlayer).IsDead(); } return false; } private bool CanOpen() { if (!CanStayOpen() || !Object.op_Implicit((Object)(object)ObjectDB.instance)) { return false; } if (InputBlockPatches.Unblocked(() => Menu.IsVisible() || Console.IsVisible() || TextInput.IsVisible() || Minimap.InTextInput())) { return false; } if (Object.op_Implicit((Object)(object)Chat.instance) && Chat.instance.HasFocus()) { return false; } if (InventoryGui.IsVisible()) { InventoryGui.instance.Hide(); } if (StoreGui.IsVisible()) { StoreGui.instance.Hide(); } if (Object.op_Implicit((Object)(object)TextViewer.instance) && TextViewer.instance.IsVisible()) { TextViewer.instance.Hide(); } if (Hud.IsPieceSelectionVisible()) { Hud.HidePieceSelection(); } if (Minimap.IsOpen()) { Minimap.instance.SetMapMode((MapMode)1); } return true; } }