Decompiled source of LogisticsPlanner v1.0.4001
BepInEx/plugins/LogisticsPlanner/LogisticsPlanner.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text.Json; using BepInEx; using BepInEx.Configuration; using BepInEx.Core.Logging.Interpolation; using BepInEx.Logging; using BepInEx.NET.Common; using Candide; using Candide.CandideUI; using Candide.CandideUI.Components; using Candide.CandideUI.Components.Buttons; using Candide.CandideUI.Containers; using Candide.CandideUI.ImmediateUi; using Candide.CandideUI.Input; using Candide.CandideUI.Logistics; using Candide.CandideUI.UiInput; using Candide.CandideUI.Windows; using Candide.Entities.Controllers.Other; using Candide.GameModels; using Candide.GameModels.Models; using Candide.GameModels.Models.Citizens; using Candide.GameModels.Models.Constructions; using Candide.GameModels.Models.Items; using Candide.GameModels.Models.Jobs; using Candide.GameModels.Services; using Candide.Graphics.Fonts; using Candide.Input.InputProviders.Native; using Candide.Multiplayer.Network; using Candide.Multiplayer.Services; using Candide.Sound; using Candide.Sound.AudioEvent; using Candide.World; using CandideCreator.Shared.Graphics; using CandideCreator.Shared.Helpers; using CandideServer; using CandideServer.Buildings.BuildingControllers; using CandideServer.Data.Citizens; using CandideServer.Entities; using CandideServer.Entities.ControllerSets.AutomaticMill; using CandideServer.Entities.ControllerSets.ManualMill; using CandideServer.EventBus; using CandideServer.Helpers; using CandideServer.MessageModels.Buildings; using CandideServer.MessageModels.InternalResourceStorage; using CandideServer.MessageModels.Inventories; using CandideServer.MessageModels.Jobs; using CandideServer.Models; using CandideServer.Models.Buildings; using CandideServer.Models.Logistics; using CandideServer.Models.Player; using CandideServer.Models.WorkOrders; using CandideServer.Server; using CandideServer.Server.RiptideSteam; using CandideServer.ServerControllers; using CandideServer.ServerManagers; using CandideServer.ServerServices; using CandideServer.SimulationModels; using FontStashSharp; using FontStashSharp.RichText; using HarmonyLib; using LogisticsPlanner.Configuration; using LogisticsPlanner.Features; using LogisticsPlanner.Networking; using LogisticsPlanner.Ui; using Microsoft.Xna.Framework; using Microsoft.Xna.Framework.Graphics; using Microsoft.Xna.Framework.Input; using ModSettingsMenu.Api; using Riptide; using RomesteadLocalizationAPI.Api; using Shared.Data; using Shared.Data.DataModels; using Shared.Entity.Base; using Shared.Inventory.DeltaModels; using Shared.Inventory.Models; using Shared.Models.Buildings; using Shared.Models.Construction; using Shared.Models.Items; using Shared.Models.Player; using Shared.Steam; using Shared.Text; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Logistics Planner")] [assembly: AssemblyDescription("Logistics Planner For Romestead by Ice Box Studio")] [assembly: AssemblyCompany("Ice Box Studio")] [assembly: AssemblyProduct("Logistics Planner")] [assembly: AssemblyCopyright("Copyright (C) 2026 Ice Box Studio All rights reserved.")] [assembly: ComVisible(false)] [assembly: Guid("6f52443b-3b87-402a-9965-44b01b12c078")] [assembly: AssemblyFileVersion("1.0.4.0")] [assembly: TargetFramework(".NETCoreApp,Version=v8.0", FrameworkDisplayName = ".NET 8.0")] [assembly: AssemblyVersion("1.0.4.0")] [module: RefSafetyRules(11)] namespace LogisticsPlanner { internal static class I18n { public static readonly RomesteadLocalizer L = RomesteadLocalization.For("IceBoxStudio.Romestead.LogisticsPlanner"); } [BepInPlugin("IceBoxStudio.Romestead.LogisticsPlanner", "Logistics Planner", "1.0.4")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public sealed class LogisticsPlanner : BasePlugin { private Harmony _harmony; public static LogisticsPlanner Instance { get; private set; } internal static ManualLogSource Logger { get; private set; } public override void Load() { //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Expected O, but got Unknown //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown //IL_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Expected O, but got Unknown //IL_0113: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Expected O, but got Unknown Instance = this; Logger = ((BasePlugin)this).Log; bool flag = default(bool); try { Logger.LogInfo((object)"============================================="); ManualLogSource logger = Logger; BepInExInfoLogInterpolatedStringHandler val = new BepInExInfoLogInterpolatedStringHandler(16, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Logistics Planner"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initializing..."); } logger.LogInfo(val); ManualLogSource logger2 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(10, 2, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("Author: "); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Ice Box Studio"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral("("); ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("https://steamcommunity.com/id/ibox666/"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(")"); } logger2.LogInfo(val); I18n.L.RegisterJson(Path.Combine(Paths.PluginPath, "LogisticsPlanner", "Localization.json")); ConfigManager.Init(((BasePlugin)this).Config); ModSettingsMenuRegistration.Register(((BasePlugin)this).Config); BaseServer.Instance.NetworkEventBusManager.Subscribe(Assembly.GetExecutingAssembly(), (string)null); _harmony = new Harmony("IceBoxStudio.Romestead.LogisticsPlanner"); _harmony.PatchAll(Assembly.GetExecutingAssembly()); ManualLogSource logger3 = Logger; val = new BepInExInfoLogInterpolatedStringHandler(13, 1, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val).AppendFormatted<string>("Logistics Planner"); ((BepInExLogInterpolatedStringHandler)val).AppendLiteral(" initialized."); } logger3.LogInfo(val); Logger.LogInfo((object)"============================================="); } catch (Exception ex) { ManualLogSource logger4 = Logger; BepInExErrorLogInterpolatedStringHandler val2 = new BepInExErrorLogInterpolatedStringHandler(24, 3, ref flag); if (flag) { ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>("Logistics Planner"); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral(" initialization error: "); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.Message); ((BepInExLogInterpolatedStringHandler)val2).AppendLiteral("\n"); ((BepInExLogInterpolatedStringHandler)val2).AppendFormatted<string>(ex.StackTrace); } logger4.LogError(val2); } } } public static class PluginInfo { public const string PLUGIN_GUID = "IceBoxStudio.Romestead.LogisticsPlanner"; public const string PLUGIN_NAME = "Logistics Planner"; public const string PLUGIN_VERSION = "1.0.4"; public const string PLUGIN_AUTHOR = "Ice Box Studio"; public const string PLUGIN_AUTHOR_URL = "https://steamcommunity.com/id/ibox666/"; public const int NEXUS_MODS_ID = 70; public const string THUNDERSTORE_TEAM = "Ice_Box_Studio_Romestead"; public const string THUNDERSTORE_MOD_NAME = "LogisticsPlanner"; public const string UPDATE_MANIFEST_URL = "https://fastly.jsdelivr.net/gh/ibox233/MyMod_Version@main/LogisticsPlanner.json"; } } namespace LogisticsPlanner.Ui { internal sealed class ConnectionItemFilterControl : CandideVerticalStackPanel { private readonly struct ItemChoice { public string Id { get; } public string Name { get; } public string Icon { get; } public ItemChoice(string id, string name, string icon) { Id = id; Name = (string.IsNullOrWhiteSpace(name) ? id : name); Icon = (string.IsNullOrWhiteSpace(icon) ? "sam" : icon); } public bool Matches(string search) { if (!string.IsNullOrWhiteSpace(search) && !Id.Contains(search, StringComparison.OrdinalIgnoreCase)) { return Name.Contains(search, StringComparison.OrdinalIgnoreCase); } return true; } } private const int SelectorMaxResults = 48; private const int WidthValue = 400; private const int SelectorWidth = 500; private const int SelectorScrollHeight = 280; private readonly HashSet<string> _selected = new HashSet<string>(StringComparer.Ordinal); private readonly CandideCheckboxLabel _enabledCheck; private readonly CandideTextLabel _summaryLabel; private readonly CandideHorizontalStackPanel _actionsRow; private readonly List<ItemChoice> _items; private CandideModalWindow _selectorModal; private CandideTextInputBox _selectorSearchField; private CandideTextLabel _selectorSummaryLabel; private CandideVerticalStackPanel _selectorResultsPanel; private string _lastSelectorSearch; public ConnectionItemFilterControl() { //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f4: 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_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Expected O, but got Unknown //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0123: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Expected O, but got Unknown //IL_016e: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_018f: 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_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01b2: Expected O, but got Unknown //IL_01c0: Unknown result type (might be due to invalid IL or missing references) //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01e0: Expected O, but got Unknown //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: 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_0216: Expected O, but got Unknown //IL_022c: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_024b: Unknown result type (might be due to invalid IL or missing references) //IL_0256: Expected O, but got Unknown ((CandideUiElement)this).Width = 400; ((CandideUiElement)this).HorizontalAlignment = (HorizontalAlignment)3; ((CandideGrid)this).DefaultColumnProportion = Proportion.Fill; ((CandideUiElement)this).Margin = new CandideThickness(0, 0, 0, 12); _items = (from item in ItemDataBase.GetAllItems().Where(IsVisibleItem) select new ItemChoice(item.Id, GetItemName(item), item.Icon)).OrderBy<ItemChoice, string>((ItemChoice item) => item.Name, StringComparer.CurrentCultureIgnoreCase).ThenBy<ItemChoice, string>((ItemChoice item) => item.Id, StringComparer.Ordinal).ToList(); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)new CandideHorizontalSeparator { HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 0, 0, 12) }, false); _enabledCheck = new CandideCheckboxLabel((CheckboxType)1, (int?)366, false) { Text = Text("planner.connection_item_filter"), HorizontalAlignment = (HorizontalAlignment)3 }; _enabledCheck.Checkbox.Toggled += delegate { UpdateVisibility(); }; ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_enabledCheck, false); _summaryLabel = new CandideTextLabel { Text = Text("planner.connection_item_filter_all"), Wrap = true, TextStyle = (CandideTextStyle)9, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 7, 0, 0) }; ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_summaryLabel, false); _actionsRow = new CandideHorizontalStackPanel { HorizontalAlignment = (HorizontalAlignment)0, Margin = new CandideThickness(0, 8, 0, 0) }; CandideLabelButton val = new CandideLabelButton(118, (int?)22) { Text = Text("planner.connection_item_filter_select"), OnClickAction = ShowSelectorModal }; ((CandideUiContainerMultipleItems)_actionsRow).AddChild((CandideUiElement)(object)val, false); CandideLabelButton val2 = new CandideLabelButton(118, (int?)22) { Text = Text("planner.connection_item_filter_clear"), Margin = new CandideThickness(6, 0, 0, 0) }; ((CandideButtonBase)val2).OnClickAction = delegate { ClearSelection(); }; ((CandideUiContainerMultipleItems)_actionsRow).AddChild((CandideUiElement)(object)val2, false); ((CandideUiContainerMultipleItems)this).AddChild((CandideUiElement)(object)_actionsRow, false); UpdateVisibility(); } public string[] GetSelectedItemIds() { if (!_enabledCheck.Checkbox.IsToggledOn) { return Array.Empty<string>(); } return _selected.OrderBy<string, string>((string id) => id, StringComparer.Ordinal).ToArray(); } public void SetSelectedItemIds(IEnumerable<string> itemIds) { _selected.Clear(); if (itemIds != null) { foreach (string itemId in itemIds) { if (!string.IsNullOrWhiteSpace(itemId) && HasVisibleItem(itemId.Trim())) { _selected.Add(itemId.Trim()); } } } _enabledCheck.Checkbox.IsToggledOn = _selected.Count > 0; UpdateVisibility(); RefreshSelectorResults(force: true); } public void CloseSelectorModal() { if (_selectorModal != null) { CandideModalWindow selectorModal = _selectorModal; _selectorModal = null; ((CandideWindow)selectorModal).Close(); } } private void UpdateVisibility() { bool isToggledOn = _enabledCheck.Checkbox.IsToggledOn; ((CandideUiElement)_actionsRow).Visible = isToggledOn; UpdateSummary(); } private void ShowSelectorModal() { if (_selectorModal == null && ((CandideUiElement)this).Desktop != null) { _lastSelectorSearch = null; _selectorModal = CandideModalWindow.ShowCustomModal(((CandideUiElement)this).Desktop, true, (Action<CandideModalWindow, CandideVerticalStackPanel>)delegate(CandideModalWindow modal, CandideVerticalStackPanel panel) { //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_001b: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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_004f: 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) //IL_0069: Expected O, but got Unknown //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0080: 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_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b3: Expected O, but got Unknown //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_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Expected O, but got Unknown //IL_0100: 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_0115: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_0134: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Unknown result type (might be due to invalid IL or missing references) //IL_0147: 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_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Unknown result type (might be due to invalid IL or missing references) //IL_015f: Expected O, but got Unknown //IL_0174: 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_018e: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a5: 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) //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_01c2: Expected O, but got Unknown //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f7: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0207: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Expected O, but got Unknown ((CandideUiContainerMultipleItems)panel).AddChild((CandideUiElement)new CandideTextLabel { Text = Text("planner.connection_item_filter_title"), Width = 500, TextAlign = (TextHorizontalAlignment)1, TextStyle = (CandideTextStyle)10, TextColor = new Color(255, 213, 128), Margin = new CandideThickness(0, 0, 0, 8) }, false); _selectorSummaryLabel = new CandideTextLabel { Text = _summaryLabel.Text, Width = 500, Wrap = true, TextStyle = (CandideTextStyle)9, Margin = new CandideThickness(0, 0, 0, 8) }; ((CandideUiContainerMultipleItems)panel).AddChild((CandideUiElement)(object)_selectorSummaryLabel, false); ((CandideUiContainerMultipleItems)panel).AddChild(CreateSelectorSearchRow(), false); _selectorResultsPanel = new CandideVerticalStackPanel { Width = 500 - CandideVerticalScrollViewer.ScrollbarWidth, HorizontalAlignment = (HorizontalAlignment)3, DefaultColumnProportion = Proportion.Fill }; CandideVerticalScrollViewer val = new CandideVerticalScrollViewer { Width = 500, Height = 280, Margin = new CandideThickness(0, 6, 0, 0), Padding = new CandideThickness(0, 0, CandideVerticalScrollViewer.ScrollbarWidth, 0), HorizontalAlignment = (HorizontalAlignment)3, VerticalScrollBackground = new Color(0, 0, 0, 64) }; ((CandideUiContainerSingleItem)val).SetChild((CandideUiElement)(object)_selectorResultsPanel); ((CandideUiContainerMultipleItems)panel).AddChild((CandideUiElement)(object)val, false); ((CandideUiContainerMultipleItems)panel).AddChild((CandideUiElement)new CandideTextLabel { Text = Text("planner.connection_item_filter_hint"), Width = 500, Wrap = true, TextStyle = (CandideTextStyle)9, Margin = new CandideThickness(0, 7, 0, 0) }, false); CandideIconLabelButton val2 = new CandideIconLabelButton("ui:yes", (IconFlag)1, (int?)72) { Text = Text("planner.connection_item_filter_done"), ButtonStyle = (CandideButtonStyle)1, HorizontalAlignment = (HorizontalAlignment)1, Margin = new CandideThickness(0, 10, 0, 0), OnClickAction = ((CandideWindow)modal).Close }; ((CandideUiContainerMultipleItems)panel).AddChild((CandideUiElement)(object)val2, false); RefreshSelectorResults(force: true); }); ((CandideWindow)_selectorModal).Closed += delegate { _selectorModal = null; _selectorSearchField = null; _selectorSummaryLabel = null; _selectorResultsPanel = null; _lastSelectorSearch = null; UpdateSummary(); }; } } private CandideUiElement CreateSelectorSearchRow() { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: 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_0025: 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_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) //IL_0043: 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_0059: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: 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_00dd: Expected O, but got Unknown //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Expected O, but got Unknown CandideGrid val = new CandideGrid { Width = 500, ColumnsProportions = { Proportion.Fill }, ColumnsProportions = { Proportion.Auto }, HorizontalAlignment = (HorizontalAlignment)3 }; _selectorSearchField = new CandideTextInputBox { Background = ColorPaletteHelper.BlackBlue, HorizontalAlignment = (HorizontalAlignment)3, Padding = new CandideThickness(6, 4, 0, 4), GridColumn = 0, SelectAllWhenSelected = true }; _selectorSearchField.TextChanged += delegate { RefreshSelectorResults(); }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)_selectorSearchField, false); CandideIconLabelButton val2 = new CandideIconLabelButton("ui:no", (IconFlag)1, (int?)72) { Text = Text("planner.connection_item_filter_clear"), GridColumn = 1, Margin = new CandideThickness(4, 0, 0, 0) }; ((CandideButtonBase)val2).OnClickAction = delegate { ClearSelection(); RefreshSelectorResults(force: true); }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false); return (CandideUiElement)val; } private void RefreshSelectorResults(bool force = false) { //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown if (_selectorResultsPanel == null) { UpdateSummary(); return; } CandideTextInputBox selectorSearchField = _selectorSearchField; string search = ((selectorSearchField != null) ? selectorSearchField.Text : null) ?? string.Empty; if (!force && string.Equals(search, _lastSelectorSearch, StringComparison.Ordinal)) { UpdateSummary(); return; } _lastSelectorSearch = search; ((CandideGrid)_selectorResultsPanel).ClearChildren(); List<ItemChoice> list = (from item in _items where item.Matches(search) || _selected.Contains(item.Id) orderby _selected.Contains(item.Id) descending select item).ThenBy<ItemChoice, string>((ItemChoice item) => item.Name, StringComparer.CurrentCultureIgnoreCase).ThenBy<ItemChoice, string>((ItemChoice item) => item.Id, StringComparer.Ordinal).Take(48) .ToList(); if (list.Count == 0) { ((CandideUiContainerMultipleItems)_selectorResultsPanel).AddChild((CandideUiElement)new CandideTextLabel { Text = Text("planner.connection_item_filter_no_results"), TextStyle = (CandideTextStyle)9, Wrap = true, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 2, 0, 2) }, false); } else { foreach (ItemChoice item in list) { ((CandideUiContainerMultipleItems)_selectorResultsPanel).AddChild(CreateItemRow(item), false); } } UpdateSummary(); } private CandideUiElement CreateItemRow(ItemChoice item) { //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0029: 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_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_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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_0080: Expected O, but got Unknown //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00ca: 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_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Expected O, but got Unknown //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Expected O, but got Unknown CandideGrid val = new CandideGrid { ColumnsProportions = { Proportion.Auto }, ColumnsProportions = { Proportion.Fill }, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(0, 2, 0, 2) }; CandideCheckbox val2 = new CandideCheckbox((CheckboxType)0) { IsToggledOn = _selected.Contains(item.Id), GridColumn = 0, VerticalAlignment = (VerticalAlignment)1 }; val2.Toggled += delegate(object _, bool enabled) { if (enabled) { _selected.Add(item.Id); } else { _selected.Remove(item.Id); } _enabledCheck.Checkbox.IsToggledOn = _selected.Count > 0; UpdateVisibility(); RefreshSelectorResults(force: true); }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val2, false); CandideIconLabel val3 = new CandideIconLabel((IconFlag)0, false) { Icon = item.Icon, Text = item.Name, GridColumn = 1, HorizontalAlignment = (HorizontalAlignment)3, Margin = new CandideThickness(6, 0, 0, 0) }; ((CandideUiContainerMultipleItems)val).AddChild((CandideUiElement)(object)val3, false); return (CandideUiElement)val; } private void UpdateSummary() { if (!_enabledCheck.Checkbox.IsToggledOn || _selected.Count == 0) { _summaryLabel.Text = Text("planner.connection_item_filter_all"); if (_selectorSummaryLabel != null) { _selectorSummaryLabel.Text = _summaryLabel.Text; } return; } List<string> list = _selected.Select(GetItemDisplayName).OrderBy<string, string>((string name) => name, StringComparer.CurrentCultureIgnoreCase).Take(4) .ToList(); string text = string.Join(", ", list); if (_selected.Count > list.Count) { text = text + ", " + Text("planner.connection_item_filter_more", _selected.Count - list.Count); } _summaryLabel.Text = Text("planner.connection_item_filter_selected", text); if (_selectorSummaryLabel != null) { _selectorSummaryLabel.Text = _summaryLabel.Text; } } private void ClearSelection() { _selected.Clear(); _enabledCheck.Checkbox.IsToggledOn = false; UpdateVisibility(); } private string GetItemDisplayName(string itemId) { foreach (ItemChoice item in _items) { if (string.Equals(item.Id, itemId, StringComparison.Ordinal)) { return item.Name; } } return itemId; } private static string GetItemName(ItemData item) { //IL_001f: 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_000e: Unknown result type (might be due to invalid IL or missing references) if (!item.NameFormatKey.HasValue) { return StringExtensions.GetTranslation(item.Name); } return string.Format(StringExtensions.GetTranslation(item.NameFormatKey.Value), StringExtensions.GetTranslation(item.Name)); } private static bool IsVisibleItem(ItemData item) { if (item == null || string.IsNullOrWhiteSpace(item.Id)) { return false; } string id = item.Id; if (id.StartsWith("tile:", StringComparison.OrdinalIgnoreCase) || id.StartsWith("cheat:", StringComparison.OrdinalIgnoreCase) || id.StartsWith("debug:", StringComparison.OrdinalIgnoreCase) || id.StartsWith("test", StringComparison.OrdinalIgnoreCase) || id.Contains(":test", StringComparison.OrdinalIgnoreCase) || id.Contains("dummy", StringComparison.OrdinalIgnoreCase)) { return false; } return !LooksLikeMissingTranslation(GetItemName(item)); } private static bool LooksLikeMissingTranslation(string text) { if (string.IsNullOrWhiteSpace(text)) { return true; } if (!text.Contains("*item:name", StringComparison.OrdinalIgnoreCase) && !text.Contains("<", StringComparison.Ordinal)) { return text.Contains(">", StringComparison.Ordinal); } return true; } private bool HasVisibleItem(string itemId) { foreach (ItemChoice item in _items) { if (string.Equals(item.Id, itemId, StringComparison.Ordinal)) { return true; } } return false; } private static string Text(string key, params object[] args) { return I18n.L.Text(key, args); } } internal sealed class LogisticsGraphCanvas : CandideUiElement { private sealed class NodeView { public Guid Id { get; } public string Name { get; } public string TownName { get; } public NodeKind Kind { get; } public Rectangle Bounds { get; set; } public Rectangle BoardBounds { get; set; } public Vector2 BoardPosition { get; set; } public bool HasInput { get; } public bool HasOutput { get; } public bool CanPauseProduction { get; } public bool ProductionPaused { get; } public Rectangle PauseButtonBounds { get; set; } public string TitleFitSource { get; set; } public int TitleFitWidth { get; set; } = -1; public float TitleFitZoom { get; set; } public FittedText TitleFit { get; set; } public string TownFitSource { get; set; } public int TownFitWidth { get; set; } = -1; public float TownFitZoom { get; set; } public FittedText TownFit { get; set; } public Vector2 InputPortCenter { get { //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_0010: 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_001f: 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) Rectangle bounds = Bounds; float num = ((Rectangle)(ref bounds)).Left; bounds = Bounds; return new Vector2(num, (float)((Rectangle)(ref bounds)).Top + (float)Bounds.Height * 0.5f); } } public Vector2 OutputPortCenter { get { //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_0010: 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_001f: 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) Rectangle bounds = Bounds; float num = ((Rectangle)(ref bounds)).Right; bounds = Bounds; return new Vector2(num, (float)((Rectangle)(ref bounds)).Top + (float)Bounds.Height * 0.5f); } } public Vector2 InputPortBoardCenter { get { //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_0010: 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_001f: 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) Rectangle boardBounds = BoardBounds; float num = ((Rectangle)(ref boardBounds)).Left; boardBounds = BoardBounds; return new Vector2(num, (float)((Rectangle)(ref boardBounds)).Top + (float)BoardBounds.Height * 0.5f); } } public Vector2 OutputPortBoardCenter { get { //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_0010: 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_001f: 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) Rectangle boardBounds = BoardBounds; float num = ((Rectangle)(ref boardBounds)).Right; boardBounds = BoardBounds; return new Vector2(num, (float)((Rectangle)(ref boardBounds)).Top + (float)BoardBounds.Height * 0.5f); } } public NodeView(Guid id, string name, string townName, NodeKind kind, Rectangle bounds, Rectangle boardBounds, Vector2 boardPosition, bool hasInput, bool hasOutput, bool canPauseProduction, bool productionPaused, Rectangle pauseButtonBounds) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_003a: 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) //IL_006a: Unknown result type (might be due to invalid IL or missing references) Id = id; Name = name; TownName = townName; Kind = kind; Bounds = bounds; BoardBounds = boardBounds; BoardPosition = boardPosition; HasInput = hasInput; HasOutput = hasOutput; CanPauseProduction = canPauseProduction; ProductionPaused = productionPaused; PauseButtonBounds = pauseButtonBounds; } } private enum TownFilterKind { All, Town, Unassigned } private enum NodeKind { Logistics, Storage, Workshop, Production } private enum LayoutActionKind { AutoLayout, UndoLayout } private readonly struct FittedText { public SpriteFontBase Font { get; } public string Text { get; } public FittedText(SpriteFontBase font, string text) { Font = font; Text = text; } } private readonly struct ConnectionVisualStyle { public Color Color { get; } public bool Repeating { get; } public bool Requesting { get; } public ConnectionVisualStyle(Color color, bool repeating, bool requesting) { //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) Color = color; Repeating = repeating; Requesting = requesting; } } private readonly struct LineSegment { public Vector2 Start { get; } public Vector2 End { get; } public LineSegment(Vector2 start, Vector2 end) { //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_0008: 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) Start = start; End = end; } } private sealed class LayoutUndoSnapshot { public Dictionary<Guid, Vector2> NodePositions { get; } public Vector2 ViewOffset { get; } public float Zoom { get; } public LayoutUndoSnapshot(Dictionary<Guid, Vector2> nodePositions, Vector2 viewOffset, float zoom) { //IL_000e: 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) NodePositions = nodePositions; ViewOffset = viewOffset; Zoom = zoom; } } private sealed class ConnectionView { public Guid Id { get; } public Guid SourceId { get; } public Guid DestinationId { get; } public ConnectionVisualStyle Style { get; } public List<Vector2> BoardPath { get; set; } = new List<Vector2>(); public List<Vector2> ScreenPath { get; set; } = new List<Vector2>(); public Rectangle ScreenBounds { get; set; } public ConnectionView(Guid id, Guid sourceId, Guid destinationId, ConnectionVisualStyle style) { Id = id; SourceId = sourceId; DestinationId = destinationId; Style = style; } } private sealed class TownFilterOption { public TownFilterKind Kind { get; } public Guid? TownId { get; } public string Label { get; } public Rectangle Bounds { get; set; } public TownFilterOption(TownFilterKind kind, Guid? townId, string label) { Kind = kind; TownId = townId; Label = label; } } private sealed class LayoutActionButton { public LayoutActionKind Kind { get; } public string Label { get; } public int Width { get; } public Rectangle Bounds { get; set; } public LayoutActionButton(LayoutActionKind kind, string label, int width) { Kind = kind; Label = label; Width = width; } } private const float AutoLayoutLayerGap = 300f; private const float AutoLayoutLaneGap = 170f; private const float AutoLayoutRowGap = 102f; private const float AutoLayoutComponentGap = 160f; private const float AutoLayoutMinNodeX = 170f; private const float AutoLayoutMinNodeY = 102f; private const int NodeWidth = 112; private const int NodeHeight = 48; private const int PortSize = 10; private const int PortHitSize = 16; private const int PauseButtonSize = 13; private const int PauseButtonMargin = 4; private const int CanvasPadding = 18; private const int FilterButtonHeight = 18; private const int FilterBarPadding = 6; private const int FilterButtonGap = 4; private const int FilterButtonAllWidth = 76; private const int FilterButtonTownWidth = 126; private const int FilterButtonUnassignedWidth = 92; private const int LayoutActionButtonWidth = 82; private const int LayoutUndoButtonWidth = 72; private const int TooltipMaxStorageLines = 6; private const int TooltipMaxWorkerLines = 4; private const int TooltipMaxConnectionFilterLines = 8; private const int ConnectionModalBodyWidth = 420; private const int ConnectionModalHeightReserve = 92; private const int ConnectionModalScreenMargin = 8; private const int ConnectionModalMinScrollHeight = 180; private const int ConnectionCurveSegments = 72; private const int ConnectionCornerSegments = 16; private const int ConnectionAvoidPadding = 16; private const int ConnectionRouteMargin = 22; private const int ConnectionBranchSpacing = 8; private const int ConnectionDashLength = 9; private const int ConnectionDashGap = 6; private const float GraphRefreshIntervalSeconds = 0.35f; private const float TooltipJobRefreshSeconds = 1f; private const float TooltipProcessingRefreshSeconds = 1f; private const float MinZoom = 0.3f; private const float MaxZoom = 2.4f; private const float ZoomScrollStep = 120f; private const float MinNodeFontZoom = 0.35f; private const float MaxNodeFontZoom = 1.85f; private static readonly float[] NodeTitleFontScales = new float[7] { 1.1818181f, 1.0909091f, 1f, 0.90909094f, 0.8181818f, 0.72727275f, 0.6363636f }; private static readonly float[] NodeMetaFontScales = new float[4] { 0.90909094f, 0.8181818f, 0.72727275f, 0.6363636f }; private static Texture2D _softLineTexture; private readonly List<NodeView> _nodes = new List<NodeView>(); private readonly Dictionary<Guid, NodeView> _nodeMap = new Dictionary<Guid, NodeView>(); private readonly List<ConnectionView> _visibleConnections = new List<ConnectionView>(); private readonly Dictionary<Guid, ConnectionView> _connectionMap = new Dictionary<Guid, ConnectionView>(); private readonly Dictionary<Guid, List<ConnectionView>> _connectionsByNode = new Dictionary<Guid, List<ConnectionView>>(); private readonly Dictionary<Guid, List<Guid>> _outgoingConnectionIds = new Dictionary<Guid, List<Guid>>(); private readonly Dictionary<Guid, List<Guid>> _incomingConnectionIds = new Dictionary<Guid, List<Guid>>(); private readonly Dictionary<Guid, int> _outgoingConnectionRanks = new Dictionary<Guid, int>(); private readonly Dictionary<Guid, int> _incomingConnectionRanks = new Dictionary<Guid, int>(); private readonly Dictionary<Guid, Vector2> _nodePositions = new Dictionary<Guid, Vector2>(); private readonly Dictionary<string, Vector2> _viewOffsets = new Dictionary<string, Vector2>(); private readonly List<TownFilterOption> _townFilters = new List<TownFilterOption>(); private readonly List<LayoutActionButton> _layoutActionButtons = new List<LayoutActionButton>(); private readonly Dictionary<Guid, SharedInventoryModel> _tooltipInventories = new Dictionary<Guid, SharedInventoryModel>(); private readonly Dictionary<Guid, InternalResourceStorageModel> _tooltipResourceStorages = new Dictionary<Guid, InternalResourceStorageModel>(); private readonly Dictionary<Guid, Job> _tooltipJobs = new Dictionary<Guid, Job>(); private readonly Dictionary<Guid, ProcessingStatusResponse> _tooltipProcessingStatuses = new Dictionary<Guid, ProcessingStatusResponse>(); private readonly Dictionary<Guid, GetResponseHandler> _tooltipInventoryRequests = new Dictionary<Guid, GetResponseHandler>(); private readonly Dictionary<Guid, GetResponseHandler> _tooltipResourceStorageRequests = new Dictionary<Guid, GetResponseHandler>(); private readonly Dictionary<Guid, GetResponseHandler> _tooltipJobRequests = new Dictionary<Guid, GetResponseHandler>(); private readonly Dictionary<Guid, GetResponseHandler> _tooltipProcessingRequests = new Dictionary<Guid, GetResponseHandler>(); private readonly Dictionary<Guid, double> _tooltipJobRefreshTimes = new Dictionary<Guid, double>(); private readonly Dictionary<Guid, double> _tooltipProcessingRefreshTimes = new Dictionary<Guid, double>(); private readonly Dictionary<Guid, string[]> _connectionItemFilterCache = new Dictionary<Guid, string[]>(); private readonly HashSet<Guid> _connectionItemFilterRequests = new HashSet<Guid>(); private string _layoutSaveKey; private Guid? _tooltipBuildingId; private double _tooltipTime; private TownFilterKind _selectedTownFilter; private Guid? _selectedTownId; private Guid? _focusedNodeId; private Guid? _focusedConnectionId; private Guid? _connectionDragSourceId; private Guid? _nodeDragId; private Vector2 _nodeDragStartMouse; private Vector2 _nodeDragStartPosition; private bool _nodeDragDirty; private bool _canvasDragActive; private Vector2 _canvasDragStartMouse; private Vector2 _canvasDragStartOffset; private float _zoom = 1f; private Vector2 _viewOffset = Vector2.Zero; private CandideModalWindow _connectionModal; private CandideModalWindow _editConnectionModal; private CandideModalWindow _renameModal; private double _graphRefreshTime; private int _graphSignature; private bool _graphDirty = true; private bool _screenProjectionDirty = true; private bool _connectionBoardPathsDirty = true; private bool _connectionScreenPathsDirty = true; private LayoutUndoSnapshot _layoutUndoSnapshot; private Rectangle _lastProjectionGraphArea; private Vector2 _lastProjectionViewOffset; private float _lastProjectionZoom; private float _lastProjectionScale; private void ApplyAutoLayout() { //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) if (_nodes.Count <= 1) { return; } SaveLayoutUndoSnapshot(); foreach (KeyValuePair<Guid, Vector2> item in BuildAutoLayoutPositions()) { _nodePositions[item.Key] = item.Value; if (_nodeMap.TryGetValue(item.Key, out var value)) { RefreshNodeGeometry(value, item.Value); } } CenterAutoLayoutView(); MarkConnectionBoardPathsDirty(); MarkScreenProjectionDirty(); SaveLayout(); } private void UndoAutoLayout() { //IL_003e: 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_00b0: Unknown result type (might be due to invalid IL or missing references) if (_layoutUndoSnapshot == null) { return; } _nodePositions.Clear(); foreach (KeyValuePair<Guid, Vector2> nodePosition in _layoutUndoSnapshot.NodePositions) { _nodePositions[nodePosition.Key] = nodePosition.Value; } _viewOffset = _layoutUndoSnapshot.ViewOffset; _zoom = _layoutUndoSnapshot.Zoom; foreach (NodeView node in _nodes) { if (_nodePositions.TryGetValue(node.Id, out var value)) { RefreshNodeGeometry(node, value); } } _layoutUndoSnapshot = null; MarkConnectionBoardPathsDirty(); MarkScreenProjectionDirty(); SaveLayout(); } private void SaveLayoutUndoSnapshot() { //IL_000d: Unknown result type (might be due to invalid IL or missing references) _layoutUndoSnapshot = new LayoutUndoSnapshot(new Dictionary<Guid, Vector2>(_nodePositions), _viewOffset, _zoom); } private Dictionary<Guid, Vector2> BuildAutoLayoutPositions() { //IL_0261: Unknown result type (might be due to invalid IL or missing references) //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Unknown result type (might be due to invalid IL or missing references) List<Guid> list = _nodes.Select((NodeView node) => node.Id).ToList(); Dictionary<Guid, List<Guid>> outgoing = list.ToDictionary((Guid id) => id, (Guid _) => new List<Guid>()); Dictionary<Guid, List<Guid>> incoming = list.ToDictionary((Guid id) => id, (Guid _) => new List<Guid>()); foreach (ConnectionView visibleConnection in _visibleConnections) { if (outgoing.ContainsKey(visibleConnection.SourceId) && incoming.ContainsKey(visibleConnection.DestinationId)) { outgoing[visibleConnection.SourceId].Add(visibleConnection.DestinationId); incoming[visibleConnection.DestinationId].Add(visibleConnection.SourceId); } } List<List<Guid>> source = BuildAutoLayoutComponents(list, outgoing, incoming); List<Guid> list2 = (from component in source where component.Count == 1 && outgoing[component[0]].Count == 0 && incoming[component[0]].Count == 0 select component[0]).ToList(); source = (from component in source where component.Count > 1 || outgoing[component[0]].Count > 0 || incoming[component[0]].Count > 0 orderby component.Count descending, component.Min((Guid id) => GetNodeSortY(id)), component.Min((Guid id) => GetNodeSortX(id)) select component).ToList(); if (list2.Count > 0) { source.Add(list2); } Dictionary<Guid, Vector2> dictionary = new Dictionary<Guid, Vector2>(); float top = 0f; foreach (List<Guid> item in source) { List<List<Guid>> layers = BuildAutoLayoutLayers(item, outgoing, incoming); PlaceAutoLayoutComponent(layers, dictionary, top); SnapAutoLayoutToFreeGrid(item, dictionary); Rectangle autoLayoutBounds = GetAutoLayoutBounds(item, dictionary); top = (float)((Rectangle)(ref autoLayoutBounds)).Bottom + 160f; } SnapAutoLayoutToFreeGrid(dictionary.Keys.ToList(), dictionary); CenterPositions(dictionary); return dictionary; } private static List<List<Guid>> BuildAutoLayoutComponents(List<Guid> nodeIds, Dictionary<Guid, List<Guid>> outgoing, Dictionary<Guid, List<Guid>> incoming) { HashSet<Guid> hashSet = new HashSet<Guid>(); List<List<Guid>> list = new List<List<Guid>>(); foreach (Guid nodeId in nodeIds) { if (!hashSet.Add(nodeId)) { continue; } List<Guid> list2 = new List<Guid>(); Queue<Guid> queue = new Queue<Guid>(); queue.Enqueue(nodeId); while (queue.Count > 0) { Guid guid = queue.Dequeue(); list2.Add(guid); foreach (Guid item in outgoing[guid]) { if (hashSet.Add(item)) { queue.Enqueue(item); } } foreach (Guid item2 in incoming[guid]) { if (hashSet.Add(item2)) { queue.Enqueue(item2); } } } list.Add(list2); } return list; } private List<List<Guid>> BuildAutoLayoutLayers(List<Guid> component, Dictionary<Guid, List<Guid>> outgoing, Dictionary<Guid, List<Guid>> incoming) { HashSet<Guid> componentSet = component.ToHashSet(); Dictionary<Guid, int> indegree = component.ToDictionary((Guid id) => id, (Guid id) => incoming[id].Count((Guid source) => componentSet.Contains(source))); Queue<Guid> queue = new Queue<Guid>(component.Where((Guid id) => indegree[id] == 0).OrderBy(GetNodeSortY).ThenBy(GetNodeSortX)); Dictionary<Guid, int> dictionary = component.ToDictionary((Guid id) => id, (Guid _) => 0); int num = 0; while (queue.Count > 0) { Guid key = queue.Dequeue(); num++; foreach (Guid item in outgoing[key].Where(componentSet.Contains)) { dictionary[item] = Math.Max(dictionary[item], dictionary[key] + 1); indegree[item]--; if (indegree[item] == 0) { queue.Enqueue(item); } } } if (num < component.Count) { foreach (Guid item2 in component) { dictionary[item2] = EstimateCyclicLayer(item2, incoming); } } List<List<Guid>> list = (from item in dictionary group item by item.Value into @group orderby @group.Key select @group.Select((KeyValuePair<Guid, int> item) => item.Key).OrderBy(GetNodeSortY).ThenBy(GetNodeSortX) .ToList()).ToList(); SortAutoLayoutLayers(list, outgoing, incoming); return list; } private void SortAutoLayoutLayers(List<List<Guid>> layers, Dictionary<Guid, List<Guid>> outgoing, Dictionary<Guid, List<Guid>> incoming) { for (int i = 0; i < 4; i++) { Dictionary<Guid, int> order = BuildLayerOrder(layers); for (int j = 1; j < layers.Count; j++) { layers[j] = layers[j].OrderBy((Guid id) => GetLinkedOrder(incoming[id], order)).ThenBy(GetNodeSortY).ThenBy(GetNodeSortX) .ToList(); } order = BuildLayerOrder(layers); for (int num = layers.Count - 2; num >= 0; num--) { layers[num] = layers[num].OrderBy((Guid id) => GetLinkedOrder(outgoing[id], order)).ThenBy(GetNodeSortY).ThenBy(GetNodeSortX) .ToList(); } } } private static Dictionary<Guid, int> BuildLayerOrder(List<List<Guid>> layers) { Dictionary<Guid, int> dictionary = new Dictionary<Guid, int>(); foreach (List<Guid> layer in layers) { for (int i = 0; i < layer.Count; i++) { dictionary[layer[i]] = i; } } return dictionary; } private static float GetLinkedOrder(List<Guid> links, Dictionary<Guid, int> order) { float num = 0f; int num2 = 0; foreach (Guid link in links) { if (order.TryGetValue(link, out var value)) { num += (float)value; num2++; } } if (num2 != 0) { return num / (float)num2; } return float.MaxValue; } private Rectangle PlaceAutoLayoutComponent(List<List<Guid>> layers, Dictionary<Guid, Vector2> result, float top) { //IL_01b2: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Unknown result type (might be due to invalid IL or missing references) List<float> list = layers.Select((List<Guid> layer) => (float)Math.Max(0, GetLayerColumnCount(layer.Count) - 1) * 170f).ToList(); List<int> list2 = layers.Select((List<Guid> layer) => GetLayerRowCount(layer.Count)).ToList(); int num = ((list2.Count == 0) ? 1 : list2.Max()); float num2 = Math.Max(0f, (float)(num - 1) * 102f); float num3 = 0f; float num4 = 0f; float num5 = 0f; Vector2 value = default(Vector2); for (int num6 = 0; num6 < layers.Count; num6++) { List<Guid> list3 = layers[num6]; GetLayerColumnCount(list3.Count); int layerRowCount = GetLayerRowCount(list3.Count); float num7 = list[num6]; float num8 = Math.Max(0f, (float)(layerRowCount - 1) * 102f); float num9 = top + (num2 - num8) * 0.5f; for (int num10 = 0; num10 < list3.Count; num10++) { int num11 = num10 / layerRowCount; int num12 = num10 % layerRowCount; float num13 = num9 + (float)num12 * 102f; if (num11 % 2 == 1) { num13 += 24.48f; } ((Vector2)(ref value))..ctor(num3 + (float)num11 * 170f, num13); result[list3[num10]] = value; } num5 = Math.Max(num5, num3 + num7); num3 += num7 + 300f; } return new Rectangle((int)MathF.Floor(num4), (int)MathF.Floor(top), Math.Max(1, (int)MathF.Ceiling(num5 - num4)), Math.Max(1, (int)MathF.Ceiling(num2))); } private static void SnapAutoLayoutToFreeGrid(List<Guid> ids, Dictionary<Guid, Vector2> positions) { //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_009c: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: 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) if (ids.Count <= 1) { return; } HashSet<Point> hashSet = new HashSet<Point>(); foreach (Guid item in (from id in ids.Where(positions.ContainsKey) orderby positions[id].Y, positions[id].X, id select id).ToList()) { Vector2 val = positions[item]; Point val2 = FindNearestFreeAutoLayoutCell(new Point(RoundAutoLayoutCell(val.X, 170f), RoundAutoLayoutCell(val.Y, 102f)), val, hashSet); hashSet.Add(val2); positions[item] = new Vector2((float)val2.X * 170f, (float)val2.Y * 102f); } } private static int RoundAutoLayoutCell(float value, float cellSize) { return (int)MathF.Round(value / cellSize); } private static Point FindNearestFreeAutoLayoutCell(Point preferred, Vector2 source, HashSet<Point> occupied) { //IL_0001: 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_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_012a: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_005e: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: 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_00cb: Unknown result type (might be due to invalid IL or missing references) if (!occupied.Contains(preferred)) { return preferred; } int num = Math.Max(8, occupied.Count + 4); Point val2 = default(Point); for (int i = 1; i <= num; i++) { Point val = preferred; float num2 = float.MaxValue; bool flag = false; for (int j = preferred.Y - i; j <= preferred.Y + i; j++) { for (int k = preferred.X - i; k <= preferred.X + i; k++) { if (Math.Abs(k - preferred.X) != i && Math.Abs(j - preferred.Y) != i) { continue; } ((Point)(ref val2))..ctor(k, j); if (!occupied.Contains(val2)) { float num3 = (float)k * 170f - source.X; float num4 = (float)j * 102f - source.Y; float num5 = num3 * num3 + num4 * num4; if (!flag || num5 < num2 || (MathF.Abs(num5 - num2) < 0.001f && CompareAutoLayoutCell(val2, val) < 0)) { val = val2; num2 = num5; flag = true; } } } } if (flag) { return val; } } Point val3 = preferred; while (occupied.Contains(val3)) { val3.Y++; } return val3; } private static int CompareAutoLayoutCell(Point left, Point right) { //IL_0007: 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) int num = left.Y.CompareTo(right.Y); if (num == 0) { return left.X.CompareTo(right.X); } return num; } private static int GetLayerColumnCount(int count) { if (count <= 1) { return 1; } return Math.Max(1, (int)MathF.Ceiling(MathF.Sqrt((float)count / 2f))); } private static int GetLayerRowCount(int count) { return Math.Max(1, (int)MathF.Ceiling((float)count / (float)GetLayerColumnCount(count))); } private static Rectangle GetAutoLayoutBounds(List<Guid> component, Dictionary<Guid, Vector2> positions) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) float num = component.Min((Guid id) => positions[id].X); float num2 = component.Min((Guid id) => positions[id].Y); float num3 = component.Max((Guid id) => positions[id].X); float num4 = component.Max((Guid id) => positions[id].Y); return new Rectangle((int)MathF.Floor(num), (int)MathF.Floor(num2), Math.Max(1, (int)MathF.Ceiling(num3 - num)), Math.Max(1, (int)MathF.Ceiling(num4 - num2))); } private void CenterPositions(Dictionary<Guid, Vector2> positions) { //IL_00f6: 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_00fd: Unknown result type (might be due to invalid IL or missing references) if (positions.Count == 0) { return; } float num = positions.Values.Min((Vector2 position) => position.X); float num2 = positions.Values.Min((Vector2 position) => position.Y); float num3 = positions.Values.Max((Vector2 position) => position.X); float num4 = positions.Values.Max((Vector2 position) => position.Y); Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((num + num3) * 0.5f, (num2 + num4) * 0.5f); foreach (Guid item in positions.Keys.ToList()) { positions[item] -= val; } } private void CenterAutoLayoutView() { //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) _viewOffset = Vector2.Zero; } private int EstimateCyclicLayer(Guid nodeId, Dictionary<Guid, List<Guid>> incoming) { if (!incoming.TryGetValue(nodeId, out var value) || value.Count <= 0) { return 0; } return 1; } private float GetNodeSortX(Guid nodeId) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!_nodeMap.TryGetValue(nodeId, out var value)) { return 0f; } return value.BoardPosition.X; } private float GetNodeSortY(Guid nodeId) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) if (!_nodeMap.TryGetValue(nodeId, out var value)) { return 0f; } return value.BoardPosition.Y; } public override void Update(GameTime gameTime) { _tooltipTime += gameTime.ElapsedGameTime.TotalSeconds; _graphRefreshTime += gameTime.ElapsedGameTime.TotalSeconds; EnsureLayoutLoaded(); RefreshGraphIfNeeded(force: false); UpdateNodeDrag(); UpdateCanvasDrag(); UpdateCachedScreenProjectionIfNeeded(); UpdateTooltipData(); if (_connectionDragSourceId.HasValue && NativeInput.Released((MouseButtons)(-1))) { CompletePendingDrag(); } } public void ReleaseTooltipData() { ClearTooltipData(); } public override void OnCursorPrimaryDown() { //IL_0007: 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_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0018: 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_007b: 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_0168: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016e: 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) //IL_017a: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0130: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) ((CandideUiElement)this).OnCursorPrimaryDown(); Vector2 val = MouseLocalPosition(); if (TrySelectTownFilter(val) || TryRunLayoutAction(val)) { return; } NodeView nodeView = FindPauseButtonNode(val); if (nodeView != null) { if (!CanEditBuilding(nodeView.Id)) { ShowCannotEditTown(); return; } _connectionDragSourceId = null; _nodeDragId = null; _canvasDragActive = false; PlannerClient.SendSetProductionPaused(nodeView.Id, !nodeView.ProductionPaused); MarkGraphDirty(); return; } NodeView nodeView2 = FindOutputNode(val); if (nodeView2 != null) { if (!CanEditBuilding(nodeView2.Id)) { ShowCannotEditTown(); return; } _connectionDragSourceId = nodeView2.Id; _nodeDragId = null; _canvasDragActive = false; return; } NodeView nodeView3 = FindNode(val); if (nodeView3 == null) { Guid? guid = FindConnection(val); if (guid.HasValue) { _connectionDragSourceId = null; _nodeDragId = null; _canvasDragActive = false; ShowEditConnectionModal(guid.Value); } else { _connectionDragSourceId = null; _nodeDragId = null; _canvasDragActive = true; _canvasDragStartMouse = val; _canvasDragStartOffset = _viewOffset; } } else { _connectionDragSourceId = null; _nodeDragId = nodeView3.Id; _nodeDragDirty = false; _canvasDragActive = false; _nodeDragStartMouse = ScreenToBoard(val); _nodeDragStartPosition = nodeView3.BoardPosition; } } public override void OnActionSecondaryPressed() { //IL_0008: 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) ((CandideUiElement)this).OnActionSecondaryPressed(); NodeView nodeView = FindNode(MouseLocalPosition()); if (nodeView != null) { if (!CanEditBuilding(nodeView.Id)) { ShowCannotEditTown(); } else { ShowRenameModal(nodeView.Id); } return; } Guid? guid = FindConnection(MouseLocalPosition()); if (guid.HasValue) { ShowEditConnectionModal(guid.Value); } } public override void OnMouseScroll(float delta) { //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_000f: 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_0015: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: 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_006a: 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_0075: Unknown result type (might be due to invalid IL or missing references) ((CandideUiElement)this).OnMouseScroll(delta); Vector2 screenPosition = MouseLocalPosition(); Vector2 val = ScreenToBoard(screenPosition); float num = MathHelper.Clamp(_zoom * MathF.Pow(1.001f, delta * 120f), 0.3f, 2.4f); if (!(MathF.Abs(num - _zoom) < 0.0001f)) { _zoom = num; Vector2 val2 = ScreenToBoard(screenPosition); _viewOffset += val2 - val; SaveLayout(); MarkScreenProjectionDirty(); } } protected override void InternalDraw(UiRenderContext context) { //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_0015: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_009b: 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_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_005c: 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_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) Rectangle actualBounds = ((CandideUiElement)this).ActualBounds; Rectangle graphArea = GetGraphArea(); UpdatePointerFocus(); context.DrawRectangle(actualBounds, new Color(21, 23, 24, 218), 0f); DrawGrid(context, graphArea); if (_nodes.Count == 0) { string text = Text("planner.empty"); Point center = ((Rectangle)(ref graphArea)).Center; DrawCenteredText(context, text, ((Point)(ref center)).ToVector2() - new Vector2(70f, 8f), new Color(218, 211, 196)); DrawTownFilterBar(context, actualBounds); return; } TextureFiltering textureFiltering = context.GetTextureFiltering(); context.SetTextureFiltering((TextureFiltering)1); DrawConnections(context); DrawDragPreview(context); context.SetTextureFiltering(textureFiltering); foreach (NodeView node in _nodes) { DrawNode(context, node); } DrawTownFilterBar(context, actualBounds); DrawLayoutActions(context, actualBounds); DrawNodeTooltip(context); DrawConnectionTooltip(context); } protected override Vector2 InternalMeasure(Vector2 availableSize) { //IL_0028: 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) return new Vector2((float)(((CandideUiElement)this).Width ?? 600), (float)(((CandideUiElement)this).Height ?? 360)) * (float)CandideUiSystem.Scale; } private void DrawConnections(UiRenderContext context) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_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) //IL_00c5: 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_004d: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) Rectangle val = Inflate(GetGraphArea(), 32f * (float)CandideUiSystem.Scale); Rectangle screenBounds; if (!HasPointerFocus()) { foreach (ConnectionView visibleConnection in _visibleConnections) { if (visibleConnection.ScreenPath.Count >= 2) { screenBounds = visibleConnection.ScreenBounds; if (((Rectangle)(ref screenBounds)).Intersects(val)) { DrawConnectionPath(context, visibleConnection.ScreenPath, visibleConnection.Style); DrawArrowHead(context, visibleConnection.ScreenPath, visibleConnection.Style); } } } return; } foreach (ConnectionView visibleConnection2 in _visibleConnections) { if (visibleConnection2.ScreenPath.Count >= 2) { screenBounds = visibleConnection2.ScreenBounds; if (((Rectangle)(ref screenBounds)).Intersects(val) && !IsConnectionFocused(visibleConnection2)) { DrawDimConnectionPath(context, visibleConnection2.ScreenPath, visibleConnection2.Style); } } } foreach (ConnectionView visibleConnection3 in _visibleConnections) { if (visibleConnection3.ScreenPath.Count >= 2) { screenBounds = visibleConnection3.ScreenBounds; if (((Rectangle)(ref screenBounds)).Intersects(val) && IsConnectionFocused(visibleConnection3)) { DrawFocusedConnectionPath(context, visibleConnection3.ScreenPath, visibleConnection3.Style); } } } } private void DrawDragPreview(UiRenderContext context) { //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_002e: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) if (_connectionDragSourceId.HasValue && _nodeMap.TryGetValue(_connectionDragSourceId.Value, out var value)) { Vector2 end = MouseLocalPosition(); Color color = default(Color); ((Color)(ref color))..ctor(255, 220, 120, 210); List<Vector2> path = BuildPreviewPath(value, end); DrawConnectionTrack(context, path, color, dashed: false); DrawArrowHead(context, path, color); } } private void DrawNode(UiRenderContext context, NodeView node) { //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_0013: 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_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0072: 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_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: 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_00db: 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_0198: 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_01bc: 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_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_0202: 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_020a: Unknown result type (might be due to invalid IL or missing references) //IL_0232: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_025c: Unknown result type (might be due to invalid IL or missing references) //IL_0270: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0296: Unknown result type (might be due to invalid IL or missing references) //IL_02a1: Unknown result type (might be due to invalid IL or missing references) //IL_02b6: Unknown result type (might be due to invalid IL or missing references) //IL_02c7: Unknown result type (might be due to invalid IL or missing references) //IL_02d2: Unknown result type (might be due to invalid IL or missing references) bool flag = IsNodeFocused(node); Rectangle bounds = node.Bounds; bool flag2 = ((Rectangle)(ref bounds)).Contains(MouseLocalPosition()); bool flag3 = _nodeDragId == node.Id; Color val = ((flag || flag2 || flag3) ? new Color(64, 70, 73, 240) : new Color(45, 49, 52, 238)); Color nodeBorderColor = GetNodeBorderColor(node.Kind, flag || flag2 || flag3); context.DrawRectangle(node.Bounds, val, 0f); DrawBorder(context, node.Bounds, nodeBorderColor, Math.Max(1f, 2f * _zoom)); float num = Math.Max(4f, 7f * (float)CandideUiSystem.Scale * _zoom); int num2 = node.Bounds.Width - (int)(num * 2f); if (node.HasInput) { num2 -= (int)MathF.Round((float)(10 * CandideUiSystem.Scale) * _zoom * 0.7f); } if (node.HasOutput) { num2 -= (int)MathF.Round((float)(10 * CandideUiSystem.Scale) * _zoom * 0.7f); } if (node.CanPauseProduction) { num2 -= node.PauseButtonBounds.Width + Math.Max(2, (int)MathF.Round(2f * (float)CandideUiSystem.Scale * _zoom)); } FittedText fittedNodeTitle = GetFittedNodeTitle(node, num2); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)node.Bounds.X + num, (float)node.Bounds.Y + num); ImmediateCandideTextLabel.Draw(context, fittedNodeTitle.Font, fittedNodeTitle.Text, val2, Color.White); if (_selectedTownFilter == TownFilterKind.All) { FittedText fittedNodeTown = GetFittedNodeTown(node, node.Bounds.Width - (int)(num * 2f)); Vector2 val3 = ImmediateCandideTextLabel.Measure(fittedNodeTown.Font, fittedNodeTown.Text); bounds = node.Bounds; float num3 = (float)((Rectangle)(ref bounds)).Bottom - Math.Max(2f, 5f * (float)CandideUiSystem.Scale * _zoom) - val3.Y; ImmediateCandideTextLabel.Draw(context, fittedNodeTown.Font, fittedNodeTown.Text, new Vector2((float)node.Bounds.X + num, num3), new Color(188, 178, 148)); } if (node.HasInput) { DrawPort(context, node.InputPortCenter, new Color(89, 190, 130), new Color(34, 71, 51)); } if (node.HasOutput) { DrawPort(context, node.OutputPortCenter, new Color(91, 155, 229), new Color(38, 61, 92)); } if (node.CanPauseProduction) { DrawPauseButton(context, node); } } private FittedText GetFittedNodeTitle(NodeView node, int maxWidth) { if (node.TitleFitWidth == maxWidth && MathF.Abs(node.TitleFitZoom - _zoom) < 0.0001f && string.Equals(node.TitleFitSource, node.Name, StringComparison.Ordinal)) { return node.TitleFit; } node.TitleFit = FitTextToWidth(node.Name, maxWidth, NodeTitleFontScales, _zoom); node.TitleFitWidth = maxWidth; node.TitleFitZoom = _zoom; node.TitleFitSource = node.Name; return node.TitleFit; } private FittedText GetFittedNodeTown(NodeView node, int maxWidth) { if (node.TownFitWidth == maxWidth && MathF.Abs(node.TownFitZoom - _zoom) < 0.0001f && string.Equals(node.TownFitSource, node.TownName, StringComparison.Ordinal)) { return node.TownFit; } node.TownFit = FitTextToWidth(node.TownName, maxWidth, NodeMetaFontScales, _zoom); node.TownFitWidth = maxWidth; node.TownFitZoom = _zoom; node.TownFitSource = node.TownName; return node.TownFit; } private void DrawPauseButton(UiRenderContext context, NodeView node) { //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_000b: 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_0053: 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_002c: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: 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_00de: 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_00f9: 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_0110: 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_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013f: 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_015e: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) Rectangle pauseButtonBounds = node.PauseButtonBounds; bool flag = ((Rectangle)(ref pauseButtonBounds)).Contains(MouseLocalPosition()); Color val = ((!node.ProductionPaused) ? (flag ? new Color(72, 79, 79, 245) : new Color(47, 52, 52, 235)) : (flag ? new Color(143, 82, 62, 245) : new Color(103, 68, 59, 235))); Color color = (node.ProductionPaused ? new Color(255, 176, 104) : new Color(177, 188, 174)); string text = (node.ProductionPaused ? ">" : "II"); SpriteFontBase nodeFont = GetNodeFont(0.72727275f, _zoom); Vector2 val2 = ImmediateCandideTextLabel.Measure(nodeFont, text); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((float)node.PauseButtonBounds.X + ((float)node.PauseButtonBounds.Width - val2.X) * 0.5f, (float)node.PauseButtonBounds.Y + ((float)node.PauseButtonBounds.Height - val2.Y) * 0.5f - (float)CandideUiSystem.Scale); context.DrawRectangle(node.PauseButtonBounds, val, 0f); DrawBorder(context, node.PauseButtonBounds, color, Math.Max(1f, CandideUiSystem.Scale)); ImmediateCandideTextLabel.Draw(context, nodeFont, text, val3, Color.White); } private void DrawPort(UiRenderContext context, Vector2 center, Color color, Color inner) { //IL_001f: 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_005e: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a2: Unknown result type (might be due to invalid IL or missing references) int num = Math.Max(5, (int)MathF.Round((float)(10 * CandideUiSystem.Scale) * _zoom)); Rectangle val = default(Rectangle); ((Rectangle)(ref val))..ctor((int)center.X - num / 2, (int)center.Y - num / 2, num, num); int num2 = Math.Max(2, (int)MathF.Round(2f * (float)CandideUiSystem.Scale * _zoom)); Rectangle val2 = default(Rectangle); ((Rectangle)(ref val2))..ctor(val.X + num2, val.Y + num2, Math.Max(1, val.Width - num2 * 2), Math.Max(1, val.Height - num2 * 2)); context.DrawRectangle(val, color, 0f); context.DrawRectangle(val2, inner, 0f); } private void DrawTownFilterBar(UiRenderContext context, Rectangle bounds) { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_00db: 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_00c9: 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_00fd: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0146: Unknown result type (might be due to invalid IL or missing references) //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_018b: 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) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) if (_townFilters.Count <= 1) { return; } LayoutTownFilterButtons(bounds); int filterBarPixelHeight = GetFilterBarPixelHeight(bounds); context.DrawRectangle(new Rectangle(bounds.X, bounds.Y, bounds.Width, filterBarPixelHeight), new Color(18, 20, 21, 190), 0f); SpriteFontBase renderFont = FontManager.OculiSmall.RenderFont; if (_townFilters.Count <= 1) { return; } foreach (TownFilterOption townFilter in _townFilters) { bool num = IsSelectedTownFilter(townFilter); Rectangle bounds2 = townFilter.Bounds; bool flag = ((Rectangle)(ref bounds2)).Contains(MouseLocalPosition()); Color val = (num ? new Color(92, 79, 48, 240) : (flag ? new Color(56, 61, 63, 235) : new Color(38, 42, 44, 225))); Color color = (num ? new Color(247, 207, 118) : new Color(121, 111, 83)); context.DrawRectangle(townFilter.Bounds, val, 0f); DrawBorder(context, townFilter.Bounds, color, Math.Max(1f, CandideUiSystem.Scale)); int num2 = 5 * CandideUiSystem.Scale; string text = TrimToWidth(renderFont, townFilter.Label, townFilter.Bounds.Width - num2 * 2); int num3 = townFilter.Bounds.Y + Math.Max(1, (townFilter.Bounds.Height - 12 * CandideUiSystem.Scale) / 2); ImmediateCandideTextLabel.Draw(context, renderFont, text, new Vector2((float)(townFilter.Bounds.X + num2), (float)num3), new Color(232, 224, 205)); } } private void DrawLayoutActions(UiRenderContext context, Rectangle bounds) { //IL_000a: 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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_009f: 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_00b6: 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_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00ea: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0168: Unknown result type (might be due to invalid IL or missing references) //IL_017c: Unknown result type (might be due to invalid IL or missing references) if (!ShouldShowLayoutActions()) { return; } LayoutActionButtons(bounds); SpriteFontBase renderFont = FontManager.OculiSmall.RenderFont; foreach (LayoutActionButton layoutActionButton in _layoutActionButtons) { Rectangle bounds2 = layoutActionButton.Bounds; bool flag = ((Rectangle)(ref bounds2)).Contains(MouseLocalPosition()); Color val = ((layoutActionButton.Kind == LayoutActionKind.UndoLayout) ? (flag ? new Color(78, 68, 54, 240) : new Color(54, 48, 42, 230)) : (flag ? new Color(59, 72, 75, 240) : new Color(42, 53, 56, 230))); Color color = ((layoutActionButton.Kind == LayoutActionKind.UndoLayout) ? new Color(180, 150, 103) : new Color(118, 185, 193)); context.DrawRectangle(layoutActionButton.Bounds, val, 0f); DrawBorder(context, layoutActionButton.Bounds, color, Math.Max(1f, CandideUiSystem.Scale)); int num = 5 * CandideUiSystem.Scale; string text = TrimToWidth(renderFont, layoutActionButton.Label, layoutActionButton.Bounds.Width - num * 2); int num2 = layoutActionButton.Bounds.Y + Math.Max(1, (layoutActionButton.Bounds.Height - 12 * CandideUiSystem.Scale) / 2); ImmediateCandideTextLabel.Draw(context, renderFont, text, new Vector2((float)(layoutActionButton.Bounds.X + num), (float)num2), new Color(232, 224, 205)); } } private void DrawGrid(UiRenderContext context, Rectangle bounds) { //IL_0038: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: 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_00de: 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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0125: 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 = Math.Max(8f, 24f * (float)CandideUiSystem.Scale * _zoom); Color val = default(Color); ((Color)(ref val))..ctor(255, 255, 255, 20); Point center = ((Rectangle)(ref bounds)).Center; Vector2 val2 = ((Point)(ref center)).ToVector2(); Vector2 val3 = _viewOffset * (float)CandideUiSystem.Scale * _zoom; float num2; for (num2 = val2.X + val3.X % num; num2 > (float)bounds.X; num2 -= num) { } for (float num3 = num2; num3 < (float)((Rectangle)(ref bounds)).Right; num3 += num) { context.DrawLine(new Vector2(num3, (float)bounds.Y), new Vector2(num3, (float)((Rectangle)(ref bounds)).Bottom), 1f, val, Vector2.One, 0f, 0f); } float num4; for (num4 = val2.Y + val3.Y % num; num4 > (float)bounds.Y; num4 -= num) { } for (float num5 = num4; num5 < (float)((Rectangle)(ref bounds)).Bottom; num5 += num) { context.DrawLine(new Vector2((float)bounds.X, num5), new Vector2((float)((Rectangle)(ref bounds)).Right, num5), 1f, val, Vector2.One, 0f, 0f); } } private static void DrawBorder(UiRenderContext context, Rectangle rect, Color color, float thickness) { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007a: 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_0090: 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) //IL_0093: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: 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_00ac: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); ((Vector2)(ref val))..ctor((float)((Rectangle)(ref rect)).Left, (float)((Rectangle)(ref rect)).Top); Vector2 val2 = default(Vector2); ((Vector2)(ref val2))..ctor((float)((Rectangle)(ref rect)).Right, (float)((Rectangle)(ref rect)).Top); Vector2 val3 = default(Vector2); ((Vector2)(ref val3))..ctor((float)((Rectangle)(ref rect)).Right, (float)((Rectangle)(ref rect)).Bottom); Vector2 val4 = default(Vector2); ((Vector2)(ref val4))..ctor((float)((Rectangle)(ref rect)).Left, (float)((Rectangle)(ref rect)).Bottom); context.DrawLine(val, val2, thickness, color, Vector2.One, 0f, 0f); context.DrawLine(val2, val3, thickness, color, Vector2.One, 0f, 0f); context.DrawLine(val3, val4, thickness, color, Vector2.One, 0f, 0f); context.DrawLine(val4, val, thickness, color, Vector2.One, 0f, 0f); } pri