Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of VikingOS BETA v0.9.2
plugins/VikingOS.dll
Decompiled an hour ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Cryptography; using System.Security.Permissions; using System.Text; using System.Text.RegularExpressions; using BarrkUI.ChatOverhaul; using BarrkUI.Compat; using BarrkUI.Configuration; using BarrkUI.Layout; using BarrkUI.Trading; using BarrkUI.UI; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using Newtonsoft.Json; using Newtonsoft.Json.Linq; using ServerSync; using SharedMedia; using SharedNet; using SharedUI; using Splatform; using TMPro; using UnityEngine; using UnityEngine.TextCore; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: IgnoresAccessChecksTo("assembly_guiutils")] [assembly: IgnoresAccessChecksTo("assembly_valheim")] [assembly: AssemblyCompany("VikingOS")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("VikingOS - rebuild Valheim's interface. Move, resize and rotate any UI element, plus chat fixes and item sharing.")] [assembly: AssemblyFileVersion("0.9.2.0")] [assembly: AssemblyInformationalVersion("0.9.2+5d942492f9f4a27b0ed403480e9fc3d59ea8eb7d")] [assembly: AssemblyProduct("VikingOS")] [assembly: AssemblyTitle("VikingOS")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.9.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [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] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace SharedMedia { public static class GifDecoder { public sealed class Frame { public Color32[] Pixels; public float DelaySeconds; } private sealed class Canvas { public int Width; public int Height; public Color32[] Pixels; } public const int MaxDimension = 512; public const int MaxFrames = 64; public static bool TryDecode(byte[] bytes, out int width, out int height, out List<Frame> frames) { width = 0; height = 0; frames = null; try { return Decode(bytes, 64, out width, out height, out frames); } catch { frames = null; return false; } } private static bool Decode(byte[] b, int maxFrames, out int width, out int height, out List<Frame> frames) { width = 0; height = 0; frames = null; if (b == null || b.Length < 13) { return false; } if (b[0] != 71 || b[1] != 73 || b[2] != 70 || b[3] != 56) { return false; } if ((b[4] != 55 && b[4] != 57) || b[5] != 97) { return false; } int num = 6; width = b[num] | (b[num + 1] << 8); height = b[num + 2] | (b[num + 3] << 8); byte b2 = b[num + 4]; num += 7; if (width <= 0 || height <= 0 || width > 512 || height > 512) { return false; } Color32[] array = null; if ((b2 & 0x80) != 0) { int size = 2 << (b2 & 7); array = ReadColourTable(b, ref num, size); if (array == null) { return false; } } Canvas canvas = new Canvas { Width = width, Height = height, Pixels = (Color32[])(object)new Color32[width * height] }; frames = new List<Frame>(); float delaySeconds = 0.1f; int transparentIndex = -1; int num2 = 0; Color32[] array2 = null; while (num < b.Length) { switch (b[num++]) { case 33: if (num >= b.Length) { return false; } if (b[num++] == 249) { if (num + 5 >= b.Length) { return false; } int num7 = b[num++]; if (num7 >= 4) { byte num8 = b[num]; num2 = (num8 >> 2) & 7; int num9 = b[num + 1] | (b[num + 2] << 8); delaySeconds = ((num9 <= 1) ? 0.1f : ((float)num9 / 100f)); transparentIndex = (((num8 & 1) != 0) ? b[num + 3] : (-1)); } num += num7; if (!SkipSubBlocks(b, ref num)) { return false; } } else if (!SkipSubBlocks(b, ref num)) { return false; } continue; default: return false; case 44: { if (num + 9 > b.Length) { return false; } int num3 = b[num] | (b[num + 1] << 8); int num4 = b[num + 2] | (b[num + 3] << 8); int num5 = b[num + 4] | (b[num + 5] << 8); int num6 = b[num + 6] | (b[num + 7] << 8); byte b3 = b[num + 8]; num += 9; if (num5 <= 0 || num6 <= 0 || num3 < 0 || num4 < 0) { return false; } if (num3 + num5 > width || num4 + num6 > height) { return false; } bool interlaced = (b3 & 0x40) != 0; Color32[] array3 = array; if ((b3 & 0x80) != 0) { int size2 = 2 << (b3 & 7); array3 = ReadColourTable(b, ref num, size2); } if (array3 == null) { return false; } if (num2 == 3) { array2 = CopyRegion(canvas, num3, num4, num5, num6); } byte[] array4 = DecodeLzwImage(b, ref num, num5, num6); if (array4 == null) { return false; } DrawIndices(canvas, array4, array3, transparentIndex, num3, num4, num5, num6, interlaced); frames.Add(new Frame { Pixels = (Color32[])canvas.Pixels.Clone(), DelaySeconds = delaySeconds }); if (frames.Count >= maxFrames) { break; } switch (num2) { case 2: ClearRegion(canvas, num3, num4, num5, num6); break; case 3: if (array2 != null) { PasteRegion(canvas, array2, num3, num4, num5, num6); } break; } delaySeconds = 0.1f; transparentIndex = -1; num2 = 0; continue; } case 59: break; } break; } return frames.Count > 0; } private static Color32[] ReadColourTable(byte[] b, ref int pos, int size) { //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) if (pos + size * 3 > b.Length) { return null; } Color32[] array = (Color32[])(object)new Color32[size]; for (int i = 0; i < size; i++) { array[i] = new Color32(b[pos], b[pos + 1], b[pos + 2], byte.MaxValue); pos += 3; } return array; } private static bool SkipSubBlocks(byte[] b, ref int pos) { while (pos < b.Length) { int num = b[pos++]; if (num == 0) { return true; } pos += num; } return false; } private static byte[] DecodeLzwImage(byte[] b, ref int pos, int fw, int fh) { if (pos >= b.Length) { return null; } int num = b[pos++]; if (num < 2 || num > 11) { return null; } List<byte> list = new List<byte>(1024); while (pos < b.Length) { int num2 = b[pos++]; if (num2 == 0) { break; } if (pos + num2 > b.Length) { return null; } for (int i = 0; i < num2; i++) { list.Add(b[pos + i]); } pos += num2; } int num3 = 1 << num; int num4 = num3 + 1; int[] array = new int[4096]; byte[] array2 = new byte[4096]; byte[] array3 = new byte[4097]; int num5 = num + 1; int num6 = num4 + 1; int num7 = -1; byte[] array4 = new byte[fw * fh]; int num8 = 0; int num9 = 0; int j = 0; int num10 = 0; while (num8 < array4.Length) { for (; j < num5; j += 8) { if (num10 >= list.Count) { if (num8 <= 0) { return null; } return array4; } num9 |= list[num10++] << j; } int num11 = num9 & ((1 << num5) - 1); num9 >>= num5; j -= num5; if (num11 == num3) { num5 = num + 1; num6 = num4 + 1; num7 = -1; continue; } if (num11 == num4) { break; } int num12 = 0; int num13 = num11; if (num13 == num6 && num7 >= 0) { array3[num12++] = FirstByteOf(array, array2, num7, num3); num13 = num7; } else if (num13 > num6) { return null; } while (num13 >= num3 + 2) { if (num12 >= array3.Length) { return null; } array3[num12++] = array2[num13]; num13 = array[num13]; } if (num12 >= array3.Length) { return null; } array3[num12++] = (byte)num13; while (num12 > 0 && num8 < array4.Length) { array4[num8++] = array3[--num12]; } if (num7 >= 0 && num6 < 4096) { array[num6] = num7; array2[num6] = FirstByteOf(array, array2, (num11 == num6) ? num7 : num11, num3); num6++; if (num6 == 1 << num5 && num5 < 12) { num5++; } } num7 = num11; } return array4; } private static byte FirstByteOf(int[] prefix, byte[] suffix, int code, int clearCode) { int num = 0; while (code >= clearCode + 2) { code = prefix[code]; if (++num > 4096) { return 0; } } return (byte)code; } private static void DrawIndices(Canvas canvas, byte[] indices, Color32[] table, int transparentIndex, int left, int top, int fw, int fh, bool interlaced) { //IL_0087: Unknown result type (might be due to invalid IL or missing references) //IL_008c: Unknown result type (might be due to invalid IL or missing references) int num = 0; for (int i = 0; i < ((!interlaced) ? 1 : 4); i++) { int num2 = (interlaced ? (new int[4] { 0, 4, 2, 1 })[i] : 0); int num3 = ((!interlaced) ? 1 : (new int[4] { 8, 8, 4, 2 })[i]); for (int j = num2; j < fh; j += num3) { int num4 = num * fw; num++; int num5 = (top + j) * canvas.Width + left; for (int k = 0; k < fw; k++) { int num6 = indices[num4 + k]; if (num6 != transparentIndex && num6 < table.Length) { canvas.Pixels[num5 + k] = table[num6]; } } } } } private static Color32[] CopyRegion(Canvas canvas, int left, int top, int fw, int fh) { Color32[] array = (Color32[])(object)new Color32[fw * fh]; for (int i = 0; i < fh; i++) { Array.Copy(canvas.Pixels, (top + i) * canvas.Width + left, array, i * fw, fw); } return array; } private static void PasteRegion(Canvas canvas, Color32[] region, int left, int top, int fw, int fh) { for (int i = 0; i < fh; i++) { Array.Copy(region, i * fw, canvas.Pixels, (top + i) * canvas.Width + left, fw); } } private static void ClearRegion(Canvas canvas, int left, int top, int fw, int fh) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) Color32 val = default(Color32); for (int i = 0; i < fh; i++) { int num = (top + i) * canvas.Width + left; for (int j = 0; j < fw; j++) { canvas.Pixels[num + j] = val; } } } } public static class GifEncoder { public sealed class Frame { public Color32[] Pixels; public float DelaySeconds; } private sealed class SubBlockWriter { private readonly MemoryStream _out; private readonly byte[] _buffer = new byte[255]; private int _bufferAt; private int _bitBuffer; private int _bitCount; public SubBlockWriter(MemoryStream output) { _out = output; } public void WriteBits(int value, int bits) { _bitBuffer |= value << _bitCount; _bitCount += bits; while (_bitCount >= 8) { WriteByte((byte)(_bitBuffer & 0xFF)); _bitBuffer >>= 8; _bitCount -= 8; } } private void WriteByte(byte b) { _buffer[_bufferAt++] = b; if (_bufferAt >= 255) { _out.WriteByte(byte.MaxValue); _out.Write(_buffer, 0, 255); _bufferAt = 0; } } public void Flush() { if (_bitCount > 0) { WriteByte((byte)(_bitBuffer & 0xFF)); } if (_bufferAt > 0) { _out.WriteByte((byte)_bufferAt); _out.Write(_buffer, 0, _bufferAt); _bufferAt = 0; } _out.WriteByte(0); _bitBuffer = 0; _bitCount = 0; } } private const int PaletteSize = 256; private const int TransparentIndex = 252; public static byte[] Encode(int width, int height, List<Frame> frames) { if (width <= 0 || height <= 0 || frames == null || frames.Count == 0) { return null; } using MemoryStream memoryStream = new MemoryStream(); Write(memoryStream, 71, 73, 70, 56, 57, 97); WriteU16(memoryStream, width); WriteU16(memoryStream, height); memoryStream.WriteByte(247); memoryStream.WriteByte(0); memoryStream.WriteByte(0); WritePalette(memoryStream); Write(memoryStream, 33, 255, 11); string text = "NETSCAPE2.0"; foreach (char c in text) { memoryStream.WriteByte((byte)c); } Write(memoryStream, 3, 1, 0, 0, 0); byte[] indices = new byte[width * height]; foreach (Frame frame in frames) { if (frame?.Pixels == null || frame.Pixels.Length < width * height) { return null; } int v = Mathf.Clamp(Mathf.RoundToInt(frame.DelaySeconds * 100f), 2, 65535); Write(memoryStream, 33, 249, 4, 9); WriteU16(memoryStream, v); memoryStream.WriteByte(252); memoryStream.WriteByte(0); memoryStream.WriteByte(44); WriteU16(memoryStream, 0); WriteU16(memoryStream, 0); WriteU16(memoryStream, width); WriteU16(memoryStream, height); memoryStream.WriteByte(0); Quantise(frame.Pixels, indices); WriteLzw(memoryStream, indices); } memoryStream.WriteByte(59); return memoryStream.ToArray(); } private static void WritePalette(MemoryStream ms) { for (int i = 0; i < 6; i++) { for (int j = 0; j < 7; j++) { for (int k = 0; k < 6; k++) { ms.WriteByte((byte)(i * 255 / 5)); ms.WriteByte((byte)(j * 255 / 6)); ms.WriteByte((byte)(k * 255 / 5)); } } } for (int l = 252; l < 256; l++) { ms.WriteByte(0); ms.WriteByte(0); ms.WriteByte(0); } } private static void Quantise(Color32[] pixels, byte[] indices) { //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_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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) for (int i = 0; i < indices.Length; i++) { Color32 val = pixels[i]; if (val.a < 128) { indices[i] = 252; continue; } int num = val.r * 6 / 256; int num2 = val.g * 7 / 256; int num3 = val.b * 6 / 256; indices[i] = (byte)((num * 7 + num2) * 6 + num3); } } private static void WriteLzw(MemoryStream ms, byte[] indices) { ms.WriteByte(8); SubBlockWriter subBlockWriter = new SubBlockWriter(ms); Dictionary<int, int> dictionary = new Dictionary<int, int>(4096); int num = 9; int num2 = 258; subBlockWriter.WriteBits(256, num); int num3 = indices[0]; for (int i = 1; i < indices.Length; i++) { int num4 = indices[i]; int key = (num3 << 8) | num4; if (dictionary.TryGetValue(key, out var value)) { num3 = value; continue; } subBlockWriter.WriteBits(num3, num); dictionary[key] = num2; if (num2 == 1 << num && num < 12) { num++; } num2++; if (num2 >= 4096) { subBlockWriter.WriteBits(256, num); dictionary.Clear(); num = 9; num2 = 258; } num3 = num4; } subBlockWriter.WriteBits(num3, num); subBlockWriter.WriteBits(257, num); subBlockWriter.Flush(); } private static void Write(MemoryStream ms, params int[] bytes) { foreach (int num in bytes) { ms.WriteByte((byte)num); } } private static void WriteU16(MemoryStream ms, int v) { ms.WriteByte((byte)(v & 0xFF)); ms.WriteByte((byte)((v >> 8) & 0xFF)); } public static Color32[] Resize(Color32[] src, int srcW, int srcH, int dstW, int dstH) { //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[dstW * dstH]; if (srcW <= 0 || srcH <= 0 || dstW <= 0 || dstH <= 0) { return array; } for (int i = 0; i < dstH; i++) { float num = ((float)i + 0.5f) / (float)dstH * (float)srcH - 0.5f; int num2 = Mathf.Clamp(Mathf.FloorToInt(num), 0, srcH - 1); int num3 = Mathf.Min(num2 + 1, srcH - 1); float t = Mathf.Clamp01(num - (float)num2); for (int j = 0; j < dstW; j++) { float num4 = ((float)j + 0.5f) / (float)dstW * (float)srcW - 0.5f; int num5 = Mathf.Clamp(Mathf.FloorToInt(num4), 0, srcW - 1); int num6 = Mathf.Min(num5 + 1, srcW - 1); float t2 = Mathf.Clamp01(num4 - (float)num5); array[i * dstW + j] = Lerp(Lerp(src[num2 * srcW + num5], src[num2 * srcW + num6], t2), Lerp(src[num3 * srcW + num5], src[num3 * srcW + num6], t2), t); } } return array; } private static Color32 Lerp(Color32 a, Color32 b, float t) { //IL_0000: 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_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_0020: Unknown result type (might be due to invalid IL or missing references) //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_003f: 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_0052: 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_0064: Unknown result type (might be due to invalid IL or missing references) return new Color32((byte)((float)(int)a.r + (float)(b.r - a.r) * t), (byte)((float)(int)a.g + (float)(b.g - a.g) * t), (byte)((float)(int)a.b + (float)(b.b - a.b) * t), (byte)((float)(int)a.a + (float)(b.a - a.a) * t)); } } } namespace SharedNet { public sealed class BlobLibrary { public enum BlobKind : byte { Png, Gif } public sealed class Entry { public string Name; public string Hash; public BlobKind Kind; public int Width; public int Height; public int Length; } public sealed class Limits { public int MaxBytes = 98304; public int MaxWidth = 256; public int MaxHeight = 256; public int MaxCount = 64; public bool AcceptGif; public Func<string, byte[], byte[]> OversizeRewriter; } private sealed class Incoming { public byte[][] Chunks; public int Received; public int Total; public float LastChunkAt; } private const byte CatalogueVersion = 1; private const int ChunkBytes = 32768; private const float TransferTimeoutSeconds = 15f; private readonly string _name; private readonly string _fetchRpc; private readonly string _chunkRpc; private readonly string _reloadRpc; private readonly string _reloadReplyRpc; private readonly CustomSyncedValue<string> _catalogue; private readonly Func<string> _packFolder; private readonly string _cacheDir; private readonly Limits _limits; private readonly Func<bool> _sharingEnabled; private readonly Func<MonoBehaviour> _host; private readonly Action<string> _logInfo; private readonly Action<string> _logWarning; private readonly Action<string> _logError; private readonly Dictionary<string, Entry> _decoded = new Dictionary<string, Entry>(StringComparer.OrdinalIgnoreCase); private string _decodedFrom; private readonly List<Entry> _packEntries = new List<Entry>(); private readonly Dictionary<string, string> _serverBlobs = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); private bool _serverScanned; private readonly HashSet<string> _have = new HashSet<string>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, float> _requested = new Dictionary<string, float>(StringComparer.OrdinalIgnoreCase); private readonly Dictionary<string, Incoming> _transfers = new Dictionary<string, Incoming>(StringComparer.OrdinalIgnoreCase); private Coroutine _pump; private Action<string> _reloadReply; public int Revision { get; private set; } public event Action Changed; public BlobLibrary(string name, string rpcPrefix, CustomSyncedValue<string> catalogue, Func<string> packFolder, string cacheDir, Limits limits, Func<bool> sharingEnabled, Func<MonoBehaviour> coroutineHost, Action<string> logInfo, Action<string> logWarning, Action<string> logError) { _name = name; _fetchRpc = rpcPrefix + "_Fetch"; _chunkRpc = rpcPrefix + "_Chunk"; _reloadRpc = rpcPrefix + "_Reload"; _reloadReplyRpc = rpcPrefix + "_Reloaded"; _catalogue = catalogue; _packFolder = packFolder; _cacheDir = cacheDir; _limits = limits ?? new Limits(); _sharingEnabled = sharingEnabled ?? ((Func<bool>)(() => true)); _host = coroutineHost; _logInfo = logInfo ?? ((Action<string>)delegate { }); _logWarning = logWarning ?? ((Action<string>)delegate { }); _logError = logError ?? ((Action<string>)delegate { }); } public void OnSessionStart() { try { if (ZRoutedRpc.instance == null) { return; } ZRoutedRpc.instance.Register<ZPackage>(_fetchRpc, (Action<long, ZPackage>)RPC_Fetch); ZRoutedRpc.instance.Register<ZPackage>(_chunkRpc, (Action<long, ZPackage>)RPC_Chunk); ZRoutedRpc.instance.Register(_reloadRpc, (Action<long>)RPC_Reload); ZRoutedRpc.instance.Register<int>(_reloadReplyRpc, (Action<long, int>)RPC_Reloaded); if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { ScanServerPack(); Publish(); } MonoBehaviour val = _host?.Invoke(); if ((Object)(object)val != (Object)null) { if (_pump != null) { val.StopCoroutine(_pump); } _pump = val.StartCoroutine(ClientPump()); } } catch (Exception arg) { _logError($"could not start the {_name} library (non-fatal, the feature idles this session). Reason: {arg}"); } } public void OnSessionEnd() { try { MonoBehaviour val = _host?.Invoke(); if (_pump != null && (Object)(object)val != (Object)null) { val.StopCoroutine(_pump); } _pump = null; _decoded.Clear(); _decodedFrom = null; _packEntries.Clear(); _serverBlobs.Clear(); _serverScanned = false; _have.Clear(); _requested.Clear(); _transfers.Clear(); Bump(); } catch (Exception arg) { _logError($"tearing down the {_name} library failed (non-fatal). Reason: {arg}"); } } private void Bump() { Revision++; try { this.Changed?.Invoke(); } catch (Exception arg) { _logError($"a {_name} change handler threw (non-fatal). Reason: {arg}"); } } public Entry Find(string name) { if (string.IsNullOrEmpty(name)) { return null; } EnsureDecoded(); if (!_decoded.TryGetValue(name, out var value)) { return null; } return value; } public List<Entry> Entries() { EnsureDecoded(); return new List<Entry>(_decoded.Values); } public bool HasBlob(string hash) { if (!string.IsNullOrEmpty(hash)) { return File.Exists(CachePath(hash)); } return false; } public byte[] TryReadBytes(Entry entry) { if (entry == null) { return null; } try { string path = CachePath(entry.Hash); if (File.Exists(path)) { return File.ReadAllBytes(path); } if (_serverBlobs.TryGetValue(entry.Hash, out var value) && File.Exists(value)) { return File.ReadAllBytes(value); } } catch (Exception arg) { _logError($"reading a cached {_name} failed (non-fatal). Reason: {arg}"); } return null; } private string CachePath(string hash) { return Path.Combine(_cacheDir, hash + ".bin"); } private void EnsureDecoded() { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected O, but got Unknown string text = _catalogue.Value ?? ""; if (text == _decodedFrom) { return; } _decodedFrom = text; _decoded.Clear(); try { if (string.IsNullOrEmpty(text)) { Bump(); return; } ZPackage val = new ZPackage(text); byte b = val.ReadByte(); if (b != 1) { _logWarning($"the server's {_name} catalogue is format {b}, not {(byte)1} - ignoring it."); Bump(); return; } int num = val.ReadInt(); for (int i = 0; i < num; i++) { Entry entry = new Entry { Name = val.ReadString(), Hash = val.ReadString(), Kind = (BlobKind)val.ReadByte(), Width = val.ReadInt(), Height = val.ReadInt(), Length = val.ReadInt() }; if (!string.IsNullOrEmpty(entry.Name) && !string.IsNullOrEmpty(entry.Hash)) { _decoded[entry.Name] = entry; } } Bump(); } catch (Exception arg) { _decoded.Clear(); _logError($"the server's {_name} catalogue could not be read (non-fatal). Reason: {arg}"); } } public int ScanServerPack() { _serverBlobs.Clear(); _serverScanned = true; try { string text = _packFolder(); List<string> list = new List<string>(); if (Directory.Exists(text)) { list.AddRange(Directory.GetFiles(text, "*.png", SearchOption.TopDirectoryOnly)); if (_limits.AcceptGif) { list.AddRange(Directory.GetFiles(text, "*.gif", SearchOption.TopDirectoryOnly)); } } list.Sort(StringComparer.OrdinalIgnoreCase); int num = 0; foreach (string item in list) { if (num >= _limits.MaxCount) { _logWarning($"the {_name} pack holds more than {_limits.MaxCount} files - the rest are not offered to clients."); break; } if (RegisterPackFile(item)) { num++; } } _logInfo($"offering {num} {_name}(s) to clients from {text}."); return num; } catch (Exception arg) { _logError($"could not scan the {_name} pack (non-fatal). Reason: {arg}"); return 0; } } private bool RegisterPackFile(string path) { try { string name = Path.GetFileNameWithoutExtension(path); byte[] array = File.ReadAllBytes(path); if (!Identify(array, out var kind, out var w, out var h)) { _logWarning("not offering '" + Path.GetFileName(path) + "' - it is not a readable PNG" + (_limits.AcceptGif ? " or GIF" : "") + "."); return false; } if (array.Length > _limits.MaxBytes || w > _limits.MaxWidth || h > _limits.MaxHeight) { byte[] array2 = _limits.OversizeRewriter?.Invoke(path, array); if (array2 == null || array2.Length > _limits.MaxBytes || !Identify(array2, out kind, out w, out h) || w > _limits.MaxWidth || h > _limits.MaxHeight) { _logWarning("not offering '" + Path.GetFileName(path) + "' - over the limits " + $"({_limits.MaxBytes / 1024} KB, {_limits.MaxWidth}x{_limits.MaxHeight}) and it could not be shrunk to fit."); return false; } Directory.CreateDirectory(_cacheDir); string text = Path.Combine(_cacheDir, "pack-" + HashOf(array2) + ".bin"); File.WriteAllBytes(text, array2); _logInfo($"'{Path.GetFileName(path)}' was over the limits and has been shrunk to {array2.Length / 1024} KB ({w}x{h}) for transfer."); array = array2; path = text; } string text2 = HashOf(array); _serverBlobs[text2] = path; _packEntries.RemoveAll((Entry e) => string.Equals(e.Name, name, StringComparison.OrdinalIgnoreCase)); _packEntries.Add(new Entry { Name = name, Hash = text2, Kind = kind, Width = w, Height = h, Length = array.Length }); return true; } catch (Exception arg) { _logError($"could not read '{path}' (non-fatal, it is skipped). Reason: {arg}"); return false; } } private bool Identify(byte[] bytes, out BlobKind kind, out int w, out int h) { if (ReadPngHeader(bytes, out w, out h)) { kind = BlobKind.Png; return true; } if (_limits.AcceptGif && ReadGifHeader(bytes, out w, out h)) { kind = BlobKind.Gif; return true; } kind = BlobKind.Png; return false; } public void Publish() { //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Expected O, but got Unknown try { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer()) { return; } if (!_sharingEnabled()) { _catalogue.Value = ""; return; } if (!_serverScanned) { ScanServerPack(); } ZPackage val = new ZPackage(); val.Write((byte)1); val.Write(_packEntries.Count); foreach (Entry packEntry in _packEntries) { val.Write(packEntry.Name); val.Write(packEntry.Hash); val.Write((byte)packEntry.Kind); val.Write(packEntry.Width); val.Write(packEntry.Height); val.Write(packEntry.Length); } _catalogue.Value = val.GetBase64(); } catch (Exception arg) { _logError($"publishing the {_name} catalogue failed (non-fatal, clients keep the previous one). Reason: {arg}"); } } public int Reload() { _packEntries.Clear(); int result = ScanServerPack(); Publish(); return result; } public void RequestReload(Action<string> reply) { _reloadReply = reply; if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer()) { int num = Reload(); reply?.Invoke($"now offering {num} {_name}(s)."); return; } ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(_reloadRpc, Array.Empty<object>()); } reply?.Invoke("asked the server to rescan its " + _name + " folder..."); } private IEnumerator ClientPump() { while ((Object)(object)ZNet.instance == (Object)null) { yield return null; } if (ZNet.instance.IsServer()) { foreach (string key in _serverBlobs.Keys) { _have.Add(key); } } else { while ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.GetPeers().Count == 0) { yield return null; } yield return (object)new WaitForSeconds(2f); } while (true) { yield return (object)new WaitForSeconds(1f); PumpOnce(); } } private void PumpOnce() { try { EnsureDecoded(); if (_decoded.Count == 0) { return; } if (_requested.Count > 0) { List<string> list = null; foreach (KeyValuePair<string, float> item in _requested) { Incoming value; float num = (_transfers.TryGetValue(item.Key, out value) ? value.LastChunkAt : item.Value); if (!(Time.realtimeSinceStartup - num <= 15f)) { (list ?? (list = new List<string>())).Add(item.Key); } } if (list != null) { foreach (string item2 in list) { _transfers.Remove(item2); _requested.Remove(item2); } _logWarning("a " + _name + " download stalled or went unanswered - it will be asked for again."); } } if (_transfers.Count > 0) { return; } foreach (Entry value2 in _decoded.Values) { if (!_have.Contains(value2.Hash) && !_requested.ContainsKey(value2.Hash)) { if (!HasBlob(value2.Hash)) { Request(value2); break; } _have.Add(value2.Hash); Bump(); } } } catch (Exception arg) { _logError($"the {_name} download pump failed (non-fatal). Reason: {arg}"); } } private void Request(Entry e) { //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Expected O, but got Unknown try { if (e.Length > _limits.MaxBytes) { _logWarning($"not fetching '{e.Name}' - the server says it is {e.Length / 1024} KB, over the {_limits.MaxBytes / 1024} KB limit."); _have.Add(e.Hash); return; } _requested[e.Hash] = Time.realtimeSinceStartup; ZPackage val = new ZPackage(); val.Write(e.Hash); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(_fetchRpc, new object[1] { val }); } } catch (Exception arg) { _requested.Remove(e.Hash); _logError($"asking for the {_name} '{e.Name}' failed (non-fatal). Reason: {arg}"); } } private void RPC_Fetch(long sender, ZPackage pkg) { try { if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer() || pkg == null || !_sharingEnabled()) { return; } string text = pkg.ReadString(); if (!string.IsNullOrEmpty(text) && _serverBlobs.TryGetValue(text, out var value) && File.Exists(value)) { MonoBehaviour val = _host?.Invoke(); if ((Object)(object)val != (Object)null) { val.StartCoroutine(SendBlob(sender, text, value)); } } } catch (Exception arg) { _logError($"{_name} fetch handler failed (non-fatal). Reason: {arg}"); } } private IEnumerator SendBlob(long target, string hash, string path) { byte[] bytes = null; try { bytes = File.ReadAllBytes(path); } catch (Exception arg) { _logError($"could not read '{path}' to send it (non-fatal). Reason: {arg}"); } if (bytes == null || bytes.Length == 0) { yield break; } int total = Mathf.Max(1, Mathf.CeilToInt((float)bytes.Length / 32768f)); for (int i = 0; i < total; i++) { int num = i * 32768; int num2 = Mathf.Min(32768, bytes.Length - num); byte[] array = new byte[num2]; Buffer.BlockCopy(bytes, num, array, 0, num2); try { ZPackage val = new ZPackage(); val.Write(hash); val.Write(i); val.Write(total); val.Write(array); ZRoutedRpc instance = ZRoutedRpc.instance; if (instance != null) { instance.InvokeRoutedRPC(target, _chunkRpc, new object[1] { val }); } } catch (Exception arg2) { _logError($"sending a {_name} chunk failed (non-fatal, the client will retry). Reason: {arg2}"); break; } yield return null; } } private void RPC_Chunk(long sender, ZPackage pkg) { try { if (pkg == null || ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())) { return; } string text = pkg.ReadString(); int num = pkg.ReadInt(); int num2 = pkg.ReadInt(); byte[] array = pkg.ReadByteArray(); if (string.IsNullOrEmpty(text) || array == null || num2 <= 0 || num < 0 || num >= num2 || num2 > _limits.MaxBytes / 32768 + 1 || array.Length > 32768 || !_requested.ContainsKey(text)) { return; } if (!_transfers.TryGetValue(text, out var value)) { value = new Incoming { Chunks = new byte[num2][], Total = num2 }; _transfers[text] = value; } if (value.Total == num2 && value.Chunks[num] == null) { value.Chunks[num] = array; value.Received++; value.LastChunkAt = Time.realtimeSinceStartup; if (value.Received >= value.Total) { _transfers.Remove(text); _requested.Remove(text); Complete(text, value); } } } catch (Exception arg) { _logError($"{_name} chunk handler failed (non-fatal). Reason: {arg}"); } } private void Complete(string hash, Incoming t) { try { int num = 0; byte[][] chunks = t.Chunks; foreach (byte[] array in chunks) { num += array.Length; } if (num <= _limits.MaxBytes) { byte[] array2 = new byte[num]; int num2 = 0; chunks = t.Chunks; foreach (byte[] array3 in chunks) { Buffer.BlockCopy(array3, 0, array2, num2, array3.Length); num2 += array3.Length; } if (!string.Equals(HashOf(array2), hash, StringComparison.OrdinalIgnoreCase)) { _logWarning("a downloaded " + _name + " did not match its hash and was discarded."); return; } if ((!ReadPngHeader(array2, out var width, out var height) && (!_limits.AcceptGif || !ReadGifHeader(array2, out width, out height))) || width > _limits.MaxWidth || height > _limits.MaxHeight) { _logWarning("a downloaded " + _name + " was not an image of a sensible size and was discarded."); return; } Directory.CreateDirectory(_cacheDir); File.WriteAllBytes(CachePath(hash), array2); _have.Add(hash); Bump(); } } catch (Exception arg) { _logError($"storing a downloaded {_name} failed (non-fatal). Reason: {arg}"); } } private void RPC_Reload(long sender) { try { if (!((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer()) { ZNetPeer peer = ZNet.instance.GetPeer(sender); string text = ((peer != null && peer.m_socket != null) ? peer.m_socket.GetHostName() : ""); if (!ZNet.instance.ListContainsId(ZNet.instance.m_adminList, text)) { _logWarning("refused a " + _name + " reload from " + text + " - not on the adminlist."); ZRoutedRpc.instance.InvokeRoutedRPC(sender, _reloadReplyRpc, new object[1] { -1 }); } else { int num = Reload(); _logInfo($"{_name} reload (via {text}): now offering {num} file(s)."); ZRoutedRpc.instance.InvokeRoutedRPC(sender, _reloadReplyRpc, new object[1] { num }); } } } catch (Exception arg) { _logError($"{_name} reload handler failed (non-fatal). Reason: {arg}"); } } private void RPC_Reloaded(long sender, int count) { try { string obj = ((count < 0) ? ("the server refused the " + _name + " reload - you are not on its adminlist.") : $"the server is now offering {count} {_name}(s). Players receive any they are missing shortly."); _reloadReply?.Invoke(obj); _reloadReply = null; _logInfo(obj); } catch (Exception arg) { _logError($"{_name} reload reply handler failed (non-fatal). Reason: {arg}"); } } public static string HashOf(byte[] bytes) { using SHA1 sHA = SHA1.Create(); byte[] array = sHA.ComputeHash(bytes); StringBuilder stringBuilder = new StringBuilder(16); for (int i = 0; i < 8; i++) { stringBuilder.Append(array[i].ToString("x2")); } return stringBuilder.ToString(); } public static bool ReadPngHeader(byte[] b, out int width, out int height) { width = 0; height = 0; if (b == null || b.Length < 24) { return false; } if (b[0] != 137 || b[1] != 80 || b[2] != 78 || b[3] != 71 || b[4] != 13 || b[5] != 10 || b[6] != 26 || b[7] != 10) { return false; } if (b[12] != 73 || b[13] != 72 || b[14] != 68 || b[15] != 82) { return false; } width = (b[16] << 24) | (b[17] << 16) | (b[18] << 8) | b[19]; height = (b[20] << 24) | (b[21] << 16) | (b[22] << 8) | b[23]; if (width > 0 && height > 0 && width <= 16384) { return height <= 16384; } return false; } public static bool ReadGifHeader(byte[] b, out int width, out int height) { width = 0; height = 0; if (b == null || b.Length < 13) { return false; } if (b[0] != 71 || b[1] != 73 || b[2] != 70 || b[3] != 56) { return false; } if (b[4] != 55 && b[4] != 57) { return false; } if (b[5] != 97) { return false; } width = b[6] | (b[7] << 8); height = b[8] | (b[9] << 8); if (width > 0) { return height > 0; } return false; } } } namespace SharedUI { internal enum FrameStyle { Gilt, Runic, Serpent, Ironbound } internal struct ThemeOptions { public Color Metal; public bool DeriveTones; public Color Deep; public Color Bright; public Color Panel; public float PanelOpacity; public Color Text; public Color MutedText; public float Scale; public int BodyDelta; public int TitleDelta; public int SubTitleDelta; public int HeaderDelta; public int ButtonDelta; public int RowDelta; public int FooterDelta; public int FieldDelta; public FrameStyle Frame; public static ThemeOptions Default => new ThemeOptions { Metal = new Color(0.8f, 0.62f, 0.26f, 1f), DeriveTones = true, Deep = new Color(0.26f, 0.17f, 0.05f, 1f), Bright = new Color(1f, 0.94f, 0.72f, 1f), Panel = new Color(0.075f, 0.065f, 0.051f, 1f), PanelOpacity = 0.955f, Text = new Color(0.9f, 0.86f, 0.75f, 1f), MutedText = new Color(0.6f, 0.56f, 0.48f, 1f), Scale = 1f, BodyDelta = 0, TitleDelta = 0, SubTitleDelta = 0, HeaderDelta = 0, ButtonDelta = 0, RowDelta = 0, FooterDelta = 0, FieldDelta = 0, Frame = FrameStyle.Gilt }; } internal static class GiltFrameTheme { private enum Edge { Top, Bottom, Left, Right } private sealed class Painter { public bool MirrorX; public bool MirrorY; public bool Transpose; private readonly int _w; private readonly int _h; private readonly float[] _a; private readonly float[] _z; public Painter(int w, int h) { _w = w; _h = h; _a = new float[w * h]; _z = new float[w * h]; } private void Put(float fx, float fy, float a, float z) { if (a <= 0f) { return; } if (Transpose) { float num = fx; fx = fy; fy = num; } int num2 = Mathf.RoundToInt(fx); int num3 = Mathf.RoundToInt(fy); if (MirrorX) { num2 = _w - 1 - num2; } if (MirrorY) { num3 = _h - 1 - num3; } if (num2 >= 0 && num3 >= 0 && num2 < _w && num3 < _h) { int num4 = num3 * _w + num2; if (a > _a[num4]) { _a[num4] = a; } if (z > _z[num4]) { _z[num4] = z; } } } public void Disc(float cx, float cy, float r) { if (r <= 0f) { return; } int num = Mathf.FloorToInt(cx - r - 1f); int num2 = Mathf.CeilToInt(cx + r + 1f); int num3 = Mathf.FloorToInt(cy - r - 1f); int num4 = Mathf.CeilToInt(cy + r + 1f); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { float num5 = (float)j - cx; float num6 = (float)i - cy; float num7 = Mathf.Sqrt(num5 * num5 + num6 * num6); float num8 = Mathf.Clamp01(r + 0.5f - num7); if (!(num8 <= 0f)) { Put(j, i, num8, Mathf.Sqrt(Mathf.Max(0f, 1f - num7 / r * (num7 / r)))); } } } } public void Lozenge(float cx, float cy, float r) { int num = Mathf.FloorToInt(cx - r - 1f); int num2 = Mathf.CeilToInt(cx + r + 1f); int num3 = Mathf.FloorToInt(cy - r - 1f); int num4 = Mathf.CeilToInt(cy + r + 1f); for (int i = num3; i <= num4; i++) { for (int j = num; j <= num2; j++) { float num5 = Mathf.Abs((float)j - cx) + Mathf.Abs((float)i - cy); float num6 = Mathf.Clamp01(r + 0.5f - num5); if (!(num6 <= 0f)) { Put(j, i, num6, Mathf.Sqrt(Mathf.Max(0f, 1f - num5 / r * (num5 / r)))); } } } } public void Taper(Vector2 a, Vector2 b, float w0, float w1) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0023: 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_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002d: 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) int num = Mathf.Max(8, Mathf.CeilToInt(Vector2.Distance(a, b) * 3f)); for (int i = 0; i <= num; i++) { float num2 = (float)i / (float)num; Vector2 val = Vector2.Lerp(a, b, num2); Disc(val.x, val.y, Mathf.Lerp(w0, w1, num2)); } } public void Bezier(Vector2 a, Vector2 b, Vector2 c, float w0, float w1) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_0038: 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_0047: 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_0054: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Unknown result type (might be due to invalid IL or missing references) //IL_005f: Unknown result type (might be due to invalid IL or missing references) //IL_0062: 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) int num = Mathf.Max(16, Mathf.CeilToInt((Vector2.Distance(a, b) + Vector2.Distance(b, c)) * 3f)); for (int i = 0; i <= num; i++) { float num2 = (float)i / (float)num; float num3 = 1f - num2; Vector2 val = num3 * num3 * a + 2f * num3 * num2 * b + num2 * num2 * c; Disc(val.x, val.y, Mathf.Lerp(w0, w1, num2)); } } public void Spiral(Vector2 eye, float r0, float growth, float t0, float t1, float phase, float w0, float w1, bool mirror = false) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) int num = Mathf.Max(48, Mathf.CeilToInt((t1 - t0) * 40f)); for (int i = 0; i <= num; i++) { float num2 = (float)i / (float)num; float num3 = Mathf.Lerp(t0, t1, num2); float num4 = r0 * Mathf.Exp(growth * num3); float num5 = num3 + phase; float num6 = Mathf.Cos(num5) * num4; float num7 = Mathf.Sin(num5) * num4; if (mirror) { num6 = 0f - num6; } Disc(eye.x + num6, eye.y + num7, Mathf.Lerp(w0, w1, num2)); } } public void RailPixel(int x, int y, float d, float half) { float num = Mathf.Clamp01(half + 0.5f - d); if (!(num <= 0f)) { Put(x, y, num, Mathf.Sqrt(Mathf.Max(0f, 1f - d / half * (d / half)))); } } public void SquareElbow(float mid, float half, float centre) { for (int i = 0; i < _h; i++) { for (int j = 0; j < _w; j++) { float d = Mathf.Min(Mathf.Abs((float)j - mid), Mathf.Abs((float)i - mid)); if (!((float)j > centre) || !((float)i > centre)) { RailPixel(j, i, d, half); } } } } public void RailElbow(float mid, float half, float centre) { float num = centre - mid; for (int i = 0; i < _h; i++) { for (int j = 0; j < _w; j++) { float d; if (!((float)j <= centre) || !((float)i <= centre)) { d = ((!((float)i <= centre)) ? ((!((float)j <= centre)) ? Mathf.Min(Mathf.Abs((float)i - mid), Mathf.Abs((float)j - mid)) : Mathf.Abs((float)j - mid)) : Mathf.Abs((float)i - mid)); } else { float num2 = (float)j - centre; float num3 = (float)i - centre; d = Mathf.Abs(Mathf.Sqrt(num2 * num2 + num3 * num3) - num); } RailPixel(j, i, d, half); } } } public Texture2D Bake() { //IL_006d: 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_00f6: Unknown result type (might be due to invalid IL or missing references) //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_010d: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(_w, _h, (TextureWrapMode)1, (FilterMode)1); Color[] array = (Color[])(object)new Color[_w * _h]; for (int i = 0; i < _h; i++) { for (int j = 0; j < _w; j++) { int num = i * _w + j; float num2 = _a[num]; int num3 = (_h - 1 - i) * _w + j; if (num2 <= 0f) { array[num3] = Color.clear; continue; } float num4 = Z(j - 1, i) - Z(j + 1, i) + (Z(j, i - 1) - Z(j, i + 1)); float num5 = Mathf.Clamp01(0.42f + 0.5f * num4 + 0.18f * _z[num]); Color val2 = ((num5 < 0.5f) ? Color.Lerp(GoldDeep, Gold, num5 * 2f) : Color.Lerp(Gold, GoldBright, (num5 - 0.5f) * 2f)); array[num3] = new Color(val2.r, val2.g, val2.b, num2); } } val.SetPixels(array); val.Apply(false); return val; } private float Z(int x, int y) { return _z[Mathf.Clamp(y, 0, _h - 1) * _w + Mathf.Clamp(x, 0, _w - 1)]; } } public static Color GoldDeep = new Color(0.26f, 0.17f, 0.05f, 1f); public static Color Gold = new Color(0.8f, 0.62f, 0.26f, 1f); public static Color GoldBright = new Color(1f, 0.94f, 0.72f, 1f); public static Color Parchment = new Color(0.9f, 0.86f, 0.75f, 1f); public static Color Muted = new Color(0.6f, 0.56f, 0.48f, 1f); private static ThemeOptions _bakedFrom = ThemeOptions.Default; private static bool _everBaked; private static int _appliedFrame = -1; private static bool _conflictLogged; private static readonly ManualLogSource Log = Logger.CreateLogSource("SharedUI.GiltFrameTheme"); public const string HexMuted = "#9A9182"; public const string HexLocked = "#E0736B"; public const string HexOpen = "#87D278"; public const float Band = 18f; public const float Pad = 22f; public static float TitleHeight = 54f; public static float FooterHeight = 30f; private static int _fontDelta; private static ThemeOptions _styledFrom = ThemeOptions.Default; private static bool _everStyled; private const int CornerTile = 84; private const float Overhang = 10f; private const float CornerExtent = 74f; private const int CrestW = 56; private const int CrestH = 34; private const float CrestOverhang = 8f; private const float OuterMid = 4.4f; private const float OuterHalf = 2.7f; private const float InnerMid = 12.4f; private const float InnerHalf = 1.6f; private const float BendCentre = 32f; public static GUIStyle Title; public static GUIStyle SubTitle; public static GUIStyle Header; public static GUIStyle Key; public static GUIStyle Value; public static GUIStyle Note; public static GUIStyle Footer; public static GUIStyle Button; public static GUIStyle Primary; public static GUIStyle Row; public static GUIStyle Field; public static GUIStyle ImageButton; private static Texture2D _railTop; private static Texture2D _railBottom; private static Texture2D _railLeft; private static Texture2D _railRight; private static Texture2D _cornerTL; private static Texture2D _cornerTR; private static Texture2D _cornerBL; private static Texture2D _cornerBR; private static Texture2D _crestTop; private static Texture2D _crestBottom; private static Texture2D _diamond; private static Texture2D _heart; private static Texture2D _dot; private static Texture2D _panel; private static Texture2D _white; private static Texture2D _btnNormal; private static Texture2D _btnHover; private static Texture2D _btnActive; private static Texture2D _rowNormal; private static Texture2D _rowHover; private static Texture2D _rowActive; private static Texture2D _selection; private static Texture2D _fieldTex; private static bool _railRepeats; private static float _railTileLength = 4f; public static float TextScale { get; private set; } = 1f; public static Color Metal(float alpha) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) return new Color(Gold.r, Gold.g, Gold.b, alpha); } public static Color MetalBright(float alpha) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) return new Color(GoldBright.r, GoldBright.g, GoldBright.b, alpha); } public static Color MetalDeep(float alpha) { //IL_001f: Unknown result type (might be due to invalid IL or missing references) return new Color(GoldDeep.r, GoldDeep.g, GoldDeep.b, alpha); } private static bool BakeInputsMatch(ThemeOptions o) { //IL_0020: 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_007f: 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_0051: 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_0068: 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) if (_everBaked && o.Frame == _bakedFrom.Frame && o.Metal == _bakedFrom.Metal && o.DeriveTones == _bakedFrom.DeriveTones && (o.DeriveTones || (o.Deep == _bakedFrom.Deep && o.Bright == _bakedFrom.Bright)) && o.Panel == _bakedFrom.Panel) { return Mathf.Approximately(o.PanelOpacity, _bakedFrom.PanelOpacity); } return false; } private static bool StyleInputsMatch(ThemeOptions o) { //IL_00c8: Unknown result type (might be due to invalid IL or missing references) //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00df: Unknown result type (might be due to invalid IL or missing references) //IL_00e9: Unknown result type (might be due to invalid IL or missing references) if (_everStyled && Title != null && Mathf.Approximately(o.Scale, _styledFrom.Scale) && o.BodyDelta == _styledFrom.BodyDelta && o.TitleDelta == _styledFrom.TitleDelta && o.SubTitleDelta == _styledFrom.SubTitleDelta && o.HeaderDelta == _styledFrom.HeaderDelta && o.ButtonDelta == _styledFrom.ButtonDelta && o.RowDelta == _styledFrom.RowDelta && o.FooterDelta == _styledFrom.FooterDelta && o.FieldDelta == _styledFrom.FieldDelta && o.Text == _styledFrom.Text) { return o.MutedText == _styledFrom.MutedText; } return false; } public static float S(float v) { return Mathf.Round(v * TextScale); } public static void EnsureBuilt(Color goldColour, float textScale = 1f, int fontSizeDelta = 0, int headingDelta = 0) { //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) ThemeOptions o = ThemeOptions.Default; o.Metal = goldColour; o.Scale = textScale; o.BodyDelta = fontSizeDelta; o.TitleDelta = headingDelta; o.SubTitleDelta = headingDelta; o.HeaderDelta = headingDelta; EnsureBuilt(o); } public static void EnsureBuilt(ThemeOptions o) { //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) //IL_0177: Unknown result type (might be due to invalid IL or missing references) //IL_0186: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Unknown result type (might be due to invalid IL or missing references) //IL_0191: Unknown result type (might be due to invalid IL or missing references) //IL_0196: Unknown result type (might be due to invalid IL or missing references) //IL_019c: Unknown result type (might be due to invalid IL or missing references) //IL_01a1: 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_00bc: Unknown result type (might be due to invalid IL or missing references) //IL_01af: Unknown result type (might be due to invalid IL or missing references) //IL_01b4: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Unknown result type (might be due to invalid IL or missing references) //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_028d: Unknown result type (might be due to invalid IL or missing references) //IL_0297: Unknown result type (might be due to invalid IL or missing references) //IL_029c: Unknown result type (might be due to invalid IL or missing references) //IL_03ca: Unknown result type (might be due to invalid IL or missing references) //IL_03df: Unknown result type (might be due to invalid IL or missing references) //IL_03f9: Unknown result type (might be due to invalid IL or missing references) //IL_03fe: Unknown result type (might be due to invalid IL or missing references) //IL_0418: Unknown result type (might be due to invalid IL or missing references) //IL_041d: Unknown result type (might be due to invalid IL or missing references) //IL_0437: Unknown result type (might be due to invalid IL or missing references) //IL_043c: Unknown result type (might be due to invalid IL or missing references) //IL_044b: Unknown result type (might be due to invalid IL or missing references) //IL_0450: Unknown result type (might be due to invalid IL or missing references) //IL_0482: Unknown result type (might be due to invalid IL or missing references) //IL_04aa: Unknown result type (might be due to invalid IL or missing references) //IL_04dc: Unknown result type (might be due to invalid IL or missing references) //IL_04e1: Unknown result type (might be due to invalid IL or missing references) //IL_0513: Unknown result type (might be due to invalid IL or missing references) //IL_052d: Unknown result type (might be due to invalid IL or missing references) //IL_0532: Unknown result type (might be due to invalid IL or missing references) //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0224: Unknown result type (might be due to invalid IL or missing references) //IL_023d: Unknown result type (might be due to invalid IL or missing references) //IL_0242: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)_railTop != (Object)null && BakeInputsMatch(o) && StyleInputsMatch(o)) { _appliedFrame = Time.frameCount; return; } if ((Object)(object)_railTop != (Object)null && _appliedFrame == Time.frameCount) { if (!_conflictLogged) { _conflictLogged = true; Log.LogWarning((object)("Two consumers of SharedUI.GiltFrameTheme asked for different values in the same " + $"frame (live: metal={_bakedFrom.Metal}, frame={_bakedFrom.Frame}, scale={TextScale}, " + $"delta={_fontDelta}; requested: metal={o.Metal}, frame={o.Frame}, scale={o.Scale}, " + $"delta={o.BodyDelta}). The theme is a single shared bake, so the first caller each " + "frame wins. Set the same UI theme values in every mod that uses this theme to resolve it.")); } return; } if ((Object)(object)_railTop != (Object)null && !BakeInputsMatch(o)) { DestroyTextures(); } if ((Object)(object)_railTop != (Object)null) { if (!StyleInputsMatch(o)) { BuildStyles(o); } _appliedFrame = Time.frameCount; return; } _bakedFrom = o; _everBaked = true; Gold = new Color(o.Metal.r, o.Metal.g, o.Metal.b, 1f); Parchment = o.Text; Muted = o.MutedText; if (!o.DeriveTones) { GoldDeep = o.Deep; GoldBright = o.Bright; } else if (Mathf.Approximately(Gold.r, 0.8f) && Mathf.Approximately(Gold.g, 0.62f) && Mathf.Approximately(Gold.b, 0.26f)) { GoldDeep = new Color(0.26f, 0.17f, 0.05f, 1f); GoldBright = new Color(1f, 0.94f, 0.72f, 1f); } else { GoldDeep = new Color(Gold.r * 0.325f, Gold.g * 0.274f, Gold.b * 0.192f, 1f); GoldBright = Color.Lerp(Gold, Color.white, 0.72f); } _railTop = BuildRail(o.Frame, Edge.Top); _railBottom = BuildRail(o.Frame, Edge.Bottom); _railLeft = BuildRail(o.Frame, Edge.Left); _railRight = BuildRail(o.Frame, Edge.Right); _railRepeats = RailRepeats(o.Frame); _railTileLength = RailTile(o.Frame); if (_railRepeats) { ((Texture)_railTop).wrapMode = (TextureWrapMode)0; ((Texture)_railBottom).wrapMode = (TextureWrapMode)0; ((Texture)_railLeft).wrapMode = (TextureWrapMode)0; ((Texture)_railRight).wrapMode = (TextureWrapMode)0; } _cornerTL = BuildCorner(o.Frame, mirrorX: false, mirrorY: false); _cornerTR = BuildCorner(o.Frame, mirrorX: true, mirrorY: false); _cornerBL = BuildCorner(o.Frame, mirrorX: false, mirrorY: true); _cornerBR = BuildCorner(o.Frame, mirrorX: true, mirrorY: true); _crestTop = BuildCrest(o.Frame, flip: false); _crestBottom = BuildCrest(o.Frame, flip: true); _diamond = BuildDiamond(14); _heart = BuildHeart(28); _dot = BuildDot(24); _panel = BuildPanel(64, o.Panel, o.PanelOpacity); _white = BuildSolid(Color.white); _btnNormal = BuildPatch(Surface(o, 0.35f, 0.95f), GoldDeep); _btnHover = BuildPatch(Surface(o, 1.3f, 0.97f), Gold); _btnActive = BuildPatch(Surface(o, 2.6f, 0.98f), GoldBright); _rowNormal = BuildPatch(Color.clear, Color.clear); _rowHover = BuildPatch(new Color(Gold.r, Gold.g, Gold.b, 0.1f), new Color(Gold.r, Gold.g, Gold.b, 0.45f)); _rowActive = BuildPatch(new Color(Gold.r, Gold.g, Gold.b, 0.2f), Gold); _selection = BuildSolid(new Color(Gold.r, Gold.g, Gold.b, 0.15f)); _fieldTex = BuildPatch(Surface(o, -0.45f, 0.95f), GoldDeep); BuildStyles(o); _appliedFrame = Time.frameCount; } private static Color Surface(ThemeOptions o, float lift, float alpha) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_003e: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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_0036: 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_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0067: 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) Color panel = o.Panel; if (lift >= 0f) { float num = Mathf.Clamp01(lift * 0.25f); panel = Color.Lerp(panel * (1f + lift * 0.55f), o.Metal, num); } else { panel *= Mathf.Clamp01(1f + lift); } return new Color(Mathf.Clamp01(panel.r), Mathf.Clamp01(panel.g), Mathf.Clamp01(panel.b), alpha); } private static void DestroyTextures() { Texture2D[] array = (Texture2D[])(object)new Texture2D[23] { _railTop, _railBottom, _railLeft, _railRight, _cornerTL, _cornerTR, _cornerBL, _cornerBR, _crestTop, _crestBottom, _diamond, _heart, _panel, _white, _dot, _btnNormal, _btnHover, _btnActive, _rowNormal, _rowHover, _rowActive, _selection, _fieldTex }; foreach (Texture2D val in array) { if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } } _railTop = (_railBottom = (_railLeft = (_railRight = null))); _cornerTL = (_cornerTR = (_cornerBL = (_cornerBR = null))); _crestTop = (_crestBottom = (_diamond = (_heart = (_dot = null)))); _panel = (_white = null); _btnNormal = (_btnHover = (_btnActive = null)); _rowNormal = (_rowHover = (_rowActive = (_selection = null))); _fieldTex = null; Title = null; } public static void DrawWindow(Rect win, string title) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) DrawPanelFill(win); DrawFrame(win); DrawShadowed(new Rect(((Rect)(ref win)).x + 74f, ((Rect)(ref win)).y + 18f + 8f, ((Rect)(ref win)).width - 148f, TitleHeight - 20f), (title ?? string.Empty).ToUpperInvariant(), Title); DrawRule(new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).y + 18f + TitleHeight - 12f, ((Rect)(ref win)).width - 80f, 1f)); } public static void DrawPanelFill(Rect win) { //IL_0034: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(new Rect(((Rect)(ref win)).x + 1f, ((Rect)(ref win)).y + 1f, ((Rect)(ref win)).width - 2f, ((Rect)(ref win)).height - 2f), (Texture)(object)_panel, (ScaleMode)0); } public static Rect Body(Rect win) { //IL_004c: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).y + 18f + TitleHeight, ((Rect)(ref win)).width - 80f, ((Rect)(ref win)).height - 36f - TitleHeight - FooterHeight); } public static Rect FooterLine(Rect win) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) return new Rect(((Rect)(ref win)).x + 18f + 22f, ((Rect)(ref win)).yMax - 18f - FooterHeight, ((Rect)(ref win)).width - 80f, S(18f)); } public static void DrawFrame(Rect r) { //IL_0161: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_01b9: Unknown result type (might be due to invalid IL or missing references) //IL_01e8: 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_006c: 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_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00d6: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Unknown result type (might be due to invalid IL or missing references) //IL_027f: Unknown result type (might be due to invalid IL or missing references) //IL_02aa: Unknown result type (might be due to invalid IL or missing references) //IL_02bb: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_030f: Unknown result type (might be due to invalid IL or missing references) //IL_0352: Unknown result type (might be due to invalid IL or missing references) //IL_037a: Unknown result type (might be due to invalid IL or missing references) float num = ((Rect)(ref r)).width - 148f; float num2 = ((Rect)(ref r)).height - 148f; if (_railRepeats) { float num3 = Mathf.Max(1f, _railTileLength); GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).y, num, 18f), (Texture)(object)_railTop, new Rect(0f, 0f, num / num3, 1f)); GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).yMax - 18f, num, 18f), (Texture)(object)_railBottom, new Rect(0f, 0f, num / num3, 1f)); GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railLeft, new Rect(0f, 0f, 1f, num2 / num3)); GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref r)).xMax - 18f, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railRight, new Rect(0f, 0f, 1f, num2 / num3)); } else { GUI.DrawTexture(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).y, num, 18f), (Texture)(object)_railTop); GUI.DrawTexture(new Rect(((Rect)(ref r)).x + 74f, ((Rect)(ref r)).yMax - 18f, num, 18f), (Texture)(object)_railBottom); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railLeft); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - 18f, ((Rect)(ref r)).y + 74f, 18f, num2), (Texture)(object)_railRight); } float num4 = 74f; GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 10f, ((Rect)(ref r)).y - 10f, 84f, 84f), (Texture)(object)_cornerTL); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num4, ((Rect)(ref r)).y - 10f, 84f, 84f), (Texture)(object)_cornerTR); GUI.DrawTexture(new Rect(((Rect)(ref r)).x - 10f, ((Rect)(ref r)).yMax - num4, 84f, 84f), (Texture)(object)_cornerBL); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - num4, ((Rect)(ref r)).yMax - num4, 84f, 84f), (Texture)(object)_cornerBR); float num5 = ((Rect)(ref r)).center.x - 28f; GUI.DrawTexture(new Rect(num5, ((Rect)(ref r)).y - 8f, 56f, 34f), (Texture)(object)_crestTop); GUI.DrawTexture(new Rect(num5, ((Rect)(ref r)).yMax + 8f - 34f, 56f, 34f), (Texture)(object)_crestBottom); DrawOutline(new Rect(((Rect)(ref r)).x + 18f, ((Rect)(ref r)).y + 18f, ((Rect)(ref r)).width - 36f, ((Rect)(ref r)).height - 36f), new Color(Gold.r, Gold.g, Gold.b, 0.45f), 1f); } public static void DrawOutline(Rect r, Color c, float t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = c; GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, t), (Texture)(object)_white); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).yMax - t, ((Rect)(ref r)).width, t), (Texture)(object)_white); GUI.DrawTexture(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)_white); GUI.DrawTexture(new Rect(((Rect)(ref r)).xMax - t, ((Rect)(ref r)).y, t, ((Rect)(ref r)).height), (Texture)(object)_white); GUI.color = color; } public static void DrawFill(Rect r, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = c; GUI.DrawTexture(r, (Texture)(object)_white); GUI.color = color; } public static void DrawInset(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001f: 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) DrawFill(r, new Color(0f, 0f, 0f, 0.45f)); DrawOutline(r, new Color(Gold.r, Gold.g, Gold.b, 0.32f), 1f); } public static void DrawSelection(Rect r) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) GUI.DrawTexture(r, (Texture)(object)_selection); } public static void DrawDot(Rect r, Color c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = c; GUI.DrawTexture(r, (Texture)(object)_dot, (ScaleMode)2); GUI.color = color; } public static void DrawHeartMark(Rect r, bool lit) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) Color color = GUI.color; GUI.color = (Color)(lit ? Gold : new Color(0.75f, 0.75f, 0.75f, 0.28f)); GUI.DrawTexture(r, (Texture)(object)_heart, (ScaleMode)2); GUI.color = color; } public static void DrawRule(Rect r) { //IL_0000: 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_0030: 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) DrawFill(r, new Color(Gold.r, Gold.g, Gold.b, 0.4f)); GUI.DrawTexture(new Rect(((Rect)(ref r)).center.x - 7f, ((Rect)(ref r)).y - 7f + 0.5f, 14f, 14f), (Texture)(object)_diamond); } public static void DrawShadowed(Rect r, string text, GUIStyle style) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0032: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) if (style != null && !string.IsNullOrEmpty(text)) { Color textColor = style.normal.textColor; style.normal.textColor = new Color(0f, 0f, 0f, 0.7f); GUI.Label(new Rect(((Rect)(ref r)).x + 1.5f, ((Rect)(ref r)).y + 1.5f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style); style.normal.textColor = textColor; GUI.Label(r, text, style); } } private static void BuildStyles(ThemeOptions o) { //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) //IL_0046: 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_0158: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: 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_0206: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0250: Expected O, but got Unknown //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_028a: Expected O, but got Unknown //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02d9: Expected O, but got Unknown //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_0313: Unknown result type (might be due to invalid IL or missing references) //IL_0318: Unknown result type (might be due to invalid IL or missing references) //IL_0320: Unknown result type (might be due to invalid IL or missing references) //IL_032f: Unknown result type (might be due to invalid IL or missing references) //IL_0336: Unknown result type (might be due to invalid IL or missing references) //IL_033b: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Expected O, but got Unknown //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_034a: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected O, but got Unknown //IL_0354: Unknown result type (might be due to invalid IL or missing references) //IL_0360: Expected O, but got Unknown //IL_03ba: Unknown result type (might be due to invalid IL or missing references) //IL_03ce: Unknown result type (might be due to invalid IL or missing references) //IL_03e2: Unknown result type (might be due to invalid IL or missing references) //IL_03f6: Unknown result type (might be due to invalid IL or missing references) _styledFrom = o; _everStyled = true; TextScale = Mathf.Clamp(o.Scale, 0.6f, 3f); _fontDelta = Mathf.Clamp(o.BodyDelta, -6, 24); Parchment = o.Text; Muted = o.MutedText; int num = Mathf.Clamp(o.TitleDelta, -16, 32); int styleDelta = Mathf.Clamp(o.SubTitleDelta, -16, 32); int styleDelta2 = Mathf.Clamp(o.HeaderDelta, -16, 32); int styleDelta3 = Mathf.Clamp(o.ButtonDelta, -16, 32); int styleDelta4 = Mathf.Clamp(o.RowDelta, -16, 32); int num2 = Mathf.Clamp(o.FooterDelta, -16, 32); int styleDelta5 = Mathf.Clamp(o.FieldDelta, -16, 32); float num3 = Mathf.Max(0, _fontDelta); float num4 = Mathf.Max(num3, (float)Mathf.Max(0, _fontDelta + num)); float num5 = Mathf.Max(num3, (float)Mathf.Max(0, _fontDelta + num2)); TitleHeight = 26f + Mathf.Round(28f * TextScale) + Mathf.Round(num4 * 1.5f); FooterHeight = Mathf.Max(30f, Mathf.Round(30f * TextScale) + num5); Font font = FindFont(); Title = Text(font, Pt(25, num), (FontStyle)1, GoldBright, (TextAnchor)4); SubTitle = Text(font, Pt(18, styleDelta), (FontStyle)1, Gold, (TextAnchor)3); Header = Text(font, Pt(13, styleDelta2), (FontStyle)1, Gold, (TextAnchor)3); Key = Text(font, Pt(13), (FontStyle)0, Muted, (TextAnchor)3); Value = Text(font, Pt(13), (FontStyle)1, Parchment, (TextAnchor)3); Note = Text(font, Pt(13), (FontStyle)2, Muted, (TextAnchor)4); Note.wordWrap = true; Footer = Text(font, Pt(11, num2), (FontStyle)0, Muted, (TextAnchor)4); Button = Patch(font, Pt(13, styleDelta3), (FontStyle)1, (TextAnchor)4, _btnNormal, _btnHover, _btnActive); Button.padding = new RectOffset(12, 12, 6, 6); Primary = Patch(font, Pt(16, styleDelta3), (FontStyle)1, (TextAnchor)4, _btnNormal, _btnHover, _btnActive); Primary.padding = new RectOffset(12, 12, 8, 8); Primary.normal.textColor = Gold; Row = Patch(font, Pt(14, styleDelta4), (FontStyle)0, (TextAnchor)3, _rowNormal, _rowHover, _rowActive); Row.padding = new RectOffset(12, 12, 4, 4); Row.normal.textColor = Parchment; ImageButton = Patch(font, Pt(11, styleDelta4), (FontStyle)0, (TextAnchor)7, _rowNormal, _rowHover, _rowActive); Field = new GUIStyle { font = font, fontSize = Pt(13, styleDelta5), alignment = (TextAnchor)3, padding = new RectOffset(8, 8, 4, 4), border = new RectOffset(3, 3, 3, 3), clipping = (TextClipping)1 }; Field.normal.background = _fieldTex; Field.focused.background = _fieldTex; Field.hover.background = _fieldTex; Field.active.background = _fieldTex; Field.normal.textColor = Parchment; Field.focused.textColor = GoldBright; Field.hover.textColor = Parchment; Field.active.textColor = Parchment; } private static int Pt(int designSize, int styleDelta = 0) { return Mathf.Max(8, Mathf.RoundToInt((float)designSize * TextScale) + _fontDelta + styleDelta); } private static GUIStyle Text(Font font, int size, FontStyle fs, Color colour, TextAnchor anchor) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0022: 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_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0044: Expected O, but got Unknown GUIStyle val = new GUIStyle { font = font, fontSize = size, fontStyle = fs, alignment = anchor, richText = true, wordWrap = false, clipping = (TextClipping)1 }; val.normal.textColor = colour; return val; } private static GUIStyle Patch(Font font, int size, FontStyle fs, TextAnchor anchor, Texture2D normal, Texture2D hover, Texture2D active) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0028: Unknown result type (might be due to invalid IL or missing references) //IL_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_003e: Expected O, but got Unknown //IL_003e: 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_0052: 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_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Unknown result type (might be due to invalid IL or missing references) //IL_007f: 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_008f: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00ba: Expected O, but got Unknown GUIStyle val = new GUIStyle { font = font, fontSize = size, fontStyle = fs, alignment = anchor, richText = true, wordWrap = false, border = new RectOffset(3, 3, 3, 3), clipping = (TextClipping)1 }; val.normal.background = normal; val.hover.background = hover; val.active.background = active; val.focused.background = normal; val.normal.textColor = Parchment; val.hover.textColor = GoldBright; val.active.textColor = GoldBright; val.focused.textColor = Parchment; return val; } private static Font FindFont() { Font[] array = Resources.FindObjectsOfTypeAll<Font>(); string[] array2 = new string[3] { "AveriaSerifLibre", "Norsebold", "Norse" }; foreach (string value in array2) { Font[] array3 = array; foreach (Font val in array3) { if ((Object)(object)val != (Object)null && ((Object)val).name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0) { return val; } } } return null; } private static int RailTile(FrameStyle style) { return style switch { FrameStyle.Serpent => 48, FrameStyle.Ironbound => 40, _ => 4, }; } private static bool RailRepeats(FrameStyle style) { return RailTile(style) > 4; } private static Texture2D BuildRail(FrameStyle style, Edge edge) { bool horizontal = edge == Edge.Top || edge == Edge.Bottom; int num = RailTile(style); int num2 = 18; int w = (horizontal ? num : num2); int h = (horizontal ? num2 : num); Painter p = new Painter(w, h) { MirrorY = (edge == Edge.Bottom), MirrorX = (edge == Edge.Right) }; Action<float, float, float> action = delegate(float a, float ac, float r) { if (horizontal) { p.Disc(a, ac, r); } else { p.Disc(ac, a, r); } }; switch (style) { case FrameStyle.Runic: RailProfile(p, horizontal, num, num2, 2f, 0.9f); RailProfile(p, horizontal, num, num2, 6.6f, 2.3f); RailProfile(p, horizontal, num, num2, 12.8f, 2.3f); break; case FrameStyle.Serpent: { for (int num3 = 0; num3 <= num * 3; num3++) { float num4 = (float)num3 / (float)(num * 3); float arg = num4 * (float)num; float num5 = Mathf.Sin(num4 * (float)Math.PI * 2f) * 3.6f; action(arg, 9f + num5, 2.3f); action(arg, 9f - num5, 2.3f); } break; } case FrameStyle.Ironbound: RailProfile(p, horizontal, num, num2, 2.4f, 1.3f); RailProfile(p, horizontal, num, num2, 9f, 5.2f); RailProfile(p, horizontal, num, num2, 15.6f, 1.3f); action((float)num * 0.5f, 9f, 3.1f); break; default: RailProfile(p, horizontal, num, num2, 4.4f, 2.7f); RailProfile(p, horizontal, num, num2, 12.4f, 1.6f); break; } return p.Bake(); } private static void RailProfile(Painter p, bool horizontal, int along, int band, float mid, float half) { for (int i = 0; i < along; i++) { for (int j = 0; j < band; j++) { float d = Mathf.Abs((float)j - mid); if (horizontal) { p.RailPixel(i, j, d, half); } else { p.RailPixel(j, i, d, half); } } } } private static Texture2D BuildCorner(FrameStyle style, bool mirrorX, bool mirrorY) { //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00d1: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_0138: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_0166: Unknown result type (might be due to invalid IL or missing references) if (style != FrameStyle.Gilt) { return BuildCornerAlt(style, mirrorX, mirrorY); } Painter painter = new Painter(84, 84) { MirrorX = mirrorX, MirrorY = mirrorY }; painter.RailElbow(14.4f, 2.7f, 32f); painter.RailElbow(22.4f, 1.6f, 32f); painter.Lozenge(11f, 11f, 4.5f); painter.Taper(new Vector2(13.5f, 13.5f), new Vector2(19.3f, 19.3f), 1.2f, 2.2f); painter.Lozenge(36f, 36f, 3.4f); for (int i = 0; i < 2; i++) { painter.Transpose = i == 1; painter.Taper(new Vector2(38.5f, 35f), new Vector2(47f, 32f), 1.4f, 0.45f); painter.Spiral(new Vector2(50f, 31f), 1.3f, 0.33f, 0f, 6.8f, 5.371f, 0.55f, 2.4f); painter.Bezier(new Vector2(56f, 36f), new Vector2(68f, 41f), new Vector2(78f, 30f), 2.2f, 0.35f); painter.Spiral(new Vector2(76f, 32f), 0.9f, 0.32f, 0f, 4.6f, 1f, 1.1f, 0.3f); painter.Disc(58f, 34f, 1.8f); } painter.Transpose = false; return painter.Bake(); } private static Texture2D BuildCornerAlt(FrameStyle style, bool mirrorX, bool mirrorY) { //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Unknown result type (might be due to invalid IL or missing references) //IL_0192: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01c0: 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_01ee: Unknown result type (might be due to invalid IL or missing references) //IL_0237: Unknown result type (might be due to invalid IL or missing references) //IL_0246: Unknown result type (might be due to invalid IL or missing references) //IL_0255: Unknown result type (might be due to invalid IL or missing references) //IL_0285: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Unknown result type (might be due to invalid IL or missing references) //IL_02a3: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) Painter painter = new Painter(84, 84) { MirrorX = mirrorX, MirrorY = mirrorY }; switch (style) { case FrameStyle.Runic: { painter.SquareElbow(12f, 0.9f, 32f); painter.SquareElbow(16.6f, 2.3f, 32f); painter.SquareElbow(22.8f, 2.3f, 32f); painter.Taper(new Vector2(26f, 54f), new Vector2(54f, 26f), 1.9f, 1.9f); painter.Taper(new Vector2(30f, 30f), new Vector2(50f, 50f), 1.5f, 1.5f); painter.Lozenge(40f, 40f, 4.2f); for (int k = 0; k < 2; k++) { painter.Transpose = k == 1; painter.Disc(52f, 9.7f, 1.9f); painter.Disc(66f, 9.7f, 1.9f); painter.Disc(80f, 9.7f, 1.9f); } painter.Transpose = false; break; } case FrameStyle.Serpent: { painter.RailElbow(15.4f, 2.3f, 32f); painter.RailElbow(22.6f, 2.3f, 32f); painter.Lozenge(19f, 19f, 7.2f); painter.Taper(new Vector2(15f, 15f), new Vector2(6f, 6f), 3.4f, 1.1f); painter.Taper(new Vector2(23f, 14f), new Vector2(12f, 8f), 1.6f, 0.5f); painter.Taper(new Vector2(14f, 23f), new Vector2(8f, 12f), 1.6f, 0.5f); painter.Disc(24f, 16f, 1.7f); painter.Disc(16f, 24f, 1.7f); painter.Bezier(new Vector2(28f, 20f), new Vector2(24f, 24f), new Vector2(20f, 28f), 1.5f, 1.5f); for (int j = 0; j < 2; j++) { painter.Transpose = j == 1; painter.Bezier(new Vector2(34f, 30f), new Vector2(50f, 24f), new Vector2(64f, 33f), 2.3f, 2.3f); painter.Spiral(new Vector2(74f, 26f), 1.1f, 0.3f, 0f, 5f, 2.2f, 2.1f, 0.9f); } painter.Transpose = false; break; } default: { painter.SquareElbow(12.4f, 1.3f, 32f); painter.SquareElbow(19f, 5.2f, 32f); painter.SquareElbow(25.6f, 1.3f, 32f); painter.Disc(19f, 19f, 4.6f); painter.Disc(19f, 19f, 2f); for (int i = 0; i < 2; i++) { painter.Transpose = i == 1; painter.Disc(44f, 19f, 3.1f); painter.Disc(70f, 19f, 3.1f); } painter.Transpose = false; break; } } return painter.Bake(); } private static Texture2D BuildCrest(FrameStyle style, bool flip) { //IL_0050: 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_007e: Unknown result type (might be due to invalid IL or missing references) //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00f0: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_010e: Unknown result type (might be due to invalid IL or missing references) //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_014b: Unknown result type (might be due to invalid IL or missing references) if (style != FrameStyle.Gilt) { return BuildCrestAlt(style, flip); } Painter painter = new Painter(56, 34); painter.MirrorY = flip; painter.Disc(28f, 2.5f, 1.8f); painter.Lozenge(28f, 9f, 6.5f); painter.Taper(new Vector2(28f, 14f), new Vector2(28f, 24f), 2.2f, 1.2f); painter.Spiral(new Vector2(17f, 25f), 1.2f, 0.33f, 0f, 5.4f, 2.6f, 2f, 0.35f); painter.Spiral(new Vector2(39f, 25f), 1.2f, 0.33f, 0f, 5.4f, 2.6f, 2f, 0.35f, mirror: true); painter.Bezier(new Vector2(23f, 19f), new Vector2(13f, 24f), new Vector2(4f, 16f), 1.6f, 0.3f); painter.Bezier(new Vector2(33f, 19f), new Vector2(43f, 24f), new Vector2(52f, 16f), 1.6f, 0.3f); painter.Disc(3f, 14f, 1.5f); painter.Disc(53f, 14f, 1.5f); return painter.Bake(); } private static Texture2D BuildCrestAlt(FrameStyle style, bool flip) { //IL_0041: 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_006f: 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_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ac: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0148: Unknown result type (might be due to invalid IL or missing references) //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_0190: Unknown result type (might be due to invalid IL or missing references) //IL_019f: Unknown result type (might be due to invalid IL or missing references) //IL_01be: 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_01dc: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) Painter painter = new Painter(56, 34) { MirrorY = flip }; switch (style) { case FrameStyle.Runic: painter.Lozenge(28f, 8f, 6f); painter.Taper(new Vector2(28f, 13f), new Vector2(28f, 27f), 2f, 2f); painter.Taper(new Vector2(28f, 16f), new Vector2(17f, 25f), 1.7f, 1.1f); painter.Taper(new Vector2(28f, 16f), new Vector2(39f, 25f), 1.7f, 1.1f); painter.Disc(7f, 10f, 1.9f); painter.Disc(49f, 10f, 1.9f); break; case FrameStyle.Serpent: painter.Lozenge(28f, 11f, 5.2f); painter.Spiral(new Vector2(19f, 17f), 1.2f, 0.32f, 0f, 5.6f, 2.4f, 2.1f, 0.5f); painter.Spiral(new Vector2(37f, 17f), 1.2f, 0.32f, 0f, 5.6f, 2.4f, 2.1f, 0.5f, mirror: true); painter.Bezier(new Vector2(24f, 20f), new Vector2(12f, 26f), new Vector2(2f, 15f), 2f, 1f); painter.Bezier(new Vector2(32f, 20f), new Vector2(44f, 26f), new Vector2(54f, 15f), 2f, 1f); break; default: painter.Taper(new Vector2(3f, 12f), new Vector2(53f, 12f), 4.4f, 4.4f); painter.Disc(28f, 12f, 8.2f); painter.Disc(28f, 12f, 4.4f); painter.Disc(11f, 12f, 2.4f); painter.Disc(45f, 12f, 2.4f); painter.Disc(28f, 25f, 2.4f); break; } return painter.Bake(); } private static Texture2D BuildDot(int size) { //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00ce: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size, (TextureWrapMode)1, (FilterMode)1); Color[] array = (Color[])(object)new Color[size * size]; float num = (float)(size - 1) * 0.5f; float num2 = (float)size * 0.42f; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = 0f; for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { float num4 = (float)j + ((float)l + 0.5f) * 0.5f - 0.5f - num; float num5 = (float)i + ((float)k + 0.5f) * 0.5f - 0.5f - num; if (Mathf.Sqrt(num4 * num4 + num5 * num5) <= num2) { num3 += 0.25f; } } } array[i * size + j] = new Color(1f, 1f, 1f, num3); } } val.SetPixels(array);