Please disclose if your mod was created primarily 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 ColorfulPieces v1.19.0
ColorfulPieces.dll
Decompiled 9 months ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using ComfyLib; using GUIFramework; using HarmonyLib; using Microsoft.CodeAnalysis; using Splatform; 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("ColorfulPieces")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("ColorfulPieces")] [assembly: AssemblyCopyright("Copyright © 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("bfaa6b86-51a5-42a3-83a5-af812a989c5a")] [assembly: AssemblyFileVersion("1.19.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.19.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ComfyLib { public sealed class ComfyArgs { public static readonly Regex CommandRegex = new Regex("^(?<command>\\w[\\w-]*)(?:\\s+--(?:(?<arg>\\w[\\w-]*)=(?:\"(?<value>[^\"]*?)\"|(?<value>\\S+))|no(?<argfalse>\\w[\\w-]*)|(?<argtrue>\\w[\\w-]*)))*"); public static readonly char[] CommaSeparator = new char[1] { ',' }; public readonly Dictionary<string, string> ArgsValueByName = new Dictionary<string, string>(); public ConsoleEventArgs Args { get; } public string Command { get; private set; } public ComfyArgs(ConsoleEventArgs args) { Args = args; ParseArgs(args.FullLine); } private void ParseArgs(string line) { Match match = CommandRegex.Match(line); Command = match.Groups["command"].Value; foreach (Capture capture3 in match.Groups["argtrue"].Captures) { ArgsValueByName[capture3.Value] = "true"; } foreach (Capture capture4 in match.Groups["argfalse"].Captures) { ArgsValueByName[capture4.Value] = "false"; } CaptureCollection captures = match.Groups["arg"].Captures; CaptureCollection captures2 = match.Groups["value"].Captures; for (int i = 0; i < captures.Count; i++) { ArgsValueByName[captures[i].Value] = ((i < captures2.Count) ? captures2[i].Value : string.Empty); } } public bool TryGetValue(string argName, out string argValue) { return ArgsValueByName.TryGetValue(argName, out argValue); } public bool TryGetValue(string argName, string argShortName, out string argValue) { if (!ArgsValueByName.TryGetValue(argName, out argValue)) { return ArgsValueByName.TryGetValue(argShortName, out argValue); } return true; } public bool TryGetValue<T>(string argName, out T argValue) { argValue = default(T); if (ArgsValueByName.TryGetValue(argName, out var value)) { return value.TryParseValue<T>(out argValue); } return false; } public bool TryGetValue<T>(string argName, string argShortName, out T argValue) { argValue = default(T); if (ArgsValueByName.TryGetValue(argName, out var value) || ArgsValueByName.TryGetValue(argShortName, out value)) { return value.TryParseValue<T>(out argValue); } return false; } public bool TryGetListValue<T>(string argName, string argShortName, out List<T> argListValue) { if (!ArgsValueByName.TryGetValue(argName, out var value) && !ArgsValueByName.TryGetValue(argShortName, out value)) { argListValue = null; return false; } string[] array = value.Split(CommaSeparator, StringSplitOptions.RemoveEmptyEntries); argListValue = new List<T>(array.Length); for (int i = 0; i < array.Length; i++) { if (!array[i].TryParseValue<T>(out var value2)) { return false; } argListValue.Add(value2); } return true; } public bool GetOptionalValue<T>(string argName, out T? argValue) { argValue = default(T); if (ArgsValueByName.TryGetValue(argName, out var value)) { return value.TryParseValue<T>(out argValue); } return true; } public bool GetOptionalValue<T>(string argName, string argShortName, out T? argValue) { argValue = default(T); if (ArgsValueByName.TryGetValue(argName, out var value) || ArgsValueByName.TryGetValue(argShortName, out value)) { return value.TryParseValue<T>(out argValue); } return true; } } [AttributeUsage(AttributeTargets.Method)] public sealed class ComfyCommand : Attribute { } public static class ComfyCommandUtils { [CompilerGenerated] private sealed class <RegisterCommands>d__5 : IEnumerable<ConsoleCommand>, IEnumerable, IEnumerator<ConsoleCommand>, IDisposable, IEnumerator { private int <>1__state; private ConsoleCommand <>2__current; private int <>l__initialThreadId; private MethodInfo method; public MethodInfo <>3__method; private IEnumerator<ConsoleCommand> <>7__wrap1; ConsoleCommand IEnumerator<ConsoleCommand>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <RegisterCommands>d__5(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || num == 2) { try { } finally { <>m__Finally1(); } } <>7__wrap1 = null; <>1__state = -2; } private bool MoveNext() { //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; if (IsRegisterCommandMethod(method)) { <>2__current = (ConsoleCommand)method.Invoke(null, null); <>1__state = 1; return true; } if (!IsRegisterCommandsMethod(method)) { break; } <>7__wrap1 = ((IEnumerable<ConsoleCommand>)method.Invoke(null, null)).GetEnumerator(); <>1__state = -3; goto IL_00bd; case 1: <>1__state = -1; break; case 2: { <>1__state = -3; goto IL_00bd; } IL_00bd: if (<>7__wrap1.MoveNext()) { ConsoleCommand current = <>7__wrap1.Current; <>2__current = current; <>1__state = 2; return true; } <>m__Finally1(); <>7__wrap1 = null; break; } return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap1 != null) { <>7__wrap1.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<ConsoleCommand> IEnumerable<ConsoleCommand>.GetEnumerator() { <RegisterCommands>d__5 <RegisterCommands>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <RegisterCommands>d__ = this; } else { <RegisterCommands>d__ = new <RegisterCommands>d__5(0); } <RegisterCommands>d__.method = <>3__method; return <RegisterCommands>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<ConsoleCommand>)this).GetEnumerator(); } } private static readonly List<ConsoleCommand> _commands = new List<ConsoleCommand>(); public static void ToggleCommands(bool toggleOn) { DeregisterCommands(_commands); _commands.Clear(); if (toggleOn) { _commands.AddRange(RegisterCommands(Assembly.GetExecutingAssembly())); } UpdateCommandLists(); } private static void UpdateCommandLists() { Terminal[] array = Object.FindObjectsOfType<Terminal>(true); for (int i = 0; i < array.Length; i++) { array[i].updateCommandList(); } } private static void DeregisterCommands(List<ConsoleCommand> commands) { foreach (ConsoleCommand command in commands) { if (Terminal.commands[command.Command] == command) { Terminal.commands.Remove(command.Command); } } } private static IEnumerable<ConsoleCommand> RegisterCommands(Assembly assembly) { return (from method in assembly.GetTypes().SelectMany((Type type) => type.GetMethods(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic)) where method.GetCustomAttributes(typeof(ComfyCommand), inherit: false).Length != 0 select method).SelectMany(RegisterCommands); } [IteratorStateMachine(typeof(<RegisterCommands>d__5))] private static IEnumerable<ConsoleCommand> RegisterCommands(MethodInfo method) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new <RegisterCommands>d__5(-2) { <>3__method = method }; } private static bool IsRegisterCommandMethod(MethodInfo method) { if (method.GetParameters().Length == 0) { return typeof(ConsoleCommand).IsAssignableFrom(method.ReturnType); } return false; } private static bool IsRegisterCommandsMethod(MethodInfo method) { if (method.GetParameters().Length == 0) { return typeof(IEnumerable<ConsoleCommand>).IsAssignableFrom(method.ReturnType); } return false; } } public sealed class ExtendedColorConfigEntry { private static readonly Texture2D _colorTexture = GUIBuilder.CreateColorTexture(10, 10, Color.white); private readonly HexColorTextField _hexInput = new HexColorTextField(); private readonly ColorPaletteDrawer _colorPalette; private bool _showSliders; public ConfigEntry<Color> ConfigEntry { get; } public Color Value { get; private set; } public ColorFloatTextField RedInput { get; } = new ColorFloatTextField("R"); public ColorFloatTextField GreenInput { get; } = new ColorFloatTextField("G"); public ColorFloatTextField BlueInput { get; } = new ColorFloatTextField("B"); public ColorFloatTextField AlphaInput { get; } = new ColorFloatTextField("A"); public IReadOnlyList<Color> GetPaletteColors() { return _colorPalette?.GetPaletteColors() ?? Array.Empty<Color>(); } public void SetPaletteColors(IEnumerable<Color> colors) { _colorPalette?.SetPaletteColors(colors); } public ExtendedColorConfigEntry(ConfigFile config, string section, string key, Color defaultValue, string description) { //IL_0055: 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) ConfigEntry = config.BindInOrder<Color>(section, key, defaultValue, description, (Action<ConfigEntryBase>)Drawer, browsable: true, hideDefaultButton: false, hideSettingName: false, isAdvanced: false, readOnly: false); SetValue(ConfigEntry.Value); } public ExtendedColorConfigEntry(ConfigFile config, string section, string key, Color defaultValue, string description, string colorPaletteKey) : this(config, section, key, defaultValue, description) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) ConfigEntry<string> paletteConfigEntry = config.BindInOrder(section, colorPaletteKey, ColorUtility.ToHtmlStringRGBA(defaultValue) + ",FF0000FF,00FF00FF,0000FFFF", "Color palette for: [" + section + "] " + key, (Action<ConfigEntryBase>)null, browsable: false, hideDefaultButton: false, hideSettingName: false, isAdvanced: false, readOnly: false); _colorPalette = new ColorPaletteDrawer(this, paletteConfigEntry); } public void SetValue(Color value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) ConfigEntry.Value = value; Value = value; RedInput.SetValue(value.r); GreenInput.SetValue(value.g); BlueInput.SetValue(value.b); AlphaInput.SetValue(value.a); _hexInput.SetValue(value); } public void Drawer(ConfigEntryBase configEntry) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Invalid comparison between Unknown and I4 //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01c1: Unknown result type (might be due to invalid IL or missing references) //IL_01cd: Unknown result type (might be due to invalid IL or missing references) //IL_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) Color val = (Color)configEntry.BoxedValue; if (GUIFocus.HasChanged() || GUIHelper.IsEnterPressed() || Value != val) { SetValue(val); } GUILayout.BeginVertical(GUI.skin.box, Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); _hexInput.DrawField(); GUILayout.Space(3f); GUIHelper.BeginColor(val); GUILayout.Label(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); if ((int)Event.current.type == 7) { GUI.DrawTexture(GUILayoutUtility.GetLastRect(), (Texture)(object)_colorTexture); } GUIHelper.EndColor(); GUILayout.Space(3f); if (GUILayout.Button(_showSliders ? "∨" : "≡", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(40f), GUILayout.ExpandWidth(false) })) { _showSliders = !_showSliders; } GUILayout.EndHorizontal(); if (_showSliders) { GUILayout.Space(4f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); RedInput.DrawField(); GUILayout.Space(3f); GreenInput.DrawField(); GUILayout.Space(3f); BlueInput.DrawField(); GUILayout.Space(3f); AlphaInput.DrawField(); GUILayout.EndHorizontal(); } if (_colorPalette != null) { GUILayout.Space(5f); _colorPalette.DrawColorPalette(); } GUILayout.EndVertical(); Color val2 = default(Color); ((Color)(ref val2))..ctor(RedInput.CurrentValue, GreenInput.CurrentValue, BlueInput.CurrentValue, AlphaInput.CurrentValue); if (val2 != val) { configEntry.BoxedValue = val2; SetValue(val2); } else if (_hexInput.CurrentValue != val) { configEntry.BoxedValue = _hexInput.CurrentValue; SetValue(_hexInput.CurrentValue); } } } public sealed class ColorPaletteDrawer { private static readonly char[] _partSeparator = new char[1] { ',' }; private static readonly string _partJoiner = ","; private static readonly Texture2D _colorTexture = GUIBuilder.CreateColorTexture(10, 10, Color.white); private readonly ExtendedColorConfigEntry _colorConfigEntry; private readonly ConfigEntry<string> _paletteConfigEntry; private readonly List<Color> _paletteColors; public IReadOnlyList<Color> GetPaletteColors() { return _paletteColors; } public void SetPaletteColors(IEnumerable<Color> colors) { _paletteColors.Clear(); _paletteColors.AddRange(colors); SavePalette(); } public ColorPaletteDrawer(ExtendedColorConfigEntry colorConfigEntry, ConfigEntry<string> paletteConfigEntry) { _colorConfigEntry = colorConfigEntry; _paletteConfigEntry = paletteConfigEntry; _paletteColors = new List<Color>(); LoadPalette(); } private void LoadPalette() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) _paletteColors.Clear(); string[] array = _paletteConfigEntry.Value.Split(_partSeparator, StringSplitOptions.RemoveEmptyEntries); Color item = default(Color); foreach (string text in array) { if (ColorUtility.TryParseHtmlString("#" + text, ref item)) { _paletteColors.Add(item); } } } private void SavePalette() { ((ConfigEntryBase)_paletteConfigEntry).BoxedValue = string.Join(_partJoiner, ((IEnumerable<Color>)_paletteColors).Select((Func<Color, string>)ColorUtility.ToHtmlStringRGBA)); } private bool PaletteColorButtons(out int colorIndex) { //IL_0050: Unknown result type (might be due to invalid IL or missing references) Texture2D background = GUI.skin.button.normal.background; GUI.skin.button.normal.background = _colorTexture; colorIndex = -1; GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int i = 0; i < _paletteColors.Count; i++) { GUIHelper.BeginColor(_paletteColors[i]); if (GUILayout.Button(string.Empty, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(20f), GUILayout.ExpandWidth(false) })) { colorIndex = i; } GUIHelper.EndColor(); if (i + 1 < _paletteColors.Count && (i + 1) % 8 == 0) { GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); } } GUILayout.EndHorizontal(); GUILayout.EndVertical(); GUI.skin.button.normal.background = background; return colorIndex >= 0; } private bool AddColorButton() { return GUILayout.Button("+", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(25f), GUILayout.ExpandWidth(false) }); } private bool RemoveColorButton() { return GUILayout.Button("−", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(25f), GUILayout.ExpandWidth(false) }); } private bool ResetColorsButton() { return GUILayout.Button("❇", (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.MinWidth(25f), GUILayout.ExpandWidth(false) }); } public void DrawColorPalette() { //IL_001e: 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) GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (AddColorButton()) { _paletteColors.Add(_colorConfigEntry.Value); SavePalette(); } GUILayout.Space(2f); if (PaletteColorButtons(out var colorIndex)) { if (Event.current.button == 0) { _colorConfigEntry.SetValue(_paletteColors[colorIndex]); } else if (Event.current.button == 1 && colorIndex >= 0 && colorIndex < _paletteColors.Count) { _paletteColors.RemoveAt(colorIndex); SavePalette(); } } GUILayout.FlexibleSpace(); if (_paletteColors.Count > 0) { if (RemoveColorButton()) { _paletteColors.RemoveAt(_paletteColors.Count - 1); SavePalette(); } } else if (ResetColorsButton()) { ((ConfigEntryBase)_paletteConfigEntry).BoxedValue = ((ConfigEntryBase)_paletteConfigEntry).DefaultValue; LoadPalette(); } GUILayout.EndHorizontal(); } } public sealed class ColorFloatTextField { private string _fieldText; private Color _fieldColor; public string Label { get; set; } public float CurrentValue { get; private set; } public float MinValue { get; private set; } public float MaxValue { get; private set; } public void SetValue(float value) { //IL_0030: 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) CurrentValue = Mathf.Clamp(value, MinValue, MaxValue); _fieldText = value.ToString("F3", CultureInfo.InvariantCulture); _fieldColor = GUI.color; } public void SetValueRange(float minValue, float maxValue) { MinValue = Mathf.Min(minValue, minValue); MaxValue = Mathf.Max(maxValue, maxValue); } public ColorFloatTextField(string label) { Label = label; SetValueRange(0f, 1f); } public void DrawField() { //IL_002f: 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_010e: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Unknown result type (might be due to invalid IL or missing references) GUILayout.BeginVertical(Array.Empty<GUILayoutOption>()); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); GUILayout.Label(Label, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUIHelper.BeginColor(_fieldColor); string text = GUILayout.TextField(_fieldText, (GUILayoutOption[])(object)new GUILayoutOption[3] { GUILayout.MinWidth(45f), GUILayout.MaxWidth(55f), GUILayout.ExpandWidth(true) }); GUIHelper.EndColor(); GUILayout.EndHorizontal(); GUILayout.Space(2f); float num = GUILayout.HorizontalSlider(CurrentValue, MinValue, MaxValue, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.ExpandWidth(true) }); GUILayout.EndVertical(); if (num != CurrentValue) { SetValue(num); } else if (!(text == _fieldText)) { if (float.TryParse(text, NumberStyles.Any, CultureInfo.InvariantCulture, out var result) && result >= MinValue && result <= MaxValue) { CurrentValue = result; _fieldColor = GUI.color; } else { _fieldColor = Color.red; } _fieldText = text; } } } public sealed class HexColorTextField { private Color _textColor = GUI.color; public Color CurrentValue { get; private set; } public string CurrentText { get; private set; } public void SetValue(Color value) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_0033: 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) CurrentValue = value; CurrentText = "#" + ((value.a == 1f) ? ColorUtility.ToHtmlStringRGB(value) : ColorUtility.ToHtmlStringRGBA(value)); _textColor = GUI.color; } public void DrawField() { //IL_0001: 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_0066: 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) GUIHelper.BeginColor(_textColor); string text = GUILayout.TextField(CurrentText, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(90f), GUILayout.ExpandWidth(false) }); GUIHelper.EndColor(); if (!(text == CurrentText)) { CurrentText = text; Color currentValue = default(Color); if (ColorUtility.TryParseHtmlString(text, ref currentValue)) { CurrentValue = currentValue; } else { _textColor = Color.red; } } } } public static class GUIBuilder { public static Texture2D CreateColorTexture(int width, int height, Color color) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Unknown result type (might be due to invalid IL or missing references) return CreateColorTexture(width, height, color, 0, color); } public static Texture2D CreateColorTexture(int width, int height, Color color, int radius, Color outsideColor) { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) if (width <= 0 || height <= 0) { throw new ArgumentException("Texture width and height must be > 0."); } if (radius < 0 || radius > width || radius > height) { throw new ArgumentException("Texture radius must be >= 0 and < width/height."); } Texture2D val = new Texture2D(width, height, (TextureFormat)5, false); ((Object)val).name = $"w-{width}-h-{height}-rad-{radius}-color-{ColorId(color)}-ocolor-{ColorId(outsideColor)}"; ((Texture)val).wrapMode = (TextureWrapMode)1; ((Texture)val).filterMode = (FilterMode)2; Texture2D val2 = val; Color[] array = (Color[])(object)new Color[width * height]; for (int i = 0; i < height; i++) { for (int j = 0; j < width; j++) { array[i * width + j] = (IsCornerPixel(j, i, width, height, radius) ? outsideColor : color); } } val2.SetPixels(array); val2.Apply(); return val2; } private static string ColorId(Color color) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) return $"{color.r:F3}r-{color.g:F3}g-{color.b:F3}b-{color.a:F3}a"; } private static bool IsCornerPixel(int x, int y, int w, int h, int rad) { if (rad == 0) { return false; } int num = Math.Min(x, w - x); int num2 = Math.Min(y, h - y); if (num == 0 && num2 == 0) { return true; } if (num > rad || num2 > rad) { return false; } num = rad - num; num2 = rad - num2; return Math.Round(Math.Sqrt(num * num + num2 * num2)) > (double)rad; } } public static class GUIFocus { private static int _lastFrameCount; private static int _lastHotControl; private static int _lastKeyboardControl; private static bool _hasChanged; public static bool HasChanged() { int frameCount = Time.frameCount; if (_lastFrameCount == frameCount) { return _hasChanged; } _lastFrameCount = frameCount; int hotControl = GUIUtility.hotControl; int keyboardControl = GUIUtility.keyboardControl; _hasChanged = hotControl != _lastHotControl || keyboardControl != _lastKeyboardControl; if (_hasChanged) { _lastHotControl = hotControl; _lastKeyboardControl = keyboardControl; } return _hasChanged; } } public static class GUIHelper { private static readonly Stack<Color> _colorStack = new Stack<Color>(); public static void BeginColor(Color color) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) _colorStack.Push(GUI.color); GUI.color = color; } public static void EndColor() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) GUI.color = _colorStack.Pop(); } public static bool IsEnterPressed() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Invalid comparison between Unknown and I4 //IL_001f: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if (Event.current.isKey) { if ((int)Event.current.keyCode != 13) { return (int)Event.current.keyCode == 271; } return true; } return false; } } 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, 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, acceptableValues, new object[1] { new ConfigurationManagerAttributes { Browsable = browsable, CustomDrawer = null, HideDefaultButton = hideDefaultButton, HideSettingName = hideSettingName, IsAdvanced = isAdvanced, Order = GetSettingOrder(section), ReadOnly = readOnly } })); } 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>)((SettingChangedEventArgs)eventArgs).ChangedSetting.BoxedValue); }; } } public static class StringExtensions { public static readonly char[] CommaSeparator = new char[1] { ',' }; public static readonly char[] ColonSeparator = new char[1] { ':' }; public static bool TryParseValue<T>(this string text, out T value) { //IL_005d: 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_00c1: 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) Type type = typeof(T); try { Type underlyingType = Nullable.GetUnderlyingType(type); if (underlyingType != null) { type = underlyingType; } Vector2 value2; Vector3 value3; Quaternion value4; ZDOID value5; if (type == typeof(string)) { value = (T)(object)text; } else if (type == typeof(Vector2) && text.TryParseVector2(out value2)) { value = (T)(object)value2; } else if (type == typeof(Vector3) && text.TryParseVector3(out value3)) { value = (T)(object)value3; } else if (type == typeof(Quaternion) && text.TryParseQuaternion(out value4)) { value = (T)(object)value4; } else if (type == typeof(ZDOID) && text.TryParseZDOID(out value5)) { value = (T)(object)value5; } else if (type.IsEnum) { value = (T)Enum.Parse(type, text); } else { value = (T)Convert.ChangeType(text, type); } return true; } catch (Exception arg) { Debug.LogError((object)$"Failed to convert value '{text}' to type {typeof(T)}: {arg}"); } value = default(T); return false; } public static bool TryParseVector2(this string text, out Vector2 value) { //IL_0050: 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_0048: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2)) { value = new Vector2(result, result2); return true; } value = default(Vector2); return false; } public static bool TryParseVector3(this string text, out Vector3 value) { //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 3, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 3 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3)) { value = new Vector3(result, result2, result3); return true; } value = default(Vector3); return false; } public static bool TryParseQuaternion(this string text, out Quaternion value) { //IL_007f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(CommaSeparator, 4, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 4 && float.TryParse(array[0], NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && float.TryParse(array[1], NumberStyles.Float, CultureInfo.InvariantCulture, out var result2) && float.TryParse(array[2], NumberStyles.Float, CultureInfo.InvariantCulture, out var result3) && float.TryParse(array[3], NumberStyles.Float, CultureInfo.InvariantCulture, out var result4)) { value = new Quaternion(result, result2, result3, result4); return true; } value = default(Quaternion); return false; } public static bool TryParseZDOID(this string text, out ZDOID value) { //IL_0048: 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_0040: Unknown result type (might be due to invalid IL or missing references) string[] array = text.Split(ColonSeparator, 2, StringSplitOptions.RemoveEmptyEntries); if (array.Length == 2 && long.TryParse(array[0], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result) && uint.TryParse(array[1], NumberStyles.Integer, CultureInfo.InvariantCulture, out var result2)) { value = new ZDOID(result, result2); return true; } value = default(ZDOID); return false; } } public static class ChatExtensions { public static void AddMessage(this Chat chat, object obj) { if (Object.op_Implicit((Object)(object)chat)) { ((Terminal)chat).AddString(obj.ToString()); chat.m_hideTimer = 0f; } } } public static class ComponentExtensions { public static bool TryGetComponentInChildren<T>(this GameObject gameObject, out T component) where T : Component { component = gameObject.GetComponentInChildren<T>(); return Object.op_Implicit((Object)(object)component); } public static bool TryGetComponentInParent<T>(this GameObject gameObject, out T component) where T : Component { component = gameObject.GetComponentInParent<T>(); return Object.op_Implicit((Object)(object)component); } } public static class ObjectExtensions { public static T FirstByNameOrThrow<T>(this T[] unityObjects, string name) where T : Object { foreach (T val in unityObjects) { if (((Object)val).name == name) { return val; } } throw new InvalidOperationException($"Could not find Unity object of type {typeof(T)} with name: {name}"); } public static T Ref<T>(this T unityObject) where T : Object { if (!Object.op_Implicit((Object)(object)unityObject)) { return default(T); } return unityObject; } } public static class ZDOExtensions { public static bool TryGetVector3(this ZDO zdo, int keyHashCode, out Vector3 value) { //IL_0006: 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) if (ZDOExtraData.s_vec3.TryGetValue(zdo.m_uid, out var value2) && value2.TryGetValue(keyHashCode, ref value)) { return true; } value = default(Vector3); return false; } public static bool TryGetFloat(this ZDO zdo, int keyHashCode, out float value) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) if (ZDOExtraData.s_floats.TryGetValue(zdo.m_uid, out var value2) && value2.TryGetValue(keyHashCode, ref value)) { return true; } value = 0f; return false; } } public sealed class ColorSlider { public GameObject Container { get; private set; } public RectTransform RectTransform { get; private set; } public TextMeshProUGUI NameLabel { get; private set; } public GuiInputField ValueInputField { get; private set; } public GameObject SliderContainer { get; private set; } public RectTransform SliderRectTransform { get; private set; } public Image Background { get; private set; } public GameObject Fill { get; private set; } public Image FillImage { get; private set; } public GameObject Handle { get; private set; } public Image HandleImage { get; private set; } public Slider Slider { get; private set; } public bool ShowValueAsPercent { get; set; } public float RawValue => Slider.value; public float PercentValue => Slider.value / Slider.maxValue; public ColorSlider(Transform parentTransform) { Container = CreateContainer(parentTransform); RectTransform = Container.GetComponent<RectTransform>(); NameLabel = CreateNameLabel((Transform)(object)RectTransform); ValueInputField = CreateValueInputField((Transform)(object)RectTransform); ((UnityEvent<string>)(object)ValueInputField.OnInputSubmit).AddListener((UnityAction<string>)OnValueInputFieldChanged); SliderContainer = CreateSliderContainer((Transform)(object)RectTransform); SliderRectTransform = SliderContainer.GetComponent<RectTransform>(); Background = CreateBackground((Transform)(object)SliderRectTransform); Fill = CreateFill((Transform)(object)SliderRectTransform); FillImage = Fill.GetComponent<Image>(); Handle = CreateHandle((Transform)(object)SliderRectTransform); HandleImage = Handle.GetComponent<Image>(); Slider = SliderContainer.AddComponent<Slider>(); SliderExtensions.SetHandleRect<Slider>(Slider.SetDirection<Slider>((Direction)0).SetFillRect<Slider>(Fill.GetComponent<RectTransform>()), Handle.GetComponent<RectTransform>()).SetTargetGraphic<Slider>((Graphic)(object)FillImage).SetTransition<Slider>((Transition)0); ((UnityEvent<float>)(object)Slider.onValueChanged).AddListener((UnityAction<float>)SetValueLabelText); } public void SetValueWithoutNotify(float value) { Slider.SetValueWithoutNotify(value); SetValueLabelText(value); } public void SetValueLabelText(float value) { ((TMP_InputField)ValueInputField).SetTextWithoutNotify(ShowValueAsPercent ? $"{value:F2}" : $"{value:0.####}"); } private void OnValueInputFieldChanged(string text) { if (float.TryParse(text, out var result) && Mathf.Clamp(result, Slider.minValue, Slider.maxValue) != Slider.value) { Slider.SetValue<Slider>(result); } else { SetValueLabelText(Slider.value); } } public void SetInteractable(bool interactable) { Slider.SetInteractable<Slider>(interactable); Handle.SetActive(interactable); ValueInputField.SetInteractable<GuiInputField>(interactable); } private static GameObject CreateContainer(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Expected O, but got Unknown GameObject val = new GameObject("ColorSlider", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.right) .SetPivot(Vector2.zero) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(0f, 25f)); return val; } private static TextMeshProUGUI CreateNameLabel(Transform parentTransform) { //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_0035: 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_005d: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateTMPLabel(parentTransform); ((Object)obj).name = "Name"; ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.up).SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(new Vector2(20f, 0f)) .SetSizeDelta(new Vector2(40f, 0f)); obj.SetFontSize<TextMeshProUGUI>(20f).SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)4097); ((TMP_Text)obj).text = "X"; return obj; } private static GuiInputField CreateValueInputField(Transform parentTransform) { //IL_0021: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) GuiInputField obj = UIBuilder.CreateInputField(parentTransform); ((Object)obj).name = "Value"; ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(new Vector2(1f, 0.5f)).SetAnchorMax(new Vector2(1f, 0.5f)) .SetPivot(new Vector2(1f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(65f, 35f)); ((TMP_InputField)obj).textComponent.SetFontSize<TMP_Text>(18f); ((TMP_Text)((Component)((TMP_InputField)obj).placeholder).GetComponent<TextMeshProUGUI>().SetFontSize<TextMeshProUGUI>(18f)).SetText("0"); ((TMP_InputField)obj).SetTextWithoutNotify("0"); ((TMP_InputField)obj).characterValidation = (CharacterValidation)3; ((TMP_InputField)obj).onFocusSelectAll = false; ((TMP_InputField)obj).m_DoubleClickDelay = 0.2f; return obj; } private static GameObject CreateSliderContainer(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Expected O, but got Unknown GameObject val = new GameObject("Slider", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0f, 0.5f)) .SetPosition(new Vector2(25f, 0f)) .SetSizeDelta(new Vector2(-105f, 0f)); return val; } private static Image CreateBackground(Transform parentTransform) { //IL_0018: 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_002a: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0074: 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_0088: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Background", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); Image val2 = val.AddComponent<Image>(); val2.SetColor(new Color(0.271f, 0.271f, 0.271f, 1f)); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); return val2; } private static GameObject CreateFill(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown GameObject val = new GameObject("Fill", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.AddComponent<Image>().SetColor(Color.white); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); return val; } private static GameObject CreateHandle(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: 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_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00b1: Expected O, but got Unknown GameObject val = new GameObject("Handle", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.AddComponent<Image>().SetColor(new Color(0f, 0f, 0f, 0.95f)); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(10f, 10f)); return val; } } public sealed class ColorSquare { private sealed class SquareInteraction : MonoBehaviour, IDragHandler, IEventSystemHandler, IPointerDownHandler { public event EventHandler<Vector2> OnClick; public void OnDrag(PointerEventData eventData) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) this.OnClick?.Invoke(this, eventData.position); } public void OnPointerDown(PointerEventData eventData) { //IL_000d: Unknown result type (might be due to invalid IL or missing references) this.OnClick?.Invoke(this, eventData.position); } } private readonly SquareInteraction _squareInteraction; public GameObject Container { get; } public RectTransform RectTransform { get; } public GameObject Square { get; } public Image SquareImage { get; } public Texture2D SquareTexture { get; } public ColorSquare(Transform parentTransform) { Container = CreateContainer(parentTransform); RectTransform = Container.GetComponent<RectTransform>(); Square = CreateSquare(Container.transform); SquareImage = Square.GetComponent<Image>(); SquareTexture = SquareImage.sprite.texture; _squareInteraction = Square.AddComponent<SquareInteraction>(); _squareInteraction.OnClick += OnSquareClick; } private void OnSquareClick(object sender, Vector2 position) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) //IL_007a: Unknown result type (might be due to invalid IL or missing references) Vector2 val = default(Vector2); RectTransformUtility.ScreenPointToLocalPointInRectangle(RectTransform, position, (Camera)null, ref val); Rect rect = RectTransform.rect; float num = (val.x - ((Rect)(ref rect)).x) * (float)((Texture)SquareTexture).width / ((Rect)(ref rect)).width; float num2 = (val.y - ((Rect)(ref rect)).y) * (float)((Texture)SquareTexture).height / ((Rect)(ref rect)).height; ZLog.Log((object)$"SquareClick: {position} --> {val} --> {num},{num2}"); } private static GameObject CreateContainer(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Expected O, but got Unknown GameObject val = new GameObject("ColorSquare", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(150f, 150f)); return val; } private static GameObject CreateSquare(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Expected O, but got Unknown GameObject val = new GameObject("Square", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); val.AddComponent<Image>().SetSprite(CreateSquareSprite(100)).SetPreserveAspect(preserveAspect: true) .SetColor(Color.white); return val; } private static Sprite CreateSquareSprite(int length) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown Sprite obj = Sprite.Create(new Texture2D(length, length) { name = "SquareTexture", wrapMode = (TextureWrapMode)1 }, new Rect(0f, 0f, (float)length, (float)length), new Vector2(0.5f, 0.5f)); ((Object)obj).name = "SquareSprite"; return obj; } } public sealed class LabelButton { public GameObject Container { get; private set; } public RectTransform RectTransform { get; } public TextMeshProUGUI Label { get; private set; } public Button Button { get; private set; } public LabelButton(Transform parentTransform) { Container = CreateContainer(parentTransform); RectTransform = Container.GetComponent<RectTransform>(); Label = CreateLabel((Transform)(object)RectTransform); Button = CreateButton(Container); } public void AddOnClickListener(UnityAction action) { ((UnityEvent)Button.onClick).AddListener(action); } private static GameObject CreateContainer(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_0060: 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) //IL_0088: 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_00a6: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Expected O, but got Unknown GameObject val = new GameObject("Button", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("button")) .SetColor(Color.white); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(120f, 45f)); return val; } private static TextMeshProUGUI CreateLabel(Transform parentTransform) { //IL_002b: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = UIBuilder.CreateTMPLabel(parentTransform); ((TMP_Text)obj.SetFontSize<TextMeshProUGUI>(16f).SetAlignment<TextMeshProUGUI>((TextAlignmentOptions)514)).SetText("Button"); ((TMP_Text)obj).rectTransform.SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one).SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); return obj; } private static Button CreateButton(GameObject container) { //IL_000f: 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) Button obj = container.AddComponent<Button>(); Button selectable = obj.SetTransition<Button>((Transition)2); SpriteState spriteState = default(SpriteState); ((SpriteState)(ref spriteState)).disabledSprite = UIResources.GetSprite("button_disabled"); ((SpriteState)(ref spriteState)).highlightedSprite = UIResources.GetSprite("button_highlight"); ((SpriteState)(ref spriteState)).pressedSprite = UIResources.GetSprite("button_pressed"); ((SpriteState)(ref spriteState)).selectedSprite = UIResources.GetSprite("button_highlight"); selectable.SetSpriteState<Button>(spriteState); return obj; } } public sealed class ListView { public GameObject Container { get; private set; } public Image Background { get; private set; } public GameObject Viewport { get; private set; } public GameObject Content { get; private set; } public VerticalLayoutGroup ContentLayoutGroup { get; private set; } public ScrollRect ScrollRect { get; private set; } public ListView(Transform parentTransform) { Container = CreateContainer(parentTransform); Background = Container.GetComponent<Image>(); Viewport = CreateViewport(Container.transform); Content = CreateContent(Viewport.transform); ContentLayoutGroup = Content.GetComponent<VerticalLayoutGroup>(); ScrollRect = CreateScrollRect(Container, Viewport, Content); } private static GameObject CreateContainer(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: 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_006a: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown GameObject val = new GameObject("ListView", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetSizeDelta(Vector2.zero); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("item_background")) .SetColor(new Color(0f, 0f, 0f, 0.5f)); return val; } private static GameObject CreateViewport(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007f: Expected O, but got Unknown GameObject val = new GameObject("Viewport", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(-10f, -10f)); val.AddComponent<RectMask2D>(); return val; } private static GameObject CreateContent(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0096: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown GameObject val = new GameObject("Content", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.up).SetAnchorMax(Vector2.one) .SetPivot(Vector2.up) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); val.AddComponent<VerticalLayoutGroup>().SetChildControl<VerticalLayoutGroup>((bool?)true, (bool?)true).SetChildForceExpand<VerticalLayoutGroup>((bool?)false, (bool?)false) .SetSpacing<VerticalLayoutGroup>(0f); val.AddComponent<ContentSizeFitter>().SetHorizontalFit((FitMode)0).SetVerticalFit((FitMode)2); return val; } private static ScrollRect CreateScrollRect(GameObject view, GameObject viewport, GameObject content) { ScrollRect obj = view.AddComponent<ScrollRect>().SetViewport<ScrollRect>(viewport.GetComponent<RectTransform>()).SetContent<ScrollRect>(content.GetComponent<RectTransform>()) .SetHorizontal<ScrollRect>(horizontal: false) .SetVertical<ScrollRect>(vertical: true) .SetScrollSensitivity<ScrollRect>(20f) .SetMovementType<ScrollRect>((MovementType)2); Scrollbar val = UIBuilder.CreateScrollbar(view.transform); val.direction = (Direction)2; obj.SetVerticalScrollbar<ScrollRect>(val).SetVerticalScrollbarVisibility<ScrollRect>((ScrollbarVisibility)0); return obj; } } public sealed class IgnoreDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IEndDragHandler, IDragHandler { public void OnBeginDrag(PointerEventData eventData) { } public void OnDrag(PointerEventData eventData) { } public void OnEndDrag(PointerEventData eventData) { } } public sealed class PanelDragger : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler, IEndDragHandler { private RectTransform _targetRectTransform; private Vector2 _lastMousePosition; private void Start() { _targetRectTransform = ((Component)this).GetComponent<RectTransform>(); } public void OnBeginDrag(PointerEventData eventData) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) _lastMousePosition = eventData.position; } public void OnDrag(PointerEventData eventData) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_001e: Unknown result type (might be due to invalid IL or missing references) //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Unknown result type (might be due to invalid IL or missing references) Vector2 val = eventData.position - _lastMousePosition; RectTransform targetRectTransform = _targetRectTransform; ((Transform)targetRectTransform).position = ((Transform)targetRectTransform).position + new Vector3(val.x, val.y, 0f); _lastMousePosition = eventData.position; } public void OnEndDrag(PointerEventData eventData) { } } public static class UIBuilder { public static readonly ColorBlock ScrollbarColors; private static readonly Dictionary<string, Sprite> _checkerboardSpriteCache; public static TextMeshProUGUI CreateTMPLabel(Transform parentTransform) { //IL_002f: Unknown result type (might be due to invalid IL or missing references) TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.bodyText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 16f; ((TMP_Text)obj).richText = true; ((Graphic)obj).color = Color.white; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = string.Empty; return obj; } public static TextMeshProUGUI CreateTMPHeaderLabel(Transform parentTransform) { TextMeshProUGUI obj = Object.Instantiate<TextMeshProUGUI>(UnifiedPopup.instance.headerText, parentTransform, false); ((Object)obj).name = "Label"; ((TMP_Text)obj).fontSize = 32f; ((TMP_Text)obj).richText = true; ((TMP_Text)obj).enableAutoSizing = false; ((TMP_Text)obj).textWrappingMode = (TextWrappingModes)0; ((TMP_Text)obj).overflowMode = (TextOverflowModes)0; ((TMP_Text)obj).text = string.Empty; return obj; } public static GameObject CreatePanel(Transform parentTransform) { //IL_0018: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Unknown result type (might be due to invalid IL or missing references) //IL_008b: 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_00c1: Expected O, but got Unknown GameObject val = new GameObject("Panel", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(275f, 350f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("woodpanel_trophys")) .SetMaterial(UIResources.GetMaterial("litpanel")) .SetColor(Color.white); return val; } public static Scrollbar CreateScrollbar(Transform parentTransform) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected O, but got Unknown //IL_0031: 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_0045: 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_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0089: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00b8: Expected O, but got Unknown //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_0102: Unknown result type (might be due to invalid IL or missing references) //IL_0125: Unknown result type (might be due to invalid IL or missing references) //IL_012a: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0174: Unknown result type (might be due to invalid IL or missing references) //IL_017e: Unknown result type (might be due to invalid IL or missing references) //IL_0188: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) GameObject val = new GameObject("Scrollbar", new Type[1] { typeof(RectTransform) }); val.transform.SetParent(parentTransform, false); val.GetComponent<RectTransform>().SetAnchorMin(Vector2.right).SetAnchorMax(Vector2.one) .SetPivot(Vector2.one) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(10f, 0f)); val.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("Background")) .SetColor(Color.black) .SetRaycastTarget(raycastTarget: true); GameObject val2 = new GameObject("SlidingArea", new Type[1] { typeof(RectTransform) }); val2.transform.SetParent(val.transform, false); val2.GetComponent<RectTransform>().SetAnchorMin(Vector2.zero).SetAnchorMax(Vector2.one) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); GameObject val3 = new GameObject("Handle", new Type[1] { typeof(RectTransform) }); val3.transform.SetParent(val2.transform, false); RectTransform handleRect = val3.GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(Vector2.zero); Image graphic = val3.AddComponent<Image>().SetType((Type)1).SetSprite(UIResources.GetSprite("UISprite")) .SetColor(Color.white) .SetPixelsPerUnitMultiplier(0.7f); return ScrollbarExtensions.SetHandleRect<Scrollbar>(val.AddComponent<Scrollbar>().SetTargetGraphic<Scrollbar>((Graphic)(object)graphic).SetTransition<Scrollbar>((Transition)1) .SetColors<Scrollbar>(ScrollbarColors) .SetDirection<Scrollbar>((Direction)3), handleRect); } public static Slider CreateSlider(Transform parentTransform) { Slider obj = Object.Instantiate<Slider>(InventoryGui.m_instance.m_splitSlider, parentTransform); ((Object)obj).name = "Slider"; return obj; } public static GuiInputField CreateInputField(Transform parentTransform) { //IL_0021: 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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) GuiInputField obj = Object.Instantiate<GuiInputField>(TextInput.instance.m_inputField, parentTransform, false); ((Component)obj).GetComponent<RectTransform>().SetAnchorMin(new Vector2(0.5f, 0.5f)).SetAnchorMax(new Vector2(0.5f, 0.5f)) .SetPivot(new Vector2(0.5f, 0.5f)) .SetPosition(Vector2.zero) .SetSizeDelta(new Vector2(120f, 40f)); ((Component)obj).GetComponentInChildren<RectMask2D>().SetPadding<RectMask2D>(Vector4.zero); return obj; } public static Sprite CreateCheckerboardSprite(int width, int height, int length = 10) { //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_0049: Expected O, but got Unknown //IL_00aa: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0066: Unknown result type (might be due to invalid IL or missing references) string text = $"CheckerboardSprite-{width}-{height}-{length}"; if (_checkerboardSpriteCache.TryGetValue(text, out var value) && Object.op_Implicit((Object)(object)value)) { return value; } Texture2D val = new Texture2D(width, height) { name = "CheckerboardTexture" }; for (int i = 0; i < width; i++) { for (int j = 0; j < height; j++) { val.SetPixel(i, j, ((i / length + j / length) % 2 == 1) ? Color.black : Color.white); } } val.SetWrapMode((TextureWrapMode)0); val.Apply(); Sprite val2 = Sprite.Create(val, new Rect(0f, 0f, (float)width, (float)height), new Vector2(0.5f, 0.5f)); ((Object)val2).name = text; _checkerboardSpriteCache[text] = val2; return val2; } static UIBuilder() { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_005b: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0089: 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) ColorBlock scrollbarColors = default(ColorBlock); ((ColorBlock)(ref scrollbarColors)).normalColor = Color.white; ((ColorBlock)(ref scrollbarColors)).highlightedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref scrollbarColors)).selectedColor = new Color(1f, 0.75f, 0f); ((ColorBlock)(ref scrollbarColors)).pressedColor = new Color(1f, 0.67f, 0.11f); ((ColorBlock)(ref scrollbarColors)).disabledColor = Color.gray; ((ColorBlock)(ref scrollbarColors)).colorMultiplier = 1f; ((ColorBlock)(ref scrollbarColors)).fadeDuration = 0.15f; ScrollbarColors = scrollbarColors; _checkerboardSpriteCache = new Dictionary<string, Sprite>(); } } public static class CanvasGroupExtensions { public static CanvasGroup SetAlpha(this CanvasGroup canvasGroup, float alpha) { canvasGroup.alpha = alpha; return canvasGroup; } public static CanvasGroup SetBlocksRaycasts(this CanvasGroup canvasGroup, bool blocksRaycasts) { canvasGroup.blocksRaycasts = blocksRaycasts; return canvasGroup; } } public static class ColorExtensions { public static Color SetAlpha(this Color color, float alpha) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) color.a = alpha; return color; } } public static class ContentSizeFitterExtensions { public static ContentSizeFitter SetHorizontalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.horizontalFit = fitMode; return fitter; } public static ContentSizeFitter SetVerticalFit(this ContentSizeFitter fitter, FitMode fitMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) fitter.verticalFit = fitMode; return fitter; } } public static class GridLayoutGroupExtensions { public static GridLayoutGroup SetCellSize(this GridLayoutGroup layoutGroup, Vector2 cellSize) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.cellSize = cellSize; return layoutGroup; } public static GridLayoutGroup SetConstraint(this GridLayoutGroup layoutGroup, Constraint constraint) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.constraint = constraint; return layoutGroup; } public static GridLayoutGroup SetConstraintCount(this GridLayoutGroup layoutGroup, int constraintCount) { layoutGroup.constraintCount = constraintCount; return layoutGroup; } public static GridLayoutGroup SetStartAxis(this GridLayoutGroup layoutGroup, Axis startAxis) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startAxis = startAxis; return layoutGroup; } public static GridLayoutGroup SetStartCorner(this GridLayoutGroup layoutGroup, Corner startCorner) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.startCorner = startCorner; return layoutGroup; } public static GridLayoutGroup SetSpacing(this GridLayoutGroup layoutGroup, Vector2 spacing) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) layoutGroup.spacing = spacing; return layoutGroup; } } public static class LayoutGroupExtensions { public static T SetChildAlignment<T>(this T layoutGroup, TextAnchor alignment) where T : LayoutGroup { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((LayoutGroup)layoutGroup).childAlignment = alignment; return layoutGroup; } public static T SetChildControl<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childControlHeight = height.Value; } return layoutGroup; } public static T SetChildForceExpand<T>(this T layoutGroup, bool? width = null, bool? height = null) where T : HorizontalOrVerticalLayoutGroup { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandWidth = width.Value; } if (height.HasValue) { ((HorizontalOrVerticalLayoutGroup)layoutGroup).childForceExpandHeight = height.Value; } return layoutGroup; } public static T SetPadding<T>(this T layoutGroup, int? left = null, int? right = null, int? top = null, int? bottom = null) where T : HorizontalOrVerticalLayoutGroup { if (!left.HasValue && !right.HasValue && !top.HasValue && !bottom.HasValue) { throw new ArgumentException("Value for left, right, top or bottom must be provided."); } if (left.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.left = left.Value; } if (right.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.right = right.Value; } if (top.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.top = top.Value; } if (bottom.HasValue) { ((LayoutGroup)(object)layoutGroup).padding.bottom = bottom.Value; } return layoutGroup; } public static T SetSpacing<T>(this T layoutGroup, float spacing) where T : HorizontalOrVerticalLayoutGroup { ((HorizontalOrVerticalLayoutGroup)layoutGroup).spacing = spacing; return layoutGroup; } } public static class ImageExtensions { public static Image SetColor(this Image image, Color color) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Graphic)image).color = color; return image; } public static Image SetFillAmount(this Image image, float amount) { image.fillAmount = amount; return image; } public static Image SetFillCenter(this Image image, bool fillCenter) { image.fillCenter = fillCenter; return image; } public static Image SetFillMethod(this Image image, FillMethod fillMethod) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.fillMethod = fillMethod; return image; } public static Image SetFillOrigin(this Image image, OriginHorizontal origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetFillOrigin(this Image image, OriginVertical origin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Expected I4, but got Unknown image.fillOrigin = (int)origin; return image; } public static Image SetMaskable(this Image image, bool maskable) { ((MaskableGraphic)image).maskable = maskable; return image; } public static Image SetMaterial(this Image image, Material material) { ((Graphic)image).material = material; return image; } public static Image SetPixelsPerUnitMultiplier(this Image image, float pixelsPerUnitMultiplier) { image.pixelsPerUnitMultiplier = pixelsPerUnitMultiplier; return image; } public static Image SetPreserveAspect(this Image image, bool preserveAspect) { image.preserveAspect = preserveAspect; return image; } public static Image SetRaycastTarget(this Image image, bool raycastTarget) { ((Graphic)image).raycastTarget = raycastTarget; return image; } public static Image SetSprite(this Image image, Sprite sprite) { image.sprite = sprite; return image; } public static Image SetType(this Image image, Type type) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) image.type = type; return image; } } public static class LayoutElementExtensions { public static LayoutElement SetFlexible(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.flexibleWidth = width.Value; } if (height.HasValue) { layoutElement.flexibleHeight = height.Value; } return layoutElement; } public static LayoutElement SetIgnoreLayout(this LayoutElement layoutElement, bool ignoreLayout) { layoutElement.ignoreLayout = ignoreLayout; return layoutElement; } public static LayoutElement SetMinimum(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.minWidth = width.Value; } if (height.HasValue) { layoutElement.minHeight = height.Value; } return layoutElement; } public static LayoutElement SetPreferred(this LayoutElement layoutElement, float? width = null, float? height = null) { if (!width.HasValue && !height.HasValue) { throw new ArgumentException("Value for width or height must be provided."); } if (width.HasValue) { layoutElement.preferredWidth = width.Value; } if (height.HasValue) { layoutElement.preferredHeight = height.Value; } return layoutElement; } } public static class RectMask2DExtensions { public static T SetPadding<T>(this T rectMask, Vector4 padding) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).padding = padding; return rectMask; } public static T SetSoftness<T>(this T rectMask, Vector2Int softness) where T : RectMask2D { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((RectMask2D)rectMask).softness = softness; return rectMask; } } public static class RectTransformExtensions { public static RectTransform SetAnchorMin(this RectTransform rectTransform, Vector2 anchorMin) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMin = anchorMin; return rectTransform; } public static RectTransform SetAnchorMax(this RectTransform rectTransform, Vector2 anchorMax) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchorMax = anchorMax; return rectTransform; } public static RectTransform SetPivot(this RectTransform rectTransform, Vector2 pivot) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.pivot = pivot; return rectTransform; } public static RectTransform SetPosition(this RectTransform rectTransform, Vector2 position) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.anchoredPosition = position; return rectTransform; } public static RectTransform SetSizeDelta(this RectTransform rectTransform, Vector2 sizeDelta) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) rectTransform.sizeDelta = sizeDelta; return rectTransform; } } public static class ScrollbarExtensions { public static T SetDirection<T>(this T scrollbar, Direction direction) where T : Scrollbar { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Scrollbar)scrollbar).direction = direction; return scrollbar; } public static T SetHandleRect<T>(this T scrollbar, RectTransform handleRect) where T : Scrollbar { ((Scrollbar)scrollbar).handleRect = handleRect; return scrollbar; } } public static class SelectableExtensions { public static T SetColors<T>(this T selectable, ColorBlock colors) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).colors = colors; return selectable; } public static T SetImage<T>(this T selectable, Image image) where T : Selectable { ((Selectable)selectable).image = image; return selectable; } public static T SetInteractable<T>(this T selectable, bool interactable) where T : Selectable { ((Selectable)selectable).interactable = interactable; return selectable; } public static T SetSpriteState<T>(this T selectable, SpriteState spriteState) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).spriteState = spriteState; return selectable; } public static T SetTargetGraphic<T>(this T selectable, Graphic graphic) where T : Selectable { ((Selectable)selectable).targetGraphic = graphic; return selectable; } public static T SetTransition<T>(this T selectable, Transition transition) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Selectable)selectable).transition = transition; return selectable; } public static T SetNavigationMode<T>(this T selectable, Mode mode) where T : Selectable { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) Navigation navigation = ((Selectable)selectable).navigation; ((Navigation)(ref navigation)).mode = mode; ((Selectable)selectable).navigation = navigation; return selectable; } } public static class SliderExtensions { public static T SetDirection<T>(this T slider, Direction direction) where T : Slider { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Slider)slider).direction = direction; return slider; } public static T SetFillRect<T>(this T slider, RectTransform fillRect) where T : Slider { ((Slider)slider).fillRect = fillRect; return slider; } public static T SetHandleRect<T>(this T slider, RectTransform handleRect) where T : Slider { ((Slider)slider).handleRect = handleRect; return slider; } public static T SetMaxValue<T>(this T slider, float maxValue) where T : Slider { ((Slider)slider).maxValue = maxValue; return slider; } public static T SetMinValue<T>(this T slider, float minValue) where T : Slider { ((Slider)slider).minValue = minValue; return slider; } public static T SetValue<T>(this T slider, float value) where T : Slider { ((Slider)slider).value = value; return slider; } public static T SetWholeNumbers<T>(this T slider, bool wholeNumbers) where T : Slider { ((Slider)slider).wholeNumbers = wholeNumbers; return slider; } } public static class ScrollRectExtensions { public static T SetContent<T>(this T scrollRect, RectTransform content) where T : ScrollRect { ((ScrollRect)scrollRect).content = content; return scrollRect; } public static T SetHorizontal<T>(this T scrollRect, bool horizontal) where T : ScrollRect { ((ScrollRect)scrollRect).horizontal = horizontal; return scrollRect; } public static T SetMovementType<T>(this T scrollRect, MovementType movementType) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).movementType = movementType; return scrollRect; } public static T SetScrollSensitivity<T>(this T scrollRect, float sensitivity) where T : ScrollRect { ((ScrollRect)scrollRect).scrollSensitivity = sensitivity; return scrollRect; } public static T SetVertical<T>(this T scrollRect, bool vertical) where T : ScrollRect { ((ScrollRect)scrollRect).vertical = vertical; return scrollRect; } public static T SetVerticalScrollbar<T>(this T scrollRect, Scrollbar verticalScrollbar) where T : ScrollRect { ((ScrollRect)scrollRect).verticalScrollbar = verticalScrollbar; return scrollRect; } public static T SetVerticalScrollPosition<T>(this T scrollRect, float position) where T : ScrollRect { ((ScrollRect)scrollRect).verticalNormalizedPosition = position; return scrollRect; } public static T SetVerticalScrollbarVisibility<T>(this T scrollRect, ScrollbarVisibility visibility) where T : ScrollRect { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((ScrollRect)scrollRect).verticalScrollbarVisibility = visibility; return scrollRect; } public static T SetViewport<T>(this T scrollRect, RectTransform viewport) where T : ScrollRect { ((ScrollRect)scrollRect).viewport = viewport; return scrollRect; } } public static class TextMeshProExtensions { public static T SetAlignment<T>(this T tmpText, TextAlignmentOptions alignment) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).alignment = alignment; return tmpText; } public static T SetCharacterSpacing<T>(this T tmpText, float characterSpacing) where T : TMP_Text { ((TMP_Text)tmpText).characterSpacing = characterSpacing; return tmpText; } public static T SetColor<T>(this T tmpText, Color color) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((Graphic)(object)tmpText).color = color; return tmpText; } public static T SetEnableAutoSizing<T>(this T tmpText, bool enableAutoSizing) where T : TMP_Text { ((TMP_Text)tmpText).enableAutoSizing = enableAutoSizing; return tmpText; } public static T SetFont<T>(this T tmpText, TMP_FontAsset font) where T : TMP_Text { ((TMP_Text)tmpText).font = font; return tmpText; } public static T SetFontSize<T>(this T tmpText, float fontSize) where T : TMP_Text { ((TMP_Text)tmpText).fontSize = fontSize; return tmpText; } public static T SetFontMaterial<T>(this T tmpText, Material fontMaterial) where T : TMP_Text { ((TMP_Text)tmpText).fontMaterial = fontMaterial; return tmpText; } public static T SetLineSpacing<T>(this T tmpText, float lineSpacing) where T : TMP_Text { ((TMP_Text)tmpText).lineSpacing = lineSpacing; return tmpText; } public static T SetMargin<T>(this T tmpText, Vector4 margin) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).margin = margin; return tmpText; } public static T SetOverflowMode<T>(this T tmpText, TextOverflowModes overflowMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).overflowMode = overflowMode; return tmpText; } public static T SetRichText<T>(this T tmpText, bool richText) where T : TMP_Text { ((TMP_Text)tmpText).richText = richText; return tmpText; } public static T SetTextWrappingMode<T>(this T tmpText, TextWrappingModes textWrappingMode) where T : TMP_Text { //IL_0006: Unknown result type (might be due to invalid IL or missing references) ((TMP_Text)tmpText).textWrappingMode = textWrappingMode; return tmpText; } } public static class Texture2DExtensions { public static Texture2D SetFilterMode(this Texture2D texture, FilterMode filterMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).filterMode = filterMode; return texture; } public static Texture2D SetWrapMode(this Texture2D texture, TextureWrapMode wrapMode) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Texture)texture).wrapMode = wrapMode; return texture; } } public static class ToggleExtensions { public static T SetGraphic<T>(this T toggle, Graphic graphic) where T : Toggle { ((Toggle)toggle).graphic = graphic; return toggle; } public static T SetToggleTransition<T>(this T toggle, ToggleTransition toggleTransition) where T : Toggle { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) ((Toggle)toggle).toggleTransition = toggleTransition; return toggle; } } public static class UIResources { public static readonly ResourceCache<Sprite> SpriteCache = new ResourceCache<Sprite>(); public static readonly ResourceCache<Material> MaterialCache = new ResourceCache<Material>(); public static Sprite GetSprite(string spriteName) { return SpriteCache.GetResource(spriteName); } public static Material GetMaterial(string materialName) { return MaterialCache.GetResource(materialName); } } public sealed class ResourceCache<T> where T : Object { private readonly Dictionary<string, T> _cache = new Dictionary<string, T>(); public T GetResource(string resourceName) { if (!_cache.TryGetValue(resourceName, out var value)) { value = Resources.FindObjectsOfTypeAll<T>().FirstByNameOrThrow(resourceName); _cache[resourceName] = value; } return value; } } } namespace ColorfulPieces { [BepInPlugin("redseiko.valheim.colorfulpieces", "ColorfulPieces", "1.19.0")] public sealed class ColorfulPieces : BaseUnityPlugin { public const string PluginGUID = "redseiko.valheim.colorfulpieces"; public const string PluginName = "ColorfulPieces"; public const string PluginVersion = "1.19.0"; private static ManualLogSource _logger; private void Awake() { _logger = ((BaseUnityPlugin)this).Logger;