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 SimpleFoodSorting v1.0.0
SimpleFoodSorting.dll
Decompiled a day agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Bootstrap; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("SimpleFoodSorting")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("SimpleFoodSorting")] [assembly: AssemblyTitle("SimpleFoodSorting")] [assembly: AssemblyVersion("1.0.0.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [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 SimpleFoodSorting { internal static class FoodSort { private class Entry { public object Item; public int Index; public SharedData Food; public float Key; public float Rest; public string Name; } internal const int Health = 0; internal const int Stamina = 1; internal const int Eitr = 2; internal static readonly bool[] Active = new bool[3]; private static Dictionary<string, SharedData> cookedInto; private static ZNetScene cookedIntoScene; internal static bool AnyActive { get { if (!Active[0] && !Active[1]) { return Active[2]; } return true; } } internal static bool HasFood { get; private set; } internal static bool HasEitr { get; private set; } internal static float MaxSum { get; private set; } internal static void Scan(List<Recipe> recipes, CraftingStation station) { HasFood = (HasEitr = false); MaxSum = 0f; if (recipes == null || !Object.op_Implicit((Object)(object)station)) { return; } foreach (Recipe recipe in recipes) { SharedData val = FoodOf(recipe); if (val != null) { MaxSum = Mathf.Max(MaxSum, Sum(val)); if (Object.op_Implicit((Object)(object)recipe.m_craftingStation) && !(recipe.m_craftingStation.m_name != station.m_name)) { HasFood = true; HasEitr |= val.m_foodEitr > 0f; } } } if (!HasEitr) { Active[2] = false; } } internal static void Clear() { bool[] active = Active; bool flag; Active[1] = (flag = (Active[2] = false)); active[0] = flag; } internal static SharedData FoodOf(Recipe recipe) { SharedData val = ((!Object.op_Implicit((Object)(object)recipe) || !Object.op_Implicit((Object)(object)recipe.m_item)) ? null : recipe.m_item.m_itemData?.m_shared); if (val == null) { return null; } BuildCookedInto(); if (cookedInto.TryGetValue(val.m_name, out var value) && IsFood(value)) { return value; } if (!IsFood(val)) { return null; } return val; } private static bool IsFood(SharedData s) { if (!(s.m_food > 0f) && !(s.m_foodStamina > 0f)) { return s.m_foodEitr > 0f; } return true; } internal static float Value(SharedData s, int stat) { return stat switch { 1 => s.m_foodStamina, 0 => s.m_food, _ => s.m_foodEitr, }; } internal static float Sum(SharedData s) { return s.m_food + s.m_foodStamina + s.m_foodEitr; } private static void BuildCookedInto() { ZNetScene instance = ZNetScene.instance; if (cookedInto != null && (Object)(object)cookedIntoScene == (Object)(object)instance) { return; } cookedInto = new Dictionary<string, SharedData>(); cookedIntoScene = instance; if ((Object)(object)instance == (Object)null) { return; } CookingStation val = default(CookingStation); Fermenter val2 = default(Fermenter); foreach (GameObject prefab in instance.m_prefabs) { if (!Object.op_Implicit((Object)(object)prefab)) { continue; } if (prefab.TryGetComponent<CookingStation>(ref val)) { foreach (ItemConversion item in val.m_conversion) { Add(item.m_from, item.m_to); } } if (!prefab.TryGetComponent<Fermenter>(ref val2)) { continue; } foreach (ItemConversion item2 in val2.m_conversion) { Add(item2.m_from, item2.m_to); } } static void Add(ItemDrop from, ItemDrop to) { if (Object.op_Implicit((Object)(object)from) && Object.op_Implicit((Object)(object)to) && !cookedInto.ContainsKey(from.m_itemData.m_shared.m_name)) { cookedInto[from.m_itemData.m_shared.m_name] = to.m_itemData.m_shared; } } } internal static void Sort(IList list, Func<object, Recipe> recipeOf) { if (!AnyActive || list == null || list.Count < 2) { return; } List<Entry> list2 = new List<Entry>(list.Count); for (int i = 0; i < list.Count; i++) { Entry entry = new Entry { Item = list[i], Index = i }; Recipe val = recipeOf(entry.Item); entry.Food = FoodOf(val); if (entry.Food != null) { for (int j = 0; j < 3; j++) { if (Active[j]) { entry.Key += Value(entry.Food, j); } else { entry.Rest += Value(entry.Food, j); } } entry.Name = Localization.instance.Localize(val.m_item.m_itemData.m_shared.m_name); } list2.Add(entry); } list2.Sort(Compare); for (int k = 0; k < list2.Count; k++) { list[k] = list2[k].Item; } } private static int Compare(Entry a, Entry b) { if (a.Food == null != (b.Food == null)) { if (a.Food != null) { return -1; } return 1; } if (a.Food != null) { int num = b.Key.CompareTo(a.Key); if (num == 0) { num = b.Rest.CompareTo(a.Rest); } if (num == 0) { num = StringComparer.CurrentCultureIgnoreCase.Compare(a.Name, b.Name); } if (num != 0) { return num; } } return a.Index.CompareTo(b.Index); } } [BepInPlugin("Iteravio.SimpleFoodSorting", "SimpleFoodSorting", "1.0.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string PluginGuid = "Iteravio.SimpleFoodSorting"; public const string PluginName = "SimpleFoodSorting"; public const string PluginVersion = "1.0.0"; internal const string AaaGuid = "Azumatt.AzuAntiArthriticCrafting"; internal static ManualLogSource Log; private const string StatBarsKey = "Iteravio.SimpleFoodSorting.ShowStatBars"; internal static bool AaaPresent; internal static bool AaaHooked; private static FieldInfo aaaPage; internal static readonly FieldInfo AvailableRecipes = AccessTools.Field(typeof(InventoryGui), "m_availableRecipes"); private static readonly PropertyInfo PairRecipe = AccessTools.Property(AccessTools.Inner(typeof(InventoryGui), "RecipeDataPair"), "Recipe"); private static readonly PropertyInfo PairElement = AccessTools.Property(AccessTools.Inner(typeof(InventoryGui), "RecipeDataPair"), "InterfaceElement"); internal static readonly Func<object, Recipe> RecipeOf = (object pair) => (Recipe)PairRecipe.GetValue(pair, null); internal static bool ShowStatBars { get { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { return Player.m_localPlayer.m_customData.ContainsKey("Iteravio.SimpleFoodSorting.ShowStatBars"); } return false; } set { if (Object.op_Implicit((Object)(object)Player.m_localPlayer)) { if (value) { Player.m_localPlayer.m_customData["Iteravio.SimpleFoodSorting.ShowStatBars"] = "1"; } else { Player.m_localPlayer.m_customData.Remove("Iteravio.SimpleFoodSorting.ShowStatBars"); } } } } internal static GameObject ElementOf(object pair) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Expected O, but got Unknown return (GameObject)PairElement.GetValue(pair, null); } private void Awake() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Harmony val = new Harmony("Iteravio.SimpleFoodSorting"); val.PatchAll(); AaaPresent = Chainloader.PluginInfos.ContainsKey("Azumatt.AzuAntiArthriticCrafting"); if (AaaPresent) { HookAaa(val); } } private static void HookAaa(Harmony harmony) { //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown MethodInfo methodInfo = AccessTools.Method("AzuAntiArthriticCrafting.Patches.Filtering.FilterManager:Apply", (Type[])null, (Type[])null); aaaPage = AccessTools.Field(AccessTools.TypeByName("AzuAntiArthriticCrafting.Patches.PaginatorPatches"), "CraftingWindowPage"); if (methodInfo == null) { Log.LogError((object)"This AAA Crafting version has no FilterManager.Apply to hook, so the food sort buttons are disabled."); return; } harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(Plugin), "AaaApplyPrefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); AaaHooked = true; Log.LogInfo((object)"AAA Crafting found: sorting its full recipe list before it splits it into pages."); } private static void AaaApplyPrefix(object[] __args) { InventoryGui instance = InventoryGui.instance; if (Object.op_Implicit((Object)(object)instance) && instance.InCraftTab() && FoodSort.HasFood) { FoodSort.Sort(__args[0] as IList, RecipeOf); } } internal static void ResetAaaPage() { aaaPage?.SetValue(null, 1); } } [HarmonyPatch(typeof(InventoryGui), "UpdateRecipeList")] internal static class UpdateRecipeListPatch { [HarmonyPriority(800)] [HarmonyBefore(new string[] { "Azumatt.AzuAntiArthriticCrafting" })] private static void Prefix(InventoryGui __instance, List<Recipe> recipes) { FoodSort.Scan(__instance.InCraftTab() ? recipes : null, Object.op_Implicit((Object)(object)Player.m_localPlayer) ? Player.m_localPlayer.GetCurrentCraftingStation() : null); } private static void Postfix(InventoryGui __instance) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) if (!Plugin.AaaPresent && FoodSort.AnyActive && FoodSort.HasFood && __instance.InCraftTab()) { IList list = (IList)Plugin.AvailableRecipes.GetValue(__instance); FoodSort.Sort(list, Plugin.RecipeOf); for (int i = 0; i < list.Count; i++) { ((RectTransform)Plugin.ElementOf(list[i]).transform).anchoredPosition = new Vector2(0f, (float)i * (0f - __instance.m_recipeListSpace)); } } } } [HarmonyPatch(typeof(InventoryGui), "UpdateCraftingPanel")] internal static class UpdateCraftingPanelPatch { private static void Postfix(InventoryGui __instance) { SortButtons.Refresh(__instance); } } [HarmonyPatch(typeof(InventoryGui), "Show")] internal static class ShowPatch { private static void Prefix() { FoodSort.Clear(); } } [HarmonyPatch(typeof(InventoryGui), "Awake")] internal static class AwakePatch { [HarmonyPriority(0)] [HarmonyAfter(new string[] { "Azumatt.AzuAntiArthriticCrafting" })] private static void Postfix(InventoryGui __instance) { SortButtons.Create(__instance); } } internal static class SortButtons { private static readonly string[] Letters = new string[3] { "H", "S", "E" }; private static readonly Color[] LetterColors = (Color[])(object)new Color[3] { Hex("ff0000"), Hex("ffff00"), Hex("00ffff") }; private static readonly Color[] BarColors = (Color[])(object)new Color[3] { Hex("e03a32", 0.75f), Hex("e8d23c", 0.75f), Hex("2fd2dc", 0.75f) }; private static readonly Color BarTrack = new Color(0f, 0f, 0f, 0.35f); private const float BarWidth = 54f; private const float BarHeight = 5f; private const string BarName = "SimpleFoodSorting_StatBar"; private const float GapBelowRepair = 16f; private const float Gap = 6f; private const float ToggleScale = 0.6f; private static RectTransform column; private static readonly Button[] Buttons = (Button[])(object)new Button[3]; private static readonly GameObject[] Glows = (GameObject[])(object)new GameObject[3]; private static Button barToggle; private static GameObject barToggleGlow; private static Action<InventoryGui, bool> updateCraftingPanel; private static Action<InventoryGui, int, bool> setRecipe; internal static void Create(InventoryGui gui) { //IL_00b8: 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_01a6: Expected O, but got Unknown //IL_025b: Unknown result type (might be due to invalid IL or missing references) //IL_026c: Expected O, but got Unknown //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_022b: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02e6: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_0321: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_033c: Unknown result type (might be due to invalid IL or missing references) //IL_0341: Unknown result type (might be due to invalid IL or missing references) if (updateCraftingPanel == null) { updateCraftingPanel = AccessTools.MethodDelegate<Action<InventoryGui, bool>>(AccessTools.Method(typeof(InventoryGui), "UpdateCraftingPanel", (Type[])null, (Type[])null), (object)null, true); } if (setRecipe == null) { setRecipe = AccessTools.MethodDelegate<Action<InventoryGui, int, bool>>(AccessTools.Method(typeof(InventoryGui), "SetRecipe", new Type[2] { typeof(int), typeof(bool) }, (Type[])null), (object)null, true); } if (!Object.op_Implicit((Object)(object)gui.m_repairButton)) { Plugin.Log.LogError((object)"No repair button to build the food sort buttons from; they're disabled."); return; } column = new GameObject("SimpleFoodSorting", new Type[1] { typeof(RectTransform) }).GetComponent<RectTransform>(); ((Transform)column).SetParent(((Component)gui.m_repairButton).transform.parent, false); GameObject clickSfx = ((!Object.op_Implicit((Object)(object)gui.m_tabCraft)) ? null : ((Component)gui.m_tabCraft).GetComponent<ButtonSfx>()?.m_sfxPrefab); TMP_Text val = (Object.op_Implicit((Object)(object)gui.m_craftButton) ? ((Component)gui.m_craftButton).GetComponentInChildren<TMP_Text>(true) : null); for (int i = 0; i < 3; i++) { int stat = i; Buttons[i] = MakeButton(gui, "Sort" + Letters[i], clickSfx, (UnityAction)delegate { Toggle(gui, stat); }, out Glows[i], out var text); ((Component)text).gameObject.SetActive(true); if (Object.op_Implicit((Object)(object)val)) { text.font = val.font; text.fontSharedMaterial = val.fontSharedMaterial; } text.text = Letters[i]; ((Graphic)text).color = LetterColors[i]; text.enableAutoSizing = false; text.fontStyle = (FontStyles)1; text.alignment = (TextAlignmentOptions)514; text.overflowMode = (TextOverflowModes)0; ((Graphic)text).raycastTarget = false; Stretch((RectTransform)text.transform, 0f); } barToggle = MakeButton(gui, "StatBars", clickSfx, (UnityAction)delegate { ToggleBars(gui); }, out barToggleGlow, out var text2); Object.Destroy((Object)(object)((Component)text2).gameObject); for (int num = 0; num < 3; num++) { RectTransform component = new GameObject("Glyph" + Letters[num], new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(((Component)barToggle).transform, false); component.anchorMin = new Vector2(0.24f, 0.62f - (float)num * 0.18f); component.anchorMax = new Vector2(0.76f - (float)num * 0.14f, 0.72f - (float)num * 0.18f); Vector2 offsetMin = (component.offsetMax = Vector2.zero); component.offsetMin = offsetMin; Image component2 = ((Component)component).GetComponent<Image>(); ((Graphic)component2).color = Opaque(BarColors[num]); ((Graphic)component2).raycastTarget = false; } ((Component)column).gameObject.SetActive(false); } private static Button MakeButton(InventoryGui gui, string name, GameObject clickSfx, UnityAction onClick, out GameObject glow, out TMP_Text text) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: 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_0047: 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) //IL_004e: 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_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Expected O, but got Unknown //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_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) GameObject val = Object.Instantiate<GameObject>(((Component)gui.m_repairButton).gameObject, (Transform)(object)column, false); ((Object)val).name = name; text = Strip(val, out glow); RectTransform val2 = (RectTransform)val.transform; Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor(0.5f, 1f); val2.pivot = val3; Vector2 anchorMin = (val2.anchorMax = val3); val2.anchorMin = anchorMin; Button component = val.GetComponent<Button>(); component.onClick = new ButtonClickedEvent(); ((UnityEvent)component.onClick).AddListener(onClick); Navigation navigation = default(Navigation); ((Navigation)(ref navigation)).mode = (Mode)0; ((Selectable)component).navigation = navigation; ((Selectable)component).interactable = true; if (Object.op_Implicit((Object)(object)clickSfx)) { val.AddComponent<ButtonSfx>().m_sfxPrefab = clickSfx; } if (Object.op_Implicit((Object)(object)glow)) { Transform transform = glow.transform; transform.localScale += new Vector3(0.25f, 0.25f, 0.25f); Graphic[] componentsInChildren = glow.GetComponentsInChildren<Graphic>(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].raycastTarget = false; } glow.SetActive(false); } return component; } private static TMP_Text Strip(GameObject go, out GameObject glow) { //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) Transform val = go.transform.Find("Text"); Transform val2 = go.transform.Find("Glow"); glow = (Object.op_Implicit((Object)(object)val2) ? ((Component)val2).gameObject : null); foreach (Transform item in ((IEnumerable)go.transform).Cast<Transform>().ToList()) { if ((Object)(object)item != (Object)(object)val && (Object)(object)item != (Object)(object)val2) { Object.DestroyImmediate((Object)(object)((Component)item).gameObject); } } Component[] components = go.GetComponents<Component>(); foreach (Component val3 in components) { if (!(val3 is Transform) && !(val3 is CanvasRenderer) && !(val3 is Image) && !(val3 is Button) && !(val3 is ButtonSfx)) { Object.DestroyImmediate((Object)(object)val3); } } TMP_Text result = default(TMP_Text); if (Object.op_Implicit((Object)(object)val) && ((Component)val).TryGetComponent<TMP_Text>(ref result)) { return result; } GameObject val4 = new GameObject("Text", new Type[2] { typeof(RectTransform), typeof(TextMeshProUGUI) }); val4.transform.SetParent(go.transform, false); TextMeshProUGUI component = val4.GetComponent<TextMeshProUGUI>(); ((TMP_Text)component).font = InventoryGui.instance.m_recipeName.font; return (TMP_Text)(object)component; } internal static void Refresh(InventoryGui gui) { if (!Object.op_Implicit((Object)(object)column)) { return; } bool flag = gui.InCraftTab() && FoodSort.HasFood && (!Plugin.AaaPresent || Plugin.AaaHooked); ((Component)column).gameObject.SetActive(flag); if (flag) { ((Component)Buttons[2]).gameObject.SetActive(FoodSort.HasEitr); Place(gui); for (int i = 0; i < 3; i++) { if (Object.op_Implicit((Object)(object)Glows[i])) { Glows[i].SetActive(FoodSort.Active[i]); } } if (Object.op_Implicit((Object)(object)barToggleGlow)) { barToggleGlow.SetActive(Plugin.ShowStatBars); } } UpdateBars(gui, flag && Plugin.ShowStatBars); } private static void Place(InventoryGui gui) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Expected O, but got Unknown //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_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_005a: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0070: 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_0079: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: 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_014e: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Unknown result type (might be due to invalid IL or missing references) //IL_0172: 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_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) RectTransform val = (RectTransform)((Component)gui.m_repairButton).transform; Rect rect = val.rect; float num = Mathf.Round(((Rect)(ref rect)).width * 0.8f); RectTransform obj = column; Vector2 anchorMin = (column.anchorMax = val.anchorMin); obj.anchorMin = anchorMin; column.pivot = new Vector2(0.5f, 1f); RectTransform obj2 = column; Vector3 localPosition = ((Transform)val).localPosition; rect = val.rect; float x = ((Rect)(ref rect)).center.x; rect = val.rect; ((Transform)obj2).localPosition = localPosition + new Vector3(x, ((Rect)(ref rect)).yMin - 16f, 0f); float num2 = 0f; for (int i = 0; i < 3; i++) { if (((Component)Buttons[i]).gameObject.activeSelf) { RectTransform val2 = (RectTransform)((Component)Buttons[i]).transform; val2.sizeDelta = new Vector2(num, num); val2.anchoredPosition = new Vector2(0f, 0f - num2); ((Component)Buttons[i]).GetComponentInChildren<TMP_Text>(true).fontSize = Mathf.Round(num * 0.55f); num2 += num + 6f; } } float num3 = Mathf.Round(num * 0.6f); RectTransform val3 = (RectTransform)((Component)barToggle).transform; val3.sizeDelta = new Vector2(num3, num3); val3.anchoredPosition = new Vector2(0f, 0f - num2); column.sizeDelta = new Vector2(num, num2 + num3); } private static void UpdateBars(InventoryGui gui, bool on) { //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Expected O, but got Unknown //IL_00cc: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_0105: 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) IList list = (IList)Plugin.AvailableRecipes.GetValue(gui); if (list == null) { return; } foreach (object item in list) { GameObject val = Plugin.ElementOf(item); if (!Object.op_Implicit((Object)(object)val)) { continue; } Transform val2 = val.transform.Find("SimpleFoodSorting_StatBar"); SharedData val3 = ((on && FoodSort.MaxSum > 0f) ? FoodSort.FoodOf(Plugin.RecipeOf(item)) : null); if (val3 == null) { if (Object.op_Implicit((Object)(object)val2)) { ((Component)val2).gameObject.SetActive(false); } continue; } if (!Object.op_Implicit((Object)(object)val2)) { val2 = CreateBar(val.transform); } ((Component)val2).gameObject.SetActive(true); LayoutBar((RectTransform)val.transform, (RectTransform)val2); float num = 0f; for (int i = 0; i < 3; i++) { RectTransform val4 = (RectTransform)val2.GetChild(i); float num2 = 54f * FoodSort.Value(val3, i) / FoodSort.MaxSum; val4.anchoredPosition = new Vector2(num, 0f); val4.sizeDelta = new Vector2(num2, 0f); num += num2; } } } private static Transform CreateBar(Transform element) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) RectTransform component = new GameObject("SimpleFoodSorting_StatBar", new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent<RectTransform>(); ((Transform)component).SetParent(element, false); Image component2 = ((Component)component).GetComponent<Image>(); ((Graphic)component2).color = BarTrack; ((Graphic)component2).raycastTarget = false; for (int i = 0; i < 3; i++) { RectTransform component3 = new GameObject(Letters[i], new Type[2] { typeof(RectTransform), typeof(Image) }).GetComponent<RectTransform>(); ((Transform)component3).SetParent((Transform)(object)component, false); component3.anchorMin = new Vector2(0f, 0f); component3.anchorMax = new Vector2(0f, 1f); component3.pivot = new Vector2(0f, 0.5f); Image component4 = ((Component)component3).GetComponent<Image>(); ((Graphic)component4).color = BarColors[i]; ((Graphic)component4).raycastTarget = false; } return (Transform)(object)component; } private static void LayoutBar(RectTransform element, RectTransform bar) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: 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_003d: Expected O, but got Unknown //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_0058: 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_005f: 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_0076: Unknown result type (might be due to invalid IL or missing references) Transform val = ((Transform)element).Find("name"); bar.sizeDelta = new Vector2(54f, 5f); Vector2 val3 = default(Vector2); if (Object.op_Implicit((Object)(object)val) && ((Component)val).gameObject.activeSelf) { RectTransform val2 = (RectTransform)val; ((Vector2)(ref val3))..ctor(0f, 0f); bar.pivot = val3; Vector2 anchorMin = (bar.anchorMax = val3); bar.anchorMin = anchorMin; bar.anchoredPosition = new Vector2(val2.anchoredPosition.x, 3f); } else { ((Vector2)(ref val3))..ctor(0.5f, 0f); bar.pivot = val3; Vector2 anchorMin = (bar.anchorMax = val3); bar.anchorMin = anchorMin; bar.anchoredPosition = new Vector2(0f, 6f); } ((Transform)bar).SetAsLastSibling(); } private static void Toggle(InventoryGui gui, int stat) { FoodSort.Active[stat] = !FoodSort.Active[stat]; Plugin.ResetAaaPage(); updateCraftingPanel(gui, arg2: false); setRecipe(gui, 0, arg3: true); if (!Plugin.AaaPresent && Object.op_Implicit((Object)(object)gui.m_recipeListScroll)) { gui.m_recipeListScroll.value = 1f; } } private static void ToggleBars(InventoryGui gui) { Plugin.ShowStatBars = !Plugin.ShowStatBars; Refresh(gui); } private static void Stretch(RectTransform rt, float inset) { //IL_0001: 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_0019: 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) rt.anchorMin = Vector2.zero; rt.anchorMax = Vector2.one; rt.offsetMin = new Vector2(inset, inset); rt.offsetMax = new Vector2(0f - inset, 0f - inset); } private static Color Hex(string rgb, float alpha = 1f) { //IL_001b: 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_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); Color result = (ColorUtility.TryParseHtmlString("#" + rgb, ref val) ? val : Color.white); result.a = alpha; return result; } private static Color Opaque(Color c) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) c.a = 1f; return c; } } }