using System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using Eremite; using Eremite.Buildings.UI; using Eremite.Model; using Eremite.View.HUD; using Eremite.View.Popups.Recipes; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: AssemblyCompany("VerticalGoodsHUD")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyDescription("Example Mod for Against The Storm")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0+d6ada77561ccfe85ca4c2c807fd24c8c3fc0d51c")] [assembly: AssemblyProduct("VerticalGoodsHUD")] [assembly: AssemblyTitle("VerticalGoodsHUD")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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 VerticalGoodsHUD { internal static class GoodsHUDCategoryState { internal static GoodsCategoryHUDSlot RawFoodSlot; internal static GoodsCategoryHUDSlot ComplexFoodSlot; internal static GoodsCategoryHUDSlot RawCraftSlot; internal static GoodsCategoryHUDSlot ComplexCraftSlot; } [HarmonyPatch(typeof(GoodsHUD), "SetUpCategories")] internal static class GoodsHUD_SetUpCategories_Patch { private static readonly MethodInfo GetOrCreateMethod = typeof(GameMB).GetMethod("GetOrCreate", BindingFlags.Instance | BindingFlags.NonPublic).MakeGenericMethod(typeof(GoodsCategoryHUDSlot)); private static bool Prefix(GoodsHUD __instance, List ___categoriesSlots) { //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Expected O, but got Unknown GoodCategoryModel[] goodsCategories = MB.Settings.GoodsCategories; if (goodsCategories == null || goodsCategories.Length == 0) { return true; } List list = new List(); GoodCategoryModel val = null; GoodCategoryModel val2 = null; GoodCategoryModel[] array = goodsCategories; foreach (GoodCategoryModel val3 in array) { if (!((Object)(object)val3 == (Object)null) && val3.showOnHUD) { string text = (((Object)(object)val3.icon != (Object)null) ? ((Object)val3.icon).name : string.Empty); if (text == "Icon_UI_CategoryFood" && (Object)(object)val == (Object)null) { val = val3; list.Add(val3); list.Add(val3); } else if (text == "Icon_UI_CategoryCrafting" && (Object)(object)val2 == (Object)null) { val2 = val3; list.Add(val3); list.Add(val3); } else { list.Add(val3); } } } for (int j = 1; j < ___categoriesSlots.Count; j++) { if ((Object)(object)___categoriesSlots[j] != (Object)null) { ((Component)___categoriesSlots[j]).gameObject.SetActive(false); } } int num = 1; GoodsHUDCategoryState.RawFoodSlot = null; GoodsHUDCategoryState.ComplexFoodSlot = null; GoodsHUDCategoryState.RawCraftSlot = null; GoodsHUDCategoryState.ComplexCraftSlot = null; int num2 = 0; int num3 = 0; foreach (GoodCategoryModel item in list) { GoodsCategoryHUDSlot val4 = (GoodsCategoryHUDSlot)GetOrCreateMethod.Invoke(__instance, new object[2] { ___categoriesSlots, num++ }); val4.SetUp(item, (Action)__instance.OnCategoryClicked, (Action)__instance.RebuildLayout); ((Component)val4).gameObject.SetActive(true); string text2 = (((Object)(object)item.icon != (Object)null) ? ((Object)item.icon).name : string.Empty); if (text2 == "Icon_UI_CategoryFood") { switch (num2) { case 0: GoodsHUDCategoryState.RawFoodSlot = val4; break; case 1: GoodsHUDCategoryState.ComplexFoodSlot = val4; break; } num2++; } else if (text2 == "Icon_UI_CategoryCrafting") { switch (num3) { case 0: GoodsHUDCategoryState.RawCraftSlot = val4; break; case 1: GoodsHUDCategoryState.ComplexCraftSlot = val4; break; } num3++; } } __instance.RebuildLayout(); return false; } } internal static class GoodsHUDClassification { private static readonly HashSet RawFoodIds = new HashSet(StringComparer.OrdinalIgnoreCase) { "Mushrooms", "Roots", "Vegetables", "Fish", "Meat", "Eggs", "Insects", "Berries" }; private static readonly HashSet RawCraftIds = new HashSet(StringComparer.OrdinalIgnoreCase) { "Clay", "Stone", "PlantFibre", "Reeds", "Algae", "Scales", "Leather", "Grain", "Herbs", "Resin", "Salt", "CopperOre", "Sparkdew" }; private static readonly List CustomOrder = new List { "Mushrooms", "Roots", "Vegetables", "Fish", "Meat", "Eggs", "Insects", "Berries", "Jerky", "Porridge", "Paste", "Skewers", "Biscuits", "Pie", "PickledGoods", "Planks", "Fabric", "Bricks", "Pipe", "Parts", "HearthParts", "Fertilizer", "Boots", "Coats", "Ale", "TrainingGear", "Incense", "Scrolls", "TutorialScrolls", "Wine", "Tea", "Clay", "Stone", "PlantFibre", "Reeds", "Algae", "Scales", "Leather", "Grain", "Herbs", "Resin", "Salt", "CopperOre", "Sparkdew", "Flour", "Pottery", "Barrels", "Waterskin", "Pigment", "CopperBar", "CrystalizedDew", "Amber", "PackofProvisions", "PackofBuildingMaterials", "PackofCrops", "PackofLuxuryGoods", "PackofTradeGoods", "AncientTablet", "Fuel Core", "_MetaArtifacts", "_MetaFoodStockpiles", "_MetaMachinery", "Wood", "Oil", "Sea Marrow", "Coal", "SimpleTools", "BlightFuel", "Fuel Rod" }; public static bool IsRawFood(GoodModel g) { return RawFoodIds.Contains(g.consoleId); } public static bool IsComplexFood(GoodModel g) { return !IsRawFood(g); } public static bool IsRawCraft(GoodModel g) { return RawCraftIds.Contains(g.consoleId); } public static bool IsComplexCraft(GoodModel g) { return !IsRawCraft(g); } public static IEnumerable OrderGoods(IEnumerable goods) { return goods.OrderBy(delegate(GoodModel g) { int num = CustomOrder.IndexOf(g.consoleId); return (num >= 0) ? num : int.MaxValue; }).ThenBy((GoodModel g) => (g.displayName != null) ? g.displayName.GetText() : ((SO)g).Name); } } internal static class GoodsHUDColumnFactory { public static RectTransform CreateColumn(string name, GameObject parent, RectTransform iconRT, float columnXShift, float iconToColumnGap, float verticalSpacing) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown //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_0046: 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_005d: 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_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: 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_00b6: 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_00d8: 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_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0165: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parent.transform, false); RectTransform component = val.GetComponent(); Rect rect = iconRT.rect; float num = ((Rect)(ref rect)).width * (iconRT.pivot.x - 0.5f); rect = iconRT.rect; Vector3 val2 = ((Transform)iconRT).TransformPoint(new Vector3(num, ((Rect)(ref rect)).height * (iconRT.pivot.y - 0.5f), 0f)); Vector3 val3 = parent.transform.InverseTransformPoint(val2); component.anchorMin = new Vector2(0.5f, 1f); component.anchorMax = new Vector2(0.5f, 1f); component.pivot = new Vector2(0.5f, 1f); float num2 = val3.x + columnXShift; float y = val3.y; rect = iconRT.rect; component.anchoredPosition = new Vector2(num2, y - ((Rect)(ref rect)).height - iconToColumnGap); rect = iconRT.rect; component.SetSizeWithCurrentAnchors((Axis)0, ((Rect)(ref rect)).width); VerticalLayoutGroup val4 = val.AddComponent(); ((LayoutGroup)val4).childAlignment = (TextAnchor)1; ((HorizontalOrVerticalLayoutGroup)val4).spacing = verticalSpacing; ((HorizontalOrVerticalLayoutGroup)val4).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)val4).childControlWidth = false; ((HorizontalOrVerticalLayoutGroup)val4).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val4).childForceExpandWidth = false; LayoutElement val5 = val.AddComponent(); rect = iconRT.rect; val5.preferredWidth = ((Rect)(ref rect)).width; return component; } public static void AddRawComplexLabel(GoodsCategoryHUDSlot slot, RectTransform iconRT, int index) { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Expected O, but got Unknown //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: 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_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) if (1 == 0) { } string text; switch (index) { case 1: case 5: text = "Raw"; break; case 2: case 6: text = "Com"; break; default: text = null; break; } if (1 == 0) { } string text2 = text; if (text2 != null) { GameObject val = new GameObject("RC_Label", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(((Component)slot).transform, false); val.transform.SetSiblingIndex(((Component)iconRT).transform.GetSiblingIndex() + 1); RectTransform component = val.GetComponent(); Rect rect = iconRT.rect; Vector3 val2 = ((Transform)iconRT).TransformPoint(new Vector3(0f, ((Rect)(ref rect)).height * 0.35f, 0f)); Vector3 localPosition = ((Component)slot).transform.InverseTransformPoint(val2); ((Transform)component).localPosition = localPosition; component.sizeDelta = new Vector2(40f, 40f); TextMeshProUGUI val3 = val.AddComponent(); ((TMP_Text)val3).text = text2; ((TMP_Text)val3).fontSize = 14f; ((Graphic)val3).color = Color.white; ((TMP_Text)val3).alignment = (TextAlignmentOptions)514; ((TMP_Text)val3).enableWordWrapping = false; } } } [HarmonyPatch(typeof(GoodsHUD), "SetUp")] internal static class GoodsHUD_SetUp_Patch { private static void Postfix(GoodsHUD __instance) { GoodsHUDVerticalController.Init(__instance); } } [HarmonyPatch(typeof(GoodsHUD), "OnCategoryClicked")] internal static class GoodsHUD_OnCategoryClicked_Patch { private static bool Prefix(GoodsHUD __instance, GoodsCategoryHUDSlot slot) { GoodsHUDVerticalController.ToggleCategory(slot); return false; } } [HarmonyPatch(typeof(GoodsHUD), "ShowGoods")] internal static class GoodsHUD_ShowGoods_Patch { private static bool Prefix(GoodsHUD __instance, List goods) { GoodsHUDVerticalController.RebuildAllColumns(); return false; } } [HarmonyPatch(typeof(GoodsHUD), "OnGoodDiscovered")] internal static class GoodsHUD_OnGoodDiscovered_Patch { private static void Postfix() { GoodsHUDVerticalController.OnGoodDiscovered(); } } [HarmonyPatch(typeof(GoodsHUD), "OnTrackingChanged")] internal static class GoodsHUD_OnTrackingChanged_Patch { private static void Postfix() { GoodsHUDVerticalController.OnTrackingChanged(); } } internal static class GoodsHUDVerticalBuilder { public static void BuildColumns(GameObject goodsParent, List categorySlots, Dictionary columns, Dictionary columnVisible, Dictionary slotIndices, FieldInfo iconField, float columnXShift, float iconToColumnGap, float verticalSpacing) { columns.Clear(); columnVisible.Clear(); slotIndices.Clear(); for (int i = 0; i < categorySlots.Count; i++) { GoodsCategoryHUDSlot val = categorySlots[i]; if (!(val is TrackedGoodsHUDSlot)) { object? value = iconField.GetValue(val); Image val2 = (Image)((value is Image) ? value : null); if (!((Object)(object)val2 == (Object)null)) { RectTransform value2 = GoodsHUDColumnFactory.CreateColumn($"GoodsColumn_{((Object)val).name}_{i}", goodsParent, ((Graphic)val2).rectTransform, columnXShift, iconToColumnGap, verticalSpacing); columns[val] = value2; columnVisible[val] = true; slotIndices[val] = i; GoodsHUDVerticalLayoutRuntime.RegisterSlot(val, i); GoodsHUDColumnFactory.AddRawComplexLabel(val, ((Graphic)val2).rectTransform, i); } } } } public static void BuildTrackedColumn(GameObject goodsParent, List categorySlots, GoodsCategoryHUDSlot trackedSlotKey, Dictionary columns, Dictionary columnVisible, FieldInfo iconField, float columnXShift, float iconToColumnGap, float verticalSpacing, out RectTransform trackedColumn) { trackedColumn = null; if (!((Object)(object)trackedSlotKey == (Object)null)) { GoodsCategoryHUDSlot obj = categorySlots[1]; object? value = iconField.GetValue(obj); Image val = (Image)((value is Image) ? value : null); if (!((Object)(object)val == (Object)null)) { float columnXShift2 = 115f; trackedColumn = GoodsHUDColumnFactory.CreateColumn("GoodsColumn_Tracked", goodsParent, ((Graphic)val).rectTransform, columnXShift2, iconToColumnGap, verticalSpacing); columns[trackedSlotKey] = trackedColumn; columnVisible[trackedSlotKey] = true; } } } public static void BuildTrackedGoods(RectTransform trackedColumn, GoodsCategoryHUDSlot trackedSlotKey, GoodsHUDSlot templateSlot, Sprite counterSprite, float counterShiftX, float counterShiftY, float counterSize, float textShiftX) { if ((Object)(object)trackedColumn == (Object)null) { return; } foreach (string trackedGood in MB.MetaStateService.Gameplay.trackedGoods) { if (GameMB.StorageService.WasDiscovered(trackedGood)) { GoodModel good = MB.Settings.GetGood(trackedGood); if (!((Object)(object)good == (Object)null)) { GoodsHUDVerticalLayout.CreateSlot(trackedColumn, templateSlot, good, counterSprite, counterShiftX, counterShiftY, counterSize, textShiftX); GameObject gameObject = ((Component)((Transform)trackedColumn).GetChild(((Transform)trackedColumn).childCount - 1)).gameObject; AddIngredientClickHandler(gameObject, good); } } } } public static void BuildCategoryGoods(Dictionary columns, Dictionary columnVisible, Dictionary slotIndices, GoodsCategoryHUDSlot trackedSlotKey, GoodsHUDSlot templateSlot, Sprite counterSprite, float counterShiftX, float counterShiftY, float counterSize, float textShiftX) { foreach (KeyValuePair column in columns) { if (column.Key == trackedSlotKey || !columnVisible[column.Key]) { continue; } object key = column.Key; GoodsCategoryHUDSlot val = (GoodsCategoryHUDSlot)((key is GoodsCategoryHUDSlot) ? key : null); if ((Object)(object)val == (Object)null || !slotIndices.TryGetValue(val, out var value)) { continue; } GoodCategoryModel category = val.category; if ((Object)(object)category == (Object)null) { continue; } IEnumerable goods = MB.Settings.Goods.Where((GoodModel g) => (Object)(object)g.category == (Object)(object)category && g.isOnHUD); goods = GoodsHUDClassification.OrderGoods(goods); foreach (GoodModel item in goods) { if (GameMB.StorageService.WasDiscovered(((SO)item).Name) && (value != 1 || GoodsHUDClassification.IsRawFood(item)) && (value != 2 || GoodsHUDClassification.IsComplexFood(item)) && (value != 5 || GoodsHUDClassification.IsRawCraft(item)) && (value != 6 || GoodsHUDClassification.IsComplexCraft(item))) { GoodsHUDVerticalLayout.CreateSlot(column.Value, templateSlot, item, counterSprite, counterShiftX, counterShiftY, counterSize, textShiftX); GameObject gameObject = ((Component)((Transform)column.Value).GetChild(((Transform)column.Value).childCount - 1)).gameObject; AddIngredientClickHandler(gameObject, item); } } } } private static void AddIngredientClickHandler(GameObject slotGO, GoodModel good) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown Image val = slotGO.GetComponent() ?? slotGO.AddComponent(); ((Graphic)val).color = new Color(0f, 0f, 0f, 0f); ((Graphic)val).raycastTarget = true; Button val2 = slotGO.GetComponent