Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Tractor v1.0.0
Tractor.dll
Decompiled 3 days ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Text; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComfyLib; using HarmonyLib; using Microsoft.CodeAnalysis; using TMPro; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("Tractor")] [assembly: AssemblyProduct("Tractor")] [assembly: AssemblyFileVersion("1.8.4")] [assembly: ComVisible(false)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyVersion("1.8.4.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ComfyLib { public static class ConfigFileExtensions { internal sealed class ConfigurationManagerAttributes { public Action<ConfigEntryBase> CustomDrawer; public bool? Browsable; public bool? HideDefaultButton; public bool? HideSettingName; public bool? IsAdvanced; public int? Order; public bool? ReadOnly; } private static readonly Dictionary<string, int> _sectionToSettingOrder = new Dictionary<string, int>(); private static int GetSettingOrder(string section) { if (!_sectionToSettingOrder.TryGetValue(section, out var value)) { value = 0; } _sectionToSettingOrder[section] = value - 1; return value; } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, AcceptableValueBase acceptableValues) { //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0031: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Order = GetSettingOrder(section) } })); } public static ConfigEntry<T> BindInOrder<T>(this ConfigFile config, string section, string key, T defaultValue, string description, Action<ConfigEntryBase> customDrawer = null, bool browsable = true, bool hideDefaultButton = false, bool hideSettingName = false, bool isAdvanced = false, bool readOnly = false) { //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return config.Bind<T>(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = customDrawer, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action settingChangedHandler) { configEntry.SettingChanged += delegate { settingChangedHandler(); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<T> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((T)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } public static void OnSettingChanged<T>(this ConfigEntry<T> configEntry, Action<ConfigEntry<T>> settingChangedHandler) { configEntry.SettingChanged += delegate(object _, EventArgs eventArgs) { //IL_0007: Unknown result type (might be due to invalid IL or missing references) settingChangedHandler((ConfigEntry<T>)(object)((SettingChangedEventArgs)eventArgs).ChangedSetting); }; } } } namespace Tractor { public static class Access { private static readonly FieldRef<ZDOMan, Dictionary<ZDOID, ZDO>> _zdosById = AccessTools.FieldRefAccess<ZDOMan, Dictionary<ZDOID, ZDO>>("m_objectsByID"); public static Dictionary<ZDOID, ZDO> ZdosById(ZDOMan zdoMan) { return _zdosById.Invoke(zdoMan); } } [HarmonyPatch(typeof(Chat))] internal static class ChatPatch { [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } [HarmonyPatch(typeof(Console))] internal static class ConsolePatch { [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } public static class TractorInputController { private static int _shortcutFrame = -1; public static bool TakeInput() { if (_shortcutFrame == Time.frameCount) { return false; } if (IsShortcutPressed()) { _shortcutFrame = Time.frameCount; TractorPanel.ToggleHovered(); return false; } return !TractorPanel.IsOpen; } private static bool IsShortcutPressed() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) if (!ZInput.GetKeyDown(PluginConfig.OpenKey.Value, true)) { if (IsShiftHeld()) { return ZInput.GetMouseButtonDown(1); } return false; } return true; } private static bool IsShiftHeld() { if (!ZInput.GetKey((KeyCode)304, true)) { return ZInput.GetKey((KeyCode)303, true); } return true; } } public static class Favorites { private const string FileName = "miker.valheim.tractor.favorites.txt"; private static readonly HashSet<string> _keys = new HashSet<string>(StringComparer.Ordinal); private static readonly HashSet<string> _fields = new HashSet<string>(StringComparer.Ordinal); public static void Load() { _keys.Clear(); _fields.Clear(); string filePath = GetFilePath(); if (!File.Exists(filePath)) { return; } try { string[] array = File.ReadAllLines(filePath); for (int i = 0; i < array.Length; i++) { string text = array[i].Trim(); if (text.Length == 0 || text[0] == '#') { continue; } int num = text.IndexOf('\t'); if (num < 0) { continue; } string text2 = text.Substring(0, num).Trim(); string text3 = text.Substring(num + 1).Trim(); if (text3.Length != 0) { if (text2 == "key") { _keys.Add(text3); } else if (text2 == "field") { _fields.Add(text3); } } } } catch (Exception ex) { Tractor.LogWarning("Could not read favorites: " + ex.Message); } } public static bool IsKey(string name) { return _keys.Contains(name); } public static bool IsField(string name) { return _fields.Contains(name); } public static bool ToggleKey(string name) { return Toggle(_keys, name); } public static bool ToggleField(string name) { return Toggle(_fields, name); } private static bool Toggle(HashSet<string> names, string name) { bool num = names.Add(name); if (!num) { names.Remove(name); } Save(); return num; } private static void Save() { List<string> list = new List<string>(_keys.Count + _fields.Count); foreach (string key in _keys) { list.Add("key\t" + key); } foreach (string field in _fields) { list.Add("field\t" + field); } list.Sort(StringComparer.OrdinalIgnoreCase); try { File.WriteAllLines(GetFilePath(), list); } catch (Exception ex) { Tractor.LogWarning("Could not write favorites: " + ex.Message); } } private static string GetFilePath() { return Path.Combine(Paths.ConfigPath, "miker.valheim.tractor.favorites.txt"); } } [HarmonyPatch(typeof(GameCamera))] internal static class GameCameraPatch { [HarmonyPrefix] [HarmonyPatch("UpdateMouseCapture")] private static bool UpdateMouseCapturePrefix() { if (!PluginConfig.IsModEnabled.Value || !TractorPanel.IsOpen) { return true; } TractorPanel.KeepCursorVisible(); return false; } [HarmonyPrefix] [HarmonyPatch("UpdateFreeFly")] private static bool UpdateFreeFlyPrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } [HarmonyPatch(typeof(InventoryGui))] internal static class InventoryGuiPatch { [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } public static class LookTarget { private const int MaxStages = 3; private static readonly FieldInfo InstancesField = AccessTools.Field(typeof(ZNetScene), "m_instances"); private static bool _reportedMissingField; private static Dictionary<ZDO, ZNetView> GetInstances(ZNetScene scene) { if (InstancesField == null) { if (!_reportedMissingField) { _reportedMissingField = true; Tractor.LogError("Look target disabled, cannot find ZNetScene.m_instances."); } return null; } return InstancesField.GetValue(scene) as Dictionary<ZDO, ZNetView>; } public static ZNetView FindInFront(Player player, float baseRadius) { //IL_004a: 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_002e: Unknown result type (might be due to invalid IL or missing references) //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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)player) || !Object.op_Implicit((Object)(object)ZNetScene.instance)) { return null; } Vector3 val = (Object.op_Implicit((Object)(object)((Character)player).m_eye) ? ((Character)player).m_eye.position : (((Component)player).transform.position + Vector3.up * 1.5f)); Vector3 lookDir = ((Character)player).GetLookDir(); if (((Vector3)(ref lookDir)).sqrMagnitude < 0.001f) { return null; } ((Vector3)(ref lookDir)).Normalize(); Dictionary<ZDO, ZNetView> instances = GetInstances(ZNetScene.instance); if (instances == null) { return null; } for (int i = 0; i < 3; i++) { float num = baseRadius * (float)(1 << i); ZNetView val2 = FindInSphere(instances, val + lookDir * num, num, player); if (Object.op_Implicit((Object)(object)val2)) { return val2; } } return null; } private static ZNetView FindInSphere(Dictionary<ZDO, ZNetView> instances, Vector3 center, float radius, Player player) { //IL_0079: 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_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0084: Unknown result type (might be due to invalid IL or missing references) float num = radius * radius; Transform transform = ((Component)player).transform; ZNetView val = null; float num2 = float.MaxValue; ZNetView val2 = null; float num3 = float.MaxValue; ZNetView val3 = null; float num4 = float.MaxValue; foreach (ZNetView value in instances.Values) { if (!Object.op_Implicit((Object)(object)value) || !value.IsValid()) { continue; } Transform transform2 = ((Component)value).transform; if ((Object)(object)transform2 == (Object)(object)transform || transform2.IsChildOf(transform)) { continue; } Vector3 val4 = transform2.position - center; float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude; if (sqrMagnitude > num) { continue; } if (Object.op_Implicit((Object)(object)((Component)value).GetComponentInChildren<Collider>(true))) { if (sqrMagnitude < num4) { val3 = value; num4 = sqrMagnitude; } } else if (Object.op_Implicit((Object)(object)((Component)value).GetComponentInChildren<Renderer>(true))) { if (sqrMagnitude < num2) { val = value; num2 = sqrMagnitude; } } else if (sqrMagnitude < num3) { val2 = value; num3 = sqrMagnitude; } } return val ?? val2 ?? val3; } } [HarmonyPatch(typeof(Menu))] internal static class MenuPatch { [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } if (!TractorPanel.IsOpen) { return !TractorPanel.WasClosedThisFrame; } return false; } } [HarmonyPatch(typeof(Minimap))] internal static class MinimapPatch { [HarmonyPrefix] [HarmonyPatch("Update")] private static bool UpdatePrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private Canvas _canvas; public RectTransform TargetRectTransform { get; set; } private void Awake() { _canvas = ((Component)this).GetComponentInParent<Canvas>(); } public void OnBeginDrag(PointerEventData eventData) { } public void OnDrag(PointerEventData eventData) { //IL_0043: 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_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) if (Object.op_Implicit((Object)(object)TargetRectTransform)) { float num = (Object.op_Implicit((Object)(object)_canvas) ? _canvas.scaleFactor : 1f); if (num <= 0f) { num = 1f; } RectTransform targetRectTransform = TargetRectTransform; targetRectTransform.anchoredPosition += eventData.delta / num; } } public void OnEndDrag(PointerEventData eventData) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)TargetRectTransform)) { PluginConfig.PanelPosition.Value = TargetRectTransform.anchoredPosition; } } } public sealed class PanelRowPointer : MonoBehaviour, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler { public TractorPanelRow Row { get; set; } public void OnPointerEnter(PointerEventData eventData) { if (Row != null) { Row.SetHovered(isHovered: true); } } public void OnPointerExit(PointerEventData eventData) { if (Row != null) { Row.SetHovered(isHovered: false); } } } public sealed class PanelScroll : MonoBehaviour, IScrollHandler, IEventSystemHandler { public ScrollRect ScrollRect { get; set; } public float RowsPerNotch { get; set; } = 3f; public void OnScroll(PointerEventData eventData) { //IL_0033: 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_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0074: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)ScrollRect) || !Object.op_Implicit((Object)(object)ScrollRect.content) || !Object.op_Implicit((Object)(object)ScrollRect.viewport)) { return; } float num = Mathf.Sign(eventData.scrollDelta.y); if (num != 0f) { Rect rect = ScrollRect.content.rect; float height = ((Rect)(ref rect)).height; rect = ScrollRect.viewport.rect; float num2 = height - ((Rect)(ref rect)).height; if (!(num2 <= 0f)) { float num3 = RowsPerNotch * (TractorPanel.RowHeight + 2f) / num2; ScrollRect.verticalNormalizedPosition = Mathf.Clamp01(ScrollRect.verticalNormalizedPosition + num * num3); } } } } [HarmonyPatch(typeof(PlayerController))] internal static class PlayerControllerPatch { [HarmonyPrefix] [HarmonyPatch("TakeInput")] private static bool TakeInputPrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return !TractorPanel.IsOpen; } } [HarmonyPatch(typeof(Player))] internal static class PlayerPatch { [HarmonyPrefix] [HarmonyPatch("TakeInput")] private static bool TakeInputPrefix() { if (!PluginConfig.IsModEnabled.Value) { return true; } return TractorInputController.TakeInput(); } [HarmonyTranspiler] [HarmonyPatch("Update")] private static IEnumerable<CodeInstruction> UpdateTranspiler(IEnumerable<CodeInstruction> instructions) { //IL_0002: 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_003b: Expected O, but got Unknown //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown return new CodeMatcher(instructions, (ILGenerator)null).Start().MatchStartForward((CodeMatch[])(object)new CodeMatch[1] { new CodeMatch((OpCode?)OpCodes.Call, (object)AccessTools.Method(typeof(Player), "UpdateHover", (Type[])null, (Type[])null), (string)null) }).ThrowIfInvalid("Could not patch Player.Update()! (update-hover)") .Advance(1) .InsertAndAdvance((CodeInstruction[])(object)new CodeInstruction[1] { new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(PlayerPatch), "UpdateHoverPostDelegate", (Type[])null, (Type[])null)) }) .InstructionEnumeration(); } private static void UpdateHoverPostDelegate() { if (PluginConfig.IsModEnabled.Value) { TractorPanel.Update(); } } } public static class PluginConfig { public static readonly Vector2 DefaultPanelPosition = new Vector2(-620f, 0f); public static ConfigEntry<bool> IsModEnabled { get; private set; } public static ConfigEntry<KeyCode> OpenKey { get; private set; } public static ConfigEntry<Vector2> PanelPosition { get; private set; } public static ConfigEntry<float> BulkRadius { get; private set; } public static ConfigEntry<float> LookRadius { get; private set; } public static ConfigEntry<bool> AutoApply { get; private set; } public static ConfigEntry<UiTheme> Theme { get; private set; } public static ConfigEntry<UiFont> FontChoice { get; private set; } public static void BindConfig(ConfigFile config) { //IL_0076: Unknown result type (might be due to invalid IL or missing references) IsModEnabled = config.BindInOrder("_Global", "isModEnabled", defaultValue: true, "Globally enable or disable this mod."); IsModEnabled.OnSettingChanged<bool>(TractorPanel.HandleModEnabledChanged); OpenKey = config.BindInOrder<KeyCode>("Panel", "openKey", (KeyCode)289, "Open the ZDO editor on the hovered object. Shift+RightClick also opens and closes it."); PanelPosition = config.BindInOrder<Vector2>("Panel", "position", DefaultPanelPosition, "Panel position relative to the center of the screen."); PanelPosition.OnSettingChanged((Action<Vector2>)TractorPanel.ApplyPanelPosition); BulkRadius = config.BindInOrder("Panel", "bulkRadius", 32f, "Radius in meters for the radius bulk action.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 256f)); BulkRadius.OnSettingChanged<float>(TractorPanel.HandleBulkRadiusChanged); LookRadius = config.BindInOrder("Selection", "lookRadius", 0f, "Radius in meters of the sphere used when Shift+RightClick has no hover target. The sphere touches the player and reaches along the look direction; the search grows to twice and four times this radius before giving up. The default of 0 disables the search.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f)); AutoApply = config.BindInOrder("Panel", "autoApply", defaultValue: true, "Apply the selected value when the editor loses focus."); Theme = config.BindInOrder("Panel", "uiTheme", UiTheme.Vanilla, "Panel skin. Vanilla uses the game's wood, button, and text-field sprites. Takes effect the next time the panel opens."); Theme.OnSettingChanged<UiTheme>(TractorPanel.HandleThemeChanged); FontChoice = config.BindInOrder("Panel", "uiFont", UiFont.AveriaSans, "Panel font. AveriaSans uses the game's sans face, the one ComfySpawner builds its panels from; Game uses the HUD hover-name face. Takes effect the next time the panel opens."); FontChoice.OnSettingChanged<UiFont>(TractorPanel.HandleFontChanged); } } public enum UiTheme { Vanilla, Dark } public enum UiFont { Game, AveriaSans } public static class Style { private static readonly string[] SpriteNames = new string[9] { "woodpanel_trophys", "item_background", "text_field", "button", "button_highlight", "button_pressed", "button_disabled", "Background", "UISprite" }; private static readonly string[] MaterialNames = new string[1] { "litpanel" }; private static readonly Color DarkPanelColor = new Color(0.05f, 0.05f, 0.05f, 0.94f); private static readonly Color DarkListColor = new Color(0f, 0f, 0f, 0.35f); private static readonly Color DarkInputColor = new Color(0f, 0f, 0f, 0.55f); private static readonly Color FavoriteOnColor = new Color(1f, 0.78f, 0.16f, 1f); private static readonly Color FavoriteOffColor = new Color(0.6f, 0.6f, 0.6f, 1f); private static Dictionary<string, Sprite> _sprites; private static Dictionary<string, Material> _materials; private static bool? _hasStarGlyph; private static TMP_FontAsset _uiFontAsset; private static readonly string[] KeyGlyphCandidates = new string[4] { "\ud83d\udddd", "\ud83d\udd11", "⚿", "•" }; private static string _keyGlyph; public static bool IsVanilla { get { if (PluginConfig.Theme != null) { return PluginConfig.Theme.Value == UiTheme.Vanilla; } return false; } } public static TMP_FontAsset UiFontAsset { get { if (!Object.op_Implicit((Object)(object)_uiFontAsset)) { _uiFontAsset = ResolveUiFont(); } return _uiFontAsset; } } public static float FontScale { get { if (PluginConfig.FontChoice == null || PluginConfig.FontChoice.Value != UiFont.AveriaSans) { return 1f; } return 1.1f; } } public static ColorBlock ButtonColors { get { //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_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: 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_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0142: 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_0032: 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_005e: 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_0094: Unknown result type (might be due to invalid IL or missing references) ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock; if (IsVanilla) { ((ColorBlock)(ref defaultColorBlock)).normalColor = new Color(0.9f, 0.9f, 0.9f, 1f); ((ColorBlock)(ref defaultColorBlock)).highlightedColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.8f, 0.8f, 0.8f, 1f); ((ColorBlock)(ref defaultColorBlock)).selectedColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).disabledColor = new Color(1f, 1f, 1f, 0.4f); ((ColorBlock)(ref defaultColorBlock)).fadeDuration = 0.08f; return defaultColorBlock; } ((ColorBlock)(ref defaultColorBlock)).normalColor = new Color(1f, 1f, 1f, 0.12f); ((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(0.4f, 0.7f, 1f, 0.4f); ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(0.3f, 0.55f, 0.9f, 0.6f); ((ColorBlock)(ref defaultColorBlock)).selectedColor = new Color(0.4f, 0.7f, 1f, 0.5f); ((ColorBlock)(ref defaultColorBlock)).disabledColor = new Color(1f, 1f, 1f, 0.05f); ((ColorBlock)(ref defaultColorBlock)).fadeDuration = 0.1f; return defaultColorBlock; } } public static ColorBlock ScrollbarColors { get { //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_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_003e: 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_0065: 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) ColorBlock defaultColorBlock = ColorBlock.defaultColorBlock; ((ColorBlock)(ref defaultColorBlock)).normalColor = Color.white; ((ColorBlock)(ref defaultColorBlock)).highlightedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref defaultColorBlock)).selectedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref defaultColorBlock)).pressedColor = new Color(1f, 0.67f, 0.11f); ((ColorBlock)(ref defaultColorBlock)).disabledColor = Color.gray; ((ColorBlock)(ref defaultColorBlock)).fadeDuration = 0.15f; return defaultColorBlock; } } public static void ResetUiFont() { _uiFontAsset = null; _hasStarGlyph = null; _keyGlyph = null; } public static float FontSize(float size) { return size * FontScale; } private static TMP_FontAsset ResolveUiFont() { TMP_FontAsset result = ((Object.op_Implicit((Object)(object)Hud.instance) && Object.op_Implicit((Object)(object)Hud.instance.m_hoverName)) ? ((TMP_Text)Hud.instance.m_hoverName).font : null); if (PluginConfig.FontChoice == null || PluginConfig.FontChoice.Value != UiFont.AveriaSans) { return result; } TMP_FontAsset val = FindSansFont(); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((TMP_Asset)val).material)) { Tractor.LogInfo("Panel font: '" + ((Object)val).name + "'."); return val; } Tractor.LogWarning("No sans font asset found, keeping the HUD hover name font."); return result; } private static TMP_FontAsset FindSansFont() { try { object obj = typeof(UnifiedPopup).GetField("instance", BindingFlags.Static | BindingFlags.NonPublic)?.GetValue(null); TextMeshProUGUI val = (TextMeshProUGUI)((obj == null) ? null : /*isinst with value type is only supported in some contexts*/); if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)((TMP_Text)val).font)) { return ((TMP_Text)val).font; } } catch (Exception ex) { Tractor.LogWarning("Cannot read the popup body font: " + ex.Message); } TMP_FontAsset[] array = Resources.FindObjectsOfTypeAll<TMP_FontAsset>(); for (int i = 0; i < array.Length; i++) { if (((Object)array[i]).name.IndexOf("sans", StringComparison.OrdinalIgnoreCase) >= 0) { return array[i]; } } return null; } public static void ApplyPanel(Image image) { //IL_003b: 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) if (IsVanilla && AssignSprite(image, "woodpanel_trophys")) { ((Graphic)image).color = Color.white; Material material = GetMaterial("litpanel"); if (Object.op_Implicit((Object)(object)material)) { ((Graphic)image).material = material; } } else { ApplyFlat(image, DarkPanelColor); } } public static void ApplyList(Image image) { //IL_0035: 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) if (IsVanilla && AssignSprite(image, "item_background")) { ((Graphic)image).color = new Color(0f, 0f, 0f, 0.5f); } else { ApplyFlat(image, DarkListColor); } } public static void ApplyInput(Image image) { //IL_0021: 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) if (IsVanilla && AssignSprite(image, "text_field")) { ((Graphic)image).color = Color.white; } else { ApplyFlat(image, DarkInputColor); } } public static void ApplyButton(Button button) { //IL_006c: 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_0047: 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) Image component = ((Component)button).GetComponent<Image>(); if (Object.op_Implicit((Object)(object)component)) { if (IsVanilla && AssignSprite(component, "button") && Object.op_Implicit((Object)(object)GetSprite("button_highlight")) && Object.op_Implicit((Object)(object)GetSprite("button_pressed"))) { ((Graphic)component).color = Color.white; ((Selectable)button).targetGraphic = (Graphic)(object)component; ((Selectable)button).transition = (Transition)2; ((Selectable)button).spriteState = CreateButtonSpriteState(); } else { ApplyFlat(component, Color.white); ((Selectable)button).targetGraphic = (Graphic)(object)component; ((Selectable)button).transition = (Transition)1; ((Selectable)button).colors = ButtonColors; } } } public static void ApplyFavorite(TextMeshProUGUI label, bool isFavorite) { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0038: Unknown result type (might be due to invalid IL or missing references) if (HasStarGlyph(label)) { ((TMP_Text)label).text = (isFavorite ? "★" : "☆"); } else { ((TMP_Text)label).text = (isFavorite ? "*" : "·"); } ((Graphic)label).color = (isFavorite ? FavoriteOnColor : FavoriteOffColor); } public static string GetKeyGlyph(TextMeshProUGUI label) { if (_keyGlyph != null) { return _keyGlyph; } TMP_FontAsset font = ((TMP_Text)label).font; uint[] array = default(uint[]); for (int i = 0; i < KeyGlyphCandidates.Length; i++) { string text = KeyGlyphCandidates[i]; if (Object.op_Implicit((Object)(object)font) && font.HasCharacters(text, ref array, true, true)) { _keyGlyph = text; break; } } if (_keyGlyph == null) { _keyGlyph = "•"; } return _keyGlyph; } private static bool HasStarGlyph(TextMeshProUGUI label) { if (_hasStarGlyph.HasValue) { return _hasStarGlyph.Value; } TMP_FontAsset font = ((TMP_Text)label).font; _hasStarGlyph = Object.op_Implicit((Object)(object)font) && font.HasCharacter('★', true, true); return _hasStarGlyph.Value; } public static void ApplyScrollbarTrack(Image image) { //IL_0035: 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) if (IsVanilla && AssignSprite(image, "Background")) { ((Graphic)image).color = Color.black; } else { ApplyFlat(image, new Color(1f, 1f, 1f, 0.08f)); } } public static void ApplyScrollbarHandle(Image image) { //IL_0035: 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) if (IsVanilla && AssignSprite(image, "UISprite")) { ((Graphic)image).color = Color.white; } else { ApplyFlat(image, new Color(0.85f, 0.85f, 0.85f, 0.95f)); } } public static Sprite GetSprite(string name) { EnsureSprites(); if (!_sprites.TryGetValue(name, out var value)) { return null; } return value; } public static Material GetMaterial(string name) { EnsureMaterials(); if (!_materials.TryGetValue(name, out var value)) { return null; } return value; } private static SpriteState CreateButtonSpriteState() { //IL_0002: 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) SpriteState result = default(SpriteState); ((SpriteState)(ref result)).highlightedSprite = GetSprite("button_highlight"); ((SpriteState)(ref result)).pressedSprite = GetSprite("button_pressed"); ((SpriteState)(ref result)).selectedSprite = ((SpriteState)(ref result)).highlightedSprite; ((SpriteState)(ref result)).disabledSprite = GetSprite("button_disabled"); return result; } private static void ApplyFlat(Image image, Color color) { //IL_0013: Unknown result type (might be due to invalid IL or missing references) image.sprite = UI.WhiteSprite; image.type = (Type)0; ((Graphic)image).color = color; } private static bool AssignSprite(Image image, string spriteName) { //IL_001a: 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) Sprite sprite = GetSprite(spriteName); if (!Object.op_Implicit((Object)(object)sprite)) { return false; } image.sprite = sprite; Vector4 border = sprite.border; image.type = (Type)(((Vector4)(ref border)).sqrMagnitude > 0f); return true; } private static void EnsureSprites() { if (_sprites != null) { return; } _sprites = new Dictionary<string, Sprite>(StringComparer.Ordinal); Sprite[] array = Resources.FindObjectsOfTypeAll<Sprite>(); foreach (Sprite val in array) { if (Object.op_Implicit((Object)(object)val)) { string name = ((Object)val).name; if (Array.IndexOf(SpriteNames, name) >= 0 && !_sprites.ContainsKey(name)) { _sprites.Add(name, val); } } } } private static void EnsureMaterials() { if (_materials != null) { return; } _materials = new Dictionary<string, Material>(StringComparer.Ordinal); Material[] array = Resources.FindObjectsOfTypeAll<Material>(); foreach (Material val in array) { if (Object.op_Implicit((Object)(object)val)) { string name = ((Object)val).name; if (Array.IndexOf(MaterialNames, name) >= 0 && !_materials.ContainsKey(name)) { _materials.Add(name, val); } } } } } [BepInPlugin("miker.valheim.tractor", "Tractor", "1.8.4")] public sealed class Tractor : BaseUnityPlugin { public const string PluginGuid = "miker.valheim.tractor"; public const string PluginName = "Tractor"; public const string PluginVersion = "1.8.4"; private static ManualLogSource _logger; private void Awake() { _logger = ((BaseUnityPlugin)this).Logger; PluginConfig.BindConfig(((BaseUnityPlugin)this).Config); Favorites.Load(); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "miker.valheim.tractor"); } public static void LogInfo(object obj) { _logger.LogInfo((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } public static void LogWarning(object obj) { _logger.LogWarning((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } public static void LogError(object obj) { _logger.LogError((object)$"[{DateTime.Now.ToString(DateTimeFormatInfo.InvariantInfo)}] {obj}"); } } public static class TractorPanel { [CompilerGenerated] private static class <>O { public static UnityAction <0>__Close; public static UnityAction<string> <1>__OnFilterChanged; public static UnityAction <2>__Reload; public static UnityAction<string> <3>__OnValueEndEdit; public static UnityAction<string> <4>__OnValueSubmit; public static UnityAction <5>__ApplySelected; public static UnityAction <6>__ResetSelected; public static UnityAction<string> <7>__OnRadiusInputEndEdit; public static UnityAction <8>__BulkToRadius; public static UnityAction <9>__BulkToSector; public static UnityAction <10>__BulkToRadiusComponent; public static UnityAction <11>__BulkToSectorComponent; public static Comparison<ZdoKeyRow> <12>__CompareKeyRows; public static Comparison<ZdoFieldRow> <13>__CompareFieldRows; } public const float RowSpacing = 2f; private const float PanelWidth = 600f; private const float PanelHeight = 720f; private const float ScrollbarWidth = 16f; private const float MinBulkRadius = 1f; private const float MaxBulkRadius = 256f; private static GameObject _panel; private static GameObject _backdrop; private static RectTransform _panelRectTransform; private static ScrollRect _scrollRect; private static RectTransform _rowContent; private static TMP_InputField _filterInput; private static TMP_InputField _valueInput; private static TextMeshProUGUI _titleLabel; private static TextMeshProUGUI _infoLabel; private static TextMeshProUGUI _selectedLabel; private static TextMeshProUGUI _statusLabel; private static TMP_InputField _radiusInput; private static Button _applyButton; private static Button _resetButton; private static Button _radiusPrefabButton; private static Button _sectorPrefabButton; private static Button _radiusComponentButton; private static Button _sectorComponentButton; private static readonly List<TractorPanelRow> _rows = new List<TractorPanelRow>(); private static List<ZdoKeyRow> _keyRows = new List<ZdoKeyRow>(); private static List<ZdoFieldRow> _fieldRows = new List<ZdoFieldRow>(); private static ZdoTarget _target; private static ZdoKeyRow _selectedKey; private static ZdoFieldRow _selectedField; private static string _filter = string.Empty; private static int _closedFrame = -1; private static bool _refocusValueInput; private static float _lastShortcutTime = float.NegativeInfinity; private const float ShortcutCooldownSeconds = 0.25f; private static readonly Color ScopeTextColor = new Color(0.85f, 0.85f, 0.85f, 1f); public static float RowHeight => Style.FontSize(24f); public static bool IsOpen { get { if (Object.op_Implicit((Object)(object)_panel)) { return _panel.activeSelf; } return false; } } public static bool WasClosedThisFrame => _closedFrame == Time.frameCount; private static Vector2 SavedPanelPosition { get { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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) if (!(PluginConfig.PanelPosition.Value == Vector2.zero)) { return PluginConfig.PanelPosition.Value; } return PluginConfig.DefaultPanelPosition; } } public static void ToggleHovered() { if (!(Time.unscaledTime - _lastShortcutTime < 0.25f)) { _lastShortcutTime = Time.unscaledTime; if (IsOpen) { Close(); } else { TryOpenHovered(); } } } public static bool TryOpenHovered() { //IL_00a2: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) if (!PluginConfig.IsModEnabled.Value || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || IsGameUiBlocking()) { return false; } Player localPlayer = Player.m_localPlayer; GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); ZNetView val = (Object.op_Implicit((Object)(object)hoverObject) ? hoverObject.GetComponentInParent<ZNetView>() : null); bool flag = false; if (!Object.op_Implicit((Object)(object)val) || !val.IsValid()) { float value = PluginConfig.LookRadius.Value; if (value > 0f) { val = LookTarget.FindInFront(localPlayer, value); flag = Object.op_Implicit((Object)(object)val); } } if (!Object.op_Implicit((Object)(object)val) || !val.IsValid()) { return false; } if (!flag) { return Open(val); } ZDO zDO = val.GetZDO(); float num = Vector3.Distance(((Component)localPlayer).transform.position, ((Component)val).transform.position); return Open(val, "No hover target. Selected '" + ZdoCatalog.GetName(zDO.GetPrefab()) + "' " + num.ToString("0.0", CultureInfo.InvariantCulture) + "m ahead."); } public static bool Open(ZNetView netView, string status = null) { //IL_001f: 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) ZDO val = (Object.op_Implicit((Object)(object)netView) ? netView.GetZDO() : null); if (val == null || !EnsurePanel()) { return false; } _target = new ZdoTarget(val.m_uid); _filter = string.Empty; if (Object.op_Implicit((Object)(object)_filterInput)) { _filterInput.SetTextWithoutNotify(string.Empty); } _panel.SetActive(true); if (Object.op_Implicit((Object)(object)_backdrop)) { _backdrop.SetActive(true); } ApplyPanelPosition(SavedPanelPosition); Refresh(); KeepCursorVisible(); SetStatus(status ?? "Escape or a click outside closes."); return true; } public static void Close() { if (Object.op_Implicit((Object)(object)_panel)) { if (Object.op_Implicit((Object)(object)_valueInput) && _valueInput.isFocused && PluginConfig.AutoApply.Value) { ApplySelected(); } _refocusValueInput = false; _panel.SetActive(false); if (Object.op_Implicit((Object)(object)_backdrop)) { _backdrop.SetActive(false); } _closedFrame = Time.frameCount; } } public static void Update() { if (!IsOpen) { return; } if (ZInput.GetKeyDown((KeyCode)27, true) || !Object.op_Implicit((Object)(object)Player.m_localPlayer) || IsGameUiBlocking()) { Close(); return; } if (_refocusValueInput) { _refocusValueInput = false; if (((Selectable)_valueInput).interactable) { _valueInput.ActivateInputField(); } } KeepCursorVisible(); } public static void HandleModEnabledChanged() { if (!PluginConfig.IsModEnabled.Value) { Close(); } } public static void HandleBulkRadiusChanged() { SyncRadiusInput(); } public static void HandleThemeChanged() { RebuildPanel(); } public static void HandleFontChanged() { Style.ResetUiFont(); RebuildPanel(); } private static void RebuildPanel() { if (Object.op_Implicit((Object)(object)_panel)) { Close(); DestroyPanel(); } } public static void ApplyPanelPosition(Vector2 position) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_panelRectTransform)) { _panelRectTransform.anchoredPosition = position; } } public static void SelectKey(ZdoKeyRow row) { _selectedKey = row; _selectedField = null; UpdateSelectedLabel(); _valueInput.SetTextWithoutNotify(row.ValueText); UpdateEditorState(); RefreshSelection(); if (row.CanEdit) { _valueInput.ActivateInputField(); SelectValueText(); } } public static void SelectField(ZdoFieldRow row) { _selectedKey = null; _selectedField = row; UpdateSelectedLabel(); _valueInput.SetTextWithoutNotify(row.ValueText); UpdateEditorState(); RefreshSelection(); _valueInput.ActivateInputField(); SelectValueText(); } private static void SelectValueText() { if (Object.op_Implicit((Object)(object)_valueInput)) { _valueInput.MoveTextStart(false); _valueInput.MoveTextEnd(true); } } private static void UpdateSelectedLabel() { if (Object.op_Implicit((Object)(object)_selectedLabel)) { if (_selectedKey != null) { ((TMP_Text)_selectedLabel).text = "Key: " + _selectedKey.Name + (_selectedKey.IsMissing ? " (not set)" : string.Empty); } else if (_selectedField != null) { ((TMP_Text)_selectedLabel).text = "Field: " + _selectedField.Name + (_selectedField.HasOverride ? " (override)" : " (prefab value)"); } else { ((TMP_Text)_selectedLabel).text = "Select a key or field."; } } } private static bool EnsurePanel() { if (Object.op_Implicit((Object)(object)_panel) && Object.op_Implicit((Object)(object)_filterInput) && Object.op_Implicit((Object)(object)_backdrop)) { return true; } DestroyPanel(); if (!Object.op_Implicit((Object)(object)Hud.instance) || !Object.op_Implicit((Object)(object)Hud.instance.m_rootObject)) { return false; } try { BuildPanel(Hud.instance.m_rootObject.transform); } catch (Exception arg) { Tractor.LogError($"Could not build the panel: {arg}"); DestroyPanel(); return false; } return true; } private static void BuildPanel(Transform parentTransform) { //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) _rows.Clear(); CreateBackdrop(parentTransform); _panel = UI.CreatePanel(parentTransform, "Tractor.Panel", new Vector2(600f, 720f)); _panelRectTransform = _panel.GetComponent<RectTransform>(); Style.ApplyPanel(_panel.GetComponent<Image>()); CreateTitleRow(); CreateToolbarRow(); CreateInfoLabel(); CreateList(); CreateEditor(); _panel.SetActive(false); _backdrop.SetActive(false); ApplyPanelPosition(SavedPanelPosition); } private static void CreateBackdrop(Transform parentTransform) { //IL_0038: 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_0079: Expected O, but got Unknown _backdrop = UI.CreateContainer(parentTransform, "Tractor.Backdrop"); UI.Stretch(_backdrop.GetComponent<RectTransform>()); ((Graphic)UI.AddBackground(_backdrop, new Color(0f, 0f, 0f, 0.01f))).raycastTarget = true; Button obj = _backdrop.AddComponent<Button>(); ((Selectable)obj).transition = (Transition)0; ButtonClickedEvent onClick = obj.onClick; object obj2 = <>O.<0>__Close; if (obj2 == null) { UnityAction val = Close; <>O.<0>__Close = val; obj2 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); } private static void DestroyPanel() { if (Object.op_Implicit((Object)(object)_backdrop)) { Object.Destroy((Object)(object)_backdrop); } if (Object.op_Implicit((Object)(object)_panel)) { Object.Destroy((Object)(object)_panel); } _panel = null; _backdrop = null; _panelRectTransform = null; _scrollRect = null; _rowContent = null; _filterInput = null; _valueInput = null; _titleLabel = null; _infoLabel = null; _selectedLabel = null; _statusLabel = null; _radiusInput = null; _applyButton = null; _resetButton = null; _radiusPrefabButton = null; _sectorPrefabButton = null; _radiusComponentButton = null; _sectorComponentButton = null; _rows.Clear(); _keyRows = new List<ZdoKeyRow>(); _fieldRows = new List<ZdoFieldRow>(); _selectedKey = null; _selectedField = null; _refocusValueInput = false; } private static void CreateTitleRow() { //IL_0033: 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_00cb: Expected O, but got Unknown GameObject obj = UI.CreateRow(_panel.transform, "Title.Row", Style.FontSize(32f)); UI.AddBackground(obj, new Color(1f, 1f, 1f, 0.06f)); _titleLabel = UI.CreateLabel(obj.transform, "Title"); ((TMP_Text)_titleLabel).text = "No target"; ((TMP_Text)_titleLabel).fontSize = Style.FontSize(20f); ((TMP_Text)_titleLabel).fontStyle = (FontStyles)1; UI.SetFlexibleWidth(((Component)_titleLabel).gameObject, 1f); ButtonClickedEvent onClick = UI.CreateButton(obj.transform, "Close", 60f).onClick; object obj2 = <>O.<0>__Close; if (obj2 == null) { UnityAction val = Close; <>O.<0>__Close = val; obj2 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj2); obj.AddComponent<PanelDragger>().TargetRectTransform = _panelRectTransform; } private static void CreateToolbarRow() { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Expected O, but got Unknown GameObject obj = UI.CreateRow(_panel.transform, "Toolbar.Row", Style.FontSize(30f)); _filterInput = UI.CreateInputField(obj.transform, "Filter keys and fields..."); LayoutElement obj2 = ((Component)_filterInput).gameObject.AddComponent<LayoutElement>(); obj2.flexibleWidth = 1f; obj2.minHeight = 28f; obj2.preferredHeight = 28f; ((UnityEvent<string>)(object)_filterInput.onValueChanged).AddListener((UnityAction<string>)OnFilterChanged); ButtonClickedEvent onClick = UI.CreateButton(obj.transform, "Reload", 70f).onClick; object obj3 = <>O.<2>__Reload; if (obj3 == null) { UnityAction val = Reload; <>O.<2>__Reload = val; obj3 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); } private static void CreateInfoLabel() { //IL_0046: Unknown result type (might be due to invalid IL or missing references) _infoLabel = UI.CreateLabel(_panel.transform, "Info"); ((TMP_Text)_infoLabel).fontSize = Style.FontSize(13f); ((Graphic)_infoLabel).color = new Color(0.7f, 0.7f, 0.7f, 1f); UI.SetHeight(((Component)_infoLabel).gameObject, Style.FontSize(20f)); } private static void CreateList() { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b5: Unknown result type (might be due to invalid IL or missing references) //IL_00ca: 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_0139: Unknown result type (might be due to invalid IL or missing references) //IL_0152: Unknown result type (might be due to invalid IL or missing references) //IL_016b: 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_0189: 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_01c4: Expected O, but got Unknown GameObject obj = UI.CreateContainer(_panel.transform, "List"); obj.AddComponent<LayoutElement>().flexibleHeight = 1f; Image obj2 = UI.AddBackground(obj, Color.clear); ((Graphic)obj2).raycastTarget = false; Style.ApplyList(obj2); _scrollRect = obj.AddComponent<ScrollRect>(); _scrollRect.horizontal = false; _scrollRect.vertical = true; _scrollRect.movementType = (MovementType)2; _scrollRect.inertia = false; GameObject obj3 = UI.CreateContainer(obj.transform, "Viewport"); RectTransform component = obj3.GetComponent<RectTransform>(); component.anchorMin = Vector2.zero; component.anchorMax = Vector2.one; component.pivot = new Vector2(0.5f, 0.5f); component.offsetMin = Vector2.zero; component.offsetMax = new Vector2(-16f, 0f); obj3.AddComponent<RectMask2D>(); ((Graphic)UI.AddBackground(obj3, new Color(0f, 0f, 0f, 0.01f))).raycastTarget = true; obj3.AddComponent<PanelScroll>().ScrollRect = _scrollRect; GameObject obj4 = UI.CreateContainer(obj3.transform, "Content"); _rowContent = obj4.GetComponent<RectTransform>(); _rowContent.anchorMin = new Vector2(0f, 1f); _rowContent.anchorMax = new Vector2(1f, 1f); _rowContent.pivot = new Vector2(0.5f, 1f); _rowContent.anchoredPosition = Vector2.zero; _rowContent.sizeDelta = Vector2.zero; VerticalLayoutGroup obj5 = obj4.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj5).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj5).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj5).childForceExpandHeight = false; ((LayoutGroup)obj5).padding = new RectOffset(0, 0, 0, 0); ((HorizontalOrVerticalLayoutGroup)obj5).spacing = 2f; ContentSizeFitter obj6 = obj4.AddComponent<ContentSizeFitter>(); obj6.horizontalFit = (FitMode)0; obj6.verticalFit = (FitMode)2; CreateScrollbar(obj.transform); _scrollRect.viewport = component; _scrollRect.content = _rowContent; } private static void CreateScrollbar(Transform parentTransform) { //IL_001c: 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) //IL_0046: 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_0065: 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_0095: 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_00e9: 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_0109: Unknown result type (might be due to invalid IL or missing references) //IL_0114: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UI.CreateContainer(parentTransform, "Scrollbar"); RectTransform component = obj.GetComponent<RectTransform>(); component.anchorMin = new Vector2(1f, 0f); component.anchorMax = new Vector2(1f, 1f); component.pivot = new Vector2(1f, 0.5f); component.sizeDelta = new Vector2(16f, 0f); component.anchoredPosition = Vector2.zero; Style.ApplyScrollbarTrack(UI.AddBackground(obj, Color.white)); Scrollbar val = obj.AddComponent<Scrollbar>(); val.direction = (Direction)2; ((Selectable)val).transition = (Transition)1; ((Selectable)val).colors = Style.ScrollbarColors; GameObject obj2 = UI.CreateContainer(obj.transform, "Sliding Area"); UI.Stretch(obj2.GetComponent<RectTransform>(), new Vector4(2f, 2f, 2f, 2f)); GameObject obj3 = UI.CreateContainer(obj2.transform, "Handle"); RectTransform component2 = obj3.GetComponent<RectTransform>(); component2.anchorMin = Vector2.zero; component2.anchorMax = Vector2.one; component2.pivot = new Vector2(0.5f, 0.5f); component2.sizeDelta = Vector2.zero; Image val2 = UI.AddBackground(obj3, Color.white); Style.ApplyScrollbarHandle(val2); val.handleRect = component2; ((Selectable)val).targetGraphic = (Graphic)(object)val2; _scrollRect.verticalScrollbar = val; _scrollRect.verticalScrollbarVisibility = (ScrollbarVisibility)0; } private static void CreateEditor() { CreateHeaderRow(_panel.transform); CreateValueRow(_panel.transform); CreateScopeRows(_panel.transform); } private static void CreateHeaderRow(Transform parentTransform) { //IL_0057: Unknown result type (might be due to invalid IL or missing references) GameObject obj = UI.CreateRow(parentTransform, "Editor.Header", Style.FontSize(24f)); _selectedLabel = UI.CreateLabel(obj.transform, "Selected"); ((TMP_Text)_selectedLabel).fontSize = Style.FontSize(13f); ((Graphic)_selectedLabel).color = new Color(0.9f, 0.9f, 0.9f, 1f); UI.SetHalfWidth(((Component)_selectedLabel).gameObject); _statusLabel = UI.CreateLabel(obj.transform, "Status"); ((TMP_Text)_statusLabel).fontSize = Style.FontSize(13f); ((TMP_Text)_statusLabel).alignment = (TextAlignmentOptions)516; UI.SetHalfWidth(((Component)_statusLabel).gameObject); } private static void CreateValueRow(Transform parentTransform) { //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Expected O, but got Unknown //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0149: Expected O, but got Unknown GameObject obj = UI.CreateRow(parentTransform, "Editor.Value", Style.FontSize(30f)); _valueInput = UI.CreateInputField(obj.transform, "Select a key or field..."); _valueInput.onFocusSelectAll = true; ((UnityEvent<string>)(object)_valueInput.onEndEdit).AddListener((UnityAction<string>)OnValueEndEdit); ((UnityEvent<string>)(object)_valueInput.onSubmit).AddListener((UnityAction<string>)OnValueSubmit); LayoutElement obj2 = ((Component)_valueInput).gameObject.AddComponent<LayoutElement>(); obj2.flexibleWidth = 1f; obj2.minHeight = Style.FontSize(28f); obj2.preferredHeight = Style.FontSize(28f); _applyButton = UI.CreateButton(obj.transform, "Apply", 64f); ButtonClickedEvent onClick = _applyButton.onClick; object obj3 = <>O.<5>__ApplySelected; if (obj3 == null) { UnityAction val = ApplySelected; <>O.<5>__ApplySelected = val; obj3 = (object)val; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); _resetButton = UI.CreateButton(obj.transform, "Reset", 64f); ButtonClickedEvent onClick2 = _resetButton.onClick; object obj4 = <>O.<6>__ResetSelected; if (obj4 == null) { UnityAction val2 = ResetSelected; <>O.<6>__ResetSelected = val2; obj4 = (object)val2; } ((UnityEvent)onClick2).AddListener((UnityAction)obj4); } private static void CreateScopeRows(Transform parentTransform) { //IL_0052: 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_0194: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Expected O, but got Unknown //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d8: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Expected O, but got Unknown //IL_0233: Unknown result type (might be due to invalid IL or missing references) //IL_0238: Unknown result type (might be due to invalid IL or missing references) //IL_023e: Expected O, but got Unknown //IL_0271: Unknown result type (might be due to invalid IL or missing references) //IL_0276: Unknown result type (might be due to invalid IL or missing references) //IL_027c: Expected O, but got Unknown GameObject obj = UI.CreateRow(parentTransform, "Editor.Scope", Style.FontSize(28f)); ((HorizontalOrVerticalLayoutGroup)obj.GetComponent<HorizontalLayoutGroup>()).spacing = 4f; TextMeshProUGUI val = UI.CreateLabel(obj.transform, "RadiusTitle"); ((TMP_Text)val).text = "Radius:"; ((TMP_Text)val).fontSize = Style.FontSize(12f); ((Graphic)val).color = ScopeTextColor; ((Component)val).gameObject.AddComponent<LayoutElement>().preferredWidth = Mathf.Max(((TMP_Text)val).GetPreferredValues(((TMP_Text)val).text).x + 6f, Style.FontSize(46f)); _radiusInput = UI.CreateInputField(obj.transform, "32", 12f); ((UnityEvent<string>)(object)_radiusInput.onEndEdit).AddListener((UnityAction<string>)OnRadiusInputEndEdit); ((UnityEvent<string>)(object)_radiusInput.onSubmit).AddListener((UnityAction<string>)OnRadiusInputEndEdit); LayoutElement obj2 = ((Component)_radiusInput).gameObject.AddComponent<LayoutElement>(); obj2.minWidth = 36f; obj2.preferredWidth = 36f; obj2.minHeight = Style.FontSize(20f); obj2.preferredHeight = Style.FontSize(20f); UI.CreateSpacer(obj.transform, "PrefabSpacer"); CreateScopeTitle(obj.transform, "All prefabs in:"); _radiusPrefabButton = CreateScopeButton(obj.transform, "Radius"); ButtonClickedEvent onClick = _radiusPrefabButton.onClick; object obj3 = <>O.<8>__BulkToRadius; if (obj3 == null) { UnityAction val2 = BulkToRadius; <>O.<8>__BulkToRadius = val2; obj3 = (object)val2; } ((UnityEvent)onClick).AddListener((UnityAction)obj3); _sectorPrefabButton = CreateScopeButton(obj.transform, "Sector"); ButtonClickedEvent onClick2 = _sectorPrefabButton.onClick; object obj4 = <>O.<9>__BulkToSector; if (obj4 == null) { UnityAction val3 = BulkToSector; <>O.<9>__BulkToSector = val3; obj4 = (object)val3; } ((UnityEvent)onClick2).AddListener((UnityAction)obj4); UI.CreateSpacer(obj.transform, "ComponentSpacer"); CreateScopeTitle(obj.transform, "All components in:"); _radiusComponentButton = CreateScopeButton(obj.transform, "Radius"); ButtonClickedEvent onClick3 = _radiusComponentButton.onClick; object obj5 = <>O.<10>__BulkToRadiusComponent; if (obj5 == null) { UnityAction val4 = BulkToRadiusComponent; <>O.<10>__BulkToRadiusComponent = val4; obj5 = (object)val4; } ((UnityEvent)onClick3).AddListener((UnityAction)obj5); _sectorComponentButton = CreateScopeButton(obj.transform, "Sector"); ButtonClickedEvent onClick4 = _sectorComponentButton.onClick; object obj6 = <>O.<11>__BulkToSectorComponent; if (obj6 == null) { UnityAction val5 = BulkToSectorComponent; <>O.<11>__BulkToSectorComponent = val5; obj6 = (object)val5; } ((UnityEvent)onClick4).AddListener((UnityAction)obj6); SyncRadiusInput(); } private static void CreateScopeTitle(Transform parentTransform, string text) { //IL_001e: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UI.CreateLabel(parentTransform, text); ((TMP_Text)obj).text = text; ((TMP_Text)obj).fontSize = Style.FontSize(12f); ((Graphic)obj).color = ScopeTextColor; } private static Button CreateScopeButton(Transform parentTransform, string text) { Button obj = UI.CreateButton(parentTransform, text, 54f); ((TMP_Text)((Component)obj).GetComponentInChildren<TextMeshProUGUI>()).fontSize = Style.FontSize(12f); return obj; } private static void OnRadiusInputEndEdit(string value) { if (float.TryParse(value.Trim(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result)) { PluginConfig.BulkRadius.Value = Mathf.Clamp(result, 1f, 256f); } SyncRadiusInput(); } private static void SyncRadiusInput() { if (Object.op_Implicit((Object)(object)_radiusInput)) { _radiusInput.SetTextWithoutNotify(PluginConfig.BulkRadius.Value.ToString("0", CultureInfo.InvariantCulture)); } } private static void OnFilterChanged(string value) { _filter = value.Trim(); RebuildRows(); } private static void OnValueEndEdit(string value) { if (IsOpen && PluginConfig.AutoApply.Value) { ApplySelected(); } } private static void OnValueSubmit(string value) { ApplySelected(); _refocusValueInput = true; } private static void Reload() { Refresh(); if (_target != null && _target.Zdo != null) { SetStatus("Reloaded."); } } private static void Refresh(bool resetScroll = true) { ClearSelection(); ZDO val = ((_target == null) ? null : _target.Zdo); if (val == null) { _keyRows = new List<ZdoKeyRow>(); _fieldRows = new List<ZdoFieldRow>(); UpdateInfo(null); RebuildRows(); SetStatus("Target ZDO is gone.", isError: true); return; } ZNetView netView = _target.NetView; _fieldRows = ((Object.op_Implicit((Object)(object)netView) && netView.IsValid()) ? ZdoEditor.ReadFields(val, netView) : new List<ZdoFieldRow>()); HashSet<int> hashSet = new HashSet<int>(); for (int i = 0; i < _fieldRows.Count; i++) { hashSet.Add(_fieldRows[i].Hash); } _keyRows = ZdoEditor.ReadKeys(val, netView, hashSet); UpdateInfo(val); RebuildRows(); if (resetScroll) { ResetScrollPosition(); } } private static void RebuildRows() { SortRows(); int num = 0; int i = 0; int num2 = 0; while (true) { if (num < _keyRows.Count && !MatchesFilter(_keyRows[num].Name)) { num++; continue; } for (; i < _fieldRows.Count && !MatchesFilter(_fieldRows[i].Name); i++) { } bool flag = num < _keyRows.Count; bool flag2 = i < _fieldRows.Count; if (!flag && !flag2) { break; } if (flag && (!flag2 || CompareDisplay(_keyRows[num], _fieldRows[i]) <= 0)) { ZdoKeyRow zdoKeyRow = _keyRows[num++]; TractorPanelRow row = GetRow(num2++); row.BindKey(zdoKeyRow); row.SetSelected(zdoKeyRow == _selectedKey); } else { ZdoFieldRow zdoFieldRow = _fieldRows[i++]; TractorPanelRow row2 = GetRow(num2++); row2.BindField(zdoFieldRow); row2.SetSelected(zdoFieldRow == _selectedField); } } for (int j = num2; j < _rows.Count; j++) { _rows[j].Hide(); } } private static void SortRows() { _keyRows.Sort(CompareKeyRows); _fieldRows.Sort(CompareFieldRows); } private static int GetRank(ZdoKeyRow row) { if (Favorites.IsKey(row.Name)) { return 0; } if (!row.IsUnresolved) { return 3; } return 4; } private static int GetRank(ZdoFieldRow row) { if (Favorites.IsField(row.Name)) { return 1; } if (!row.HasOverride) { return 5; } return 2; } private static int CompareDisplay(ZdoKeyRow keyRow, ZdoFieldRow fieldRow) { int rank = GetRank(keyRow); int rank2 = GetRank(fieldRow); if (rank != rank2) { return rank.CompareTo(rank2); } return string.Compare(keyRow.Name, fieldRow.Name, StringComparison.OrdinalIgnoreCase); } private static int CompareKeyRows(ZdoKeyRow a, ZdoKeyRow b) { int num = GetRank(a).CompareTo(GetRank(b)); if (num == 0) { return string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); } return num; } private static int CompareFieldRows(ZdoFieldRow a, ZdoFieldRow b) { int num = GetRank(a).CompareTo(GetRank(b)); if (num == 0) { return string.Compare(a.Name, b.Name, StringComparison.OrdinalIgnoreCase); } return num; } public static void ToggleFavorite(TractorPanelRow row) { if (!IsOpen) { return; } string text = null; bool flag = false; if (row.KeyRow != null) { text = row.KeyRow.Name; flag = Favorites.ToggleKey(text); } else { if (row.FieldRow == null) { return; } text = row.FieldRow.Name; flag = Favorites.ToggleField(text); } RebuildRows(); SetStatus((flag ? "Pinned '" : "Unpinned '") + text + "'."); } private static TractorPanelRow GetRow(int index) { while (_rows.Count <= index) { _rows.Add(new TractorPanelRow((Transform)(object)_rowContent)); } return _rows[index]; } private static bool MatchesFilter(string name) { if (_filter.Length != 0) { return name.IndexOf(_filter, StringComparison.OrdinalIgnoreCase) >= 0; } return true; } private static void ClearSelection() { _selectedKey = null; _selectedField = null; _refocusValueInput = false; UpdateSelectedLabel(); if (Object.op_Implicit((Object)(object)_valueInput)) { _valueInput.SetTextWithoutNotify(string.Empty); ((Selectable)_valueInput).interactable = false; } UpdateEditorState(); if (_rows.Count > 0) { RefreshSelection(); } } private static void RefreshSelection() { for (int i = 0; i < _rows.Count; i++) { TractorPanelRow tractorPanelRow = _rows[i]; tractorPanelRow.SetSelected((_selectedKey != null && tractorPanelRow.KeyRow == _selectedKey) || (_selectedField != null && tractorPanelRow.FieldRow == _selectedField)); } } private static void RefreshRowValues() { for (int i = 0; i < _rows.Count; i++) { if (_rows[i].Row.activeSelf) { _rows[i].RefreshValue(); } } } private static void UpdateEditorState() { bool flag = ((_selectedKey != null) ? _selectedKey.CanEdit : (_selectedField != null)); bool interactable = ((_selectedKey != null) ? _selectedKey.CanRemove : (_selectedField != null)); bool flag2 = _selectedField != null; if (Object.op_Implicit((Object)(object)_applyButton)) { ((Selectable)_applyButton).interactable = flag; } if (Object.op_Implicit((Object)(object)_resetButton)) { ((Selectable)_resetButton).interactable = interactable; } if (Object.op_Implicit((Object)(object)_radiusPrefabButton)) { ((Selectable)_radiusPrefabButton).interactable = flag; } if (Object.op_Implicit((Object)(object)_sectorPrefabButton)) { ((Selectable)_sectorPrefabButton).interactable = flag; } if (Object.op_Implicit((Object)(object)_radiusComponentButton)) { ((Selectable)_radiusComponentButton).interactable = flag && flag2; } if (Object.op_Implicit((Object)(object)_sectorComponentButton)) { ((Selectable)_sectorComponentButton).interactable = flag && flag2; } if (Object.op_Implicit((Object)(object)_valueInput)) { ((Selectable)_valueInput).interactable = flag; } } private static void ApplySelected() { if (_selectedKey != null) { ApplyKey(); } else if (_selectedField != null) { ApplyField(); } else { SetStatus("Select a key or field first.", isError: true); } } private static void ApplyKey() { ZdoKeyRow selectedKey = _selectedKey; string text = _valueInput.text; bool isMissing = selectedKey.IsMissing; bool flag = IsHashedKeyText(selectedKey, text); if (isMissing || !(text == selectedKey.ValueText)) { if (!ZdoEditor.TryApplyKey(_target, selectedKey, text, out var error)) { SetStatus(error, isError: true); return; } _valueInput.SetTextWithoutNotify(selectedKey.ValueText); RefreshRowValues(); UpdateEditorState(); UpdateSelectedLabel(); SetStatus(isMissing ? ("Added '" + selectedKey.Name + "'.") : (flag ? ("Applied '" + selectedKey.Name + "' as stable hash " + selectedKey.ValueText + ".") : ("Applied '" + selectedKey.Name + "'."))); } } private static bool IsHashedKeyText(ZdoKeyRow row, string text) { int result; if (row.Type == ZdoKeyType.Int && !row.IsBool) { return !int.TryParse(text.Trim(), NumberStyles.Integer, CultureInfo.InvariantCulture, out result); } return false; } private static void ApplyField() { ZdoFieldRow selectedField = _selectedField; string text = _valueInput.text; if (!(text == selectedField.ValueText)) { if (!ZdoEditor.TryApplyField(_target, selectedField, text, out var error)) { SetStatus(error, isError: true); return; } _valueInput.SetTextWithoutNotify(selectedField.ValueText); RefreshRowValues(); UpdateSelectedLabel(); SetStatus("Applied '" + selectedField.Name + "'."); } } private static void ResetSelected() { if (_selectedKey != null) { ResetKey(); } else if (_selectedField != null) { ResetField(); } else { SetStatus("Select a key or field first.", isError: true); } } private static void ResetKey() { ZdoKeyRow selectedKey = _selectedKey; if (!selectedKey.CanRemove) { SetStatus(selectedKey.IsMissing ? ("'" + selectedKey.Name + "' is not set.") : "Connections are read-only.", isError: true); return; } if (!ZdoEditor.TryRemoveKey(_target, selectedKey, out var error)) { SetStatus(error, isError: true); return; } Refresh(resetScroll: false); SetStatus("Removed '" + selectedKey.Name + "'."); } private static void ResetField() { ZdoFieldRow selectedField = _selectedField; if (!ZdoEditor.TryResetField(_target, selectedField, out var error)) { SetStatus(error, isError: true); return; } _valueInput.SetTextWithoutNotify(selectedField.ValueText); RefreshRowValues(); UpdateSelectedLabel(); SetStatus("Reset '" + selectedField.Name + "' to the prefab value."); } private static void BulkToRadius() { BulkApply(zoneOnly: false, matchComponent: false); } private static void BulkToSector() { BulkApply(zoneOnly: true, matchComponent: false); } private static void BulkToRadiusComponent() { BulkApply(zoneOnly: false, matchComponent: true); } private static void BulkToSectorComponent() { BulkApply(zoneOnly: true, matchComponent: true); } private static void BulkApply(bool zoneOnly, bool matchComponent) { string text = _valueInput.text; string scope = (zoneOnly ? "this sector" : (PluginConfig.BulkRadius.Value.ToString("0", CultureInfo.InvariantCulture) + "m")); if (_selectedKey != null) { int candidateCount; string error; int applied = ZdoEditor.BulkApplyKey(_target, _selectedKey, text, zoneOnly, out candidateCount, out error); if (error == null) { _valueInput.SetTextWithoutNotify(_selectedKey.ValueText); RefreshRowValues(); UpdateEditorState(); } ReportBulk(applied, candidateCount, error, scope, "same-prefab"); } else if (_selectedField != null) { int candidateCount2; string error2; int applied2 = ZdoEditor.BulkApplyField(_target, _selectedField, text, zoneOnly, matchComponent, out candidateCount2, out error2); if (error2 == null) { _valueInput.SetTextWithoutNotify(_selectedField.ValueText); RefreshRowValues(); } ReportBulk(applied2, candidateCount2, error2, scope, matchComponent ? "same-component" : "same-prefab"); } else { SetStatus("Select a key or field first.", isError: true); } } private static void ReportBulk(int applied, int candidates, string error, string scope, string match) { if (error != null) { SetStatus(error, isError: true); } else if (candidates == 0) { SetStatus("No " + match + " objects in " + scope + ".", isError: true); } else { SetStatus($"Applied to {applied}/{candidates} {match} objects in {scope}."); } } private static void UpdateInfo(ZDO zdo) { //IL_00fe: Unknown result type (might be due to invalid IL or missing references) if (!Object.op_Implicit((Object)(object)_titleLabel) || !Object.op_Implicit((Object)(object)_infoLabel)) { return; } if (zdo == null) { ((TMP_Text)_titleLabel).text = "No target"; ((TMP_Text)_infoLabel).text = "0 keys | 0 fields"; return; } int num = 0; for (int i = 0; i < _keyRows.Count; i++) { if (_keyRows[i].IsMissing) { num++; } } int num2 = 0; for (int j = 0; j < _fieldRows.Count; j++) { if (_fieldRows[j].HasOverride) { num2++; } } ((TMP_Text)_titleLabel).text = ZdoCatalog.GetName(zdo.GetPrefab()); ((TMP_Text)_infoLabel).text = $"{_keyRows.Count} keys" + ((num > 0) ? $" ({num} not set)" : string.Empty) + $" | {_fieldRows.Count} fields | {num2} overrides | {zdo.m_uid}"; } private static void ResetScrollPosition() { if (Object.op_Implicit((Object)(object)_scrollRect) && Object.op_Implicit((Object)(object)_rowContent)) { LayoutRebuilder.ForceRebuildLayoutImmediate(_rowContent); _scrollRect.verticalNormalizedPosition = 1f; } } private static void SetStatus(string message, bool isError = false) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) if (Object.op_Implicit((Object)(object)_statusLabel)) { ((TMP_Text)_statusLabel).text = message; ((Graphic)_statusLabel).color = (isError ? new Color(1f, 0.45f, 0.45f, 1f) : new Color(0.75f, 0.9f, 0.75f, 1f)); } } private static bool IsGameUiBlocking() { if (!Menu.IsActive() && !InventoryGui.IsVisible() && !Console.IsVisible() && !TextInput.IsVisible() && !Minimap.IsOpen()) { if (Object.op_Implicit((Object)(object)Chat.instance)) { return Chat.instance.HasFocus(); } return false; } return true; } public static void KeepCursorVisible() { ZCursor.LockState = (CursorLockMode)0; ZCursor.Show(); } } public sealed class TractorPanelRow { private static readonly Color NormalColor = new Color(1f, 1f, 1f, 0f); private static readonly Color HoveredColor = new Color(1f, 1f, 1f, 0.08f); private static readonly Color SelectedColor = new Color(1f, 1f, 1f, 0.2f); private static readonly Color KeyNameColor = new Color(1f, 1f, 1f, 1f); private static readonly Color FieldNameColor = new Color(0.85f, 0.85f, 0.85f, 1f); private static readonly Color OverrideNameColor = new Color(1f, 0.9f, 0.5f, 1f); private static readonly Color ValueColor = new Color(0.9f, 0.9f, 0.7f, 1f); private static readonly Color ReadOnlyColor = new Color(0.65f, 0.65f, 0.65f, 1f); private static readonly Color TypeColor = new Color(0.68f, 0.7f, 0.74f, 1f); private static readonly Color KeyIconColor = new Color(1f, 0.9f, 0.5f, 1f); private bool _isSelected; private bool _isHovered; public GameObject Row { get; } public Image Background { get; } public Button Button { get; } public Button FavoriteButton { get; } public TextMeshProUGUI FavoriteLabel { get; } public TextMeshProUGUI IconLabel { get; } public TextMeshProUGUI NameLabel { get; } public TextMeshProUGUI ValueLabel { get; } public TextMeshProUGUI TypeLabel { get; } public ZdoKeyRow KeyRow { get; private set; } public ZdoFieldRow FieldRow { get; private set; } public TractorPanelRow(Transform parentTransform) { //IL_0023: 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_006b: Expected O, but got Unknown //IL_00c4: 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_010f: Expected O, but got Unknown //IL_01c5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_0266: Unknown result type (might be due to invalid IL or missing references) //IL_02cb: Unknown result type (might be due to invalid IL or missing references) Row = UI.CreateRow(parentTransform, "Row", TractorPanel.RowHeight); Background = UI.AddBackground(Row, NormalColor); Button = Row.AddComponent<Button>(); ((Selectable)Button).transition = (Transition)0; ((UnityEvent)Button.onClick).AddListener(new UnityAction(OnClick)); Row.AddComponent<PanelRowPointer>().Row = this; GameObject val = UI.CreateContainer(Row.transform, "Favorite"); LayoutElement obj = val.AddComponent<LayoutElement>(); obj.minWidth = 20f; obj.preferredWidth = 20f; obj.minHeight = 20f; obj.preferredHeight = 20f; Image targetGraphic = UI.AddBackground(val, Color.clear); FavoriteButton = val.AddComponent<Button>(); ((Selectable)FavoriteButton).targetGraphic = (Graphic)(object)targetGraphic; ((Selectable)FavoriteButton).transition = (Transition)0; ((UnityEvent)FavoriteButton.onClick).AddListener(new UnityAction(OnFavoriteClick)); FavoriteLabel = UI.CreateLabel(val.transform, "Star"); ((TMP_Text)FavoriteLabel).fontSize = Style.FontSize(18f); ((TMP_Text)FavoriteLabel).alignment = (TextAlignmentOptions)514; ((TMP_Text)FavoriteLabel).overflowMode = (TextOverflowModes)0; GameObject val2 = UI.CreateInlineGroup(Row.transform, "NameGroup"); UI.SetFlexibleWidth(val2, 1f); IconLabel = UI.CreateLabel(val2.transform, "Icon"); ((TMP_Text)IconLabel).fontSize = Style.FontSize(14f); ((TMP_Text)IconLabel).alignment = (TextAlignmentOptions)513; ((TMP_Text)IconLabel).overflowMode = (TextOverflowModes)0; ((Graphic)IconLabel).color = KeyIconColor; NameLabel = UI.CreateLabel(val2.transform, "Name"); ((TMP_Text)NameLabel).fontSize = Style.FontSize(14f); ((Graphic)NameLabel).color = KeyNameColor; UI.SetFlexibleWidth(((Component)NameLabel).gameObject, 1f); ValueLabel = UI.CreateLabel(Row.transform, "Value"); ((TMP_Text)ValueLabel).fontSize = Style.FontSize(14f); ((TMP_Text)ValueLabel).alignment = (TextAlignmentOptions)516; ((Graphic)ValueLabel).color = ValueColor; LayoutElement obj2 = ((Component)ValueLabel).gameObject.AddComponent<LayoutElement>(); obj2.minWidth = 150f; obj2.preferredWidth = 150f; TypeLabel = UI.CreateLabel(Row.transform, "Type"); ((TMP_Text)TypeLabel).fontSize = Style.FontSize(13f); ((Graphic)TypeLabel).color = TypeColor; LayoutElement obj3 = ((Component)TypeLabel).gameObject.AddComponent<LayoutElement>(); obj3.minWidth = 68f; obj3.preferredWidth = 68f; UpdateBackground(); } public void BindKey(ZdoKeyRow row) { KeyRow = row; FieldRow = null; Row.SetActive(true); Style.ApplyFavorite(FavoriteLabel, Favorites.IsKey(row.Name)); RefreshValue(); } public void BindField(ZdoFieldRow row) { KeyRow = null; FieldRow = row; Row.SetActive(true); Style.ApplyFavorite(FavoriteLabel, Favorites.IsField(row.Name)); RefreshValue(); } public void Hide() { KeyRow = null; FieldRow = null; _isHovered = false; Row.SetActive(false); } public void RefreshValue() { //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_012c: 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_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) if (KeyRow != null) { ((TMP_Text)IconLabel).text = Style.GetKeyGlyph(IconLabel); ((TMP_Text)NameLabel).text = KeyRow.Name; ((TMP_Text)NameLabel).fontStyle = (FontStyles)0; ((Graphic)NameLabel).color = (KeyRow.CanEdit ? KeyNameColor : ReadOnlyColor); ((TMP_Text)ValueLabel).text = (KeyRow.IsMissing ? "(not set)" : KeyRow.ValueText); ((Graphic)ValueLabel).color = (KeyRow.CanEdit ? ValueColor : ReadOnlyColor); ((TMP_Text)TypeLabel).text = KeyRow.TypeText; } else if (FieldRow != null) { ((TMP_Text)IconLabel).text = string.Empty; ((TMP_Text)NameLabel).text = FieldRow.Name; ((TMP_Text)NameLabel).fontStyle = (FontStyles)(FieldRow.HasOverride ? 1 : 0); ((Graphic)NameLabel).color = (FieldRow.HasOverride ? OverrideNameColor : FieldNameColor); ((TMP_Text)ValueLabel).text = FieldRow.ValueText; ((Graphic)ValueLabel).color = ValueColor; ((TMP_Text)TypeLabel).text = FieldRow.TypeText; } } public void SetSelected(bool isSelected) { _isSelected = isSelected; UpdateBackground(); } public void SetHovered(bool isHovered) { _isHovered = isHovered; UpdateBackground(); } private void UpdateBackground() { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) ((Graphic)Background).color = (_isSelected ? SelectedColor : (_isHovered ? HoveredColor : NormalColor)); } private void OnClick() { if (KeyRow != null) { TractorPanel.SelectKey(KeyRow); } else if (FieldRow != null) { TractorPanel.SelectField(FieldRow); } } private void OnFavoriteClick() { TractorPanel.ToggleFavorite(this); } } public static class UI { private static Sprite _whiteSprite; public static Sprite WhiteSprite { get { if (!Object.op_Implicit((Object)(object)_whiteSprite)) { _whiteSprite = CreateWhiteSprite(); } return _whiteSprite; } } public static GameObject CreatePanel(Transform parentTransform, string name, Vector2 size) { //IL_0018: 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_0042: 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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown GameObject obj = CreateContainer(parentTransform, name); RectTransform component = obj.GetComponent<RectTransform>(); component.anchorMin = new Vector2(0.5f, 0.5f); component.anchorMax = new Vector2(0.5f, 0.5f); component.pivot = new Vector2(0.5f, 0.5f); component.anchoredPosition = Vector2.zero; component.sizeDelta = size; Image obj2 = obj.AddComponent<Image>(); obj2.sprite = WhiteSprite; obj2.type = (Type)0; ((Graphic)obj2).color = new Color(0.05f, 0.05f, 0.05f, 0.94f); ((Graphic)obj2).raycastTarget = true; VerticalLayoutGroup obj3 = obj.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj3).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj3).childForceExpandHeight = false; ((LayoutGroup)obj3).padding = new RectOffset(14, 14, 14, 14); ((HorizontalOrVerticalLayoutGroup)obj3).spacing = 6f; return obj; } public static GameObject CreateContainer(Transform parentTransform, string name) { //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_0027: Expected O, but got Unknown GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); return val; } public static GameObject CreateRow(Transform parentTransform, string name, float height) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown GameObject obj = CreateContainer(parentTransform, name); HorizontalLayoutGroup obj2 = obj.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((LayoutGroup)obj2).childAlignment = (TextAnchor)3; ((LayoutGroup)obj2).padding = new RectOffset(2, 2, 2, 2); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 6f; LayoutElement obj3 = obj.AddComponent<LayoutElement>(); obj3.minHeight = height; obj3.preferredHeight = height; return obj; } public static GameObject CreateInlineGroup(Transform parentTransform, string name) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown GameObject obj = CreateContainer(parentTransform, name); HorizontalLayoutGroup obj2 = obj.AddComponent<HorizontalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = false; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((LayoutGroup)obj2).childAlignment = (TextAnchor)3; ((LayoutGroup)obj2).padding = new RectOffset(0, 0, 0, 0); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 2f; return obj; } public static GameObject CreateSpacer(Transform parentTransform, string name) { GameObject obj = CreateContainer(parentTransform, name); LayoutElement obj2 = obj.AddComponent<LayoutElement>(); obj2.minWidth = 0f; obj2.preferredWidth = 0f; obj2.flexibleWidth = 1f; return obj; } public static GameObject CreateColumn(Transform parentTransform, string name) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Expected O, but got Unknown GameObject obj = CreateContainer(parentTransform, name); VerticalLayoutGroup obj2 = obj.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true; ((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = false; ((LayoutGroup)obj2).childAlignment = (TextAnchor)0; ((LayoutGroup)obj2).padding = new RectOffset(0, 0, 0, 0); ((HorizontalOrVerticalLayoutGroup)obj2).spacing = 4f; return obj; } public static Image AddBackground(GameObject gameObject, Color color) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) Image obj = gameObject.AddComponent<Image>(); obj.sprite = WhiteSprite; obj.type = (Type)0; ((Graphic)obj).color = color; ((Graphic)obj).raycastTarget = true; return obj; } public static TextMeshProUGUI CreateLabel(Transform parentTransform, string name) { //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI val = Object.Instantiate<TextMeshProUGUI>(Hud.instance.m_hoverName, parentTransform, false); ((Object)val).name = name; TMP_FontAsset uiFontAsset = Style.UiFontAsset; if (Object.op_Implicit((Object)(object)uiFontAsset) && Object.op_Implicit((Object)(object)((TMP_Asset)uiFontAsset).material) && (Object)(object)((TMP_Text)val).font != (Object)(object)uiFontAsset) { ((TMP_Text)val).font = uiFontAsset; ((TMP_Text)val).fontSharedMaterial = ((TMP_Asset)uiFontAsset).material; } ((TMP_Text)val).text = string.Empty; ((TMP_Text)val).fontSize = Style.FontSize(16f); ((Graphic)val).color = Color.white; ((TMP_Text)val).alignment = (TextAlignmentOptions)513; ((TMP_Text)val).enableAutoSizing = false; ((TMP_Text)val).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)val).overflowMode = (TextOverflowModes)1; ((TMP_Text)val).richText = false; ((Graphic)val).raycastTarget = false; ((Component)val).gameObject.SetActive(true); RectTransform rectTransform = ((TMP_Text)val).rectTransform; rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.anchoredPosition = Vector2.zero; rectTransform.sizeDelta = Vector2.zero; return val; } public static TMP_InputField CreateInputField(Transform parentTransform, string placeholderText, float fontSize = 16f) { //IL_0029: 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_00c9: 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_0134: Unknown result type (might be due to invalid IL or missing references) //IL_0153: Unknown result type (might be due to invalid IL or missing references) fontSize = Style.FontSize(fontSize); GameObject val = CreateContainer(parentTransform, "InputField"); Image val2 = AddBackground(val, new Color(0f, 0f, 0f, 0.55f)); ((Graphic)val2).raycastTarget = true; Style.ApplyInput(val2); val.AddComponent<RectMask2D>(); TextMeshProUGUI val3 = CreateLabel(val.transform, "Text"); ((TMP_Text)val3).alignment = (TextAlignmentOptions)513; ((TMP_Text)val3).fontSize = fontSize; ((TMP_Text)val3).overflowMode = (TextOverflowModes)1; ((TMP_Text)val3).margin = new Vector4(8f, 0f, 8f, 0f); TextMeshProUGUI val4 = CreateLabel(val.transform, "Placeholder"); ((TMP_Text)val4).alignment = (TextAlignmentOptions)513; ((TMP_Text)val4).fontSize = fontSize; ((Graphic)val4).color = new Color(1f, 1f, 1f, 0.4f); ((TMP_Text)val4).text = placeholderText; ((TMP_Text)val4).margin = new Vector4(8f, 0f, 8f, 0f); TMP_InputField obj = val.AddComponent<TMP_InputField>(); obj.textViewport = val.GetComponent<RectTransform>(); obj.textComponent = (TMP_Text)(object)val3; obj.placeholder = (Graphic)(object)val4; obj.fontAsset = ((TMP_Text)val3).font; obj.pointSize = fontSize; obj.caretWidth = 2; obj.caretColor = Color.white; obj.selectionColor = new Color(0.3f, 0.6f, 1f, 0.5f); obj.lineType = (LineType)0; obj.onFocusSelectAll = false; obj.richText = false; ((Selectable)obj).targetGraphic = (Graphic)(object)val2; ((Behaviour)obj).enabled = false; ((Behaviour)obj).enabled = true; return obj; } public static Button CreateButton(Transform parentTransform, string buttonText, float width) { //IL_000c: 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) GameObject obj = CreateContainer(parentTransform, "Button"); AddBackground(obj, Color.white); LayoutElement obj2 = obj.AddComponent<LayoutElement>(); obj2.minWidth = width; obj2.preferredWidth = width; obj2.minHeight = 28f; obj2.preferredHeight = 28f; TextMeshProUGUI obj3 = CreateLabel(obj.transform, "Label"); ((TMP_Text)obj3).text = buttonText; ((TMP_Text)obj3).alignment = (TextAlignmentOptions)514; ((TMP_Text)obj3).fontSize = Style.FontSize(15f); ((Graphic)obj3).color = Color.white; Button obj4 = obj.AddComponent<Button>(); Style.ApplyButton(obj4); return obj4; } public static LayoutElement SetHeight(GameObject gameObject, float height) { LayoutElement obj = gameObject.AddComponent<LayoutElement>(); obj.minHeight = height; obj.preferredHeight = height; return obj; } public static LayoutElement SetFlexibleWidth(GameObject gameObject, float width) { LayoutElement obj = gameObject.AddComponent<LayoutElement>(); obj.flexibleWidth = width; return obj; } public static LayoutElement SetHalfWidth(GameObject gameObject) { LayoutElement obj = gameObject.AddComponent<LayoutElement>(); obj.preferredWidth = 0f; obj.flexibleWidth = 1f; return obj; } public static void Stretch(RectTransform rectTransform) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) Stretch(rectTransform, Vector4.zero); } public static void Stretch(RectTransform rectTransform, Vector4 padding) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0021: 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_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = Vector2.zero; rectTransform.anchorMax = Vector2.one; rectTransform.pivot = new Vector2(0.5f, 0.5f); rectTransform.offsetMin = new Vector2(padding.x, padding.y); rectTransform.offsetMax = new Vector2(0f - padding.z, 0f - padding.w); } private static Sprite CreateWhiteSprite() { //IL_0004: 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_0014: 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_0021: Unknown result type (might be due to invalid IL or missing references) //IL_003b: 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_0054: Expected O, but got Unknown Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false) { name = "Tractor.White" }; val.SetPixel(0, 0, Color.white); val.Apply(); Sprite obj = Sprite.Create(val, new Rect(0f, 0f, 1f, 1f), new Vector2(0.5f, 0.5f)); ((Object)obj).name = "Tractor.White"; return obj; } } public static class ZdoCatalog { private const string NameResourceName = "Tractor.catalog.tsv"; private const string KeyResourceName = "Tractor.keys.tsv"; private static Dictionary<int, string> _names; private static HashSet<int> _boolHashes; private static Dictionary<string, string[]> _classBases; private static Dictionary<string, List<ZdoKnownKey>> _classKeys; public static string GetName(int hash) { EnsureLoaded(); if (_names.TryGetValue(hash, out var value)) { return value; } return "<" + hash.ToString(CultureInfo.InvariantCulture) + ">"; } public static bool IsBool(int hash) { EnsureLoaded(); return _boolHashes.Contains(hash); } public static void Register(string name) { EnsureLoaded(); int stableHashCode = StringExtensionMethods.GetStableHashCode(name); if (!_names.ContainsKey(stableHashCode)) { _names.Add(stableHashCode, name); if (name.StartsWith("HasFields", StringComparison.Ordinal)) { _boolHashes.Add(stableHashCode); } } } public static void CollectKnownKeys(string className, Dictionary<int, ZdoKnownKey> keys) { EnsureLoaded(); CollectKnownKeys(className, keys, new HashSet<string>(StringComparer.Ordinal)); } private static void CollectKnownKeys(string className, Dictionary<int, ZdoKnownKey> keys, HashSet<string> visited) { if (!visited.Add(className)) { return; } if (_classKeys.TryGetValue(className, out