using System; 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 GameState; using HarmonyLib; using Items; using Items.Craft; using Items.Delivery; using Items.Tag; using Map.MapObjects.Mono; using Map.Ownership; using R3; using Stats; using TMPro; using UI; using UI.Cursor; using UI.SelectableWindow.Managers; using UnityEngine; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; using Utility.Localization; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyVersion("0.0.0.0")] namespace LwfEconomyGraph; internal sealed class SourceSeries { internal readonly string Key; internal readonly int Reason; internal readonly bool HasSource; internal long Total; internal long Held; internal readonly List ByPeriod = new List(); internal readonly List RepaidByPeriod = new List(); internal SourceSeries(string key, int reason, bool hasSource) { Key = key; Reason = reason; HasSource = hasSource; } internal long At(int period) { if (period < 0 || period >= ByPeriod.Count) { return 0L; } return ByPeriod[period]; } internal long RepaidAt(int period) { if (period < 0 || period >= RepaidByPeriod.Count) { return 0L; } return RepaidByPeriod[period]; } internal void AddRepaid(int period, long value) { while (RepaidByPeriod.Count <= period) { RepaidByPeriod.Add(0L); } RepaidByPeriod[period] += value; } internal void Add(int period, long value) { while (ByPeriod.Count <= period) { ByPeriod.Add(0L); } ByPeriod[period] += value; Total += value; } } internal sealed class TagSeries { internal readonly string TagID; internal readonly int Index; internal string DisplayName; internal long Balance; internal long InitialBalance; internal long PeakBalance; internal double PeakAt; internal long IncomeTotal; internal long ExpenseTotal; internal long RecordCount; internal readonly long[] IncomeByReason; internal readonly long[] ExpenseByReason; internal readonly Dictionary IncomeBySource = new Dictionary(StringComparer.Ordinal); internal readonly Dictionary ExpenseBySource = new Dictionary(StringComparer.Ordinal); internal List Balances = new List(); internal readonly List Flows = new List(); internal readonly List PeriodFlows = new List(); internal long HeldUnattributed; internal readonly List IncomeSources = new List(); internal readonly List ExpenseSources = new List(); private readonly Dictionary _incomeIndex = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _expenseIndex = new Dictionary(StringComparer.Ordinal); private readonly List _lotSource = new List(); private readonly List _lotAmount = new List(); internal TagSeries(string tagID, int index, int reasonCount) { TagID = tagID; Index = index; DisplayName = tagID; IncomeByReason = new long[reasonCount]; ExpenseByReason = new long[reasonCount]; } internal SourceSeries GetOrCreateSource(bool income, string key, int reason, bool hasSource) { Dictionary dictionary = (income ? _incomeIndex : _expenseIndex); if (dictionary.TryGetValue(key, out var value)) { return value; } value = new SourceSeries(key, reason, hasSource); dictionary.Add(key, value); (income ? IncomeSources : ExpenseSources).Add(value); return value; } internal long HeldTotal() { long num = HeldUnattributed; for (int i = 0; i < IncomeSources.Count; i++) { num += IncomeSources[i].Held; } return num; } internal void AddHolding(SourceSeries src, long amount) { if (src != null && amount > 0) { src.Held += amount; int num = _lotSource.Count - 1; if (num >= 0 && object.ReferenceEquals(_lotSource[num], src)) { _lotAmount[num] += amount; return; } _lotSource.Add(src); _lotAmount.Add(amount); } } internal void TakeFromHolding(long amount, List srcOut, List amtOut) { if (amount <= 0) { return; } long num = amount; int num2 = _lotSource.Count - 1; while (num2 >= 0 && num > 0) { long num3 = ((_lotAmount[num2] < num) ? _lotAmount[num2] : num); if (num3 > 0) { _lotAmount[num2] -= num3; _lotSource[num2].Held -= num3; num -= num3; if (srcOut != null) { srcOut.Add(_lotSource[num2]); amtOut.Add(num3); } } num2--; } while (_lotAmount.Count > 0 && _lotAmount[_lotAmount.Count - 1] <= 0) { _lotAmount.RemoveAt(_lotAmount.Count - 1); _lotSource.RemoveAt(_lotSource.Count - 1); } if (num > 0 && HeldUnattributed > 0) { long num4 = ((HeldUnattributed < num) ? HeldUnattributed : num); HeldUnattributed -= num4; num -= num4; if (srcOut != null) { srcOut.Add(null); amtOut.Add(num4); } } } internal void SpendFromHolding(long amount) { TakeFromHolding(amount, null, null); } internal long BalanceAt(int bucket) { int count = Balances.Count; if (count == 0) { return InitialBalance; } if (bucket < 0) { return Balances[0]; } if (bucket >= count) { return Balances[count - 1]; } return Balances[bucket]; } internal long FlowAt(int bucket, int slot) { int num = bucket * (IncomeByReason.Length * 2) + slot; if (bucket < 0 || num < 0 || num >= Flows.Count) { return 0L; } return Flows[num]; } internal long PeriodFlowAt(int period, int slot) { int num = period * (IncomeByReason.Length * 2) + slot; if (period < 0 || num < 0 || num >= PeriodFlows.Count) { return 0L; } return PeriodFlows[num]; } } internal interface IChartPainter { float FontSize { get; } float LineHeight { get; } void SetScale(float scale); float Measure(string text); float MeasureTitle(string text); void Fill(Rect r, Color color); void Text(float x, float y, string text, Color color); void Title(float x, float y, string text, Color color); bool Icon(Rect r, string sourceKey, string tagID, Color tint, Color outline); string ReasonLabel(int reason); } internal sealed class ChartData { internal List Ordered = new List(); internal TagSeries Selected; internal float BucketSeconds = 1f; internal int BucketCount; internal int MaxColumns = 480; internal int PeriodIndex; internal List PeriodRepaid = new List(); internal int RepaidTotal; internal int TargetProgress; internal string RequiredTagID; internal int RequiredCount; internal long RequiredCurrent; internal List PeriodEnds = new List(); internal HashSet HiddenTags = new HashSet(StringComparer.Ordinal); internal int Mode; internal bool LastMinute; internal bool ExpenseSide; internal Vector2 Mouse; internal bool MouseValid; internal readonly List IconRects = new List(); internal readonly List IconTagIDs = new List(); internal readonly List ModeRects = new List(); internal readonly List ModeIDs = new List(); internal readonly List ToggleRects = new List(); internal readonly List ToggleIDs = new List(); internal readonly List RateSources = new List(); internal readonly List RateValues = new List(); internal readonly List RateTotals = new List(); internal float RateSlotSeconds = 1f; internal long RateTotal; } internal sealed class ChartRenderer { internal const int ReasonCount = 16; internal const int SlotsPerBucket = 32; internal const float DesignWidth = 494f; internal const int ModeNetFlow = 0; internal const int ModeBalanceAll = 1; internal const int ModeComposition = 2; internal const int ModeCount = 3; internal const int ToggleRange = 0; internal const int ToggleSide = 1; internal const string CraftIconKey = "#craft"; private const float MinShare = 0.03f; private const int HoverRows = 10; internal static readonly string[] KnownTagIDs = new string[8] { "Cash", "Construction", "Grocery", "Luxury", "Fertilizer", "Chemical", "Magic", "Fuel" }; internal static readonly string[] KnownTagNamesJa = new string[8] { "現金", "建材", "食品", "高級品", "肥料", "薬品", "魔力", "燃料" }; private static readonly Color[] TagColors = (Color[])(object)new Color[9] { new Color(1f, 0.82f, 0.25f), new Color(0.72f, 0.72f, 0.76f), new Color(0.55f, 0.85f, 0.45f), new Color(0.95f, 0.55f, 0.85f), new Color(0.78f, 0.6f, 0.32f), new Color(0.45f, 0.85f, 0.8f), new Color(0.65f, 0.55f, 0.98f), new Color(0.98f, 0.55f, 0.3f), new Color(0.6f, 0.6f, 0.62f) }; private static readonly Color[] SourcePalette = (Color[])(object)new Color[8] { new Color(1f, 0.62f, 0.2f), new Color(0.42f, 0.8f, 0.45f), new Color(0.4f, 0.68f, 0.98f), new Color(0.95f, 0.45f, 0.55f), new Color(0.75f, 0.55f, 0.95f), new Color(0.35f, 0.85f, 0.82f), new Color(0.95f, 0.85f, 0.35f), new Color(0.9f, 0.55f, 0.85f) }; private static readonly Color OthersColor = new Color(0.55f, 0.55f, 0.58f); private static readonly Color IconOutline = new Color(1f, 1f, 1f, 0.95f); private static readonly Color Faint = new Color(1f, 1f, 1f, 0.14f); private static readonly Color Fainter = new Color(1f, 1f, 1f, 0.1f); private static readonly Color Ink = Color.white; private static readonly Color Accent = new Color(1f, 0.68f, 0.25f, 1f); private static readonly Color DeficitColor = new Color(0.95f, 0.32f, 0.34f, 1f); private static readonly Color ZeroColor = new Color(0.66f, 0.63f, 0.6f, 0.9f); private static readonly Color NetLineUp = new Color(0.55f, 0.95f, 0.6f, 1f); private static readonly Color NetLineDown = new Color(0.98f, 0.55f, 0.55f, 1f); private static readonly Color NetFillUp = new Color(0.35f, 0.85f, 0.45f, 0.26f); private static readonly Color NetFillDown = new Color(0.95f, 0.35f, 0.38f, 0.26f); private readonly List _rank = new List(); private readonly List _hover = new List(); private readonly List _rankTotals = new List(); private readonly List _rateLines = new List(); private readonly List _rateOrder = new List(); private bool _hoverByRepaid; private bool _hoverHeld; private int _hoverPeriod; private readonly List _rankColors = new List(); private readonly List _lineColors = new List(); private readonly List _capOrder = new List(); private readonly List _capY = new List(); private static readonly float[] RisingLevels = new float[4] { 0.16f, 0.4f, 0.28f, 0.72f }; private static readonly float[] NetLevels = new float[4] { 0.2f, 0.72f, 0.34f, 0.78f }; private static readonly float[] FallingLevels = new float[4] { 0.82f, 0.6f, 0.66f, 0.34f }; private long[] _net; private long[] _bucketNet; private string _netTag; private int _netCount; private int _netWindow; private long _netLast; private static bool UsesNorm(ChartData d) { if (!d.ExpenseSide && d.RequiredCount > 0 && d.Selected != null) { return string.Equals(d.RequiredTagID, d.Selected.TagID, StringComparison.Ordinal); } return false; } private static float NormRatio(ChartData d) { if (d.RequiredCount <= 0) { return 1f; } return (float)((double)d.RequiredCurrent / (double)d.RequiredCount); } internal void Draw(Rect area, ChartData d, IChartPainter p) { //IL_00e6: 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_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_03de: Unknown result type (might be due to invalid IL or missing references) //IL_03ad: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01c7: 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_0267: Unknown result type (might be due to invalid IL or missing references) //IL_02e9: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) p.SetScale(Mathf.Clamp(((Rect)(ref area)).width / 494f, 0.8f, 2.2f)); d.IconRects.Clear(); d.IconTagIDs.Clear(); d.ModeRects.Clear(); d.ModeIDs.Clear(); d.ToggleRects.Clear(); d.ToggleIDs.Clear(); float lineHeight = p.LineHeight; float num = lineHeight + 4f; float x = ((Rect)(ref area)).x; float num2 = ((Rect)(ref area)).y; if (d.Mode == 0 && d.Selected != null) { BuildNet(d, d.Selected); } float num3 = Mathf.Max(16f, lineHeight) + 8f; Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).yMax - num3, ((Rect)(ref area)).width, num3); if (((Rect)(ref area)).height > num3 + 40f) { DrawToolbar(r, d, p); ((Rect)(ref area))..ctor(((Rect)(ref area)).x, ((Rect)(ref area)).y, ((Rect)(ref area)).width, ((Rect)(ref r)).y - ((Rect)(ref area)).y - 2f); } if (d.Ordered.Count == 0) { DrawZeroLine(area, p); return; } if (d.Mode != 1 && d.Selected != null) { p.Icon(new Rect(x, num2, num, num), null, d.Selected.TagID, Ink, IconOutline); x += num + 6f; if (d.Mode == 0) { long netLast = _netLast; string text = ((netLast >= 0) ? "+" : "-") + N(Math.Abs(netLast)) + "/min"; p.Title(x, num2 + 2f, text, (netLast >= 0) ? NetLineUp : NetLineDown); } else { bool lastMinute = d.LastMinute; long v = (lastMinute ? d.RateTotal : (d.ExpenseSide ? d.Selected.ExpenseTotal : d.Selected.IncomeTotal)); string text2 = (d.ExpenseSide ? "-" : "+") + N(v) + (lastMinute ? "/min" : ""); p.Title(x, num2 + 2f, text2, d.ExpenseSide ? new Color(0.98f, 0.55f, 0.55f) : new Color(0.55f, 0.95f, 0.6f)); float num4 = x + p.MeasureTitle(text2) + 8f; if (d.TargetProgress > 0) { string text3 = d.RepaidTotal.ToString(CultureInfo.InvariantCulture) + "/" + d.TargetProgress.ToString(CultureInfo.InvariantCulture); p.Text(num4, num2 + 6f, text3, new Color(0.75f, 0.72f, 0.68f)); num4 += p.Measure(text3) + 8f; } if (UsesNorm(d)) { int num5 = Mathf.RoundToInt(NormRatio(d) * 100f); string text4 = num5.ToString(CultureInfo.InvariantCulture) + "%"; p.Text(num4, num2 + 6f, text4, (num5 < 0) ? DeficitColor : Accent); } } } if (d.Mode != 1) { num2 += num + 4f; } Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref area)).x, num2, ((Rect)(ref area)).width, ((Rect)(ref area)).yMax - num2); if (((Rect)(ref r2)).height < 40f) { return; } if (d.Mode == 2) { if (d.Selected == null) { DrawZeroLine(r2, p); } else if (d.LastMinute) { DrawRates(r2, d, p); } else { DrawComposition(r2, d, p); } } else if (d.Mode == 1) { DrawBalanceChart(r2, d, null, p); } else if (d.Selected == null) { DrawZeroLine(r2, p); } else { DrawNetChart(r2, d, p); } } private void DrawToolbar(Rect r, ChartData d, IChartPainter p) { float num = Mathf.Max(14f, p.LineHeight); float num2 = num * 1.9f; float num3 = 4f; float num4 = 10f; int count = d.Ordered.Count; float num5 = num2 * 4f + num * (float)count + num3 * (float)(count + 1) + num4 * 7.5f; if (num5 > ((Rect)(ref r)).width && num5 > 0f) { float num6 = ((Rect)(ref r)).width / num5; num = Mathf.Max(11f, num * num6); num2 = Mathf.Max(13f, num2 * num6); num3 = Mathf.Max(2f, num3 * num6); num4 = Mathf.Max(4f, num4 * num6); } float y = ((Rect)(ref r)).y + (((Rect)(ref r)).height - num) * 0.5f - 1f; float num7 = num4; float x = ((Rect)(ref r)).x + num7; x = DrawModeButton(x, y, num2, num, 1, d, p) + num4; x = DrawTagRow(x, y, num, num3, d, p) + num4; x = DrawModeButton(x, y, num2, num, 0, d, p) + num4 * 2.5f; x = DrawToggleButton(x, y, num2, num, 1, d, p) + num3; DrawToggleButton(x, y, num2, num, 0, d, p); DrawModeButton(((Rect)(ref r)).xMax - num7 - num2, y, num2, num, 2, d, p); } private float DrawTagRow(float x, float y, float icon, float gap, ChartData d, IChartPainter p) { //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00ab: 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_00c8: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) bool flag = d.Mode == 1; Rect val = default(Rect); for (int i = 0; i < d.Ordered.Count; i++) { string tagID = d.Ordered[i].TagID; bool flag2 = (flag ? (!d.HiddenTags.Contains(tagID)) : (d.Selected != null && d.Selected.TagID == tagID)); ((Rect)(ref val))..ctor(x, y, icon, icon); p.Icon(val, null, tagID, (Color)(flag2 ? Ink : new Color(1f, 1f, 1f, 0.3f)), (Color)(flag2 ? IconOutline : new Color(0f, 0f, 0f, 0f))); p.Fill(new Rect(x, y + icon + 1f, icon, 2f), flag2 ? TagColor(tagID) : Fainter); d.IconRects.Add(val); d.IconTagIDs.Add(tagID); x += icon + gap; } return x - gap; } private float DrawModeButton(float x, float y, float bw, float icon, int mode, ChartData d, IChartPainter p) { //IL_0026: 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_003e: 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_0084: 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_0097: Unknown result type (might be due to invalid IL or missing references) Rect val = default(Rect); ((Rect)(ref val))..ctor(x, y - 2f, bw, icon + 4f); bool flag = mode == d.Mode; p.Fill(val, flag ? new Color(1f, 1f, 1f, 0.15f) : new Color(1f, 1f, 1f, 0.05f)); DrawModeGlyph(val, mode, (Color)(flag ? Accent : new Color(1f, 1f, 1f, 0.45f)), p); d.ModeRects.Add(val); d.ModeIDs.Add(mode); return ((Rect)(ref val)).xMax; } private float DrawToggleButton(float x, float y, float bw, float icon, int id, ChartData d, IChartPainter p) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) Rect box = default(Rect); ((Rect)(ref box))..ctor(x, y - 2f, bw, icon + 4f); AddToggle(box, id, d, p); return ((Rect)(ref box)).xMax; } private static void DrawModeGlyph(Rect box, int mode, Color c, IChartPainter p) { //IL_01e4: Unknown result type (might be due to invalid IL or missing references) //IL_01ec: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0222: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: 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_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0126: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(2f, ((Rect)(ref box)).height * 0.24f); Rect g = default(Rect); ((Rect)(ref g))..ctor(((Rect)(ref box)).x + num, ((Rect)(ref box)).y + num, ((Rect)(ref box)).width - num * 2f, ((Rect)(ref box)).height - num * 2f); if (((Rect)(ref g)).width < 4f || ((Rect)(ref g)).height < 4f) { return; } if (mode == 2) { float num2 = ((Rect)(ref g)).width / 3f; for (int i = 0; i < 3; i++) { float num3 = Mathf.Max(1f, num2 - 1.5f); float num4 = ((Rect)(ref g)).height * (0.34f + (float)i * 0.13f); p.Fill(new Rect(((Rect)(ref g)).x + (float)i * num2, ((Rect)(ref g)).yMax - num4, num3, num4), c); p.Fill(new Rect(((Rect)(ref g)).x + (float)i * num2, ((Rect)(ref g)).y, num3, ((Rect)(ref g)).height - num4 - 1f), new Color(c.r, c.g, c.b, c.a * 0.38f)); } return; } float thick = Mathf.Max(1f, ((Rect)(ref g)).height * 0.16f); if (mode == 0) { float num5 = Mathf.Min(((Rect)(ref box)).width, ((Rect)(ref box)).height) - 2f; Rect r = default(Rect); ((Rect)(ref r))..ctor(((Rect)(ref box)).x + (((Rect)(ref box)).width - num5) * 0.5f, ((Rect)(ref box)).y + (((Rect)(ref box)).height - num5) * 0.5f, num5, num5); if (!p.Icon(r, "#craft", null, c, new Color(0f, 0f, 0f, 0f))) { DrawFactoryGlyph(g, c, p); } } else { DrawGlyphLine(g, RisingLevels, thick, c, p); if (mode == 1) { DrawGlyphLine(g, FallingLevels, thick, new Color(c.r, c.g, c.b, c.a * 0.5f), p); } } } private static void AddToggle(Rect box, int id, ChartData d, IChartPainter p) { //IL_0001: 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_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) p.Fill(box, new Color(1f, 1f, 1f, 0.08f)); if (id == 1) { DrawSideGlyph(box, d.ExpenseSide, p); } else { DrawRangeGlyph(box, d.LastMinute, p); } d.ToggleRects.Add(box); d.ToggleIDs.Add(id); } private static void DrawSideGlyph(Rect box, bool expense, IChartPainter p) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_0139: Unknown result type (might be due to invalid IL or missing references) //IL_013e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(2f, ((Rect)(ref box)).height * 0.24f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref box)).x + num, ((Rect)(ref box)).y + num, ((Rect)(ref box)).width - num * 2f, ((Rect)(ref box)).height - num * 2f); if (!(((Rect)(ref val)).width < 4f) && !(((Rect)(ref val)).height < 4f)) { Color color = (expense ? new Color(0.98f, 0.55f, 0.55f) : new Color(0.55f, 0.95f, 0.6f)); int num2 = Mathf.Max(3, Mathf.RoundToInt(((Rect)(ref val)).height / 2f)); float num3 = ((Rect)(ref val)).height / (float)num2; for (int i = 0; i < num2; i++) { float num4 = (float)i / (float)(num2 - 1); float num5 = (expense ? (1f - num4) : num4); float num6 = Mathf.Max(1f, ((Rect)(ref val)).width * (0.12f + 0.88f * num5)); p.Fill(new Rect(((Rect)(ref val)).x + (((Rect)(ref val)).width - num6) * 0.5f, ((Rect)(ref val)).y + (float)i * num3, num6, Mathf.Max(1f, num3)), color); } } } private static void DrawRangeGlyph(Rect box, bool lastMinute, IChartPainter p) { //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(2f, ((Rect)(ref box)).height * 0.28f); Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref box)).x + num, ((Rect)(ref box)).y + num, ((Rect)(ref box)).width - num * 2f, ((Rect)(ref box)).height - num * 2f); if (!(((Rect)(ref val)).width < 4f) && !(((Rect)(ref val)).height < 4f)) { float num2 = Mathf.Max(2f, ((Rect)(ref val)).height * 0.36f); float num3 = ((Rect)(ref val)).y + (((Rect)(ref val)).height - num2) * 0.5f; p.Fill(new Rect(((Rect)(ref val)).x, num3, ((Rect)(ref val)).width, num2), new Color(1f, 1f, 1f, 0.22f)); float num4 = (lastMinute ? (((Rect)(ref val)).width * 0.3f) : ((Rect)(ref val)).width); p.Fill(new Rect(((Rect)(ref val)).xMax - num4, num3, num4, num2), Accent); } } private static void DrawFactoryGlyph(Rect g, Color c, IChartPainter p) { //IL_008a: 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_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0197: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) float width = ((Rect)(ref g)).width; float height = ((Rect)(ref g)).height; float num = Mathf.Max(1f, height * 0.14f); Color color = default(Color); ((Color)(ref color))..ctor(c.r, c.g, c.b, c.a * 0.45f); float num2 = Mathf.Max(2f, width * 0.16f); float num3 = ((Rect)(ref g)).x + width * 0.12f; p.Fill(new Rect(num3, ((Rect)(ref g)).y + height * 0.34f, num2, height * 0.66f), c); float num4 = Mathf.Max(2f, width * 0.11f); p.Fill(new Rect(num3 + num2 * 0.15f, ((Rect)(ref g)).y + height * 0.14f, num4, num4 * 0.8f), color); p.Fill(new Rect(num3 + num2 * 0.9f, ((Rect)(ref g)).y, num4 * 0.9f, num4 * 0.7f), color); float num5 = ((Rect)(ref g)).x + width * 0.4f; float num6 = ((Rect)(ref g)).xMax - num5; p.Fill(new Rect(num5, ((Rect)(ref g)).y + height * 0.5f, num6 * 0.5f, height * 0.5f), c); p.Fill(new Rect(num5 + num6 * 0.5f, ((Rect)(ref g)).y + height * 0.66f, num6 * 0.5f, height * 0.34f), c); p.Fill(new Rect(((Rect)(ref g)).x, ((Rect)(ref g)).yMax - num, width, num), c); } private static void DrawGlyphLine(Rect g, float[] levels, float thick, Color c, IChartPainter p) { //IL_0048: 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_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref g)).width / (float)levels.Length; float num2 = 0f; for (int i = 0; i < levels.Length; i++) { float num3 = ((Rect)(ref g)).yMax - ((Rect)(ref g)).height * levels[i] - thick; p.Fill(new Rect(((Rect)(ref g)).x + (float)i * num, num3, Mathf.Max(1f, num), thick), c); if (i > 0) { float num4 = Mathf.Min(num2, num3); p.Fill(new Rect(((Rect)(ref g)).x + (float)i * num, num4, thick, Mathf.Abs(num2 - num3) + thick), c); } num2 = num3; } } private void DrawNetChart(Rect r, ChartData d, IChartPainter p) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_029a: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Unknown result type (might be due to invalid IL or missing references) //IL_030e: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_038f: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_0203: Unknown result type (might be due to invalid IL or missing references) //IL_0255: 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_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0267: Unknown result type (might be due to invalid IL or missing references) //IL_0260: Unknown result type (might be due to invalid IL or missing references) TagSeries selected = d.Selected; int num = TotalBuckets(d); if (selected == null || num <= 0) { DrawZeroLine(r, p); return; } BuildNet(d, selected); int num2 = 0; if (d.LastMinute) { int num3 = Mathf.Max(2, Mathf.CeilToInt(60f / d.BucketSeconds)); num2 = Mathf.Max(0, num - num3); } if (num - num2 < 2) { num2 = Mathf.Max(0, num - 2); } long num4 = 0L; long num5 = 0L; for (int i = num2; i < num && i < _netCount; i++) { if (_net[i] > num4) { num4 = _net[i]; } if (_net[i] < num5) { num5 = _net[i]; } } if (num4 == num5) { num4 = num5 + 1; } float num6 = p.FontSize + 4f; float num7 = Mathf.Max(p.Measure(N(num4)), p.Measure("-" + N(-num5))) + 10f; Rect plot = default(Rect); ((Rect)(ref plot))..ctor(((Rect)(ref r)).x + num7, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - num7 - 6f, ((Rect)(ref r)).height - num6 - 6f); if (((Rect)(ref plot)).width < 20f || ((Rect)(ref plot)).height < 20f) { return; } float num8 = ValueToY(plot, num5, num4, 0L); int num9 = num - num2; int num10 = Mathf.Max(2, Mathf.CeilToInt(((Rect)(ref plot)).width)); float num11 = 0f; for (int j = 0; j < num10; j++) { int num12 = num2 + (int)((long)j * (long)(num9 - 1) / (num10 - 1)); long num13 = ((num12 < _netCount) ? _net[num12] : 0); float num14 = ValueToY(plot, num5, num4, num13); float num15 = Mathf.Min(num14, num8); float num16 = Mathf.Abs(num14 - num8); if (num16 >= 1f) { p.Fill(new Rect(((Rect)(ref plot)).x + (float)j, num15, 1f, num16), (num13 >= 0) ? NetFillUp : NetFillDown); } if (j == 0) { num11 = num14; } float num17 = Mathf.Min(num11, num14); p.Fill(new Rect(((Rect)(ref plot)).x + (float)j, num17, 1.6f, Mathf.Abs(num11 - num14) + 1.6f), (num13 >= 0) ? NetLineUp : NetLineDown); num11 = num14; } p.Fill(new Rect(((Rect)(ref plot)).x, num8, ((Rect)(ref plot)).width, 1f), new Color(1f, 1f, 1f, 0.35f)); p.Text(((Rect)(ref r)).x, ((Rect)(ref plot)).y - 2f, N(num4), Ink); p.Text(((Rect)(ref r)).x, num8 - p.FontSize * 0.6f, "0", new Color(0.75f, 0.72f, 0.68f)); if (num5 < 0) { p.Text(((Rect)(ref r)).x, ((Rect)(ref plot)).yMax - p.FontSize, "-" + N(-num5), Ink); } DrawRepaymentMarks(plot, d, num2, num, p); double seconds = (double)num2 * (double)d.BucketSeconds; double seconds2 = (double)num * (double)d.BucketSeconds; p.Text(((Rect)(ref plot)).x, ((Rect)(ref plot)).yMax + 2f, FormatTime(seconds), Ink); string text = FormatTime(seconds2); p.Text(((Rect)(ref plot)).xMax - p.Measure(text), ((Rect)(ref plot)).yMax + 2f, text, Ink); } private static bool IsSteadyFlow(int reason) { if (reason != 2 && reason != 13) { return reason == 14; } return true; } private void BuildNet(ChartData d, TagSeries s) { int num = TotalBuckets(d); if (num <= 0) { _netCount = 0; _netLast = 0L; return; } int num2 = Mathf.Max(1, Mathf.CeilToInt(60f / d.BucketSeconds)); if (_net == null || _net.Length < num) { int num3 = Mathf.Max(num, 256); _net = new long[num3]; _bucketNet = new long[num3]; _netTag = null; } bool flag = _netTag != s.TagID || _netCount != num || _netWindow != num2; int num4 = ((!flag) ? (num - 1) : 0); for (int i = num4; i < num; i++) { long num5 = 0L; for (int j = 0; j < 16; j++) { if (IsSteadyFlow(j)) { num5 += s.FlowAt(i, j); num5 -= s.FlowAt(i, 16 + j); } } _bucketNet[i] = num5; long num6 = 0L; int num7 = i - num2 + 1; if (num7 < 0) { num7 = 0; } if (flag && i > 0 && num7 > 0) { num6 = _net[i - 1] + num5 - _bucketNet[num7 - 1]; } else if (flag && i > 0) { num6 = _net[i - 1] + num5; } else { for (int k = num7; k <= i; k++) { num6 += _bucketNet[k]; } } _net[i] = num6; } _netTag = s.TagID; _netCount = num; _netWindow = num2; _netLast = _net[num - 1]; } private void DrawRates(Rect r, ChartData d, IChartPainter p) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_0258: Unknown result type (might be due to invalid IL or missing references) //IL_0302: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0366: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03dd: Unknown result type (might be due to invalid IL or missing references) //IL_057d: Unknown result type (might be due to invalid IL or missing references) //IL_05ad: Unknown result type (might be due to invalid IL or missing references) //IL_048a: Unknown result type (might be due to invalid IL or missing references) //IL_048f: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_051d: Unknown result type (might be due to invalid IL or missing references) //IL_066f: Unknown result type (might be due to invalid IL or missing references) //IL_0688: Unknown result type (might be due to invalid IL or missing references) //IL_0708: Unknown result type (might be due to invalid IL or missing references) //IL_06db: Unknown result type (might be due to invalid IL or missing references) //IL_06e8: Unknown result type (might be due to invalid IL or missing references) if (d.RateSources.Count == 0 || d.Selected == null) { DrawZeroLine(r, p); return; } float lineHeight = p.LineHeight; float iconSize = Mathf.Max(12f, lineHeight); _rank.Clear(); _rankTotals.Clear(); _rateLines.Clear(); long num = 0L; for (int i = 0; i < d.RateSources.Count && i < d.RateValues.Count; i++) { _rank.Add(d.RateSources[i]); _rankTotals.Add(d.RateTotals[i]); _rateLines.Add(d.RateValues[i]); num += d.RateTotals[i]; } if (num <= 0) { DrawZeroLine(r, p); return; } AssignRankColors(d.Selected.TagID); while (_rank.Count > 1 && LegendWidth(p, iconSize, num) > ((Rect)(ref r)).width) { _rank.RemoveAt(_rank.Count - 1); _rankColors.RemoveAt(_rankColors.Count - 1); _rankTotals.RemoveAt(_rankTotals.Count - 1); _rateLines.RemoveAt(_rateLines.Count - 1); } long num2 = 0L; for (int j = 0; j < _rankTotals.Count; j++) { num2 += _rankTotals[j]; } float num3 = DrawSourceLegend(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, lineHeight, iconSize, d.Selected.TagID, num, num - num2, p); float num4 = 0f; int num5 = 0; for (int k = 0; k < _rateLines.Count; k++) { float[] array = _rateLines[k]; if (array.Length > num5) { num5 = array.Length; } for (int l = 0; l < array.Length; l++) { if (array[l] > num4) { num4 = array[l]; } } } if (num4 <= 0f || num5 < 2) { DrawZeroLine(new Rect(((Rect)(ref r)).x, num3, ((Rect)(ref r)).width, ((Rect)(ref r)).yMax - num3), p); return; } float num6 = p.FontSize + 4f; float num7 = p.Measure(N((long)num4)) + 10f; float num8 = lineHeight + 4f; Rect plot = default(Rect); ((Rect)(ref plot))..ctor(((Rect)(ref r)).x + num7, num3 + 2f, ((Rect)(ref r)).width - num7 - num8, ((Rect)(ref r)).yMax - num3 - num6 - 6f); if (((Rect)(ref plot)).width < 20f || ((Rect)(ref plot)).height < 20f) { return; } p.Fill(new Rect(((Rect)(ref plot)).x, ((Rect)(ref plot)).yMax, ((Rect)(ref plot)).width, 1f), Faint); p.Fill(new Rect(((Rect)(ref plot)).x, ((Rect)(ref plot)).y + ((Rect)(ref plot)).height * 0.5f, ((Rect)(ref plot)).width, 1f), Fainter); p.Text(((Rect)(ref r)).x, ((Rect)(ref plot)).y - 2f, N((long)num4), Ink); p.Text(((Rect)(ref r)).x, ((Rect)(ref plot)).yMax - p.FontSize * 0.6f, "0", Ink); float num9 = num5 - 1; _ = ((Rect)(ref plot)).width / num9; float num10 = ((Rect)(ref plot)).height / num4; Rect r2 = default(Rect); for (int m = 0; m < _rateLines.Count; m++) { float[] array2 = _rateLines[m]; Color val = _rankColors[m]; int num11 = Mathf.Max(2, Mathf.CeilToInt(((Rect)(ref plot)).width)); float num12 = 0f; for (int n = 0; n < num11; n++) { float num13 = (float)n / (float)(num11 - 1) * num9; int num14 = Mathf.Clamp((int)num13, 0, array2.Length - 1); int num15 = Mathf.Min(num14 + 1, array2.Length - 1); float num16 = ((Rect)(ref plot)).yMax - Mathf.Lerp(array2[num14], array2[num15], num13 - (float)num14) * num10; if (n == 0) { num12 = num16; } float num17 = Mathf.Min(num12, num16); p.Fill(new Rect(((Rect)(ref plot)).x + (float)n, num17, 1.6f, Mathf.Abs(num12 - num16) + 1.6f), val); num12 = num16; } float num18 = Mathf.Min(num8, lineHeight); if (num18 >= 10f) { ((Rect)(ref r2))..ctor(((Rect)(ref plot)).xMax + 2f, num12 - num18 * 0.5f, num18, num18); ((Rect)(ref r2)).y = Mathf.Clamp(((Rect)(ref r2)).y, ((Rect)(ref plot)).y, ((Rect)(ref plot)).yMax - num18); DrawSourceIcon(r2, _rank[m], d.Selected.TagID, val, p); } } string text = "-" + ((int)(num9 * d.RateSlotSeconds)).ToString(CultureInfo.InvariantCulture) + "s"; p.Text(((Rect)(ref plot)).x, ((Rect)(ref plot)).yMax + 2f, text, Ink); p.Text(((Rect)(ref plot)).xMax - p.Measure("0"), ((Rect)(ref plot)).yMax + 2f, "0", Ink); if (!d.MouseValid || d.Mouse.x < ((Rect)(ref plot)).x || d.Mouse.x > ((Rect)(ref plot)).xMax || d.Mouse.y < ((Rect)(ref plot)).y || d.Mouse.y > ((Rect)(ref plot)).yMax) { return; } int num19 = Mathf.Clamp(Mathf.RoundToInt((d.Mouse.x - ((Rect)(ref plot)).x) / ((Rect)(ref plot)).width * num9), 0, num5 - 1); float num20 = ((Rect)(ref plot)).x + (float)num19 / num9 * ((Rect)(ref plot)).width; p.Fill(new Rect(num20, ((Rect)(ref plot)).y, 1f, ((Rect)(ref plot)).height), new Color(1f, 1f, 1f, 0.35f)); for (int num21 = 0; num21 < _rateLines.Count; num21++) { float[] array3 = _rateLines[num21]; if (num19 < array3.Length) { float num22 = ((Rect)(ref plot)).yMax - array3[num19] * num10; p.Fill(new Rect(num20 - 2f, num22 - 2f, 5f, 5f), _rankColors[num21]); } } DrawRateHover(plot, d, num19, num5, p); } private void DrawRateHover(Rect plot, ChartData d, int at, int slots, IChartPainter p) { //IL_031c: Unknown result type (might be due to invalid IL or missing references) //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0365: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03b5: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03ee: Unknown result type (might be due to invalid IL or missing references) //IL_0407: Unknown result type (might be due to invalid IL or missing references) //IL_043b: Unknown result type (might be due to invalid IL or missing references) //IL_0461: Unknown result type (might be due to invalid IL or missing references) //IL_0472: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_050b: Unknown result type (might be due to invalid IL or missing references) //IL_0597: Unknown result type (might be due to invalid IL or missing references) //IL_05d5: Unknown result type (might be due to invalid IL or missing references) //IL_063f: Unknown result type (might be due to invalid IL or missing references) //IL_055e: Unknown result type (might be due to invalid IL or missing references) _rateOrder.Clear(); long num = 0L; for (int i = 0; i < _rateLines.Count; i++) { if (at < _rateLines[i].Length && !(_rateLines[i][at] <= 0f)) { _rateOrder.Add(i); num += (long)_rateLines[i][at]; } } if (_rateOrder.Count == 0) { return; } float[][] lines = _rateLines.ToArray(); _rateOrder.Sort((int a, int b) => lines[b][at].CompareTo(lines[a][at])); float num2 = Mathf.Max(12f, p.LineHeight); int num3 = Mathf.Min(_rateOrder.Count, 10); float num4 = Mathf.Max(num2, p.LineHeight) + 2f; float num5 = 6f; float num6 = 0f; float num7 = 0f; float num8 = 0f; for (int num9 = 0; num9 < num3; num9++) { SourceSeries sourceSeries = _rank[_rateOrder[num9]]; long num10 = (long)_rateLines[_rateOrder[num9]][at]; num6 = Mathf.Max(num6, p.Measure(N(num10))); num7 = Mathf.Max(num7, p.Measure(Percent(num10, num))); if (!sourceSeries.HasSource) { num8 = Mathf.Max(num8, p.Measure(p.ReasonLabel(sourceSeries.Reason)) + 8f); } } int num11 = (int)((float)(slots - 1 - at) * d.RateSlotSeconds); string text = ((num11 > 0) ? ("-" + num11.ToString(CultureInfo.InvariantCulture) + "s") : "0"); string text2 = N(num); float num12 = p.Measure(text) + 6f + num2 + 4f + p.Measure(text2); float num13 = Mathf.Max(num12, num2 + 6f + num8 + num6 + 6f + num7) + num5 * 2f; float num14 = num5 * 2f + num4 + (float)num3 * num4; if (_rateOrder.Count > num3) { num14 += p.LineHeight; } float num15 = d.Mouse.x + 14f; float num16 = d.Mouse.y + 10f; if (num15 + num13 > ((Rect)(ref plot)).xMax) { num15 = d.Mouse.x - 14f - num13; } if (num16 + num14 > ((Rect)(ref plot)).yMax) { num16 = ((Rect)(ref plot)).yMax - num14; } if (num15 < ((Rect)(ref plot)).x) { num15 = ((Rect)(ref plot)).x; } if (num16 < ((Rect)(ref plot)).y) { num16 = ((Rect)(ref plot)).y; } p.Fill(new Rect(num15, num16, num13, num14), new Color(0.04f, 0.04f, 0.05f, 0.94f)); p.Fill(new Rect(num15, num16, num13, 1f), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num15, num16 + num14 - 1f, num13, 1f), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num15, num16, 1f, num14), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num15 + num13 - 1f, num16, 1f, num14), new Color(1f, 1f, 1f, 0.25f)); float num17 = (num2 - p.FontSize) * 0.5f; float num18 = num16 + num5; float num19 = num15 + num5; p.Text(num19, num18 + num17, text, Accent); num19 += p.Measure(text) + 6f; p.Icon(new Rect(num19, num18, num2, num2), null, d.Selected.TagID, Ink, IconOutline); num19 += num2 + 4f; p.Text(num19, num18 + num17, text2, Ink); num18 += num4; for (int num20 = 0; num20 < num3; num20++) { int index = _rateOrder[num20]; SourceSeries sourceSeries2 = _rank[index]; long num21 = (long)_rateLines[index][at]; DrawSourceIcon(new Rect(num15 + num5, num18, num2, num2), sourceSeries2, d.Selected.TagID, _rankColors[index], p); if (!sourceSeries2.HasSource) { string text3 = p.ReasonLabel(sourceSeries2.Reason); if (!string.IsNullOrEmpty(text3)) { p.Text(num15 + num5 + num2 + 6f, num18 + num17, text3, new Color(0.78f, 0.75f, 0.7f)); } } string text4 = N(num21); p.Text(num15 + num5 + num2 + 6f + num8 + (num6 - p.Measure(text4)), num18 + num17, text4, Ink); string text5 = Percent(num21, num); p.Text(num15 + num13 - num5 - p.Measure(text5), num18 + num17, text5, new Color(0.75f, 0.72f, 0.68f)); num18 += num4; } if (_rateOrder.Count > num3) { p.Text(num15 + num5, num18, "+" + (_rateOrder.Count - num3).ToString(CultureInfo.InvariantCulture), new Color(0.65f, 0.62f, 0.58f)); } } private static void DrawZeroLine(Rect r, IChartPainter p) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: 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_00c1: 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) float num = p.FontSize + 4f; float num2 = p.Measure("0") + 10f; Rect val = default(Rect); ((Rect)(ref val))..ctor(((Rect)(ref r)).x + num2, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - num2 - 4f, ((Rect)(ref r)).height - num - 6f); if (!(((Rect)(ref val)).width < 8f) && !(((Rect)(ref val)).height < 8f)) { p.Fill(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), Fainter); p.Fill(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).yMax, ((Rect)(ref val)).width, 2f), ZeroColor); p.Text(((Rect)(ref r)).x, ((Rect)(ref val)).yMax - p.FontSize * 0.6f, "0", Ink); } } private static void DrawZeroColumn(float cx, float bw, float baseline, float fullHeight, IChartPainter p) { //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_005a: 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_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_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) Rect val = default(Rect); ((Rect)(ref val))..ctor(cx + 1f, baseline - fullHeight, bw, fullHeight); p.Fill(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 1f), Fainter); p.Fill(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), Fainter); p.Fill(new Rect(((Rect)(ref val)).xMax - 1f, ((Rect)(ref val)).y, 1f, ((Rect)(ref val)).height), Fainter); float num = Mathf.Max(4f, fullHeight * 0.018f); p.Fill(new Rect(((Rect)(ref val)).x, baseline - num, ((Rect)(ref val)).width, num), ZeroColor); } private void DrawBalanceChart(Rect r, ChartData d, TagSeries single, IChartPainter p) { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: 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_0219: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_02af: Unknown result type (might be due to invalid IL or missing references) //IL_02e2: 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_031c: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0465: Unknown result type (might be due to invalid IL or missing references) //IL_049a: Unknown result type (might be due to invalid IL or missing references) //IL_04e2: Unknown result type (might be due to invalid IL or missing references) //IL_04e7: Unknown result type (might be due to invalid IL or missing references) //IL_0521: Unknown result type (might be due to invalid IL or missing references) //IL_0387: Unknown result type (might be due to invalid IL or missing references) //IL_0392: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_03d8: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) int num = TotalBuckets(d); if (num <= 0) { DrawZeroLine(r, p); return; } int num2 = 0; if (d.LastMinute) { int num3 = Mathf.Max(2, Mathf.CeilToInt(60f / d.BucketSeconds)); num2 = Mathf.Max(0, num - num3); } if (num - num2 < 2) { num2 = Mathf.Max(0, num - 2); } float num4 = p.Measure("00,000") + 10f; float num5 = p.FontSize + 4f; float num6 = ((single == null) ? (p.LineHeight + 4f) : 4f); Rect plot = default(Rect); ((Rect)(ref plot))..ctor(((Rect)(ref r)).x + num4, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width - num4 - num6, ((Rect)(ref r)).height - num5 - 6f); if (((Rect)(ref plot)).width < 20f || ((Rect)(ref plot)).height < 20f) { return; } long min = long.MaxValue; long max = long.MinValue; if (single != null) { ScanRange(single, num2, num, ref min, ref max); } else { for (int i = 0; i < d.Ordered.Count; i++) { if (!d.HiddenTags.Contains(d.Ordered[i].TagID)) { ScanRange(d.Ordered[i], num2, num, ref min, ref max); } } } if (min == long.MaxValue) { min = 0L; max = 1L; } if (max <= min) { max = min + 1; } long num7 = (long)Math.Max(1.0, (double)(max - min) * 0.06); max += num7; min -= num7; if (min < 0 && !HasNegative(d, single, num2, num)) { min = 0L; } p.Fill(new Rect(((Rect)(ref plot)).x, ((Rect)(ref plot)).yMax, ((Rect)(ref plot)).width, 1f), Faint); p.Fill(new Rect(((Rect)(ref plot)).x, ((Rect)(ref plot)).y + ((Rect)(ref plot)).height * 0.5f, ((Rect)(ref plot)).width, 1f), Fainter); float num8 = ((Rect)(ref r)).x + num4 - 6f; long v = min + (max - min) / 2; p.Text(num8 - p.Measure(N(max)), ((Rect)(ref plot)).y - 2f, N(max), Ink); p.Text(num8 - p.Measure(N(v)), ((Rect)(ref plot)).y + ((Rect)(ref plot)).height * 0.5f - p.FontSize * 0.5f, N(v), Ink); p.Text(num8 - p.Measure(N(min)), ((Rect)(ref plot)).yMax - p.FontSize, N(min), Ink); DrawRepaymentMarks(plot, d, num2, num, p); int num9 = ColumnCount(((Rect)(ref plot)).width, d.MaxColumns); float colW = ((Rect)(ref plot)).width / (float)num9; if (single != null) { DrawBalanceLine(plot, single, num2, num, num9, colW, min, max, TagColor(single.TagID), p); } else { _lineColors.Clear(); for (int j = 0; j < d.Ordered.Count; j++) { if (!d.HiddenTags.Contains(d.Ordered[j].TagID)) { _lineColors.Add(Separate(TagColor(d.Ordered[j].TagID), _lineColors)); } } int num10 = 0; for (int k = 0; k < d.Ordered.Count; k++) { if (!d.HiddenTags.Contains(d.Ordered[k].TagID)) { DrawBalanceLine(plot, d.Ordered[k], num2, num, num9, colW, min, max, _lineColors[num10], p); num10++; } } DrawLineEndCaps(plot, d, num, min, max, p); } double num11 = (double)num2 * (double)d.BucketSeconds; double num12 = (double)num * (double)d.BucketSeconds; p.Text(((Rect)(ref plot)).x, ((Rect)(ref plot)).yMax + 2f, FormatTime(num11), Ink); string text = FormatTime(num12); p.Text(((Rect)(ref plot)).xMax - p.Measure(text), ((Rect)(ref plot)).yMax + 2f, text, Ink); string text2 = FormatTime((num11 + num12) * 0.5); p.Fill(new Rect(((Rect)(ref plot)).x + ((Rect)(ref plot)).width * 0.5f, ((Rect)(ref plot)).yMax, 1f, 4f), Faint); p.Text(((Rect)(ref plot)).x + (((Rect)(ref plot)).width - p.Measure(text2)) * 0.5f, ((Rect)(ref plot)).yMax + 2f, text2, Ink); } private static bool HasNegative(ChartData d, TagSeries single, int from, int count) { if (single != null) { return HasNegative(single, from, count); } for (int i = 0; i < d.Ordered.Count; i++) { if (!d.HiddenTags.Contains(d.Ordered[i].TagID) && HasNegative(d.Ordered[i], from, count)) { return true; } } return false; } private static bool HasNegative(TagSeries s, int from, int count) { for (int i = from; i < count; i++) { if (s.BalanceAt(i) < 0) { return true; } } return false; } private void DrawLineEndCaps(Rect plot, ChartData d, int count, long min, long max, IChartPainter p) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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_0164: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) float lineHeight = p.LineHeight; if (((Rect)(ref plot)).height < lineHeight * 2f) { return; } _capOrder.Clear(); _capY.Clear(); for (int i = 0; i < d.Ordered.Count; i++) { if (!d.HiddenTags.Contains(d.Ordered[i].TagID)) { _capOrder.Add(d.Ordered[i]); _capY.Add(ValueToY(plot, min, max, d.Ordered[i].BalanceAt(count - 1))); } } if (_capOrder.Count != 0) { SortCapsByY(); float num = float.MinValue; for (int j = 0; j < _capY.Count; j++) { float num2 = Mathf.Max(_capY[j], num + lineHeight + 1f); _capY[j] = Mathf.Min(num2, ((Rect)(ref plot)).yMax - lineHeight); num = _capY[j]; } float num3 = ((Rect)(ref plot)).xMax - lineHeight; Rect val = default(Rect); for (int k = 0; k < _capOrder.Count; k++) { ((Rect)(ref val))..ctor(num3, _capY[k] - lineHeight * 0.5f, lineHeight, lineHeight); p.Icon(val, null, _capOrder[k].TagID, Ink, IconOutline); d.IconRects.Add(val); d.IconTagIDs.Add(_capOrder[k].TagID); } } } private void SortCapsByY() { for (int i = 1; i < _capY.Count; i++) { float num = _capY[i]; TagSeries value = _capOrder[i]; int num2 = i - 1; while (num2 >= 0 && _capY[num2] > num) { _capY[num2 + 1] = _capY[num2]; _capOrder[num2 + 1] = _capOrder[num2]; num2--; } _capY[num2 + 1] = num; _capOrder[num2 + 1] = value; } } private static void ScanRange(TagSeries s, int from, int count, ref long min, ref long max) { for (int i = from; i < count; i++) { long num = s.BalanceAt(i); if (num < min) { min = num; } if (num > max) { max = num; } } } private static void DrawBalanceLine(Rect plot, TagSeries s, int from, int count, int cols, float colW, long min, long max, Color stroke, IChartPainter p) { //IL_000e: 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_00b7: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) int num = count - from; if (num <= 0) { return; } if (num < cols) { DrawInterpolatedLine(plot, s, from, count, cols, colW, min, max, stroke, p); return; } float num2 = float.NaN; for (int i = 0; i < cols; i++) { int num3 = from + (int)((long)i * (long)num / cols); int num4 = from + (int)((long)(i + 1) * (long)num / cols); if (num4 <= num3) { num4 = num3 + 1; } long num5 = long.MaxValue; long num6 = long.MinValue; long value = 0L; for (int j = num3; j < num4 && j < count; j++) { long num7 = s.BalanceAt(j); if (num7 < num5) { num5 = num7; } if (num7 > num6) { num6 = num7; } value = num7; } if (num5 != long.MaxValue) { float num8 = ValueToY(plot, min, max, num6); float num9 = ValueToY(plot, min, max, num5); if (!float.IsNaN(num2)) { num8 = Mathf.Min(num8, num2); num9 = Mathf.Max(num9, num2); } float num10 = ((Rect)(ref plot)).x + (float)i * colW; p.Fill(new Rect(num10, num8, colW, Mathf.Max(2f, num9 - num8 + 2f)), stroke); num2 = ValueToY(plot, min, max, value); } } } private static void DrawInterpolatedLine(Rect plot, TagSeries s, int from, int count, int cols, float colW, long min, long max, Color stroke, IChartPainter p) { //IL_005c: 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_00c7: Unknown result type (might be due to invalid IL or missing references) int num = count - from; float num2 = float.NaN; for (int i = 0; i < cols; i++) { float num3 = (float)from + (float)i * (float)(num - 1) / (float)(cols - 1); int num4 = (int)num3; int bucket = Mathf.Min(num4 + 1, count - 1); float num5 = num3 - (float)num4; float value = (float)s.BalanceAt(num4) * (1f - num5) + (float)s.BalanceAt(bucket) * num5; float num6 = ValueToYFloat(plot, min, max, value); float num7 = ((Rect)(ref plot)).x + (float)i * colW; float num8 = (float.IsNaN(num2) ? num6 : Mathf.Min(num2, num6)); float num9 = (float.IsNaN(num2) ? num6 : Mathf.Max(num2, num6)); p.Fill(new Rect(num7, num8, colW, Mathf.Max(2f, num9 - num8 + 2f)), stroke); num2 = num6; } } private static float ValueToYFloat(Rect plot, long min, long max, float value) { double num = ((double)value - (double)min) / (double)(max - min); if (num < 0.0) { num = 0.0; } if (num > 1.0) { num = 1.0; } return ((Rect)(ref plot)).yMax - (float)(num * (double)((Rect)(ref plot)).height); } private static void DrawRepaymentMarks(Rect plot, ChartData d, int from, int count, IChartPainter p) { //IL_0122: 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_012b: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) double num = (double)from * (double)d.BucketSeconds; double num2 = (double)count * (double)d.BucketSeconds; double num3 = num2 - num; if (num3 <= 0.0) { return; } float num4 = float.MinValue; Color val = default(Color); ((Color)(ref val))..ctor(0.92f, 0.34f, 0.36f, 0.28f); Color val2 = default(Color); ((Color)(ref val2))..ctor(0.95f, 0.38f, 0.4f, 0.85f); for (int i = 0; i < d.PeriodEnds.Count; i++) { double num5 = d.PeriodEnds[i]; if (num5 < num || num5 > num2) { continue; } int num6 = ((i < d.PeriodRepaid.Count) ? d.PeriodRepaid[i] : (i + 1)); int num7 = ((i > 0 && i - 1 < d.PeriodRepaid.Count) ? d.PeriodRepaid[i - 1] : 0); bool flag = num6 / 5 != num7 / 5; float num8 = ((Rect)(ref plot)).x + (float)((num5 - num) / num3) * ((Rect)(ref plot)).width; p.Fill(new Rect(num8, ((Rect)(ref plot)).y, flag ? 2f : 1f, ((Rect)(ref plot)).height), flag ? val2 : val); if (flag) { string text = num6.ToString(CultureInfo.InvariantCulture); if (!(num8 + 3f < num4)) { p.Text(num8 + 3f, ((Rect)(ref plot)).y, text, new Color(0.98f, 0.62f, 0.62f)); num4 = num8 + 3f + p.Measure(text) + 3f; } } } } private void DrawComposition(Rect r, ChartData d, IChartPainter p) { //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01b5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0205: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) TagSeries selected = d.Selected; List list = (d.ExpenseSide ? selected.ExpenseSources : selected.IncomeSources); float lineHeight = p.LineHeight; float num = Mathf.Max(10f, lineHeight * 0.7f); float iconSize = Mathf.Max(16f, lineHeight * 1.6f); float iconSize2 = Mathf.Max(12f, lineHeight); long num2 = 0L; for (int i = 0; i < list.Count; i++) { if (list[i].Total > 0) { num2 += list[i].Total; } } if (num2 <= 0) { num2 = 1L; } RankSources(list, selected.TagID, SourcePalette.Length); while (_rank.Count > 1 && LegendWidth(p, iconSize2, num2) > ((Rect)(ref r)).width) { _rank.RemoveAt(_rank.Count - 1); _rankColors.RemoveAt(_rankColors.Count - 1); } if (_rank.Count == 0) { DrawPeriodColumns(r, d, list, iconSize, p); return; } long num3 = 0L; for (int j = 0; j < _rank.Count; j++) { num3 += _rank[j].Total; } long num4 = num2 - num3; float num5 = ((Rect)(ref r)).x; for (int k = 0; k < _rank.Count; k++) { float num6 = ((Rect)(ref r)).width * (float)((double)_rank[k].Total / (double)num2); p.Fill(new Rect(num5, ((Rect)(ref r)).y, Mathf.Max(1f, num6 - 1f), num), _rankColors[k]); num5 += num6; } if (num4 > 0) { p.Fill(new Rect(num5, ((Rect)(ref r)).y, Mathf.Max(1f, ((Rect)(ref r)).xMax - num5), num), OthersColor); } float y = ((Rect)(ref r)).y + num + 4f; y = DrawSourceLegend(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, lineHeight, iconSize2, selected.TagID, num2, num4, p); Rect r2 = default(Rect); ((Rect)(ref r2))..ctor(((Rect)(ref r)).x, y, ((Rect)(ref r)).width, ((Rect)(ref r)).yMax - y); if (((Rect)(ref r2)).height > 40f) { DrawPeriodColumns(r2, d, list, iconSize, p); } } private static long ColumnRepaidSum(List all, int period) { long num = 0L; for (int i = 0; i < all.Count; i++) { num += all[i].RepaidAt(period); } return num; } private static long Value(SourceSeries src, int period, bool byRepaid) { if (!byRepaid) { return src.At(period); } return src.RepaidAt(period); } private float LegendWidth(IChartPainter p, float iconSize, long grand) { float num = 0f; long num2 = 0L; for (int i = 0; i < _rank.Count; i++) { num2 += _rankTotals[i]; num += iconSize + 2f + p.Measure(Percent(_rankTotals[i], grand)) + 10f; } long num3 = grand - num2; if (num3 > 0) { num += iconSize + 2f + p.Measure(Percent(num3, grand)) + 10f; } return num; } private float DrawSourceLegend(float x, float y, float w, float line, float iconSize, string tagID, long grand, long others, IChartPainter p) { //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) //IL_00e3: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: 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_00da: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) float num = x; float num2 = y; int num3 = 1; Rect r = default(Rect); for (int i = 0; i <= _rank.Count; i++) { bool flag = i == _rank.Count; if (flag && others <= 0) { break; } long num4 = (flag ? others : _rankTotals[i]); string text = ((int)Math.Round((double)num4 * 100.0 / (double)grand)).ToString(CultureInfo.InvariantCulture) + "%"; float num5 = iconSize + 2f + p.Measure(text) + 10f; if (num + num5 > x + w) { if (num3 >= 2) { break; } num3++; num = x; num2 += line + 2f; } Color val = (flag ? OthersColor : _rankColors[i]); ((Rect)(ref r))..ctor(num, num2, iconSize, iconSize); if (flag) { p.Fill(r, val); } else { DrawSourceIcon(r, _rank[i], tagID, val, p); } p.Fill(new Rect(num, num2 + iconSize, iconSize, 2f), val); p.Text(num + iconSize + 2f, num2 + (iconSize - p.FontSize) * 0.5f, text, Ink); num += num5; } return num2 + iconSize + 6f; } private void DrawPeriodColumns(Rect r, ChartData d, List all, float iconSize, IChartPainter p) { //IL_00ba: 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_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0428: 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_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0342: Unknown result type (might be due to invalid IL or missing references) //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_0269: Unknown result type (might be due to invalid IL or missing references) //IL_0276: 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_02e8: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(1, d.PeriodIndex + 1); float num2 = p.FontSize + 4f; float num3 = 2f; Rect plot = default(Rect); ((Rect)(ref plot))..ctor(((Rect)(ref r)).x + num3, ((Rect)(ref r)).y, ((Rect)(ref r)).width - num3 - 2f, ((Rect)(ref r)).height - num2 - 2f); if (((Rect)(ref plot)).width < 20f || ((Rect)(ref plot)).height < 20f) { return; } bool flag = UsesNorm(d); if (flag) { NormRatio(d); } float yMax = ((Rect)(ref plot)).yMax; float height = ((Rect)(ref plot)).height; p.Fill(new Rect(((Rect)(ref plot)).x, yMax - height * 0.5f, ((Rect)(ref plot)).width, 1f), Faint); p.Fill(new Rect(((Rect)(ref plot)).x, yMax, ((Rect)(ref plot)).width, 1f), Faint); float num4 = ((Rect)(ref plot)).width / (float)num; float num5 = Mathf.Max(1f, num4 - 2f); int num6 = num - 1; float num7 = Mathf.Min(iconSize, num5); Rect r2 = default(Rect); for (int i = 0; i < num; i++) { bool byRepaid = ColumnRepaidSum(all, i) > 0; long num8 = 0L; for (int j = 0; j < all.Count; j++) { num8 += Value(all[j], i, byRepaid); } float num9 = ((Rect)(ref plot)).x + (float)i * num4; bool flag2 = i == num6; if (flag2) { DrawCurrentFrame(new Rect(num9, ((Rect)(ref plot)).y, num4, yMax - ((Rect)(ref plot)).y), p); } if (flag2 && flag) { DrawHoldingColumn(num9, num5, yMax, height, num7, d, all, p); continue; } if (num8 <= 0) { DrawZeroColumn(num9, num5, yMax, height, p); continue; } float num10 = height; float num11 = ((num8 > 0) ? (num10 / (float)num8) : 0f); float num12 = yMax; long num13 = 0L; for (int k = 0; k < _rank.Count; k++) { long num14 = Value(_rank[k], i, byRepaid); if (num14 <= 0) { continue; } num13 += num14; float num15 = (float)num14 * num11; if (!(num15 <= 0f)) { num12 -= num15; p.Fill(new Rect(num9 + 1f, num12, num5, Mathf.Max(1f, num15)), _rankColors[k]); if (num7 >= 16f && num15 >= num7 + 4f) { float num16 = num7; ((Rect)(ref r2))..ctor(num9 + 1f + (num5 - num16) * 0.5f, num12 + (num15 - num16) * 0.5f, num16, num16); DrawSourceIcon(r2, _rank[k], d.Selected.TagID, _rankColors[k], p); } } } long num17 = num8 - num13; if (num17 > 0) { float num18 = (float)num17 * num11; num12 -= num18; p.Fill(new Rect(num9 + 1f, num12, num5, Mathf.Max(1f, num18)), OthersColor); } } bool flag3 = num <= 12; for (int l = 0; l < num; l++) { if (l < d.PeriodRepaid.Count) { int num19 = d.PeriodRepaid[l]; int num20 = ((l > 0) ? d.PeriodRepaid[l - 1] : 0); if (flag3 || l == 0 || num19 / 5 != num20 / 5) { string text = num19.ToString(CultureInfo.InvariantCulture); p.Text(((Rect)(ref plot)).x + (float)l * num4 + num4 * 0.5f - p.Measure(text) * 0.5f, ((Rect)(ref plot)).yMax + 2f, text, Ink); } } } DrawHover(plot, d, all, num, num4, iconSize, flag, p); } private void DrawHover(Rect plot, ChartData d, List all, int total, float cw, float iconSize, bool useNorm, IChartPainter p) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0115: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) if (!d.MouseValid || !((Rect)(ref plot)).Contains(d.Mouse)) { return; } int num = (int)((d.Mouse.x - ((Rect)(ref plot)).x) / cw); if (num < 0 || num >= total) { return; } _hoverHeld = useNorm && num == total - 1; _hoverByRepaid = ColumnRepaidSum(all, num) > 0; _hoverPeriod = num; _hover.Clear(); long num2 = 0L; for (int i = 0; i < all.Count; i++) { long num3 = HoverValue(all[i]); if (num3 > 0) { _hover.Add(all[i]); num2 += num3; } } if (_hover.Count != 0 && num2 > 0) { _hover.Sort(CompareHover); float num4 = ((Rect)(ref plot)).x + (float)num * cw; p.Fill(new Rect(num4, ((Rect)(ref plot)).y, cw, ((Rect)(ref plot)).height), new Color(1f, 1f, 1f, 0.1f)); long denom = ((_hoverHeld && d.RequiredCount > 0) ? d.RequiredCount : num2); DrawHoverBox(plot, d, num, num2, denom, iconSize, p); } } private int CompareHover(SourceSeries a, SourceSeries b) { return HoverValue(b).CompareTo(HoverValue(a)); } private long HoverValue(SourceSeries src) { if (_hoverHeld) { return src.Held; } return Value(src, _hoverPeriod, _hoverByRepaid); } private void DrawHoverBox(Rect plot, ChartData d, int period, long sum, long denom, float iconSize, IChartPainter p) { //IL_02b8: Unknown result type (might be due to invalid IL or missing references) //IL_02d1: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_0301: 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_033a: Unknown result type (might be due to invalid IL or missing references) //IL_0351: Unknown result type (might be due to invalid IL or missing references) //IL_036a: Unknown result type (might be due to invalid IL or missing references) //IL_038a: Unknown result type (might be due to invalid IL or missing references) //IL_03a3: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_0414: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_0464: Unknown result type (might be due to invalid IL or missing references) //IL_04a2: Unknown result type (might be due to invalid IL or missing references) //IL_04bc: Unknown result type (might be due to invalid IL or missing references) //IL_0579: Unknown result type (might be due to invalid IL or missing references) //IL_05c5: Unknown result type (might be due to invalid IL or missing references) //IL_062d: Unknown result type (might be due to invalid IL or missing references) //IL_0533: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Min(_hover.Count, 10); float num2 = Mathf.Max(iconSize, p.LineHeight) + 2f; float num3 = 6f; float num4 = 0f; float num5 = 0f; float num6 = 0f; for (int i = 0; i < num; i++) { long num7 = HoverValue(_hover[i]); num4 = Mathf.Max(num4, p.Measure(N(num7))); num5 = Mathf.Max(num5, p.Measure(Percent(num7, denom))); if (!_hover[i].HasSource) { num6 = Mathf.Max(num6, p.Measure(p.ReasonLabel(_hover[i].Reason)) + 8f); } } int num8 = ((period < d.PeriodRepaid.Count) ? d.PeriodRepaid[period] : (d.RepaidTotal + 1)); int num9 = ((period > 0 && period - 1 < d.PeriodRepaid.Count) ? d.PeriodRepaid[period - 1] : 0); string text = ((num8 - num9 > 1) ? ((num9 + 1).ToString(CultureInfo.InvariantCulture) + "-" + num8.ToString(CultureInfo.InvariantCulture)) : Math.Max(1, num8).ToString(CultureInfo.InvariantCulture)); string text2 = N(sum); string text3 = ((denom != sum) ? Percent(sum, denom) : null); float num10 = p.Measure(text) + 6f + iconSize + 4f + p.Measure(text2) + ((text3 != null) ? (p.Measure(text3) + 6f) : 0f); float num11 = Mathf.Max(num10, iconSize + 6f + num6 + num4 + 6f + num5) + num3 * 2f; float num12 = num3 * 2f + num2 + (float)num * num2; if (_hover.Count > num) { num12 += p.LineHeight; } float num13 = d.Mouse.x + 14f; float num14 = d.Mouse.y + 10f; if (num13 + num11 > ((Rect)(ref plot)).xMax) { num13 = d.Mouse.x - 14f - num11; } if (num14 + num12 > ((Rect)(ref plot)).yMax) { num14 = ((Rect)(ref plot)).yMax - num12; } if (num13 < ((Rect)(ref plot)).x) { num13 = ((Rect)(ref plot)).x; } if (num14 < ((Rect)(ref plot)).y) { num14 = ((Rect)(ref plot)).y; } p.Fill(new Rect(num13, num14, num11, num12), new Color(0.04f, 0.04f, 0.05f, 0.94f)); p.Fill(new Rect(num13, num14, num11, 1f), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num13, num14 + num12 - 1f, num11, 1f), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num13, num14, 1f, num12), new Color(1f, 1f, 1f, 0.25f)); p.Fill(new Rect(num13 + num11 - 1f, num14, 1f, num12), new Color(1f, 1f, 1f, 0.25f)); float num15 = num14 + num3; float num16 = num13 + num3; float num17 = (iconSize - p.FontSize) * 0.5f; p.Text(num16, num15 + num17, text, Accent); num16 += p.Measure(text) + 6f; p.Icon(new Rect(num16, num15, iconSize, iconSize), null, d.Selected.TagID, Ink, IconOutline); num16 += iconSize + 4f; p.Text(num16, num15 + num17, text2, Ink); if (text3 != null) { num16 += p.Measure(text2) + 6f; p.Text(num16, num15 + num17, text3, Accent); } num15 += num2; Rect r = default(Rect); for (int j = 0; j < num; j++) { long num18 = HoverValue(_hover[j]); ((Rect)(ref r))..ctor(num13 + num3, num15, iconSize, iconSize); DrawSourceIcon(r, _hover[j], d.Selected.TagID, OthersColor, p); if (!_hover[j].HasSource) { string text4 = p.ReasonLabel(_hover[j].Reason); if (!string.IsNullOrEmpty(text4)) { p.Text(num13 + num3 + iconSize + 6f, num15 + (iconSize - p.FontSize) * 0.5f, text4, new Color(0.78f, 0.75f, 0.7f)); } } string text5 = N(num18); p.Text(num13 + num3 + iconSize + 6f + num6 + (num4 - p.Measure(text5)), num15 + (iconSize - p.FontSize) * 0.5f, text5, Ink); string text6 = Percent(num18, denom); p.Text(num13 + num11 - num3 - p.Measure(text6), num15 + (iconSize - p.FontSize) * 0.5f, text6, new Color(0.75f, 0.72f, 0.68f)); num15 += num2; } if (_hover.Count > num) { p.Text(num13 + num3, num15, "+" + (_hover.Count - num).ToString(CultureInfo.InvariantCulture), new Color(0.65f, 0.62f, 0.58f)); } } private static string Percent(long value, long sum) { if (sum <= 0) { return "0%"; } return Mathf.RoundToInt((float)((double)value * 100.0 / (double)sum)).ToString(CultureInfo.InvariantCulture) + "%"; } private void DrawHoldingColumn(float cx, float bw, float baseline, float fullHeight, float iconFit, ChartData d, List all, IChartPainter p) { //IL_0185: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: 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) //IL_0140: Unknown result type (might be due to invalid IL or missing references) TagSeries selected = d.Selected; long num = selected.HeldTotal(); if (num <= 0 || d.RequiredCount <= 0) { DrawZeroColumn(cx, bw, baseline, fullHeight, p); return; } double num2 = (double)Math.Max(0L, d.RequiredCurrent) / (double)num; float num3 = fullHeight / (float)d.RequiredCount; float top = baseline - fullHeight; float num4 = (float)((double)num * num2) * num3; float num5 = ((num4 > fullHeight) ? (fullHeight / num4) : 1f); float yy = baseline; long num6 = 0L; Rect r = default(Rect); for (int i = 0; i < _rank.Count; i++) { long held = _rank[i].Held; if (held <= 0) { continue; } num6 += held; float num7 = (float)((double)held * num2) * num3 * num5; if (!(num7 <= 0f)) { float num8 = StackBand(cx, bw, top, ref yy, num7, _rankColors[i], p); if (num8 <= 0f) { break; } if (iconFit >= 16f && num8 >= iconFit + 4f) { ((Rect)(ref r))..ctor(cx + 1f + (bw - iconFit) * 0.5f, yy + (num8 - iconFit) * 0.5f, iconFit, iconFit); DrawSourceIcon(r, _rank[i], selected.TagID, _rankColors[i], p); } } } long num9 = num - num6; if (num9 > 0) { float h = (float)((double)num9 * num2) * num3 * num5; StackBand(cx, bw, top, ref yy, h, OthersColor, p); } float num10 = num4 / fullHeight; if (num10 >= 1.05f) { DrawOverflowCap(cx + 1f, bw, baseline, num10, p); } } private static void DrawOverflowCap(float x, float w, float baseline, float ratio, IChartPainter p) { //IL_0044: Unknown result type (might be due to invalid IL or missing references) string text = "×" + ratio.ToString("0.#", CultureInfo.InvariantCulture); float num = p.Measure(text); if (num <= w + 6f) { p.Text(x + (w - num) * 0.5f, baseline + 2f, text, Accent); } } private static float StackBand(float cx, float bw, float top, ref float yy, float h, Color color, IChartPainter p) { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) float num = yy - top; if (num <= 0f) { return 0f; } float num2 = Mathf.Min(h, num); yy -= num2; p.Fill(new Rect(cx + 1f, yy, bw, Mathf.Max(1f, num2)), color); return num2; } private static void DrawCurrentFrame(Rect slot, IChartPainter p) { //IL_0002: 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_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Unknown result type (might be due to invalid IL or missing references) //IL_0070: Unknown result type (might be due to invalid IL or missing references) //IL_0091: 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_00bd: 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) Color color = default(Color); ((Color)(ref color))..ctor(Accent.r, Accent.g, Accent.b, 0.75f); p.Fill(new Rect(((Rect)(ref slot)).x, ((Rect)(ref slot)).y, ((Rect)(ref slot)).width, 1f), color); p.Fill(new Rect(((Rect)(ref slot)).x, ((Rect)(ref slot)).yMax, ((Rect)(ref slot)).width, 1f), color); p.Fill(new Rect(((Rect)(ref slot)).x, ((Rect)(ref slot)).y, 1f, ((Rect)(ref slot)).height), color); p.Fill(new Rect(((Rect)(ref slot)).xMax - 1f, ((Rect)(ref slot)).y, 1f, ((Rect)(ref slot)).height), color); } private void RankSources(List all, string tagID, int maxEntries) { _rank.Clear(); _rankColors.Clear(); _rankTotals.Clear(); long num = 0L; for (int i = 0; i < all.Count; i++) { if (all[i].Total > 0) { num += all[i].Total; } } if (num <= 0) { return; } long num2 = (long)((float)num * 0.03f); for (int j = 0; j < all.Count; j++) { if (all[j].Total > 0 && all[j].Total >= num2) { _rank.Add(all[j]); } } _rank.Sort((SourceSeries a, SourceSeries b) => b.Total.CompareTo(a.Total)); int num3 = Mathf.Min(SourcePalette.Length, Mathf.Max(1, maxEntries)); while (_rank.Count > num3) { _rank.RemoveAt(_rank.Count - 1); } for (int num4 = 0; num4 < _rank.Count; num4++) { _rankTotals.Add(_rank[num4].Total); } AssignRankColors(tagID); } private void AssignRankColors(string tagID) { //IL_0060: 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_0054: 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) _rankColors.Clear(); for (int i = 0; i < _rank.Count; i++) { string id = (_rank[i].HasSource ? _rank[i].Key : tagID); if (!ChartColors.TryGet(id, out var color)) { color = SourcePalette[i % SourcePalette.Length]; } _rankColors.Add(Separate(color, _rankColors)); } } private static Color Separate(Color color, List used) { //IL_005a: 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_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) for (int i = 1; i <= 6; i++) { bool flag = false; for (int j = 0; j < used.Count; j++) { if (Distance(used[j], color) < 0.2f) { flag = true; break; } } if (!flag) { return color; } float num = 0.16f * (float)((i + 1) / 2); if (i % 2 == 0) { num = 0f - num; } color = ShiftValue(color, num); } return color; } private static float Distance(Color a, Color b) { float num = a.r - b.r; float num2 = a.g - b.g; float num3 = a.b - b.b; return Mathf.Sqrt(num * num + num2 * num2 + num3 * num3); } private static Color ShiftValue(Color c, float delta) { //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Max(c.r, Mathf.Max(c.g, c.b)); if (num <= 0.001f) { return new Color(0.5f, 0.5f, 0.5f, c.a); } float num2 = Mathf.Clamp(num + delta, 0.22f, 1f); float num3 = num2 / num; return new Color(Mathf.Clamp01(c.r * num3), Mathf.Clamp01(c.g * num3), Mathf.Clamp01(c.b * num3), c.a); } private static void DrawSourceIcon(Rect r, SourceSeries src, string tagID, Color fallback, IChartPainter p) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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) if (!p.Icon(r, src.Key, tagID, Ink, IconOutline)) { p.Fill(r, fallback); } } internal static int KnownIndex(string tagID) { for (int i = 0; i < KnownTagIDs.Length; i++) { if (string.Equals(KnownTagIDs[i], tagID, StringComparison.Ordinal)) { return i; } } return KnownTagIDs.Length; } internal static Color TagColor(string tagID) { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) if (ChartColors.TryGet(tagID, out var color)) { return color; } int num = KnownIndex(tagID); if (num < 0 || num >= TagColors.Length) { num = TagColors.Length - 1; } return TagColors[num]; } private static int ColumnCount(float width, int cap) { int num = (int)width; if (cap >= 32 && num > cap) { num = cap; } if (num < 2) { num = 2; } return num; } private static float ValueToY(Rect plot, long min, long max, long value) { double num = (double)(value - min) / (double)(max - min); if (num < 0.0) { num = 0.0; } if (num > 1.0) { num = 1.0; } return ((Rect)(ref plot)).yMax - (float)(num * (double)((Rect)(ref plot)).height); } private static int TotalBuckets(ChartData d) { int num = d.BucketCount; for (int i = 0; i < d.Ordered.Count; i++) { if (d.Ordered[i].Balances.Count > num) { num = d.Ordered[i].Balances.Count; } } return num; } internal static string N(long v) { bool flag = v < 0; double num = (flag ? (0.0 - (double)v) : ((double)v)); string text = ((num >= 1000000000000.0) ? ((num / 1000000000000.0).ToString("0.0", CultureInfo.InvariantCulture) + "T") : ((num >= 1000000000.0) ? ((num / 1000000000.0).ToString("0.0", CultureInfo.InvariantCulture) + "B") : ((num >= 1000000.0) ? ((num / 1000000.0).ToString("0.0", CultureInfo.InvariantCulture) + "M") : ((!(num >= 1000.0)) ? num.ToString("0", CultureInfo.InvariantCulture) : ((num / 1000.0).ToString("0.0", CultureInfo.InvariantCulture) + "K"))))); if (!flag) { return text; } return "-" + text; } internal static string F(double v) { return v.ToString("0.##", CultureInfo.InvariantCulture); } internal static string FormatTime(double seconds) { if (seconds < 0.0) { seconds = 0.0; } int num = (int)seconds; int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; if (num2 > 0) { return num2.ToString(CultureInfo.InvariantCulture) + ":" + num3.ToString("00", CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture); } return num3.ToString(CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture); } } internal static class ChartColors { private static Dictionary _map; private static readonly string[] Ids = new string[238] { "Adamantite", "All", "AllCritByTime", "Amethyst", "BuffGemMagic", "CancelGetFam", "Cash", "CashByLandTime", "Chemical", "Cinnabar", "Cobalt", "Coin", "Compost", "Construction", "ConvertOnRAllFuel", "Conveyor2Supplies", "ConveyorSpeedByTime", "ConveyorSupplies", "Crafter", "CrimeCoin", "CrimeContract", "CrimeLand", "Debug1", "Debug2", "Debug3", "Debug4", "Debug5", "FakeCoin", "FakeStamp", "FamExpense", "FamIncome", "FasterOrder", "Fertilizer", "FreeLand", "FreeLandSupplies", "Fuel", "GemPowder", "Gold", "GoldOre", "Grocery", "Gunpowder", "HDAStamp", "Honey", "Hourglass", "IntervalChemical", "IntervalCrafter", "IntervalFuel", "IntervalGrocery", "IntervalMagic", "IntervalSmelter", "IntervalSummoner", "IntervalTransporter", "IntervalWorker", "Iron", "IronOre", "Jade", "Lemon", "Lemonade", "LoseTransportSpeed", "Luxury", "Lye", "Magic", "MagicChunk", "MagicToCash", "Mercury", "Monitoring", "Mushroom", "Mythril", "Nitro", "Oil", "Olive", "OnDeliveryPatronResources", "OnPurchaseTag1", "OnPurchaseTag6", "OrderTag6ByAll", "Orichalcum", "Pickaxe", "ReduceSkillCost", "RelicAllSmelter", "RelicAmethyst", "RelicCobalt", "RelicCritCash", "RelicJade", "RelicLye", "RelicOrderTag1", "RelicOrderTag6", "RelicRepaymentTag4", "RelicRuby", "RelicTag2X10", "RelicTag6X10", "RepaymentLoseCash", "RoyalStraightFlush", "Ruby", "Salt", "Smelter", "SmelterSpeedByTime", "Smuggling", "Soda", "Splitter", "Stamp", "Sulfur", "Summon-Caretaker", "Summon-Conveyor", "Summon-Conveyor2", "Summon-Crafter", "Summon-Farmer", "Summon-Smelter", "Summon-Splitter", "Summon-Splitter2", "Summon-Summoner", "Summon-Transporter", "Summon-TransporterExit", "Summon-Worker", "Summoner", "SummonerSpeed", "SusPowder", "TradeCrafterAmethystCoin", "TradeCrafterAmethystFuelGold", "TradeCrafterAmethystWoodGold", "TradeCrafterCinnabarFuelSoda", "TradeCrafterCinnabarGold", "TradeCrafterCobaltFuelMercury", "TradeCrafterCobaltSoda", "TradeCrafterCobaltWoodMercury", "TradeCrafterCoinFuelGold", "TradeCrafterCoinWoodGold", "TradeCrafterComplexCoin", "TradeCrafterComplexNitro", "TradeCrafterComplexPickaxe", "TradeCrafterComplexSoda", "TradeCrafterConstructionSplitter2", "TradeCrafterFuelCoin", "TradeCrafterFuelSplitter2", "TradeCrafterGoldOreCoin", "TradeCrafterIronCoin", "TradeCrafterIronOreFuelPickaxe", "TradeCrafterIronOreGold", "TradeCrafterJadeFuelIron", "TradeCrafterJadePickaxe", "TradeCrafterJadeWoodIron", "TradeCrafterLuxurySplitter2", "TradeCrafterMagicSplitter2", "TradeCrafterOliveFuelGunpowder", "TradeCrafterOliveWoodGunpowder", "TradeCrafterRubyFuelGunpowder", "TradeCrafterRubyNitro", "TradeCrafterRubyWoodGunpowder", "TradeCrafterSaltMercury", "TradeCrafterSulfurFuelGunpowder", "TradeCrafterSulfurNitro", "TradeCrafterSulfurWoodGunpowder", "TradeCrafterWaxFuelGunpowder", "TradeCrafterWaxWoodGunpowder", "TradeCrafterWoodCoin", "TradeCrafterWoodIron", "TradeSmelterBlueSoda", "TradeSmelterChemicalCinnabar", "TradeSmelterChemicalCompost", "TradeSmelterChemicalConveyor", "TradeSmelterChemicalGemPowder", "TradeSmelterChemicalLemonade", "TradeSmelterChemicalLye", "TradeSmelterChemicalSalt", "TradeSmelterChemicalSulfur", "TradeSmelterConstructionCompost", "TradeSmelterConstructionConveyor", "TradeSmelterConstructionGemPowder", "TradeSmelterConstructionLemonade", "TradeSmelterConstructionLye", "TradeSmelterConstructionSoda", "TradeSmelterConveyorLye", "TradeSmelterFertilizerCompost", "TradeSmelterFertilizerConveyor", "TradeSmelterFertilizerGemPowder", "TradeSmelterFertilizerLemonade", "TradeSmelterFertilizerLye", "TradeSmelterFertilizerSoda", "TradeSmelterFromTransporter", "TradeSmelterFromWorker", "TradeSmelterFuelCompost", "TradeSmelterFuelConveyor", "TradeSmelterFuelGemPowder", "TradeSmelterFuelLemonade", "TradeSmelterFuelLye", "TradeSmelterFuelSoda", "TradeSmelterGoldSulfur", "TradeSmelterGroceryCompost", "TradeSmelterGroceryConveyor", "TradeSmelterGroceryGemPowder", "TradeSmelterGroceryLemonade", "TradeSmelterGroceryLye", "TradeSmelterGrocerySoda", "TradeSmelterIronOreCinnabar", "TradeSmelterIronOreSalt", "TradeSmelterLuxuryCompost", "TradeSmelterLuxuryConveyor", "TradeSmelterLuxuryGemPowder", "TradeSmelterLuxuryLemonade", "TradeSmelterLuxuryLye", "TradeSmelterLuxurySoda", "TradeSmelterMagicCompost", "TradeSmelterMagicConveyor", "TradeSmelterMagicGemPowder", "TradeSmelterMagicLemonade", "TradeSmelterMagicLye", "TradeSmelterMagicSoda", "TradeSmelterNoneMushroom", "TradeSmelterWoodMushroom", "TradeSummoneCreateFam2", "TradeSummoneCreateFam4", "TradeSummoneCreateFam6", "TradeSummoneCreateFam8", "TradeSummonerAdamantite", "TradeSummonerAmethystFromBuff", "TradeSummonerAmethystIncrease", "TradeSummonerAmethystRock", "TradeSummonerAmethystTag", "TradeSummonerCobaltFromBuff", "TradeSummonerCobaltIncrease", "TradeSummonerCobaltRock", "TradeSummonerCobaltTag", "TradeSummonerJadeFromBuff", "TradeSummonerJadeIncrease", "TradeSummonerJadeRock", "TradeSummonerJadeTag", "TradeSummonerMythril", "TradeSummonerRubyFromBuff", "TradeSummonerRubyIncrease", "TradeSummonerRubyRock", "TradeSummonerRubyTag", "Transporter", "Wand", "Wax", "WingPen", "Wood", "Worker", "WorkerIncome", "WorkerSpeedByTime" }; private static readonly uint[] Rgb = new uint[238] { 14899763u, 13073999u, 13075489u, 8869063u, 13060953u, 13049134u, 13081948u, 13082989u, 3568071u, 13056887u, 2382288u, 15053878u, 13074797u, 6997849u, 13388338u, 51047u, 367303u, 104135u, 13791605u, 13054777u, 13054777u, 13082733u, 7265251u, 13076333u, 6532575u, 15053878u, 7194546u, 16102695u, 9059575u, 13062216u, 13082477u, 13058871u, 13055417u, 13082733u, 13148526u, 13257009u, 5487815u, 16703090u, 13075232u, 13082165u, 7184839u, 14639976u, 16110197u, 14299192u, 5277650u, 7182023u, 15965718u, 13072973u, 13062491u, 7191495u, 13085538u, 8416711u, 15843666u, 8767341u, 8636269u, 5359432u, 15916893u, 14859601u, 8701805u, 8808391u, 6532575u, 2869191u, 7194546u, 15053878u, 7185351u, 13069701u, 6457799u, 12879608u, 13061440u, 16110198u, 11519818u, 825799u, 8809927u, 6589127u, 7192775u, 7265251u, 13076333u, 2803655u, 7192519u, 8934855u, 2316236u, 13067607u, 5359432u, 1265395u, 13078065u, 7192519u, 9642695u, 13782107u, 8046445u, 15692130u, 13061188u, 12879608u, 14306396u, 14777493u, 7193031u, 8374117u, 12959687u, 6476281u, 52207u, 13070937u, 16366865u, 13089389u, 38087u, 51046u, 13791605u, 16446967u, 7193031u, 52207u, 116583u, 7174087u, 12283592u, 13071469u, 13081425u, 7174087u, 2603975u, 5846471u, 15053878u, 16703090u, 16703090u, 6476281u, 16703090u, 7185351u, 6476281u, 7185351u, 16703090u, 16703090u, 15053878u, 13061440u, 13076333u, 6476281u, 116583u, 15053878u, 116583u, 15053878u, 15053878u, 13076333u, 16703090u, 8767341u, 13076333u, 8767341u, 116583u, 116583u, 7184839u, 7184839u, 7184839u, 13061440u, 7184839u, 7185351u, 7184839u, 13061440u, 7184839u, 7184839u, 7184839u, 15053878u, 8767341u, 6476281u, 13056887u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 14777493u, 16366865u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 6532575u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 7193031u, 7193031u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 16366865u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 13056887u, 14777493u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 13074797u, 38087u, 5487815u, 14859601u, 6532575u, 6476281u, 6457799u, 6457799u, 13081425u, 12283592u, 7193031u, 13791605u, 14899763u, 8869063u, 8869063u, 8869063u, 8869063u, 2382288u, 2382288u, 2382288u, 2382288u, 5359432u, 5359432u, 5359432u, 5359432u, 12879608u, 14306396u, 14306396u, 14306396u, 14306396u, 12283592u, 13937525u, 15648598u, 7176903u, 13731409u, 13081425u, 13354096u, 13545036u }; internal static bool TryGet(string id, out Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) color = Color.white; if (string.IsNullOrEmpty(id)) { return false; } if (_map == null) { Build(); } return _map.TryGetValue(id, out color); } private static void Build() { //IL_0065: Unknown result type (might be due to invalid IL or missing references) _map = new Dictionary(Ids.Length, StringComparer.Ordinal); for (int i = 0; i < Ids.Length; i++) { uint num = Rgb[i]; _map[Ids[i]] = new Color((float)((num >> 16) & 0xFF) / 255f, (float)((num >> 8) & 0xFF) / 255f, (float)(num & 0xFF) / 255f, 1f); } } } internal sealed class Hotkey { private readonly bool _ctrl; private readonly bool _alt; private readonly bool _shift; private readonly Key _key; private readonly string _text; private Hotkey(bool ctrl, bool alt, bool shift, Key key, string text) { //IL_001c: 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) _ctrl = ctrl; _alt = alt; _shift = shift; _key = key; _text = text; } public override string ToString() { return _text; } internal static Hotkey Parse(string spec) { //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(spec)) { return null; } bool ctrl = false; bool alt = false; bool shift = false; string text = null; string[] array = spec.Split('+'); for (int i = 0; i < array.Length; i++) { string text2 = array[i].Trim(); if (text2.Length != 0) { switch (text2.ToLowerInvariant()) { case "ctrl": case "control": ctrl = true; break; case "alt": alt = true; break; case "shift": shift = true; break; default: text = text2; break; } } } if (text == null) { return null; } try { Key key = (Key)Enum.Parse(typeof(Key), text, ignoreCase: true); return new Hotkey(ctrl, alt, shift, key, spec.Trim()); } catch (Exception) { return null; } } internal bool WasPressedThisFrame(Keyboard kb) { //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Invalid comparison between Unknown and I4 if (kb == null) { return false; } bool flag = ((ButtonControl)kb.leftCtrlKey).isPressed || ((ButtonControl)kb.rightCtrlKey).isPressed; bool flag2 = ((ButtonControl)kb.leftAltKey).isPressed || ((ButtonControl)kb.rightAltKey).isPressed; bool flag3 = ((ButtonControl)kb.leftShiftKey).isPressed || ((ButtonControl)kb.rightShiftKey).isPressed; if (flag != _ctrl || flag2 != _alt || flag3 != _shift) { return false; } if (((ButtonControl)kb[_key]).wasPressedThisFrame) { return true; } if ((int)_key == 2 && ((ButtonControl)kb[(Key)77]).wasPressedThisFrame) { return true; } return false; } } [BepInPlugin("kiyonakanata.lwfeconomygraph", "LWF Economy Graph", "1.0.1")] public sealed class EconomyGraphPlugin : BaseUnityPlugin { private sealed class ImguiPainter : IChartPainter { private readonly EconomyGraphPlugin _owner; private int _baseSize; public float FontSize => _owner._text.fontSize; public float LineHeight => _owner._text.fontSize + 6; internal ImguiPainter(EconomyGraphPlugin owner) { _owner = owner; } internal void Begin(int baseSize) { _baseSize = baseSize; SetScale(1f); } public void SetScale(float scale) { _owner._text.fontSize = Mathf.RoundToInt((float)_baseSize * scale); _owner._title.fontSize = _owner._text.fontSize + 3; } public float Measure(string text) { return _owner.W(text, _owner._text); } public float MeasureTitle(string text) { return _owner.W(text, _owner._title); } public void Fill(Rect r, Color color) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: Unknown result type (might be due to invalid IL or missing references) EconomyGraphPlugin.Fill(r, color); } public void Text(float x, float y, string text, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) _owner.DrawText(x, y, text, _owner._text, color); } public void Title(float x, float y, string text, Color color) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) _owner.DrawText(x, y, text, _owner._title, color); } public bool Icon(Rect r, string sourceKey, string tagID, Color tint, Color outline) { //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0108: Unknown result type (might be due to invalid IL or missing references) Sprite val = ((sourceKey == "#craft") ? _owner.GetCraftIcon() : ((sourceKey == null) ? _owner.GetTagSprite(tagID) : ((sourceKey.Length <= 1 || sourceKey[0] != '#') ? _owner.GetSourceSprite(sourceKey, tagID) : _owner.GetReasonSprite(sourceKey, tagID)))); if ((Object)(object)val == (Object)null) { return false; } if (outline.a > 0.01f) { Texture2D silhouette = _owner.GetSilhouette(val); if ((Object)(object)silhouette != (Object)null) { float num = Mathf.Max(1f, ((Rect)(ref r)).width * _owner._iconOutline.Value); Color color = GUI.color; GUI.color = outline; Rect r2 = default(Rect); for (int i = -1; i <= 1; i++) { for (int j = -1; j <= 1; j++) { if (i != 0 || j != 0) { ((Rect)(ref r2))..ctor(((Rect)(ref r)).x + (float)i * num, ((Rect)(ref r)).y + (float)j * num, ((Rect)(ref r)).width, ((Rect)(ref r)).height); GUI.DrawTexture(SpriteDest(r2, val), (Texture)(object)silhouette, (ScaleMode)0, true); } } } GUI.color = color; } } DrawSprite(r, val, tint); return true; } public string ReasonLabel(int reason) { return _owner.ReasonName(reason); } } internal const string PluginGuid = "kiyonakanata.lwfeconomygraph"; internal const string PluginName = "LWF Economy Graph"; internal const string PluginVersion = "1.0.1"; private const int LandReason = 15; private const string StateKey = "lwf.economygraph.store.v2"; private const int StoreVersion = 2; private const int StoreSlots = 14; private const int SVersion = 0; private const int SGameID = 1; private const int SBucketSeconds = 2; private const int SBucketCount = 3; private const int SElapsed = 4; private const int SPeriodIndex = 5; private const int SRepaidTotal = 6; private const int SClosedColumns = 7; private const int SHasRun = 8; private const int STruncated = 9; private const int FailureLimit = 20; private const int RateWindow = 60; private const int RateSlots = 60; private const int RateHistory = 120; private const int RateMaxLines = 8; private static readonly Color ShadowColor = new Color(0f, 0f, 0f, 0.9f); private static readonly string[] ReasonIconTag = new string[16] { "", "FasterOrder", "", "", "FasterOrder", "", "", "", "", "", "", "", "", "", "", "FreeLand" }; private static readonly string[] ReasonMessageKeys = new string[16] { "StatsReasonOther", "Order", "StatsColumnSale", "Relic", "Order", "Repayment", "DebuffRelic", "Pact", "StatsReasonOther", "StatsReasonOther", "StatsReasonOther", "Pact", "StatsReasonOther", "StatsColumnProduction", "StatsColumnProduction", "" }; private static readonly string[] ReasonFallback = new string[16] { "その他", "注文", "売却", "レリック", "注文", "返済", "ペナルティ", "契約", "リロール", "杖", "初期", "契約", "電話", "生産", "生産", "土地" }; private ConfigEntry _enabled; private ConfigEntry _autoShowOnResult; private ConfigEntry _embedInStatsWindow; private ConfigEntry _keepDataOnReload; private ConfigEntry _bucketSecondsInitial; private ConfigEntry _maxBuckets; private ConfigEntry _maxRawEvents; private ConfigEntry _startMode; private ConfigEntry _maxColumns; private ConfigEntry _iconOutline; private ConfigEntry _fontSize; private ConfigEntry _fontName; private ConfigEntry _panelRect; private ConfigEntry _resultPanelRect; private ConfigEntry _graphAreaWidth; private ConfigEntry _keyToggleSpec; private ConfigEntry _keyNextTagSpec; private ConfigEntry _keyPrevTagSpec; private ConfigEntry _keyExportSpec; private ConfigEntry _keyAdjustSpec; private ConfigEntry _keyCycleModeSpec; private ConfigEntry _keyCycleRangeSpec; private ConfigEntry _keyToggleSideSpec; private Hotkey _keyToggle; private Hotkey _keyNextTag; private Hotkey _keyPrevTag; private Hotkey _keyExport; private Hotkey _keyAdjust; private Hotkey _keyCycleMode; private Hotkey _keyCycleRange; private Hotkey _keyToggleSide; private GameStateManager _boundGame; private readonly List _subscriptions = new List(); private readonly HashSet _subscribed = new HashSet(); private static readonly List NewRecorders = new List(); private static bool InLandPurchase; private Harmony _harmony; private bool _patched; private float _nextRecorderScan; private readonly List _series = new List(); private readonly List _ordered = new List(); private readonly Dictionary _seriesByTag = new Dictionary(StringComparer.Ordinal); private List _evT; private List _evDelta; private List _evBalance; private List _evTag; private List _evReason; private List _evSource; private List _evPeriod; private List _sourceIDs; private readonly Dictionary _sourceIndex = new Dictionary(StringComparer.Ordinal); private bool _rawEventsTruncated; private float _bucketSeconds = 1f; private int _bucketCount; private double _elapsed; private double _runEndElapsed = -1.0; private bool _isResultShown; private float _nextResultPoll; private bool _hasRun; private bool _replaying; private int _restoredGameId; private bool _seeded; private bool _visible; private int _chartDrawnFrame = -100; private int _selectedTag; private int _mode; private bool _lastMinute; private bool _expenseSide; private int _periodIndex; private int _repaidTotal; private int _closedColumns; private List _periodRepaid; private int _targetProgress; private string _requiredTag; private int _requiredCount; private long _requiredCurrent; private List _periodEnds; private readonly Dictionary _tagSprites = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _statsFields = new Dictionary(StringComparer.Ordinal); private CursorViewSwitcher _cursorView; private GameObject _cursorChaser; private float _nextCursorProbe; private readonly List _cursorGraphics = new List(); private Rect _lastDrawn; private bool _drewThisFrame; private CommonUIController _commonUI; private List _menuObjects; private float _nextMenuProbe; private StatsWindowController _statsWindow; private RectTransform _graphFrame; private float _nextWindowProbe; private float _nextFrameProbe; private bool _loggedFrameFound; private bool _adjustMode; private float _nextAdjustRepeat; private string _message = string.Empty; private float _messageUntil; private GUIStyle _text; private GUIStyle _title; private Font _font; private int _styleFontSize; private readonly HashSet _hiddenTags = new HashSet(StringComparer.Ordinal); private readonly Dictionary _sourceSprites = new Dictionary(StringComparer.Ordinal); private readonly Dictionary _silhouettes = new Dictionary(); private readonly string[] _reasonNames = new string[16]; private Sprite _gehennaFace; private bool _gehennaFaceResolved; private float _nextFaceProbe; private int _faceAttempts; private readonly List _silhouettePending = new List(); private readonly ChartData _chart = new ChartData(); private readonly ChartRenderer _renderer = new ChartRenderer(); private ImguiPainter _painter; private readonly GUIContent _content = new GUIContent(); private readonly Vector3[] _frameCorners = (Vector3[])(object)new Vector3[4]; private double[] _scalars; private List _storeTagIDs; private List _storeInitial; private List> _storeBalances; private int _failures; private bool _brokenDown; private readonly List _takeSources = new List(); private readonly List _takeAmounts = new List(); private Sprite _craftIcon; private int _craftIconTries; private readonly Dictionary _rateBuckets = new Dictionary(StringComparer.Ordinal); private readonly List _rateKeys = new List(); private float _nextRateBuild; private readonly Dictionary _statsMethods = new Dictionary(StringComparer.Ordinal); private void Awake() { _enabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "false にすると記録も表示も止める(素のゲームと同じ挙動)"); _embedInStatsWindow = ((BaseUnityPlugin)this).Config.Bind("General", "EmbedInStatsWindow", true, "本体の統計窓(収支タブ)に用意されている空き枠にグラフを描く。false にすると自前のパネルだけになる"); _keepDataOnReload = ((BaseUnityPlugin)this).Config.Bind("General", "KeepDataOnReload", false, "ScriptEngine で読み直したとき、それまでの記録を引き継ぐ(開発用)。ScriptEngine を入れていなければ何も起きない。false にすると読み直しのたびに取り直す"); _autoShowOnResult = ((BaseUnityPlugin)this).Config.Bind("General", "AutoShowOnResult", false, "リザルトに入ったら自前のパネルを自動で出す。統計窓の枠に描いているなら不要(リザルトの「統計」から開けば出る)"); _bucketSecondsInitial = ((BaseUnityPlugin)this).Config.Bind("Recording", "BucketSeconds", 1f, "グラフ1本ぶんの時間(秒)。細かいほど詳しいが、上限を超えると自動で倍になる"); _maxBuckets = ((BaseUnityPlugin)this).Config.Bind("Recording", "MaxBuckets", 1800, "バケット数の上限。超えると2つずつ束ねて幅を倍にする(ラン全体が必ず収まる)"); _maxRawEvents = ((BaseUnityPlugin)this).Config.Bind("Recording", "MaxRawEvents", 300000, "CSV 書き出し用にためる生ログの上限件数。0 でためない"); _startMode = ((BaseUnityPlugin)this).Config.Bind("HUD", "StartMode", 0, "起動時にどの表示から始めるか。0=工場の収支/1=残高の推移/2=返済区切りの収支情報"); _maxColumns = ((BaseUnityPlugin)this).Config.Bind("HUD", "MaxColumns", 480, "グラフを何本の縦棒で描くか。IMGUI は1本が描画1回なので、増やすほど重い"); _iconOutline = ((BaseUnityPlugin)this).Config.Bind("HUD", "IconOutlineWidth", 0.05f, "アイコンの白縁の太さ(アイコンの大きさに対する割合)。0 で縁無し"); _fontSize = ((BaseUnityPlugin)this).Config.Bind("HUD", "FontSize", 14, "文字サイズ"); _fontName = ((BaseUnityPlugin)this).Config.Bind("HUD", "FontName", "", "使うフォント名(例: Yu Gothic UI)。空なら Unity の既定フォント。日本語が □ になるときだけ指定する"); _panelRect = ((BaseUnityPlugin)this).Config.Bind("Layout", "PanelRect", "0.06,0.08,0.88,0.78", "通常時のパネル位置(画面比 x,y,w,h)。ゲーム中に AdjustLayout キーで動かせる"); _resultPanelRect = ((BaseUnityPlugin)this).Config.Bind("Layout", "ResultPanelRect", "0.05,0.50,0.62,0.46", "リザルト時のパネル位置(画面比 x,y,w,h)"); _keyToggleSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "Toggle", "", "単独パネルの開閉。空で無効(統計窓の枠に描くので普段は要らない)"); _keyNextTagSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "NextTag", "", "次のタグ。空で無効(統計窓のタグタブに従うため)"); _keyPrevTagSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "PrevTag", "", "前のタグ。空で無効"); _keyExportSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "ExportCsv", "F8", "CSV 書き出し"); _graphAreaWidth = ((BaseUnityPlugin)this).Config.Bind("Layout", "GraphAreaWidth", 0, "統計窓のグラフ枠の幅を広げる(本体の既定は 534、左のカード欄が 1068)。0 なら本体のまま触らない。例: 900 にするとカード欄が 702 に縮んでグラフが広くなる"); _keyCycleModeSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "CycleMode", "F5", "表示の切替:工場の収支→残高の推移→返済区切りの収支情報"); _keyCycleRangeSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "CycleRange", "", "横軸の範囲:全体/直近1分。空で無効(統計窓の「累計/直近1分」に従うため)"); _keyToggleSideSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "ToggleSide", "", "構成を収入側と支出側で切替。空で無効(統計窓の収入/支出タブに従うため)"); _keyAdjustSpec = ((BaseUnityPlugin)this).Config.Bind("Keys", "AdjustLayout", "", "レイアウト調整モードの ON/OFF。矢印で移動、Shift+矢印で大きさ、Ctrl+矢印で1px単位。抜けると設定に保存する"); _keyToggle = Hotkey.Parse(_keyToggleSpec.Value); _keyNextTag = Hotkey.Parse(_keyNextTagSpec.Value); _keyPrevTag = Hotkey.Parse(_keyPrevTagSpec.Value); _keyExport = Hotkey.Parse(_keyExportSpec.Value); _keyAdjust = Hotkey.Parse(_keyAdjustSpec.Value); _keyCycleMode = Hotkey.Parse(_keyCycleModeSpec.Value); _keyCycleRange = Hotkey.Parse(_keyCycleRangeSpec.Value); _keyToggleSide = Hotkey.Parse(_keyToggleSideSpec.Value); _bucketSeconds = ((_bucketSecondsInitial.Value > 0.05f) ? _bucketSecondsInitial.Value : 1f); _painter = new ImguiPainter(this); _mode = Mathf.Clamp(_startMode.Value, 0, 2); PatchRecorderConstructor(); AttachStore(); RestoreState(); string text; try { text = Application.version; } catch (Exception) { text = "?"; } ((BaseUnityPlugin)this).Logger.LogInfo((object)("[boot] LWF Economy Graph 1.0.1 (ゲーム " + text + ") " + _keyToggleSpec.Value + ":開閉 " + _keyExportSpec.Value + ":CSV " + _keyAdjustSpec.Value + ":レイアウト")); } private void OnDestroy() { SyncScalars(); Unbind(); if (_harmony != null) { try { _harmony.UnpatchSelf(); } catch (Exception) { } _harmony = null; } NewRecorders.Clear(); InLandPurchase = false; } private void AttachStore() { object[] array = null; if (_keepDataOnReload.Value) { try { array = AppDomain.CurrentDomain.GetData("lwf.economygraph.store.v2") as object[]; } catch (Exception) { array = null; } } double[] array2 = ((array != null && array.Length == 14) ? (array[0] as double[]) : null); if (array2 == null || array2.Length < 10 || (int)array2[0] != 2) { array2 = new double[10] { 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 }; array = new object[14] { array2, new List(), new List(), new List(), new List(), new List>(), new List(), new List(), null, null, null, null, null, null }; for (int i = 8; i < 14; i++) { array[i] = new List(); } if (_keepDataOnReload.Value) { try { AppDomain.CurrentDomain.SetData("lwf.economygraph.store.v2", array); } catch (Exception) { } } } _scalars = array2; _periodEnds = (List)array[1]; _periodRepaid = (List)array[2]; _storeTagIDs = (List)array[3]; _storeInitial = (List)array[4]; _storeBalances = (List>)array[5]; _sourceIDs = (List)array[6]; _evT = (List)array[7]; _evDelta = (List)array[8]; _evBalance = (List)array[9]; _evTag = (List)array[10]; _evReason = (List)array[11]; _evSource = (List)array[12]; _evPeriod = (List)array[13]; } private void SyncScalars() { if (_scalars != null) { _scalars[1] = (((Object)(object)_boundGame != (Object)null) ? ((Object)_boundGame).GetInstanceID() : 0); _scalars[2] = _bucketSeconds; _scalars[3] = _bucketCount; _scalars[4] = _elapsed; _scalars[5] = _periodIndex; _scalars[6] = _repaidTotal; _scalars[7] = _closedColumns; _scalars[8] = (_hasRun ? 1.0 : 0.0); _scalars[9] = (_rawEventsTruncated ? 1.0 : 0.0); } } private void RegisterStoreTag(TagSeries s) { if (_storeTagIDs == null) { return; } if (s.Index < _storeTagIDs.Count) { if (string.Equals(_storeTagIDs[s.Index], s.TagID, StringComparison.Ordinal)) { s.Balances = _storeBalances[s.Index]; return; } _storeTagIDs.RemoveRange(s.Index, _storeTagIDs.Count - s.Index); _storeInitial.RemoveRange(s.Index, _storeInitial.Count - s.Index); _storeBalances.RemoveRange(s.Index, _storeBalances.Count - s.Index); } _storeTagIDs.Add(s.TagID); _storeInitial.Add(s.InitialBalance); _storeBalances.Add(s.Balances); } private void RestoreState() { //IL_0288: Unknown result type (might be due to invalid IL or missing references) if (_scalars == null || _scalars[8] < 0.5) { return; } try { _restoredGameId = (int)_scalars[1]; _bucketSeconds = (float)_scalars[2]; _bucketCount = (int)_scalars[3]; _repaidTotal = (int)_scalars[6]; _closedColumns = (int)_scalars[7]; _rawEventsTruncated = _scalars[9] >= 0.5; int periodIndex = (int)_scalars[5]; double elapsed = _scalars[4]; _series.Clear(); _ordered.Clear(); _seriesByTag.Clear(); for (int i = 0; i < _storeTagIDs.Count; i++) { TagSeries orCreateSeries = GetOrCreateSeries(_storeTagIDs[i]); orCreateSeries.InitialBalance = _storeInitial[i]; orCreateSeries.HeldUnattributed = _storeInitial[i]; if (orCreateSeries.Balances.Count > 0) { orCreateSeries.Balance = orCreateSeries.Balances[orCreateSeries.Balances.Count - 1]; } } _sourceIndex.Clear(); for (int j = 0; j < _sourceIDs.Count; j++) { _sourceIndex[_sourceIDs[j]] = j; } _replaying = true; int count = _evT.Count; for (int k = 0; k < count; k++) { int num = _evTag[k]; if (num >= 0 && num < _storeTagIDs.Count) { _elapsed = _evT[k]; _periodIndex = _evPeriod[k]; _requiredTag = _storeTagIDs[num]; string text = ((_evSource[k] >= 0 && _evSource[k] < _sourceIDs.Count) ? _sourceIDs[_evSource[k]] : null); InLandPurchase = false; OnTagRecorded(new TagRecordedEvent(_storeTagIDs[num], Math.Abs(_evDelta[k]), _evBalance[k], _evDelta[k] > 0, (StatsCashReason)_evReason[k], text)); } } _replaying = false; _requiredTag = null; _periodIndex = periodIndex; _elapsed = elapsed; for (int l = 0; l < _series.Count; l++) { TagSeries tagSeries = _series[l]; tagSeries.PeakBalance = tagSeries.InitialBalance; tagSeries.PeakAt = 0.0; for (int m = 0; m < tagSeries.Balances.Count; m++) { if (tagSeries.Balances[m] > tagSeries.PeakBalance) { tagSeries.PeakBalance = tagSeries.Balances[m]; tagSeries.PeakAt = (double)m * (double)_bucketSeconds; } } } _hasRun = true; _seeded = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[state] 記録を引き継いだ(" + count + " 件 / 返済 " + _repaidTotal + " 回)")); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("記録の引き継ぎに失敗(新しく取り直す): " + ex)); _replaying = false; _requiredTag = null; ResetRun(); _restoredGameId = 0; } } private void PatchRecorderConstructor() { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Expected O, but got Unknown try { ConstructorInfo constructor = typeof(ResourceTagsRecorder).GetConstructor(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[2] { typeof(DeliveryEffectSpawner), typeof(bool) }, null); if (constructor == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"記録係のコンストラクタが見つからない。定期的に探す方に落ちる"); return; } MethodInfo method = typeof(EconomyGraphPlugin).GetMethod("OnRecorderCreated", BindingFlags.Static | BindingFlags.NonPublic); _harmony = new Harmony("kiyonakanata.lwfeconomygraph"); _harmony.Patch((MethodBase)constructor, (HarmonyMethod)null, new HarmonyMethod(method), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); _patched = true; } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("記録係の生成を捕まえられなかった(定期的に探す方に落ちる): " + ex.Message)); _patched = false; } PatchLandPurchase(); } private void PatchLandPurchase() { //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Expected O, but got Unknown //IL_0096: Expected O, but got Unknown //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown try { MethodInfo method = typeof(LandPurchaseManager).GetMethod("TryPurchase", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (method == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"土地購入が見つからない(その他のままになる)"); return; } MethodInfo method2 = typeof(EconomyGraphPlugin).GetMethod("LandPurchaseBegin", BindingFlags.Static | BindingFlags.NonPublic); MethodInfo method3 = typeof(EconomyGraphPlugin).GetMethod("LandPurchaseEnd", BindingFlags.Static | BindingFlags.NonPublic); if (_harmony == null) { _harmony = new Harmony("kiyonakanata.lwfeconomygraph"); } _harmony.Patch((MethodBase)method, new HarmonyMethod(method2), (HarmonyMethod)null, (HarmonyMethod)null, new HarmonyMethod(method3), (HarmonyMethod)null); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("土地購入を挟めなかった(その他のままになる): " + ex.Message)); } } private static void OnRecorderCreated(ResourceTagsRecorder __instance) { if (__instance != null) { NewRecorders.Add(__instance); } } private static void LandPurchaseBegin() { InLandPurchase = true; } private static void LandPurchaseEnd() { InLandPurchase = false; } private void Update() { if (_enabled == null || !_enabled.Value || _brokenDown) { return; } try { TrackGame(); TrackStatsWindow(); BuildPendingSilhouettes(); ResolveGehennaFace(); HandleInput(); } catch (Exception e) { ReportBreakdown("記録", e); } } private void ReportBreakdown(string where, Exception e) { _failures++; if (_failures <= 3) { ((BaseUnityPlugin)this).Logger.LogError((object)("[" + where + "] 例外: " + e)); } if (_failures >= 20 && !_brokenDown) { _brokenDown = true; ((BaseUnityPlugin)this).Logger.LogError((object)("例外が " + 20 + " 回続いたので、このMODを止めました。本体の更新で内部の作りが変わった可能性があります。設定の Enabled を false にすれば警告も出ません")); } } private void TrackGame() { GameStateManager instance = GameStateManager.Instance; if (!object.ReferenceEquals(instance, _boundGame)) { Unbind(); _boundGame = instance; if ((Object)(object)instance != (Object)null) { if (((Object)instance).GetInstanceID() != _restoredGameId) { ResetRun(); } _restoredGameId = 0; _hasRun = true; } } if ((Object)(object)_boundGame == (Object)null) { return; } if (_boundGame.IsSetRecorder) { DrainNewRecorders(); if ((!_patched || _subscribed.Count == 0) && Time.unscaledTime >= _nextRecorderScan) { _nextRecorderScan = Time.unscaledTime + 10f; SubscribeRecorders(); } } SampleBalances(); SyncScalars(); try { _elapsed = _boundGame.GetElapsedGameplaySeconds(); } catch (Exception) { } int num = (int)(_elapsed / (double)_bucketSeconds) + 1; if (num > _bucketCount) { _bucketCount = num; while (_bucketCount > _maxBuckets.Value && _maxBuckets.Value >= 16) { Downsample(); } } TrackRepayment(); TrackRequirement(); TrackRunEnd(); } private void TrackRequirement() { _requiredTag = null; _requiredCount = 0; _requiredCurrent = 0L; try { WinCondition winCondition = _boundGame.GetWinCondition(); if (winCondition == null) { return; } string targetTag = winCondition.GetTargetTag(); if (!string.IsNullOrEmpty(targetTag) && !(targetTag == "None")) { _requiredTag = targetTag; _requiredCount = _boundGame.GetTargetCount(); ResourceTagsRecorder tagsRecorder = _boundGame.GetTagsRecorder(); if (tagsRecorder != null) { _requiredCurrent = tagsRecorder.GetCount(targetTag); } } } catch (Exception) { _requiredTag = null; _requiredCount = 0; } } private void TrackRepayment() { int num = 0; try { num = _boundGame.GetCurrentProgress(); _targetProgress = _boundGame.GetTargetProgress(); } catch (Exception) { return; } if (num > _repaidTotal) { _repaidTotal = num; while (_closedColumns < num) { CloseColumn(); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[run] 返済 " + _closedColumns + " 回目(イベント無し) " + FormatTime(_elapsed))); } } } private void CloseColumn() { _closedColumns++; _periodEnds.Add(_elapsed); _periodRepaid.Add(_closedColumns); _periodIndex++; } private void TrackStatsWindow() { if (!_embedInStatsWindow.Value) { _graphFrame = null; return; } if ((Object)(object)_statsWindow == (Object)null) { if (Time.unscaledTime < _nextWindowProbe) { return; } _nextWindowProbe = Time.unscaledTime + 1f; try { StatsWindowController[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); if (array.Length > 0) { _statsWindow = array[0]; } } catch (Exception) { } if ((Object)(object)_statsWindow == (Object)null) { return; } } if (!_statsWindow.IsVisible) { _graphFrame = null; _loggedFrameFound = false; return; } if ((Object)(object)_graphFrame != (Object)null && !((Component)_graphFrame).gameObject.activeInHierarchy) { _graphFrame = null; } if ((Object)(object)_graphFrame != (Object)null || Time.unscaledTime < _nextFrameProbe) { return; } _nextFrameProbe = Time.unscaledTime + 0.2f; Transform val = FindActiveChildRecursive(((Component)_statsWindow).transform, "StatsBalanceGraphFrame"); if ((Object)(object)val == (Object)null) { return; } _graphFrame = (RectTransform)(object)((val is RectTransform) ? val : null); if (!((Object)(object)_graphFrame == (Object)null)) { ApplyGraphAreaWidth(_graphFrame); Transform val2 = FindChildRecursive(val, "StatsBalanceGraphUnderDevelopment"); if ((Object)(object)val2 != (Object)null && ((Component)val2).gameObject.activeSelf) { ((Component)val2).gameObject.SetActive(false); } if (!_loggedFrameFound) { _loggedFrameFound = true; ((BaseUnityPlugin)this).Logger.LogInfo((object)"[stats] 収支グラフの枠に描いている(under development を退けた)"); } } } private void ApplyGraphAreaWidth(RectTransform frame) { //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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_0081: Unknown result type (might be due to invalid IL or missing references) int value = _graphAreaWidth.Value; if (value <= 0 || (Object)(object)frame == (Object)null) { return; } Transform parent = ((Transform)frame).parent; RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null); if ((Object)(object)val == (Object)null) { return; } Transform parent2 = ((Transform)val).parent; RectTransform val2 = (RectTransform)(object)((parent2 is RectTransform) ? parent2 : null); if ((Object)(object)val2 == (Object)null) { return; } Transform val3 = ((Transform)val2).Find("StatsBalanceCardsArea"); RectTransform val4 = (RectTransform)(object)((val3 is RectTransform) ? val3 : null); Rect rect = val.rect; float width = ((Rect)(ref rect)).width; float num; if (!((Object)(object)val4 != (Object)null)) { num = 0f; } else { Rect rect2 = val4.rect; num = ((Rect)(ref rect2)).width; } float num2 = width + num; if (!(num2 < 400f)) { float num3 = Mathf.Clamp((float)value, 200f, num2 - 200f); SetAreaWidth(val, num3); if ((Object)(object)val4 != (Object)null) { SetAreaWidth(val4, num2 - num3); } } } private static void SetAreaWidth(RectTransform rt, float width) { rt.SetSizeWithCurrentAnchors((Axis)0, width); LayoutElement component = ((Component)rt).GetComponent(); if ((Object)(object)component != (Object)null) { component.preferredWidth = width; if (component.minWidth > 0f) { component.minWidth = width; } } } private static Transform FindChildRecursive(Transform root, string name) { if ((Object)(object)root == (Object)null) { return null; } for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (string.Equals(((Object)child).name, name, StringComparison.Ordinal)) { return child; } Transform val = FindChildRecursive(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private static Transform FindActiveChildRecursive(Transform root, string name) { if ((Object)(object)root == (Object)null) { return null; } for (int i = 0; i < root.childCount; i++) { Transform child = root.GetChild(i); if (string.Equals(((Object)child).name, name, StringComparison.Ordinal) && ((Component)child).gameObject.activeInHierarchy) { return child; } Transform val = FindActiveChildRecursive(child, name); if ((Object)(object)val != (Object)null) { return val; } } return null; } private void TrackRunEnd() { bool flag = false; try { flag = _boundGame.IsEndingGame(); } catch (Exception) { } if (!flag) { return; } if (_runEndElapsed < 0.0) { _runEndElapsed = _elapsed; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[run] 終了。経過 " + FormatTime(_elapsed) + " / 記録 " + TotalRecordCount() + " 件")); } if (_isResultShown || Time.unscaledTime < _nextResultPoll) { return; } _nextResultPoll = Time.unscaledTime + 1f; if (IsResultWindowUp()) { _isResultShown = true; if (_autoShowOnResult.Value) { _visible = true; } ((BaseUnityPlugin)this).Logger.LogInfo((object)"[run] リザルト画面を検出した"); } } private static bool IsResultWindowUp() { try { ResultUIManager[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && ((Component)array[i]).gameObject.activeInHierarchy) { return true; } } } catch (Exception) { } return false; } private void DrainNewRecorders() { if (NewRecorders.Count == 0) { return; } for (int i = 0; i < NewRecorders.Count; i++) { ResourceTagsRecorder val = NewRecorders[i]; if (val != null && _subscribed.Add(val)) { try { _subscriptions.Add(ObservableSubscribeExtensions.Subscribe(val.OnTagRecorded, (Action)OnTagRecorded)); } catch (Exception) { } } } NewRecorders.Clear(); } private void SubscribeRecorders() { try { bool flag = _subscribed.Count == 0; ResourceTagsRecorder tagsRecorder = _boundGame.GetTagsRecorder(); if (tagsRecorder != null && _subscribed.Add(tagsRecorder)) { _subscriptions.Add(ObservableSubscribeExtensions.Subscribe(tagsRecorder.OnTagRecorded, (Action)OnTagRecorded)); } DeliveryDepositor[] array = Object.FindObjectsByType((FindObjectsInactive)0, (FindObjectsSortMode)0); for (int i = 0; i < array.Length; i++) { if (!((Object)(object)array[i] == (Object)null)) { ResourceTagsRecorder recorder = array[i].GetRecorder(); if (recorder != null && _subscribed.Add(recorder)) { _subscriptions.Add(ObservableSubscribeExtensions.Subscribe(recorder.OnTagRecorded, (Action)OnTagRecorded)); } } } if (flag && tagsRecorder != null) { SeedInitialBalances(tagsRecorder); ((BaseUnityPlugin)this).Logger.LogInfo((object)("[run] 記録を開始した(記録係 " + _subscribed.Count + " 件)")); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("記録係への購読に失敗しました: " + ex)); } } private void SeedInitialBalances(ResourceTagsRecorder main) { if (_seeded) { return; } _seeded = true; for (int i = 0; i < ChartRenderer.KnownTagIDs.Length; i++) { int num = 0; try { num = main.GetCount(ChartRenderer.KnownTagIDs[i]); } catch (Exception) { continue; } if (num != 0) { TagSeries orCreateSeries = GetOrCreateSeries(ChartRenderer.KnownTagIDs[i]); orCreateSeries.InitialBalance = num; if (_storeInitial != null && orCreateSeries.Index < _storeInitial.Count) { _storeInitial[orCreateSeries.Index] = num; } orCreateSeries.Balance = num; orCreateSeries.HeldUnattributed = num; orCreateSeries.PeakBalance = num; orCreateSeries.PeakAt = 0.0; EnsureBucket(orCreateSeries, 0); orCreateSeries.Balances[0] = num; } } } private void SampleBalances() { ResourceTagsRecorder val = null; try { val = _boundGame.GetTagsRecorder(); } catch (Exception) { return; } if (val == null) { return; } int num = (int)(_elapsed / (double)_bucketSeconds); if (num < 0) { num = 0; } for (int i = 0; i < ChartRenderer.KnownTagIDs.Length; i++) { string text = ChartRenderer.KnownTagIDs[i]; int count; try { count = val.GetCount(text); } catch (Exception) { continue; } if (!_seriesByTag.TryGetValue(text, out var value)) { if (count == 0) { continue; } value = GetOrCreateSeries(text); } EnsureBucket(value, num); value.Balance = count; value.Balances[num] = count; if (count > value.PeakBalance) { value.PeakBalance = count; value.PeakAt = _elapsed; } } } private void Unbind() { for (int i = 0; i < _subscriptions.Count; i++) { try { _subscriptions[i].Dispose(); } catch (Exception) { } } _subscriptions.Clear(); _subscribed.Clear(); _nextRecorderScan = 0f; _boundGame = null; } private void ResetRun() { _series.Clear(); _ordered.Clear(); _seriesByTag.Clear(); _evT.Clear(); _evDelta.Clear(); _evBalance.Clear(); _evTag.Clear(); _evReason.Clear(); _evSource.Clear(); _evPeriod.Clear(); _sourceIDs.Clear(); _sourceIndex.Clear(); _storeTagIDs.Clear(); _storeInitial.Clear(); _storeBalances.Clear(); if (_scalars != null) { for (int i = 1; i < _scalars.Length; i++) { _scalars[i] = 0.0; } } _rawEventsTruncated = false; _periodEnds.Clear(); _periodRepaid.Clear(); _repaidTotal = 0; _closedColumns = 0; _hiddenTags.Clear(); _requiredTag = null; _requiredCount = 0; _requiredCurrent = 0L; _periodIndex = 0; _targetProgress = 0; _bucketSeconds = ((_bucketSecondsInitial.Value > 0.05f) ? _bucketSecondsInitial.Value : 1f); _bucketCount = 0; _elapsed = 0.0; _seeded = false; _runEndElapsed = -1.0; _isResultShown = false; _nextResultPoll = 0f; _selectedTag = 0; } private void OnTagRecorded(TagRecordedEvent ev) { //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0059: Expected I4, but got Unknown //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_0263: Unknown result type (might be due to invalid IL or missing references) if (_enabled.Value && !string.IsNullOrEmpty(ev.tagID) && !(ev.tagID == "None") && ev.delta > 0 && ChartRenderer.KnownIndex(ev.tagID) < ChartRenderer.KnownTagIDs.Length) { int num = (int)ev.statsCashReason; if (num < 0 || num >= 16) { num = 0; } if (InLandPurchase && !ev.isAdd && num == 0) { num = 15; } double elapsed = _elapsed; int num2 = (int)(elapsed / (double)_bucketSeconds); if (num2 < 0) { num2 = 0; } TagSeries orCreateSeries = GetOrCreateSeries(ev.tagID); EnsureBucket(orCreateSeries, num2); if (num2 >= _bucketCount) { _bucketCount = num2 + 1; } orCreateSeries.RecordCount++; int num3 = ((!ev.isAdd) ? 16 : 0) + num; orCreateSeries.Flows[num2 * 32 + num3] += ev.delta; EnsurePeriod(orCreateSeries, _periodIndex); orCreateSeries.PeriodFlows[_periodIndex * 32 + num3] += ev.delta; RecordSource(orCreateSeries, ev, num); bool flag = !ev.isAdd && (int)ev.statsCashReason == 5 && string.Equals(ev.tagID, _requiredTag, StringComparison.Ordinal); if (flag) { RecordRepaidComposition(orCreateSeries, ev.delta); } else if (!ev.isAdd) { orCreateSeries.SpendFromHolding(ev.delta); } if (flag && !_replaying) { CloseColumn(); } if (ev.isAdd) { orCreateSeries.IncomeTotal += ev.delta; orCreateSeries.IncomeByReason[num] += ev.delta; AddSource(orCreateSeries.IncomeBySource, ev.statsSourceID, ev.delta); } else { orCreateSeries.ExpenseTotal += ev.delta; orCreateSeries.ExpenseByReason[num] += ev.delta; AddSource(orCreateSeries.ExpenseBySource, ev.statsSourceID, ev.delta); } if (!_replaying) { RecordRaw(orCreateSeries, ev, elapsed, num); } while (_bucketCount > _maxBuckets.Value && _maxBuckets.Value >= 16) { Downsample(); } } } private void RecordSource(TagSeries s, TagRecordedEvent ev, int reason) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 if ((int)ev.statsCashReason != 8) { bool flag = !string.IsNullOrEmpty(ev.statsSourceID) && UsesSourceID(reason); string key = (flag ? ev.statsSourceID : ("#" + reason.ToString(CultureInfo.InvariantCulture))); SourceSeries orCreateSource = s.GetOrCreateSource(ev.isAdd, key, reason, flag); orCreateSource.Add(_periodIndex, ev.delta); if (ev.isAdd) { s.AddHolding(orCreateSource, ev.delta); } } } private void RecordRepaidComposition(TagSeries s, long amount) { if (amount <= 0) { return; } _takeSources.Clear(); _takeAmounts.Clear(); s.TakeFromHolding(amount, _takeSources, _takeAmounts); for (int i = 0; i < _takeSources.Count && i < _takeAmounts.Count; i++) { SourceSeries sourceSeries = _takeSources[i]; if (sourceSeries == null) { sourceSeries = s.GetOrCreateSource(income: true, "#10", 10, hasSource: false); } sourceSeries.AddRepaid(_periodIndex, _takeAmounts[i]); } } private static bool UsesSourceID(int reason) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Invalid comparison between Unknown and I4 //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Invalid comparison between Unknown and I4 //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Invalid comparison between Unknown and I4 StatsCashReason val = (StatsCashReason)reason; if ((int)val != 2 && (int)val != 3 && (int)val != 6 && (int)val != 13) { return (int)val == 14; } return true; } private static void AddSource(Dictionary dict, string sourceID, int delta) { if (!string.IsNullOrEmpty(sourceID)) { dict.TryGetValue(sourceID, out var value); dict[sourceID] = value + delta; } } private void RecordRaw(TagSeries s, TagRecordedEvent ev, double t, int reason) { int value = _maxRawEvents.Value; if (value <= 0) { return; } if (_evT.Count >= value) { _rawEventsTruncated = true; return; } int index = s.Index; int value2 = -1; if (!string.IsNullOrEmpty(ev.statsSourceID) && !_sourceIndex.TryGetValue(ev.statsSourceID, out value2)) { value2 = _sourceIDs.Count; _sourceIDs.Add(ev.statsSourceID); _sourceIndex[ev.statsSourceID] = value2; } _evT.Add((float)t); _evDelta.Add(ev.isAdd ? ev.delta : (-ev.delta)); _evBalance.Add(ev.newTotal); _evTag.Add(index); _evReason.Add(reason); _evSource.Add(value2); _evPeriod.Add(_periodIndex); } private TagSeries GetOrCreateSeries(string tagID) { if (_seriesByTag.TryGetValue(tagID, out var value)) { return value; } value = new TagSeries(tagID, _series.Count, 16); value.DisplayName = ResolveTagName(tagID); _seriesByTag.Add(tagID, value); _series.Add(value); RegisterStoreTag(value); RebuildOrder(); return value; } private void RebuildOrder() { _ordered.Clear(); for (int i = 0; i < _series.Count; i++) { _ordered.Add(_series[i]); } _ordered.Sort(delegate(TagSeries a, TagSeries b) { int num = ChartRenderer.KnownIndex(a.TagID); int num2 = ChartRenderer.KnownIndex(b.TagID); return (num != num2) ? num.CompareTo(num2) : string.CompareOrdinal(a.TagID, b.TagID); }); } private static string ResolveTagName(string tagID) { try { string name = TagParamGetter.GetName(tagID); name = StripRichText(name); if (!string.IsNullOrEmpty(name)) { return name; } } catch (Exception) { } int num = ChartRenderer.KnownIndex(tagID); if (num < ChartRenderer.KnownTagNamesJa.Length) { return ChartRenderer.KnownTagNamesJa[num]; } return tagID; } private static string StripRichText(string value) { if (string.IsNullOrEmpty(value) || value.IndexOf('<') < 0) { return value; } StringBuilder stringBuilder = new StringBuilder(value.Length); bool flag = false; foreach (char c in value) { switch (c) { case '<': flag = true; continue; case '>': flag = false; continue; } if (!flag) { stringBuilder.Append(c); } } return stringBuilder.ToString().Trim(); } private static void EnsurePeriod(TagSeries s, int period) { while (s.PeriodFlows.Count <= (period + 1) * 32 - 1) { s.PeriodFlows.Add(0L); } } private void EnsureBucket(TagSeries s, int bucket) { while (s.Balances.Count <= bucket) { long item = ((s.Balances.Count > 0) ? s.Balances[s.Balances.Count - 1] : s.InitialBalance); s.Balances.Add(item); } int num = (bucket + 1) * 32; while (s.Flows.Count < num) { s.Flows.Add(0L); } } private void Downsample() { for (int i = 0; i < _series.Count; i++) { TagSeries tagSeries = _series[i]; int num = ((_bucketCount > tagSeries.Balances.Count) ? _bucketCount : tagSeries.Balances.Count); if (num > 0) { EnsureBucket(tagSeries, num - 1); } int count = tagSeries.Balances.Count; int num2 = (count + 1) / 2; for (int j = 0; j < num2; j++) { int num3 = j * 2; int num4 = ((num3 + 1 < count) ? (num3 + 1) : num3); tagSeries.Balances[j] = tagSeries.Balances[num4]; for (int k = 0; k < 32; k++) { long num5 = tagSeries.Flows[num3 * 32 + k]; if (num4 != num3) { num5 += tagSeries.Flows[num4 * 32 + k]; } tagSeries.Flows[j * 32 + k] = num5; } } tagSeries.Balances.RemoveRange(num2, count - num2); tagSeries.Flows.RemoveRange(num2 * 32, (count - num2) * 32); } _bucketSeconds *= 2f; _bucketCount = (_bucketCount + 1) / 2; ((BaseUnityPlugin)this).Logger.LogInfo((object)("[graph] バケット幅を " + F(_bucketSeconds) + " 秒にした")); } private long TotalRecordCount() { long num = 0L; for (int i = 0; i < _series.Count; i++) { num += _series[i].RecordCount; } return num; } private void HandleInput() { Keyboard current = Keyboard.current; if (current == null) { return; } if (_keyToggle != null && _keyToggle.WasPressedThisFrame(current)) { _visible = !_visible; if (!_visible && _adjustMode) { LeaveAdjustMode(); } } if (_keyCycleMode != null && _keyCycleMode.WasPressedThisFrame(current)) { _mode = (_mode + 1) % 3; } if (_keyCycleRange != null && _keyCycleRange.WasPressedThisFrame(current)) { _lastMinute = !_lastMinute; Say(_lastMinute ? "直近1分" : "全体"); } if (_keyToggleSide != null && _keyToggleSide.WasPressedThisFrame(current)) { _expenseSide = !_expenseSide; } if (_keyNextTag != null && _keyNextTag.WasPressedThisFrame(current)) { CycleTag(1); } if (_keyPrevTag != null && _keyPrevTag.WasPressedThisFrame(current)) { CycleTag(-1); } if (_keyExport != null && _keyExport.WasPressedThisFrame(current)) { ExportCsv(); } if (_keyAdjust != null && _keyAdjust.WasPressedThisFrame(current)) { if (_adjustMode) { LeaveAdjustMode(); } else { _adjustMode = true; _visible = true; Say("レイアウト調整モード:矢印=移動 Shift+矢印=大きさ Ctrl+矢印=1px " + _keyAdjustSpec.Value + "=確定"); } } HandleIconClick(); if (_adjustMode) { HandleAdjust(current); } } private void CycleTag(int direction) { if (_ordered.Count != 0) { _selectedTag = (_selectedTag + direction + _ordered.Count) % _ordered.Count; _visible = true; } } private void HandleAdjust(Keyboard kb) { //IL_00e4: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) if (Time.unscaledTime < _nextAdjustRepeat) { return; } float num = 0f; float num2 = 0f; if (((ButtonControl)kb.leftArrowKey).isPressed) { num -= 1f; } if (((ButtonControl)kb.rightArrowKey).isPressed) { num += 1f; } if (((ButtonControl)kb.upArrowKey).isPressed) { num2 -= 1f; } if (((ButtonControl)kb.downArrowKey).isPressed) { num2 += 1f; } if (num != 0f || num2 != 0f) { bool flag = ((ButtonControl)kb.leftCtrlKey).isPressed || ((ButtonControl)kb.rightCtrlKey).isPressed; bool flag2 = ((ButtonControl)kb.leftShiftKey).isPressed || ((ButtonControl)kb.rightShiftKey).isPressed; float num3 = (flag ? 1f : 6f); _nextAdjustRepeat = Time.unscaledTime + (flag ? 0.05f : 0.02f); Rect currentRectPixels = CurrentRectPixels(); if (flag2) { ((Rect)(ref currentRectPixels)).width = Mathf.Max(200f, ((Rect)(ref currentRectPixels)).width + num * num3); ((Rect)(ref currentRectPixels)).height = Mathf.Max(120f, ((Rect)(ref currentRectPixels)).height + num2 * num3); } else { ((Rect)(ref currentRectPixels)).x = ((Rect)(ref currentRectPixels)).x + num * num3; ((Rect)(ref currentRectPixels)).y = ((Rect)(ref currentRectPixels)).y + num2 * num3; } SetCurrentRectPixels(currentRectPixels); } } private void LeaveAdjustMode() { _adjustMode = false; try { ((BaseUnityPlugin)this).Config.Save(); } catch (Exception) { } Say("レイアウトを保存した: " + CurrentRectEntry().Value); } private ConfigEntry CurrentRectEntry() { if (!_isResultShown) { return _panelRect; } return _resultPanelRect; } private Rect CurrentRectPixels() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) Rect val = ParseRect(CurrentRectEntry().Value); return new Rect(((Rect)(ref val)).x * (float)Screen.width, ((Rect)(ref val)).y * (float)Screen.height, ((Rect)(ref val)).width * (float)Screen.width, ((Rect)(ref val)).height * (float)Screen.height); } private void SetCurrentRectPixels(Rect px) { float num = Screen.width; float num2 = Screen.height; if (!(num <= 0f) && !(num2 <= 0f)) { CurrentRectEntry().Value = F4(((Rect)(ref px)).x / num) + "," + F4(((Rect)(ref px)).y / num2) + "," + F4(((Rect)(ref px)).width / num) + "," + F4(((Rect)(ref px)).height / num2); } } private static Rect ParseRect(string spec) { //IL_00d1: Unknown result type (might be due to invalid IL or missing references) float num = 0.06f; float num2 = 0.08f; float num3 = 0.88f; float num4 = 0.78f; if (!string.IsNullOrEmpty(spec)) { string[] array = spec.Split(','); if (array.Length == 4 && float.TryParse(array[0].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array[3].Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { num = result; num2 = result2; num3 = result3; num4 = result4; } } if (num3 < 0.1f) { num3 = 0.1f; } if (num4 < 0.08f) { num4 = 0.08f; } return new Rect(num, num2, num3, num4); } private void ExportCsv() { if (_series.Count == 0) { Say("書き出すものが無い(記録が空)"); return; } try { string text = Path.Combine(Paths.BepInExRootPath, "LwfEconomy"); Directory.CreateDirectory(text); string text2 = DateTime.Now.ToString("yyyyMMdd_HHmmss", CultureInfo.InvariantCulture); string text3 = Path.Combine(text, "economy_" + text2 + ".csv"); StringBuilder stringBuilder = new StringBuilder(65536); stringBuilder.Append("# ").Append("LWF Economy Graph").Append(' ') .Append("1.0.1") .Append('\n'); stringBuilder.Append("# elapsed_seconds=").Append(F(_elapsed)).Append(" bucket_seconds=") .Append(F(_bucketSeconds)) .Append(" records=") .Append(TotalRecordCount()) .Append(" raw=") .Append(_evT.Count) .Append(_rawEventsTruncated ? " (上限で打ち切り)" : "") .Append('\n'); stringBuilder.Append("t_sec,tag,delta,balance,reason,source\n"); for (int i = 0; i < _evT.Count; i++) { int num = _evTag[i]; string value = ((num >= 0 && num < _series.Count) ? _series[num].TagID : "?"); string value2 = ((_evSource[i] >= 0 && _evSource[i] < _sourceIDs.Count) ? _sourceIDs[_evSource[i]] : ""); stringBuilder.Append(_evT[i].ToString("0.00", CultureInfo.InvariantCulture)).Append(',').Append(value) .Append(',') .Append(_evDelta[i].ToString(CultureInfo.InvariantCulture)) .Append(',') .Append(_evBalance[i].ToString(CultureInfo.InvariantCulture)) .Append(',') .Append(ReasonEnumName(_evReason[i])) .Append(',') .Append(Csv(value2)) .Append('\n'); } File.WriteAllText(text3, stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: true)); ((BaseUnityPlugin)this).Logger.LogInfo((object)("CSV を書き出した: " + text3)); Say("CSV を書き出した: " + text3); } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogError((object)("CSV の書き出しに失敗しました: " + ex)); Say("CSV の書き出しに失敗: " + ex.Message); } } private static string Csv(string value) { if (string.IsNullOrEmpty(value)) { return ""; } if (value.IndexOf(',') < 0 && value.IndexOf('"') < 0) { return value; } return "\"" + value.Replace("\"", "\"\"") + "\""; } private static string ReasonEnumName(int reason) { switch (reason) { case 15: return "LandPurchase"; default: return "Unknown"; case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: case 8: case 9: case 10: case 11: case 12: case 13: case 14: return ((object)(StatsCashReason)reason).ToString(); } } private void Say(string msg) { _message = msg; _messageUntil = Time.unscaledTime + 6f; } private void OnGUI() { //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Invalid comparison between Unknown and I4 if (_enabled == null || !_enabled.Value || !_hasRun || _brokenDown || (int)Event.current.type != 7) { return; } try { DrawFrame(); } catch (Exception e) { ReportBreakdown("描画", e); } } private void DrawFrame() { //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0047: 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) EnsureStyles(); _drewThisFrame = false; if (!IsMenuOpen()) { if (TryGetFrameRect(out var guiRect)) { DrawEmbedded(guiRect); _lastDrawn = guiRect; _drewThisFrame = true; } else if (_visible) { Rect val = CurrentRectPixels(); DrawPanel(val); _lastDrawn = val; _drewThisFrame = true; } if (_drewThisFrame) { DrawGameCursorOnTop(); } } } private void DrawGameCursorOnTop() { //IL_0019: 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_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f5: Unknown result type (might be due to invalid IL or missing references) //IL_00eb: 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) if (!_chart.MouseValid || !((Rect)(ref _lastDrawn)).Contains(_chart.Mouse)) { return; } if ((Object)(object)_cursorChaser == (Object)null) { if (Time.unscaledTime < _nextCursorProbe) { return; } _nextCursorProbe = Time.unscaledTime + 1f; if (!TryFindCursor()) { return; } } if (!_cursorChaser.activeInHierarchy) { return; } try { _cursorGraphics.Clear(); _cursorChaser.GetComponentsInChildren(false, _cursorGraphics); for (int i = 0; i < _cursorGraphics.Count; i++) { Graphic val = _cursorGraphics[i]; if ((Object)(object)val == (Object)null || !((Behaviour)val).enabled || !TryGetScreenRect(val.rectTransform, out var guiRect)) { continue; } Image val2 = (Image)(object)((val is Image) ? val : null); if ((Object)(object)val2 != (Object)null) { if (!((Object)(object)val2.sprite == (Object)null)) { DrawSprite(val2.preserveAspect ? FitAspect(guiRect, val2.sprite) : guiRect, val2.sprite, ((Graphic)val2).color); } continue; } TextMeshProUGUI val3 = (TextMeshProUGUI)(object)((val is TextMeshProUGUI) ? val : null); if ((Object)(object)val3 != (Object)null && !string.IsNullOrEmpty(((TMP_Text)val3).text)) { DrawText(((Rect)(ref guiRect)).x, ((Rect)(ref guiRect)).y, ((TMP_Text)val3).text, _text, ((Graphic)val3).color); } } } catch (Exception) { } } private bool IsMenuOpen() { if ((Object)(object)_commonUI == (Object)null) { if (Time.unscaledTime < _nextMenuProbe) { return false; } _nextMenuProbe = Time.unscaledTime + 1f; try { CommonUIController[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); if (array.Length == 0) { return false; } _commonUI = array[0]; _menuObjects = null; } catch (Exception) { return false; } } if (_menuObjects == null) { _menuObjects = new List(); string[] array2 = new string[1] { "_gameMenu" }; for (int i = 0; i < array2.Length; i++) { try { FieldInfo field = typeof(CommonUIController).GetField(array2[i], BindingFlags.Instance | BindingFlags.NonPublic); GameObject val = (GameObject)((field != null) ? /*isinst with value type is only supported in some contexts*/: null); if ((Object)(object)val != (Object)null) { _menuObjects.Add(val); } } catch (Exception) { } } if (_menuObjects.Count == 0) { ((BaseUnityPlugin)this).Logger.LogWarning((object)"メニューの開閉を読めなかった"); } } for (int j = 0; j < _menuObjects.Count; j++) { if ((Object)(object)_menuObjects[j] != (Object)null && _menuObjects[j].activeInHierarchy) { return true; } } return false; } private bool TryFindCursor() { try { if ((Object)(object)_cursorView == (Object)null) { CursorViewSwitcher[] array = Object.FindObjectsByType((FindObjectsInactive)1, (FindObjectsSortMode)0); if (array.Length == 0) { return false; } _cursorView = array[0]; } FieldInfo field = typeof(CursorViewSwitcher).GetField("_cursorChaser", BindingFlags.Instance | BindingFlags.NonPublic); _cursorChaser = (GameObject)(((object)((field != null) ? /*isinst with value type is only supported in some contexts*/: null)) ?? ((object)((Component)_cursorView).gameObject)); return (Object)(object)_cursorChaser != (Object)null; } catch (Exception) { return false; } } private bool TryGetFrameRect(out Rect guiRect) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) guiRect = default(Rect); if ((Object)(object)_graphFrame == (Object)null) { return false; } if ((Object)(object)_statsWindow == (Object)null || !_statsWindow.IsVisible) { return false; } if (!((Component)_graphFrame).gameObject.activeInHierarchy) { return false; } if (!TryGetScreenRect(_graphFrame, out guiRect)) { return false; } if (((Rect)(ref guiRect)).width > 40f) { return ((Rect)(ref guiRect)).height > 40f; } return false; } private bool TryGetScreenRect(RectTransform rectTransform, out Rect guiRect) { //IL_0001: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Unknown result type (might be due to invalid IL or missing references) guiRect = default(Rect); if ((Object)(object)rectTransform == (Object)null) { return false; } rectTransform.GetWorldCorners(_frameCorners); Canvas componentInParent = ((Component)rectTransform).GetComponentInParent(); Camera val = null; if ((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) { val = componentInParent.worldCamera; } Vector2 val2 = RectTransformUtility.WorldToScreenPoint(val, _frameCorners[0]); Vector2 val3 = RectTransformUtility.WorldToScreenPoint(val, _frameCorners[2]); float num = Mathf.Min(val2.x, val3.x); float num2 = Mathf.Max(val2.x, val3.x); float num3 = Mathf.Min(val2.y, val3.y); float num4 = Mathf.Max(val2.y, val3.y); guiRect = new Rect(num, (float)Screen.height - num4, num2 - num, num4 - num3); if (((Rect)(ref guiRect)).width > 0.5f) { return ((Rect)(ref guiRect)).height > 0.5f; } return false; } private void EnsureStyles() { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Expected O, but got Unknown //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Expected O, but got Unknown if (_text != null && _styleFontSize == _fontSize.Value) { return; } _styleFontSize = _fontSize.Value; if ((Object)(object)_font == (Object)null && !string.IsNullOrEmpty(_fontName.Value)) { try { _font = Font.CreateDynamicFontFromOSFont(_fontName.Value, _fontSize.Value); } catch (Exception) { _font = null; } } _text = new GUIStyle(GUI.skin.label); _text.fontSize = _fontSize.Value; _text.normal.textColor = Color.white; _text.alignment = (TextAnchor)0; _text.richText = false; _text.wordWrap = false; _text.padding = new RectOffset(0, 0, 0, 0); _text.margin = new RectOffset(0, 0, 0, 0); if ((Object)(object)_font != (Object)null) { _text.font = _font; } _title = new GUIStyle(_text); _title.fontSize = _fontSize.Value + 3; _title.fontStyle = (FontStyle)1; } private static void Fill(Rect r, Color c) { //IL_001d: 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) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (!(((Rect)(ref r)).width <= 0f) && !(((Rect)(ref r)).height <= 0f)) { Color color = GUI.color; GUI.color = c; GUI.DrawTexture(r, (Texture)(object)Texture2D.whiteTexture); GUI.color = color; } } private float W(string s, GUIStyle style) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) if (string.IsNullOrEmpty(s)) { return 0f; } _content.text = s; return style.CalcSize(_content).x; } private void DrawText(float x, float y, string s, GUIStyle style, Color color) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0035: 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_007b: 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_0092: Unknown result type (might be due to invalid IL or missing references) if (!string.IsNullOrEmpty(s)) { Rect val = default(Rect); ((Rect)(ref val))..ctor(x, y, 4000f, (float)(style.fontSize + 6)); Color textColor = style.normal.textColor; style.normal.textColor = ShadowColor; GUI.Label(new Rect(((Rect)(ref val)).x + 1f, ((Rect)(ref val)).y + 1f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), s, style); style.normal.textColor = color; GUI.Label(val, s, style); style.normal.textColor = textColor; } } private Sprite GetReasonSprite(string key, string tagID) { if (!int.TryParse(key.Substring(1), NumberStyles.None, CultureInfo.InvariantCulture, out var result) || result < 0 || result >= 16) { return GetTagSprite(tagID); } if (result == 5) { Sprite gehennaFace = GetGehennaFace(); if ((Object)(object)gehennaFace != (Object)null) { return gehennaFace; } } string text = ReasonIconTag[result]; if (string.IsNullOrEmpty(text)) { return GetTagSprite(tagID); } Sprite tagSprite = GetTagSprite(text); return tagSprite ?? GetTagSprite(tagID); } private Sprite GetCraftIcon() { if ((Object)(object)_craftIcon != (Object)null) { return _craftIcon; } if ((Object)(object)_statsWindow == (Object)null || _craftIconTries > 8) { return null; } _craftIconTries++; try { Image[] componentsInChildren = ((Component)_statsWindow).GetComponentsInChildren(true); for (int i = 0; i < componentsInChildren.Length; i++) { Sprite sprite = componentsInChildren[i].sprite; if (!((Object)(object)sprite == (Object)null) && ((Object)sprite).name.StartsWith("MenuCraft", StringComparison.Ordinal)) { _craftIcon = sprite; return sprite; } } } catch (Exception) { } return null; } private Sprite GetGehennaFace() { return _gehennaFace; } private void ResolveGehennaFace() { //IL_0078: 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) if (_gehennaFaceResolved || Time.unscaledTime < _nextFaceProbe) { return; } _nextFaceProbe = Time.unscaledTime + 3f; _faceAttempts++; Texture2D val = FindTexture("InGameFaceIcons"); if ((Object)(object)val != (Object)null) { try { float num = (float)((Texture)val).width * 0.25f; float num2 = (float)((Texture)val).height * 0.25f; _gehennaFace = Sprite.Create(val, new Rect((float)((Texture)val).width - num, 0f, num, num2), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0); _gehennaFaceResolved = true; return; } catch (Exception) { _gehennaFace = null; } } if (_faceAttempts >= 5) { try { _gehennaFace = Patrons.GetFaceIcon((Patron)1); } catch (Exception) { _gehennaFace = null; } _gehennaFaceResolved = true; } } private static Texture2D FindTexture(string name) { try { Texture2D[] array = Resources.FindObjectsOfTypeAll(); for (int i = 0; i < array.Length; i++) { if ((Object)(object)array[i] != (Object)null && string.Equals(((Object)array[i]).name, name, StringComparison.Ordinal)) { return array[i]; } } } catch (Exception) { } return null; } private string ReasonName(int reason) { if (reason < 0 || reason >= 16) { return string.Empty; } if (!string.IsNullOrEmpty(ReasonIconTag[reason]) || reason == 5) { return string.Empty; } string text = _reasonNames[reason]; if (text != null) { return text; } string text2 = ReasonMessageKeys[reason]; string text3 = null; if (!string.IsNullOrEmpty(text2)) { try { text3 = LocalizedTextGetter.GetLocalizedText((StringTableType)0, text2); text3 = StripRichText(text3); } catch (Exception) { text3 = null; } } if (string.IsNullOrEmpty(text3)) { text3 = ReasonFallback[reason]; } _reasonNames[reason] = text3; return text3; } private void DrawEmbedded(Rect frame) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp(((Rect)(ref frame)).width / 494f, 0.8f, 2.2f); float num2 = 8f * num; Rect area = default(Rect); ((Rect)(ref area))..ctor(((Rect)(ref frame)).x + num2, ((Rect)(ref frame)).y + num2, ((Rect)(ref frame)).width - num2 * 2f, ((Rect)(ref frame)).height - num2 * 2f); DrawChart(area); } private void DrawPanel(Rect panel) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0039: 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_0093: 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_00c7: 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) //IL_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: 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_01ad: Unknown result type (might be due to invalid IL or missing references) Fill(panel, new Color(0.04f, 0.05f, 0.07f, 0.88f)); Fill(new Rect(((Rect)(ref panel)).x, ((Rect)(ref panel)).y, ((Rect)(ref panel)).width, 2f), new Color(1f, 0.62f, 0.2f, 0.9f)); float num = 10f; DrawChart(new Rect(((Rect)(ref panel)).x + num, ((Rect)(ref panel)).y + num, ((Rect)(ref panel)).width - num * 2f, ((Rect)(ref panel)).height - num * 2f)); if (_adjustMode) { Fill(new Rect(((Rect)(ref panel)).x, ((Rect)(ref panel)).y, ((Rect)(ref panel)).width, 2f), Color.cyan); Fill(new Rect(((Rect)(ref panel)).x, ((Rect)(ref panel)).yMax - 2f, ((Rect)(ref panel)).width, 2f), Color.cyan); Fill(new Rect(((Rect)(ref panel)).x, ((Rect)(ref panel)).y, 2f, ((Rect)(ref panel)).height), Color.cyan); Fill(new Rect(((Rect)(ref panel)).xMax - 2f, ((Rect)(ref panel)).y, 2f, ((Rect)(ref panel)).height), Color.cyan); } if (Time.unscaledTime < _messageUntil && _message.Length > 0) { DrawText(((Rect)(ref panel)).x + num, ((Rect)(ref panel)).yMax - ((float)_text.fontSize + 10f), ">> " + _message, _text, Color.white); } } private void DrawChart(Rect area) { //IL_0022: Unknown result type (might be due to invalid IL or missing references) FillChartData(); _painter.Begin(_fontSize.Value); _renderer.Draw(area, _chart, _painter); _chartDrawnFrame = Time.frameCount; } private void FillChartData() { _chart.Ordered = _ordered; _chart.Selected = ResolveSeries(); _chart.BucketSeconds = _bucketSeconds; _chart.BucketCount = _bucketCount; _chart.MaxColumns = _maxColumns.Value; _chart.PeriodIndex = _periodIndex; _chart.PeriodRepaid = _periodRepaid; _chart.RepaidTotal = _repaidTotal; _chart.TargetProgress = _targetProgress; _chart.RequiredTagID = _requiredTag; _chart.RequiredCount = _requiredCount; _chart.RequiredCurrent = _requiredCurrent; _chart.PeriodEnds = _periodEnds; _chart.HiddenTags = _hiddenTags; _chart.Mode = _mode; FillMouse(); _chart.LastMinute = UseLastMinute(); _chart.ExpenseSide = IsExpenseSide(); BuildRates(); } private void BuildRates() { if (_mode != 2 || !_chart.LastMinute) { if (_chart.RateSources.Count > 0) { _chart.RateSources.Clear(); _chart.RateValues.Clear(); _chart.RateTotals.Clear(); } } else { if (Time.unscaledTime < _nextRateBuild) { return; } _nextRateBuild = Time.unscaledTime + 0.25f; _chart.RateSources.Clear(); _chart.RateValues.Clear(); _chart.RateTotals.Clear(); _chart.RateSlotSeconds = 1f; _chart.RateTotal = 0L; TagSeries selected = _chart.Selected; if (selected == null || _evT == null) { return; } int num = (int)_elapsed; int num2 = num - 119; double num3 = num2; bool expenseSide = _chart.ExpenseSide; _rateBuckets.Clear(); _rateKeys.Clear(); int num4 = _evT.Count - 1; while (num4 >= 0 && !((double)_evT[num4] < num3)) { if (_evTag[num4] == selected.Index) { int num5 = _evDelta[num4]; if (num5 > 0 != expenseSide) { int num6 = _evReason[num4]; if (num6 != 8) { int num7 = (int)_evT[num4] - num2; if (num7 >= 0 && num7 < 120) { string text = ((_evSource[num4] >= 0 && _evSource[num4] < _sourceIDs.Count) ? _sourceIDs[_evSource[num4]] : null); string text2 = ((!string.IsNullOrEmpty(text) && UsesSourceID(num6)) ? text : ("#" + num6.ToString(CultureInfo.InvariantCulture))); if (!_rateBuckets.TryGetValue(text2, out var value)) { value = new long[120]; _rateBuckets[text2] = value; _rateKeys.Add(text2); } value[num7] += Math.Abs(num5); } } } } num4--; } if (_rateKeys.Count == 0) { return; } for (int i = 0; i < _rateKeys.Count; i++) { _chart.RateTotal += Latest(_rateBuckets[_rateKeys[i]]); } _rateKeys.Sort((string a, string b) => Latest(_rateBuckets[b]).CompareTo(Latest(_rateBuckets[a]))); int num8 = Mathf.Min(8, _rateKeys.Count); for (int num9 = 0; num9 < num8; num9++) { string key = _rateKeys[num9]; long[] seconds = _rateBuckets[key]; SourceSeries sourceSeries = FindSource(selected, !expenseSide, key); if (sourceSeries != null) { _chart.RateSources.Add(sourceSeries); _chart.RateTotals.Add(Latest(seconds)); _chart.RateValues.Add(Rolling(seconds)); } } } } private static long Latest(long[] seconds) { long num = 0L; for (int i = 60; i < seconds.Length; i++) { num += seconds[i]; } return num; } private static float[] Rolling(long[] seconds) { float[] array = new float[60]; long num = 0L; for (int i = 0; i < 60; i++) { num += seconds[i]; } for (int j = 0; j < 60; j++) { num += seconds[60 + j]; num -= seconds[j]; array[j] = num; } return array; } private static SourceSeries FindSource(TagSeries s, bool income, string key) { List list = (income ? s.IncomeSources : s.ExpenseSources); for (int i = 0; i < list.Count; i++) { if (string.Equals(list[i].Key, key, StringComparison.Ordinal)) { return list[i]; } } return null; } private void FillMouse() { //IL_001c: 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_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) Mouse current = Mouse.current; if (current == null) { _chart.MouseValid = false; return; } Vector2 val = ((InputControl)(object)((Pointer)current).position).ReadValue(); _chart.Mouse = new Vector2(val.x, (float)Screen.height - val.y); _chart.MouseValid = true; } private TagSeries ResolveSeries() { string text = StatsSelectedTagID(); if (!string.IsNullOrEmpty(text)) { if (_seriesByTag.TryGetValue(text, out var value)) { return value; } return null; } if (_ordered.Count == 0) { return null; } if (_selectedTag >= _ordered.Count) { _selectedTag = 0; } return _ordered[_selectedTag]; } private static void DrawSprite(Rect r, Sprite sp, Color tint) { //IL_0019: 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) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0099: 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_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: 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) if (!((Object)(object)sp == (Object)null) && !((Object)(object)sp.texture == (Object)null)) { Rect textureRect = sp.textureRect; float num = ((Texture)sp.texture).width; float num2 = ((Texture)sp.texture).height; if (!(num <= 0f) && !(num2 <= 0f) && !(((Rect)(ref textureRect)).width <= 0f) && !(((Rect)(ref textureRect)).height <= 0f)) { Rect val = SpriteDest(r, sp); Rect val2 = default(Rect); ((Rect)(ref val2))..ctor(((Rect)(ref textureRect)).x / num, ((Rect)(ref textureRect)).y / num2, ((Rect)(ref textureRect)).width / num, ((Rect)(ref textureRect)).height / num2); Color color = GUI.color; GUI.color = tint; GUI.DrawTextureWithTexCoords(val, (Texture)(object)sp.texture, val2, true); GUI.color = color; } } } private static Rect SpriteDest(Rect r, Sprite sp) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: 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_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) Rect textureRect = sp.textureRect; Rect rect = sp.rect; if (((Rect)(ref rect)).width <= 0.5f || ((Rect)(ref rect)).height <= 0.5f) { return r; } float num = ((Rect)(ref r)).width / ((Rect)(ref rect)).width; float num2 = ((Rect)(ref r)).height / ((Rect)(ref rect)).height; Vector2 textureRectOffset = sp.textureRectOffset; return new Rect(((Rect)(ref r)).x + textureRectOffset.x * num, ((Rect)(ref r)).yMax - (textureRectOffset.y + ((Rect)(ref textureRect)).height) * num2, ((Rect)(ref textureRect)).width * num, ((Rect)(ref textureRect)).height * num2); } private Texture2D GetSilhouette(Sprite sp) { if ((Object)(object)sp == (Object)null || (Object)(object)sp.texture == (Object)null) { return null; } int instanceID = ((Object)sp).GetInstanceID(); if (_silhouettes.TryGetValue(instanceID, out var value)) { return value; } if (!_silhouettePending.Contains(sp)) { _silhouettePending.Add(sp); } return null; } private void BuildPendingSilhouettes() { if (_silhouettePending.Count == 0) { return; } int num = 4; int num2 = _silhouettePending.Count - 1; while (num2 >= 0 && num > 0) { Sprite val = _silhouettePending[num2]; _silhouettePending.RemoveAt(num2); num--; if (!((Object)(object)val == (Object)null)) { int instanceID = ((Object)val).GetInstanceID(); if (!_silhouettes.ContainsKey(instanceID)) { _silhouettes[instanceID] = BuildSilhouette(val); } } num2--; } } private static Texture2D BuildSilhouette(Sprite sp) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Expected O, but got Unknown //IL_00be: Unknown result type (might be due to invalid IL or missing references) RenderTexture val = null; RenderTexture active = RenderTexture.active; try { Rect textureRect = sp.textureRect; int num = Mathf.Max(1, Mathf.RoundToInt(((Rect)(ref textureRect)).width)); int num2 = Mathf.Max(1, Mathf.RoundToInt(((Rect)(ref textureRect)).height)); float num3 = ((Texture)sp.texture).width; float num4 = ((Texture)sp.texture).height; val = RenderTexture.GetTemporary(num, num2, 0, (RenderTextureFormat)0); Graphics.Blit((Texture)(object)sp.texture, val, new Vector2(((Rect)(ref textureRect)).width / num3, ((Rect)(ref textureRect)).height / num4), new Vector2(((Rect)(ref textureRect)).x / num3, ((Rect)(ref textureRect)).y / num4)); RenderTexture.active = val; Texture2D val2 = new Texture2D(num, num2, (TextureFormat)5, false); val2.ReadPixels(new Rect(0f, 0f, (float)num, (float)num2), 0, 0); Color32[] pixels = val2.GetPixels32(); for (int i = 0; i < pixels.Length; i++) { pixels[i].r = byte.MaxValue; pixels[i].g = byte.MaxValue; pixels[i].b = byte.MaxValue; } val2.SetPixels32(pixels); ((Texture)val2).filterMode = (FilterMode)1; ((Texture)val2).wrapMode = (TextureWrapMode)1; val2.Apply(false, false); return val2; } catch (Exception) { return null; } finally { RenderTexture.active = active; if ((Object)(object)val != (Object)null) { RenderTexture.ReleaseTemporary(val); } } } private static Rect FitAspect(Rect r, Sprite sp) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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) if ((Object)(object)sp == (Object)null) { return r; } Rect rect = sp.rect; if (((Rect)(ref rect)).width <= 0.5f || ((Rect)(ref rect)).height <= 0.5f || ((Rect)(ref r)).width <= 0f || ((Rect)(ref r)).height <= 0f) { return r; } float num = ((Rect)(ref rect)).width / ((Rect)(ref rect)).height; float num2 = ((Rect)(ref r)).width / ((Rect)(ref r)).height; if (num > num2) { float num3 = ((Rect)(ref r)).width / num; return new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + (((Rect)(ref r)).height - num3) * 0.5f, ((Rect)(ref r)).width, num3); } float num4 = ((Rect)(ref r)).height * num; return new Rect(((Rect)(ref r)).x + (((Rect)(ref r)).width - num4) * 0.5f, ((Rect)(ref r)).y, num4, ((Rect)(ref r)).height); } private static Sprite GetRecipeResultSprite(string recipeID) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 try { RecipeDefinition val = default(RecipeDefinition); if (!RecipeDatabase.TryGetDefinition(recipeID, ref val)) { return null; } if (val == null || val.Result == null) { return null; } string key = val.Result.Key; if (string.IsNullOrEmpty(key)) { return null; } return ((int)val.Result.Type == 1) ? TagParamGetter.GetSprite(key) : ItemParamGetter.GetSprite(key); } catch (Exception) { return null; } } private Sprite GetTagSprite(string tagID) { if (_tagSprites.TryGetValue(tagID, out var value)) { return value; } try { value = TagParamGetter.GetSprite(tagID); } catch (Exception) { value = null; } _tagSprites[tagID] = value; return value; } private Sprite GetSourceSprite(string sourceKey, string tagID) { if (_sourceSprites.TryGetValue(sourceKey, out var value)) { return value; } Sprite val = null; try { val = ItemParamGetter.GetSprite(sourceKey); } catch (Exception) { val = null; } if ((Object)(object)val == (Object)null) { try { val = TagParamGetter.GetSprite(sourceKey); } catch (Exception) { val = null; } } if ((Object)(object)val == (Object)null) { val = GetRecipeResultSprite(sourceKey); } if ((Object)(object)val == (Object)null) { val = GetTagSprite(tagID); } _sourceSprites[sourceKey] = val; return val; } private void HandleIconClick() { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: 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_00d0: 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_0192: Unknown result type (might be due to invalid IL or missing references) if (Time.frameCount - _chartDrawnFrame > 2) { return; } Mouse current = Mouse.current; if (current == null || !current.leftButton.wasPressedThisFrame) { return; } Vector2 val = ((InputControl)(object)((Pointer)current).position).ReadValue(); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor(val.x, (float)Screen.height - val.y); for (int i = 0; i < _chart.ModeRects.Count && i < _chart.ModeIDs.Count; i++) { Rect val3 = _chart.ModeRects[i]; if (((Rect)(ref val3)).Contains(val2)) { _mode = _chart.ModeIDs[i]; return; } } for (int j = 0; j < _chart.ToggleRects.Count && j < _chart.ToggleIDs.Count; j++) { Rect val4 = _chart.ToggleRects[j]; if (((Rect)(ref val4)).Contains(val2)) { if (_chart.ToggleIDs[j] == 1) { _expenseSide = !IsExpenseSide(); InvokeStats("SwitchTab", new object[1] { _expenseSide ? 1 : 0 }); } else { _lastMinute = !UseLastMinute(); InvokeStats("ToggleStatsRange", null); } return; } } for (int k = 0; k < _chart.IconRects.Count && k < _chart.IconTagIDs.Count; k++) { Rect val5 = _chart.IconRects[k]; if (!((Rect)(ref val5)).Contains(val2)) { continue; } if (_mode == 1) { string item = _chart.IconTagIDs[k]; if (!_hiddenTags.Remove(item)) { _hiddenTags.Add(item); } } else { _selectedTag = k; SetStatsSelectedTag(_chart.IconTagIDs[k]); } break; } } private bool UseLastMinute() { if ((Object)(object)_graphFrame != (Object)null) { bool? flag = ReadStatsBool("_isLastMinuteRangeSelected"); if (flag.HasValue) { return flag.Value; } } return _lastMinute; } private bool IsExpenseSide() { if ((Object)(object)_graphFrame != (Object)null) { int? num = ReadStatsInt("_selectedTabIndex"); if (num.HasValue) { return num.Value == 1; } } return _expenseSide; } private bool? ReadStatsBool(string fieldName) { object obj = ReadStatsField(fieldName); if (obj is bool) { return (bool)obj; } return null; } private int? ReadStatsInt(string fieldName) { object obj = ReadStatsField(fieldName); if (obj is int) { return (int)obj; } return null; } private void SetStatsSelectedTag(string tagID) { if (!string.IsNullOrEmpty(tagID)) { InvokeStats("OnBalanceTagSelected", new object[1] { tagID }); } } private void InvokeStats(string methodName, object[] args) { if ((Object)(object)_statsWindow == (Object)null) { return; } try { if (!_statsMethods.TryGetValue(methodName, out var value)) { value = typeof(StatsWindowController).GetMethod(methodName, BindingFlags.Instance | BindingFlags.NonPublic); _statsMethods[methodName] = value; if (value == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("統計窓の " + methodName + " が見つからない(窓の外でだけ切り替わる)")); } } if (value != null) { value.Invoke(_statsWindow, args); } } catch (Exception ex) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("統計窓の " + methodName + " を呼べなかった: " + ex.Message)); } } private object ReadStatsField(string fieldName) { if ((Object)(object)_statsWindow == (Object)null) { return null; } if (!_statsFields.TryGetValue(fieldName, out var value)) { try { value = typeof(StatsWindowController).GetField(fieldName, BindingFlags.Instance | BindingFlags.NonPublic); } catch (Exception) { value = null; } _statsFields[fieldName] = value; if (value == null) { ((BaseUnityPlugin)this).Logger.LogWarning((object)("統計窓の " + fieldName + " を読めなかった")); } } if (value == null) { return null; } try { return value.GetValue(_statsWindow); } catch (Exception) { return null; } } private string StatsSelectedTagID() { if ((Object)(object)_graphFrame == (Object)null) { return null; } return ReadStatsField("_selectedBalanceTagID") as string; } private static string N(long v) { return v.ToString("N0", CultureInfo.InvariantCulture); } private static string F(double v) { return v.ToString("0.##", CultureInfo.InvariantCulture); } private static string F4(float v) { return v.ToString("0.####", CultureInfo.InvariantCulture); } private static string FormatTime(double seconds) { if (seconds < 0.0) { seconds = 0.0; } int num = (int)seconds; int num2 = num / 3600; int num3 = num % 3600 / 60; int num4 = num % 60; if (num2 > 0) { return num2.ToString(CultureInfo.InvariantCulture) + ":" + num3.ToString("00", CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture); } return num3.ToString(CultureInfo.InvariantCulture) + ":" + num4.ToString("00", CultureInfo.InvariantCulture); } }