using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Runtime.CompilerServices; using System.Text; using BaseSystem; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using Buff.Debuffs; using GameState; using GameState.StaticStateHolders; using HarmonyLib; using Harvestable; using Harvestable.HarvestableManagerHelper; using Items; using Items.Craft; using Items.Delivery; using Items.Tag; using Items.ValueCountSettings; using Map.MapObjects.PureClass; using Map.MapObjects.PureClass.FamObjects; using R3; using TMPro; using Tax; using UI.SelectableWindow.Managers; using UnityEngine; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.Localization.Components; using UnityEngine.UI; using Utility.LWFApp; using Utility.Localization; [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: AssemblyVersion("0.0.0.0")] namespace LwfTaxLedger; [BepInPlugin("kiyonakanata.lwftaxledger", "LWF Tax Ledger", "1.0.0")] public sealed class TaxLedgerPlugin : BaseUnityPlugin { internal const string PluginGuid = "kiyonakanata.lwftaxledger"; internal const string PluginName = "LWF Tax Ledger"; internal const string PluginVersion = "1.0.0"; internal static ManualLogSource Log; private Harmony _harmony; internal static ConfigEntry Enabled; internal static ConfigEntry FontSize; internal static ConfigEntry Padding; internal static ConfigEntry IconSize; internal static ConfigEntry RowSpacing; internal static ConfigEntry ColumnSpacing; internal static ConfigEntry Indent; internal static ConfigEntry MarkerWidth; internal static ConfigEntry ExpandBreakdown; internal static ConfigEntry ValueWidth; internal static ConfigEntry ResourceWidth; internal static ConfigEntry ScrollStep; internal static ConfigEntry NameShrink; internal static ConfigEntry BackgroundDarken; internal static ConfigEntry ScrollbarWidth; internal static ConfigEntry ResourceColumns; internal static ConfigEntry NumberGap; internal static ConfigEntry SubStep; internal static ConfigEntry DevMode; internal static ConfigEntry PreviewKey; internal static ConfigEntry DumpKey; internal static ConfigEntry DevTaxes; private Key _previewKeyCode; private Key _dumpKeyCode; private int _dummySet; private float _nextResultPoll; private void Awake() { //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f3: Unknown result type (might be due to invalid IL or missing references) //IL_0305: Unknown result type (might be due to invalid IL or missing references) //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Unknown result type (might be due to invalid IL or missing references) //IL_031f: Expected O, but got Unknown Log = ((BaseUnityPlugin)this).Logger; Enabled = ((BaseUnityPlugin)this).Config.Bind("1. General", "Enabled", true, ""); FontSize = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Font size", 24, ""); Padding = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Padding", 12, ""); IconSize = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Icon size", 28, ""); RowSpacing = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Row spacing", 2, ""); ColumnSpacing = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Column spacing", 6, ""); Indent = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Item indent", 20, ""); MarkerWidth = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Marker width", 20, ""); ExpandBreakdown = ((BaseUnityPlugin)this).Config.Bind("1. General", "Expand breakdown", false, ""); ValueWidth = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Value width", 88, ""); ResourceWidth = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Resource width", 76, ""); ScrollStep = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Scroll step", 30, ""); NameShrink = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Name shrink", 8, ""); BackgroundDarken = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Background brightness (%)", 25, ""); ScrollbarWidth = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Scrollbar width", 20, ""); ResourceColumns = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Resource columns", 2, ""); NumberGap = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Resource number gap", 8, ""); SubStep = ((BaseUnityPlugin)this).Config.Bind("2. Layout", "Breakdown size step", 4, ""); DevMode = ((BaseUnityPlugin)this).Config.Bind("9. Dev", "Enabled", false, ""); PreviewKey = ((BaseUnityPlugin)this).Config.Bind("9. Dev", "Preview key", "F7", ""); DumpKey = ((BaseUnityPlugin)this).Config.Bind("9. Dev", "Dump key", "F5", ""); DevTaxes = ((BaseUnityPlugin)this).Config.Bind("9. Dev", "Taxes", "", "LongerCraft, SampleProvision, SlowConveyor, HarvestRockPenalty, HarvestTreePenalty, ReduceTagCraftResult, ReduceItemCraftResult, CutLocalTag, CutBuffCash, Centralization, FamCountPenalty, LandCountPenalty, LockRandomPatron, NoTagRandomPatron, OrderExecutePenalty"); _previewKeyCode = ParseKey(PreviewKey.Value, (Key)100); _dumpKeyCode = ParseKey(DumpKey.Value, (Key)98); _harmony = new Harmony("kiyonakanata.lwftaxledger"); TaxHooks.Init(_harmony); DevTax.Init(); _harmony.PatchAll(typeof(TaxLedgerPlugin).Assembly); int num = 0; foreach (MethodBase patchedMethod in _harmony.GetPatchedMethods()) { _ = patchedMethod; num++; } Log.LogInfo((object)("[boot] LWF Tax Ledger 1.0.0 patches=" + num)); } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } } private void Update() { //IL_0049: 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_009e: Unknown result type (might be due to invalid IL or missing references) if (!Enabled.Value) { return; } if (Time.unscaledTime >= _nextResultPoll) { _nextResultPoll = Time.unscaledTime + 0.5f; LedgerView.TrackResult(); } if (!DevMode.Value) { return; } Keyboard current = Keyboard.current; if (current == null) { return; } if (((ButtonControl)current[_dumpKeyCode]).wasPressedThisFrame && (((ButtonControl)current.leftShiftKey).isPressed || ((ButtonControl)current.rightShiftKey).isPressed)) { EndRunNow(); return; } if (((ButtonControl)current[_dumpKeyCode]).wasPressedThisFrame) { Ledger.Dump(); TaxHooks.LogCheck(); LedgerFile.Save(); } if (((ButtonControl)current[_previewKeyCode]).wasPressedThisFrame) { if (((ButtonControl)current.leftAltKey).isPressed || ((ButtonControl)current.rightAltKey).isPressed) { DevTax.Toggle(); return; } if (((ButtonControl)current.leftShiftKey).isPressed || ((ButtonControl)current.rightShiftKey).isPressed) { Ledger.DummyPayTag = LedgerView.PayTag(); Ledger.FillDummy(_dummySet); Log.LogInfo((object)("[dev] dummy set " + (_dummySet % Ledger.DummySetCount + 1) + "/" + Ledger.DummySetCount)); _dummySet++; } else { Ledger.DropDummy(); if (Ledger.Entries.Count == 0) { LedgerFile.Load(); } Log.LogInfo((object)("[dev] preview: entries=" + Ledger.Entries.Count)); } if (LedgerView.IsResultWindowUp()) { LedgerView.Reattach(); } else { LedgerView.ShowOrRefreshPreview(); } } if (LedgerView.IsPreviewShown && ((ButtonControl)current[(Key)60]).wasPressedThisFrame) { LedgerView.TogglePreview(); } } private void OnGUI() { if (DevMode.Value) { DevTax.Draw(); } } private static void EndRunNow() { GameStateManager instance = GameStateManager.Instance; if ((Object)(object)instance == (Object)null) { Log.LogWarning((object)"[dev] not in a shift"); return; } bool flag = instance.DebugLose(); Log.LogInfo((object)(flag ? "[dev] ending the shift now" : "[dev] the shift cannot be ended yet")); } internal static void Trace(string line) { if (DevMode != null && DevMode.Value) { Log.LogInfo((object)line); } } private static Key ParseKey(string name, Key fallback) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: 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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) try { return (Key)Enum.Parse(typeof(Key), name, ignoreCase: true); } catch (Exception) { return fallback; } } } internal sealed class ItemLoss { public string ItemID; public int Count; public readonly Dictionary Resources = new Dictionary(); public void Add(int count, string tag1, int c1, string tag2, int c2, string tag3, int c3) { Count += count; AddTag(tag1, c1 * count); AddTag(tag2, c2 * count); AddTag(tag3, c3 * count); } public void AddTag(string tag, int amount) { if (!string.IsNullOrEmpty(tag) && !(tag == "None") && amount != 0) { Resources.TryGetValue(tag, out var value); Resources[tag] = value + amount; } } } internal sealed class TaxEntry { public string EffectID; public int Slot; public int Points; public readonly Dictionary LostResources = new Dictionary(); public int CancelledSales; public int PatronID = -1; public readonly Dictionary Items = new Dictionary(); public int ExtraHits; public string RateText; public float ActiveSeconds; public bool IsEmpty { get { if (Points == 0 && LostResources.Count == 0 && CancelledSales == 0 && Items.Count == 0 && ExtraHits == 0) { return string.IsNullOrEmpty(RateText); } return false; } } public ItemLoss GetItem(string itemID) { if (!Items.TryGetValue(itemID, out var value)) { value = new ItemLoss(); value.ItemID = itemID; Items[itemID] = value; } return value; } public void AddLostResource(string tag, int amount) { if (!string.IsNullOrEmpty(tag) && !(tag == "None") && amount != 0) { LostResources.TryGetValue(tag, out var value); LostResources[tag] = value + amount; } } } internal static class Ledger { public static readonly List Entries = new List(); public static bool IsDummy; public static string DummyPayTag = "Cash"; private static readonly string[][] DummySets = new string[5][] { new string[3] { "LongerCraft", "ReduceItemCraftResult", "SlowConveyor" }, new string[3] { "LandCountPenalty", "CutBuffCash", "HarvestRockPenalty" }, new string[3] { "OrderExecutePenalty", "Centralization", "LockRandomPatron" }, new string[3] { "CutLocalTag", "SampleProvision", "HarvestTreePenalty" }, new string[3] { "NoTagRandomPatron", "ReduceTagCraftResult", "FamCountPenalty" } }; public static int DummySetCount => DummySets.Length; public static void Reset() { Entries.Clear(); IsDummy = false; } public static void DropDummy() { if (IsDummy) { Reset(); TaxLedgerPlugin.Trace("[ledger] dropped the dummy; recording the real shift"); } } public static TaxEntry Get(string effectID, int slot) { for (int i = 0; i < Entries.Count; i++) { if (Entries[i].Slot == slot && Entries[i].EffectID == effectID) { return Entries[i]; } } TaxEntry taxEntry = new TaxEntry(); taxEntry.EffectID = effectID; taxEntry.Slot = slot; Entries.Add(taxEntry); Entries.Sort((TaxEntry a, TaxEntry b) => a.Slot.CompareTo(b.Slot)); return taxEntry; } public static void Dump() { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append("[ledger] entries=").Append(Entries.Count); for (int i = 0; i < Entries.Count; i++) { TaxEntry taxEntry = Entries[i]; stringBuilder.Append('\n').Append(" slot").Append(taxEntry.Slot) .Append(' ') .Append(taxEntry.EffectID); if (taxEntry.Points != 0) { stringBuilder.Append(" points=").Append(taxEntry.Points); } if (taxEntry.CancelledSales != 0) { stringBuilder.Append(" sales=").Append(taxEntry.CancelledSales); } if (taxEntry.ExtraHits != 0) { stringBuilder.Append(" hits=").Append(taxEntry.ExtraHits); } if (!string.IsNullOrEmpty(taxEntry.RateText)) { stringBuilder.Append(" rate=").Append(taxEntry.RateText); } if (taxEntry.PatronID > 0) { stringBuilder.Append(" patron=").Append(taxEntry.PatronID); } foreach (KeyValuePair lostResource in taxEntry.LostResources) { stringBuilder.Append(' ').Append(lostResource.Key).Append('=') .Append(lostResource.Value); } foreach (KeyValuePair item in taxEntry.Items) { stringBuilder.Append('\n').Append(" ").Append(item.Key) .Append(" x") .Append(item.Value.Count); foreach (KeyValuePair resource in item.Value.Resources) { stringBuilder.Append(' ').Append(resource.Key).Append('=') .Append(resource.Value); } } } TaxLedgerPlugin.Log.LogInfo((object)stringBuilder.ToString()); } public static void FillDummy(int setIndex) { Reset(); IsDummy = true; string[] array = DummySets[(setIndex % DummySets.Length + DummySets.Length) % DummySets.Length]; Random rng = new Random(setIndex * 7919 + 17); for (int i = 0; i < array.Length; i++) { TaxEntry taxEntry = Get(array[i], i); taxEntry.ActiveSeconds = 600f; FillDummyEntry(taxEntry, rng); } } private static void FillDummyEntry(TaxEntry e, Random rng) { switch (e.EffectID) { case "FamCountPenalty": e.Points = 160 * (40 + rng.Next(60)); e.AddLostResource(DummyPayTag, e.Points * (1 + rng.Next(6))); break; case "LandCountPenalty": e.Points = 800 * (20 + rng.Next(30)); e.AddLostResource(DummyPayTag, e.Points * (1 + rng.Next(6))); break; case "OrderExecutePenalty": e.Points = 500 * (8 + rng.Next(30)); e.AddLostResource(DummyPayTag, e.Points * (1 + rng.Next(4))); break; case "CutBuffCash": e.AddLostResource("Cash", 8000 + rng.Next(90000)); break; case "NoTagRandomPatron": e.PatronID = 2; e.AddLostResource("Construction", 4000 + rng.Next(60000)); break; case "CutLocalTag": e.AddLostResource("Luxury", 2000 + rng.Next(40000)); break; case "Centralization": FillDummyItems(e, rng); { foreach (KeyValuePair item in e.Items) { e.CancelledSales += item.Value.Count; } break; } case "LockRandomPatron": e.PatronID = 8; FillDummyItems(e, rng); break; case "HarvestRockPenalty": case "HarvestTreePenalty": e.ExtraHits = 3000 + rng.Next(90000); break; case "SlowConveyor": e.RateText = "-90%"; break; default: FillDummyItems(e, rng); break; } } private static void FillDummyItems(TaxEntry e, Random rng) { AddDummyItem(e, rng, "Gold", 40, "Luxury", 50, "Cash", 10, "None", 0); AddDummyItem(e, rng, "Iron", 200, "Construction", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "Lemonade", 60, "Grocery", 1, "Cash", 5, "None", 0); AddDummyItem(e, rng, "Nitro", 30, "Fuel", 100, "Cash", 10, "None", 0); AddDummyItem(e, rng, "Soda", 25, "Chemical", 100, "Cash", 10, "None", 0); AddDummyItem(e, rng, "Wax", 80, "Chemical", 1, "Grocery", 1, "Fuel", 1); AddDummyItem(e, rng, "Mercury", 90, "Magic", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "Lye", 45, "Chemical", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "MagicChunk", 55, "Magic", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "Gunpowder", 35, "Fuel", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "Compost", 120, "Fertilizer", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "GemPowder", 20, "Magic", 20, "Cash", 1, "None", 0); AddDummyItem(e, rng, "Pickaxe", 8, "Construction", 100, "Cash", 10, "None", 0); AddDummyItem(e, rng, "Adamantite", 6, "Fuel", 2000, "Cash", 500, "None", 0); AddDummyItem(e, rng, "Summon-Worker", 12, "None", 0, "None", 0, "None", 0); } private static void AddDummyItem(TaxEntry e, Random rng, string itemID, int scale, string t1, int c1, string t2, int c2, string t3, int c3) { int count = scale / 2 + rng.Next(scale * 2); e.GetItem(itemID).Add(count, t1, c1, t2, c2, t3, c3); } } internal static class LedgerView { private const string BodyName = "AchievementBody"; private const string TitleName = "AchievementTitle"; private const string PlaceholderName = "TMPTemporary"; private const string FrameName = "FrameAchievement"; private const string RowsName = "TaxLedgerRows"; private const string PreviewName = "TaxLedgerPreview"; private const string CashTag = "Cash"; private const string FixedCostTag = "RepaymentLoseCash"; private const string HitItem = "Pickaxe"; private const string ConveyorItem = "Summon-Conveyor"; private const string GehennaSmile = "portrait_patron_gehenna_smile"; private const string BackdropName = "TaxLedgerBackdrop"; private static string _payTag = "Cash"; private static readonly string[] ResourceOrder = new string[7] { "Construction", "Grocery", "Luxury", "Fertilizer", "Chemical", "Magic", "Fuel" }; private static readonly Color NameColor = LWFColors.HEADER_COLOR; private static readonly Color SectionColor = Fade(LWFColors.HEADER_COLOR, 0.72f); private static readonly Color ValueColor = Fade(LWFColors.RED_COLOR, 0.85f); private static readonly Color SubColor = Fade(LWFColors.HEADER_COLOR, 0.7f); private static readonly Color SubValueColor = Fade(LWFColors.HEADER_COLOR, 0.92f); private static GameObject _preview; private static bool _attached; private static TextMeshProUGUI _template; private static ResultUIManager _result; private static CanvasGroup[] _dimmed; private static readonly Dictionary SpriteCache = new Dictionary(); public static bool IsPreviewShown => (Object)(object)_preview != (Object)null; private static Color Fade(Color c, float alpha) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) return new Color(c.r, c.g, c.b, alpha); } public static bool IsResultWindowUp() { ResultUIManager val = Result(); if ((Object)(object)val != (Object)null) { return ((Component)val).gameObject.activeInHierarchy; } return false; } private static ResultUIManager Result() { if ((Object)(object)_result != (Object)null) { return _result; } try { ResultUIManager[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); _result = ((array.Length > 0) ? array[0] : null); } catch (Exception) { _result = null; } return _result; } public static void Reattach() { _attached = false; _dimmed = null; TrackResult(); } public static void TrackResult() { if (!IsResultWindowUp()) { _attached = false; _dimmed = null; return; } if (_attached) { Undim(); return; } if (!IsTaxRun() && !TaxLedgerPlugin.DevMode.Value) { _attached = true; return; } Transform val = FindResultBody(); if ((Object)(object)val == (Object)null) { return; } _attached = true; if (Ledger.Entries.Count == 0) { TaxLedgerPlugin.Trace("[view] nothing to show; left the frame untouched"); return; } try { Build(val, isPreview: false); _dimmed = ((Component)val).GetComponentsInChildren(true); Undim(); TaxLedgerPlugin.Trace("[view] attached to the result frame (" + _dimmed.Length + " canvas groups)"); if (TaxLedgerPlugin.DevMode.Value) { LedgerFile.Save(); } } catch (Exception ex) { TaxLedgerPlugin.Log.LogWarning((object)("[view] cannot build the result frame: " + ex.Message)); } } private static bool IsTaxRun() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) try { return TaxUnlockPolicy.CanApplyRuntimeEffects(CurrentGameMode.Get); } catch (Exception) { return false; } } private static void DarkenFrame(Transform frame) { //IL_00b6: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: 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_007a: 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) if ((Object)(object)frame == (Object)null) { return; } Transform val = frame.Find("TaxLedgerBackdrop"); while ((Object)(object)val != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val).gameObject); val = frame.Find("TaxLedgerBackdrop"); } float num = 1f - Mathf.Clamp01((float)TaxLedgerPlugin.BackgroundDarken.Value / 100f); if (!(num <= 0f)) { Image component = ((Component)frame).GetComponent(); if (!((Object)(object)component != (Object)null) || !(((Graphic)component).color.r + ((Graphic)component).color.g + ((Graphic)component).color.b < 0.2f)) { GameObject val2 = new GameObject("TaxLedgerBackdrop", new Type[1] { typeof(RectTransform) }); RectTransform component2 = val2.GetComponent(); ((Transform)component2).SetParent(frame, false); ((Transform)component2).localScale = Vector3.one; Stretch(component2); Image val3 = val2.AddComponent(); ((Graphic)val3).color = new Color(0f, 0f, 0f, num); ((Graphic)val3).raycastTarget = false; ((Transform)component2).SetSiblingIndex(0); } } } private static void Undim() { if (_dimmed == null) { return; } for (int i = 0; i < _dimmed.Length; i++) { CanvasGroup val = _dimmed[i]; if (!((Object)(object)val == (Object)null)) { if (val.alpha < 1f) { val.alpha = 1f; } if (!val.interactable) { val.interactable = true; } if (!val.blocksRaycasts) { val.blocksRaycasts = true; } } } } private static Transform FindResultBody() { ResultUIManager val = Result(); if ((Object)(object)val == (Object)null) { return null; } return FindChildRecursive(((Component)val).transform, "AchievementBody"); } public static void TogglePreview() { if ((Object)(object)_preview != (Object)null) { Object.Destroy((Object)(object)_preview); _preview = null; } else { ShowPreview(); } } public static void ShowOrRefreshPreview() { if ((Object)(object)_preview != (Object)null) { Object.DestroyImmediate((Object)(object)_preview); _preview = null; } ShowPreview(); } private static void ShowPreview() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Expected O, but got Unknown //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Expected O, but got Unknown //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_010b: 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_0114: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0119: 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_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_0149: 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_0152: Unknown result type (might be due to invalid IL or missing references) //IL_0160: 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_018d: Unknown result type (might be due to invalid IL or missing references) Transform val = FindResultBody(); if ((Object)(object)val == (Object)null) { TaxLedgerPlugin.Log.LogWarning((object)"[preview] AchievementBody not found (ResultUIManager missing in this scene)"); return; } GameObject val2 = GameObject.Find("TaxLedgerPreview"); if ((Object)(object)val2 != (Object)null) { Object.DestroyImmediate((Object)(object)val2); } _preview = new GameObject("TaxLedgerPreview"); Canvas val3 = _preview.AddComponent(); val3.renderMode = (RenderMode)0; val3.sortingOrder = 5000; CopyScaler(val, _preview.AddComponent()); _preview.AddComponent(); GameObject val4 = new GameObject("Dim"); val4.transform.SetParent(_preview.transform, false); Image val5 = val4.AddComponent(); ((Graphic)val5).color = new Color(0f, 0f, 0f, 0.75f); Stretch(val4.GetComponent()); Transform val6 = FindChildRecursive(val.parent, "AchievementTitle"); RectTransform val7 = (RectTransform)(object)((val is RectTransform) ? val : null); ? val8; if (!((Object)(object)val7 != (Object)null)) { val8 = new Vector2(600f, 420f); } else { Rect rect = val7.rect; val8 = ((Rect)(ref rect)).size; } Vector2 size = (Vector2)val8; float num = 0f; if ((Object)(object)val6 != (Object)null) { GameObject go = CloneInto(val6, _preview.transform, "Title"); Rect rect2 = ((RectTransform)((val6 is RectTransform) ? val6 : null)).rect; RectTransform val9 = Center(go, ((Rect)(ref rect2)).size); Rect rect3 = val9.rect; num = ((Rect)(ref rect3)).height; val9.anchoredPosition = new Vector2(0f, size.y * 0.5f + num * 0.5f); SetTitleText(val9); } RectTransform val10 = Center(CloneInto(val, _preview.transform, "Body"), size); val10.anchoredPosition = new Vector2(0f, (0f - num) * 0.5f); CanvasGroup[] componentsInChildren = ((Component)val10).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { componentsInChildren[i].alpha = 1f; componentsInChildren[i].interactable = true; componentsInChildren[i].blocksRaycasts = true; } Build((Transform)(object)val10, isPreview: true); TaxLedgerPlugin.Trace("[preview] shown (" + size.x + "x" + size.y + ")"); } private static void CopyScaler(Transform body, CanvasScaler mine) { //IL_003a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) CanvasScaler componentInParent = ((Component)body).GetComponentInParent(); if ((Object)(object)componentInParent == (Object)null) { mine.uiScaleMode = (ScaleMode)1; mine.referenceResolution = new Vector2(1920f, 1080f); mine.matchWidthOrHeight = 1f; } else { mine.uiScaleMode = componentInParent.uiScaleMode; mine.referenceResolution = componentInParent.referenceResolution; mine.screenMatchMode = componentInParent.screenMatchMode; mine.matchWidthOrHeight = componentInParent.matchWidthOrHeight; mine.referencePixelsPerUnit = componentInParent.referencePixelsPerUnit; } } private static GameObject CloneInto(Transform source, Transform parent, string name) { GameObject val = Object.Instantiate(((Component)source).gameObject, parent, false); ((Object)val).name = name; val.SetActive(true); DisableLocalizers(val); return val; } private static RectTransform Center(GameObject go, Vector2 size) { //IL_0022: 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_004c: 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_005e: 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) RectTransform val = go.GetComponent(); if ((Object)(object)val == (Object)null) { val = go.AddComponent(); } val.anchorMin = new Vector2(0.5f, 0.5f); val.anchorMax = new Vector2(0.5f, 0.5f); val.pivot = new Vector2(0.5f, 0.5f); val.sizeDelta = size; val.anchoredPosition = Vector2.zero; ((Transform)val).localScale = Vector3.one; return val; } private static void Stretch(RectTransform r) { //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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) r.anchorMin = Vector2.zero; r.anchorMax = Vector2.one; r.offsetMin = Vector2.zero; r.offsetMax = Vector2.zero; } private static void Build(Transform body, bool isPreview) { //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_01a0: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01d5: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_0227: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0277: Expected O, but got Unknown //IL_03c1: Unknown result type (might be due to invalid IL or missing references) //IL_03c6: Unknown result type (might be due to invalid IL or missing references) //IL_03ed: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) Transform val = FindChildRecursive(body, "TMPTemporary"); _template = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent() : null); if ((Object)(object)_template == (Object)null) { _template = ((Component)body).GetComponentInChildren(true); TaxLedgerPlugin.Log.LogWarning((object)("[view] TMPTemporary not found; using " + (((Object)(object)_template != (Object)null) ? ((Object)_template).name : "nothing") + " as the text template")); } if ((Object)(object)_template == (Object)null) { throw new InvalidOperationException("no TextMeshProUGUI under AchievementBody"); } _payTag = CurrentPayTag(); TaxLedgerPlugin.Trace("[view] pay tag = " + _payTag); Transform val2 = FindChildRecursive(body, "FrameAchievement"); ScrollRect componentInChildren = ((Component)(((Object)(object)val2 != (Object)null) ? val2 : body)).GetComponentInChildren(true); if (!isPreview) { Transform val3 = FindChildRecursive(body.parent, "AchievementTitle"); if ((Object)(object)val3 != (Object)null) { SetTitleText((RectTransform)(object)((val3 is RectTransform) ? val3 : null)); } } if ((Object)(object)val2 != (Object)null) { ((Component)val2).gameObject.SetActive(true); } if ((Object)(object)componentInChildren != (Object)null) { ((Component)componentInChildren).gameObject.SetActive(true); } HideOthers(body, val2); RectTransform val4 = (((Object)(object)componentInChildren != (Object)null) ? componentInChildren.viewport : null); if ((Object)(object)val4 == (Object)null) { val4 = (RectTransform)(object)((body is RectTransform) ? body : null); } Transform val5 = ((Transform)val4).Find("TaxLedgerRows"); while ((Object)(object)val5 != (Object)null) { Object.DestroyImmediate((Object)(object)((Component)val5).gameObject); val5 = ((Transform)val4).Find("TaxLedgerRows"); } GameObject val6 = new GameObject("TaxLedgerRows", new Type[1] { typeof(RectTransform) }); RectTransform component = val6.GetComponent(); ((Transform)component).SetParent((Transform)(object)val4, false); component.anchorMin = new Vector2(0f, 1f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(0f, 1f); component.anchoredPosition = Vector2.zero; component.offsetMin = new Vector2(0f, component.offsetMin.y); component.offsetMax = new Vector2(0f, component.offsetMax.y); ((Transform)component).localScale = Vector3.one; VerticalLayoutGroup val7 = val6.AddComponent(); int value = TaxLedgerPlugin.Padding.Value; ((LayoutGroup)val7).padding = new RectOffset(value, value + BarWidth(componentInChildren), value, value); ((HorizontalOrVerticalLayoutGroup)val7).spacing = TaxLedgerPlugin.RowSpacing.Value; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandHeight = false; ((HorizontalOrVerticalLayoutGroup)val7).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)val7).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)val7).childControlWidth = true; ((LayoutGroup)val7).childAlignment = (TextAnchor)0; ContentSizeFitter val8 = val6.AddComponent(); val8.verticalFit = (FitMode)2; val8.horizontalFit = (FitMode)0; BuildRows(component); DarkenFrame(val2); DarkenFrame((Transform)(object)val4); if ((Object)(object)componentInChildren != (Object)null) { RectTransform content = componentInChildren.content; if ((Object)(object)content != (Object)null && (Object)(object)content != (Object)(object)component) { ((Component)content).gameObject.SetActive(false); } componentInChildren.content = component; componentInChildren.horizontal = false; componentInChildren.vertical = true; componentInChildren.movementType = (MovementType)2; componentInChildren.inertia = false; componentInChildren.elasticity = 0f; componentInChildren.scrollSensitivity = TaxLedgerPlugin.ScrollStep.Value; componentInChildren.verticalScrollbarVisibility = (ScrollbarVisibility)1; componentInChildren.verticalNormalizedPosition = 1f; } object[] array = new object[14] { "[view] template=", ((Object)_template).name, " size=", ((TMP_Text)_template).fontSize, " holder=", ((Object)val4).name, " (", null, null, null, null, null, null, null }; Rect rect = val4.rect; array[7] = ((Rect)(ref rect)).width.ToString("0"); array[8] = "x"; Rect rect2 = val4.rect; array[9] = ((Rect)(ref rect2)).height.ToString("0"); array[10] = ") bar="; array[11] = BarWidth(componentInChildren); array[12] = " entries="; array[13] = Ledger.Entries.Count; TaxLedgerPlugin.Trace(string.Concat(array)); } private static void HideOthers(Transform parent, Transform keep) { for (int i = 0; i < parent.childCount; i++) { Transform child = parent.GetChild(i); if (!((Object)(object)child == (Object)(object)keep) && !(((Object)child).name == "TaxLedgerRows") && ((Component)child).gameObject.activeSelf) { ((Component)child).gameObject.SetActive(false); TaxLedgerPlugin.Trace("[view] hid " + ((Object)parent).name + "/" + ((Object)child).name); } } } private static void BuildRows(RectTransform rows) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) List entries = Ledger.Entries; for (int i = 0; i < entries.Count; i++) { TaxEntry taxEntry = entries[i]; if (i > 0) { AddSeparator(rows); } RectTransform val = NewRow(rows, 0, TaxLedgerPlugin.IconSize.Value); TextMeshProUGUI marker = AddMarker(val); AddFixedText(val, SectionName(taxEntry.Slot), TaxLedgerPlugin.FontSize.Value, SectionColor); AddName(val, TaxName(taxEntry.EffectID), TaxLedgerPlugin.FontSize.Value); if (taxEntry.PatronID > 0) { AddIcon(val, PatronSprite(taxEntry.PatronID), null, TaxLedgerPlugin.IconSize.Value, TaxLedgerPlugin.FontSize.Value); } AddHeadValue(val, taxEntry); int font = SubFontSize(); int num = SubIconSize(); List list = new List(); foreach (KeyValuePair item in taxEntry.Items) { ItemLoss value = item.Value; RectTransform val2 = NewRow(rows, TaxLedgerPlugin.Indent.Value, num); AddIcon(val2, ItemSprite(value.ItemID), value.ItemID, num, font); AddFixedText(val2, "x" + Format(value.Count), font, SubValueColor); AddFlex(val2); AddOtherResources(val2, value.Resources, font, num); AddValue(val2, TagSprite(_payTag), _payTag, "-" + Format(Pay(value.Resources)), font, num, SubValueColor); list.Add(((Component)val2).gameObject); } MakeExpandable(val, marker, list); } } private static TextMeshProUGUI AddMarker(RectTransform row) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) GameObject val = NewText(row, " ", TaxLedgerPlugin.FontSize.Value, SectionColor, bold: false); ((Object)val).name = "Marker"; TextMeshProUGUI component = val.GetComponent(); ((TMP_Text)component).alignment = (TextAlignmentOptions)4098; LayoutElement val2 = val.AddComponent(); int value = TaxLedgerPlugin.MarkerWidth.Value; val2.preferredWidth = value; val2.minWidth = value; return component; } private static void MakeExpandable(RectTransform head, TextMeshProUGUI marker, List rows) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Expected O, but got Unknown if (rows.Count == 0) { return; } bool value = TaxLedgerPlugin.ExpandBreakdown.Value; for (int i = 0; i < rows.Count; i++) { rows[i].SetActive(value); } ((TMP_Text)marker).text = (value ? "-" : "+"); Image val = ((Component)head).gameObject.AddComponent(); ((Graphic)val).color = new Color(1f, 1f, 1f, 0f); ((Graphic)val).raycastTarget = true; Button val2 = ((Component)head).gameObject.AddComponent