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 Sailwright v0.1.0
plugins/Sailwright/Sailwright.dll
Decompiled 2 weeks ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Sailwright.Core; using Sailwright.Game; using Sailwright.UI; using SharedUI; using Splatform; using UnityEngine; [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_valheim")] [assembly: AssemblyCompany("Sailwright")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyDescription("Paint your ship's sail (colours, patterns, emblems) for everyone to see, and see through it while aboard. Pure BepInEx, no Jotunn.")] [assembly: AssemblyFileVersion("0.1.0.0")] [assembly: AssemblyInformationalVersion("0.1.0")] [assembly: AssemblyProduct("Sailwright")] [assembly: AssemblyTitle("Sailwright")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.1.0.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace 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_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_003a: Unknown result type (might be due to invalid IL or missing references) //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Unknown result type (might be due to invalid IL or missing references) //IL_0167: Unknown result type (might be due to invalid IL or missing references) //IL_0182: Unknown result type (might be due to invalid IL or missing references) //IL_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01b8: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01fa: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0244: Expected O, but got Unknown //IL_0274: Unknown result type (might be due to invalid IL or missing references) //IL_027e: Expected O, but got Unknown //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_02c3: Unknown result type (might be due to invalid IL or missing references) //IL_02cd: Expected O, but got Unknown //IL_02d7: Unknown result type (might be due to invalid IL or missing references) //IL_0307: Unknown result type (might be due to invalid IL or missing references) //IL_030c: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_0323: Unknown result type (might be due to invalid IL or missing references) //IL_032a: 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_0339: Expected O, but got Unknown //IL_0339: Unknown result type (might be due to invalid IL or missing references) //IL_033e: Unknown result type (might be due to invalid IL or missing references) //IL_0348: Expected O, but got Unknown //IL_0348: Unknown result type (might be due to invalid IL or missing references) //IL_0354: Expected O, but got Unknown //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03ea: Unknown result type (might be due to invalid IL or missing references) 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; _styledFrom = o; _everStyled = true; } 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); val.Apply(false); return val; } private static Texture2D BuildDiamond(int size) { Painter painter = new Painter(size, size); float num = (float)(size - 1) * 0.5f; painter.Lozenge(num, num, (float)size * 0.36f); return painter.Bake(); } private static Texture2D BuildHeart(int size) { //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(size, size, (TextureWrapMode)1, (FilterMode)1); Color[] array = (Color[])(object)new Color[size * size]; for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num = 0f; for (int k = 0; k < 2; k++) { for (int l = 0; l < 2; l++) { float num2 = (((float)j + ((float)l + 0.5f) * 0.5f) / (float)size - 0.5f) * 2.6f; float num3 = (((float)i + ((float)k + 0.5f) * 0.5f) / (float)size - 0.42f) * 2.9f; float num4 = num2 * num2 + num3 * num3 - 1f; if (num4 * num4 * num4 - num2 * num2 * num3 * num3 * num3 <= 0f) { num += 0.25f; } } } array[i * size + j] = new Color(1f, 1f, 1f, num); } } val.SetPixels(array); val.Apply(false); return val; } private static Texture2D BuildPanel(int size, Color colour, float opacity) { //IL_0085: Unknown result type (might be due to invalid IL or missing references) //IL_008e: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00a6: 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 = Mathf.Clamp01(opacity); for (int i = 0; i < size; i++) { for (int j = 0; j < size; j++) { float num3 = ((float)j - num) / num; float num4 = ((float)i - num) / num; float num5 = Mathf.Clamp01(1f - 0.55f * Mathf.Sqrt(0.6f * (num3 * num3 + num4 * num4))); float num6 = 0.73f + 0.27f * num5; array[i * size + j] = new Color(colour.r * num6, colour.g * num6, colour.b * num6, num2); } } val.SetPixels(array); val.Apply(false); return val; } private static Texture2D BuildPatch(Color fill, Color border) { //IL_0048: 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_0049: Unknown result type (might be due to invalid IL or missing references) Texture2D val = New(12, 12, (TextureWrapMode)1, (FilterMode)0); Color[] array = (Color[])(object)new Color[144]; for (int i = 0; i < 12; i++) { for (int j = 0; j < 12; j++) { int num = Mathf.Min(Mathf.Min(j, i), Mathf.Min(11 - j, 11 - i)); array[i * 12 + j] = ((num == 0) ? border : fill); } } val.SetPixels(array); val.Apply(false); return val; } private static Texture2D BuildSolid(Color c) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) Texture2D obj = New(1, 1, (TextureWrapMode)1, (FilterMode)0); obj.SetPixel(0, 0, c); obj.Apply(false); return obj; } private static Texture2D New(int w, int h, TextureWrapMode wrap, FilterMode filter) { //IL_0004: Unknown result type (might be due to invalid IL or missing references) //IL_0009: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0011: 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_0020: Expected O, but got Unknown return new Texture2D(w, h, (TextureFormat)4, false) { wrapMode = wrap, filterMode = filter, hideFlags = (HideFlags)61 }; } } } namespace Sailwright { [BepInPlugin("com.ravenironstudios.sailwright", "Sailwright", "0.1.0")] public class SailwrightPlugin : BaseUnityPlugin { public const string ModGuid = "com.ravenironstudios.sailwright"; public const string ModName = "Sailwright"; internal static SailwrightPlugin Instance; internal static ManualLogSource Log; internal static ConfigEntry<bool> SeeThroughEnabled; internal static ConfigEntry<KeyboardShortcut> SeeThroughKey; internal static ConfigEntry<float> SeeThroughIntensity; internal static ConfigEntry<KeyboardShortcut> PaintKey; internal static ConfigEntry<int> TextureSize; internal static ConfigEntry<bool> DebugLog; private Harmony _harmony; private void Awake() { //IL_0048: Unknown result type (might be due to invalid IL or missing references) //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Expected O, but got Unknown //IL_00b0: Unknown result type (might be due to invalid IL or missing references) //IL_00f9: Unknown result type (might be due to invalid IL or missing references) //IL_0103: Expected O, but got Unknown //IL_0180: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Expected O, but got Unknown Instance = this; Log = ((BaseUnityPlugin)this).Logger; SeeThroughEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("See-through", "See-through sail", true, "Make the sail see-through for you while you are aboard (only your view; others see it as normal)."); SeeThroughKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("See-through", "Toggle key", new KeyboardShortcut((KeyCode)121, Array.Empty<KeyCode>()), "Turns the see-through sail on and off."); SeeThroughIntensity = ((BaseUnityPlugin)this).Config.Bind<float>("See-through", "Opacity", 0.2f, new ConfigDescription("How solid the sail stays while see-through: 0 hides it, 1 is fully solid.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>())); PaintKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Painting", "Paint key", new KeyboardShortcut((KeyCode)112, Array.Empty<KeyCode>()), "At the helm of a ship you may paint, this opens the sail painter."); TextureSize = ((BaseUnityPlugin)this).Config.Bind<int>("Painting", "Texture size", 512, new ConfigDescription("Resolution of painted sails on your screen. Lower saves memory on big fleets.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[3] { 256, 512, 1024 }), Array.Empty<object>())); DebugLog = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Debug logging", false, "Log painting, permission and texture details."); SeeThroughIntensity.SettingChanged += delegate { SailTextures.RefreshSeeThroughOpacity(); }; TextureSize.SettingChanged += delegate { SailTracker.RepaintAll(); }; _harmony = new Harmony("com.ravenironstudios.sailwright"); _harmony.PatchAll(typeof(SailwrightPlugin).Assembly); Log.LogInfo((object)"Sailwright 0.1.0 loaded."); } private void Update() { //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0071: Unknown result type (might be due to invalid IL or missing references) try { if (!PainterPanel.IsOpen && !InputBlocked()) { KeyboardShortcut value = SeeThroughKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { SeeThroughEnabled.Value = !SeeThroughEnabled.Value; Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, SeeThroughEnabled.Value ? "See-through sail: on" : "See-through sail: off", 0, (Sprite)null, false); } } else { value = PaintKey.Value; if (((KeyboardShortcut)(ref value)).IsDown()) { PainterPanel.TryOpenAtHelm(); } } } PainterPanel.Tick(); } catch (Exception arg) { Log.LogWarning((object)$"Update: {arg}"); } } private void OnGUI() { PainterPanel.OnGUI(); } private void OnDestroy() { Harmony harmony = _harmony; if (harmony != null) { harmony.UnpatchSelf(); } SailTextures.Clear(); } internal static bool InputBlocked() { if ((Object)(object)Player.m_localPlayer == (Object)null) { return true; } if ((Object)(object)Chat.instance != (Object)null && Chat.instance.HasFocus()) { return true; } if (Console.IsVisible() || TextInput.IsVisible() || Menu.IsVisible() || InventoryGui.IsVisible()) { return true; } if (Minimap.IsOpen()) { return true; } return false; } internal static void Debug(string msg) { if (DebugLog != null && DebugLog.Value) { Log.LogInfo((object)msg); } } } internal static class SailwrightBuild { internal const string Version = "0.1.0"; } } namespace Sailwright.UI { internal static class PainterPanel { private const float Width = 660f; private const float Height = 640f; private const float CloseDistance = 15f; private const float PreviewDelay = 0.2f; private const float ApplyTimeout = 6f; private static Ship _ship; private static SailTracker _tracker; private static SailDesign _design; private static Rect _rect; private static Vector2 _scroll; private static string _message; private static bool _dirty; private static float _dirtyAt; private static Action _pending; private static readonly Dictionary<string, string> HexBuffers = new Dictionary<string, string>(); private static readonly List<(SailTracker tracker, string design, float until)> Applied = new List<(SailTracker, string, float)>(); public static bool IsOpen => (Object)(object)_ship != (Object)null; public static void TryOpenAtHelm() { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null) { return; } ShipControlls val = null; GameObject hoverObject = ((Humanoid)localPlayer).GetHoverObject(); if ((Object)(object)hoverObject != (Object)null) { val = hoverObject.GetComponentInParent<ShipControlls>(); } if ((Object)(object)val == (Object)null && (Object)(object)localPlayer.GetControlledShip() != (Object)null) { val = ((Component)localPlayer.GetControlledShip()).GetComponentInChildren<ShipControlls>(); } if ((Object)(object)val == (Object)null || (Object)(object)val.m_ship == (Object)null || !InHelmReach(val, localPlayer)) { return; } Ship ship = val.m_ship; if (!SailNet.LocalMayPaint(ship)) { ((Character)localPlayer).Message((MessageType)2, "Only the ship's builder (or its first painter) and admins may paint this sail.", 0, (Sprite)null, false); return; } SailTracker sailTracker = ((Component)ship).GetComponent<SailTracker>() ?? SailTracker.Attach(ship); if ((Object)(object)sailTracker == (Object)null) { ((Character)localPlayer).Message((MessageType)2, "This ship's sail cannot be painted.", 0, (Sprite)null, false); } else { Open(ship, sailTracker); } } internal static void Open(Ship ship, SailTracker tracker) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0094: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Unknown result type (might be due to invalid IL or missing references) _ship = ship; _tracker = tracker; _design = (SailDesign.TryParse(tracker.StoredDesign(), out var d) ? d : new SailDesign()); HexBuffers.Clear(); _message = null; _scroll = Vector2.zero; _dirty = false; float num = Mathf.Min(660f, (float)Screen.width - 40f); float num2 = Mathf.Min(640f, (float)Screen.height - 40f); _rect = new Rect(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2); } public static void Close(bool keepPreview = false) { if (!keepPreview && (Object)(object)_tracker != (Object)null) { _tracker.ClearPreview(); } _ship = null; _tracker = null; _pending = null; } internal static bool InHelmReach(ShipControlls helm, Player p) { //IL_0034: 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) if ((Object)(object)helm.m_attachPoint == (Object)null || (Object)(object)p == (Object)null) { return false; } if ((Object)(object)p.GetControlledShip() == (Object)(object)helm.m_ship) { return true; } return Vector3.Distance(((Component)p).transform.position, helm.m_attachPoint.position) < helm.m_maxUseRange; } public static void Tick() { //IL_0044: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) TickApplied(); if (IsOpen) { Player localPlayer = Player.m_localPlayer; if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead() || (Object)(object)_ship == (Object)null || (Object)(object)_tracker == (Object)null || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)_ship).transform.position) > 15f || Input.GetKeyDown((KeyCode)27)) { Close(); } else if (_dirty && Time.unscaledTime - _dirtyAt >= 0.2f) { _dirty = false; _tracker.SetPreview(_design.Format()); } } } private static void TickApplied() { for (int num = Applied.Count - 1; num >= 0; num--) { var (sailTracker, text, num2) = Applied[num]; if ((Object)(object)sailTracker == (Object)null) { Applied.RemoveAt(num); } else if (sailTracker.StoredDesign() == text) { if ((Object)(object)sailTracker != (Object)(object)_tracker) { sailTracker.ClearPreview(); } Applied.RemoveAt(num); } else if (Time.unscaledTime > num2) { if ((Object)(object)sailTracker != (Object)(object)_tracker) { sailTracker.ClearPreview(); } Applied.RemoveAt(num); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)2, "The ship did not take the paint. Whoever is sailing her may not have Sailwright.", 0, (Sprite)null, false); } } } } private static void MarkDirty() { _dirty = true; _dirtyAt = Time.unscaledTime; } public static void OnGUI() { //IL_0008: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_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_03b1: Unknown result type (might be due to invalid IL or missing references) //IL_03b6: Unknown result type (might be due to invalid IL or missing references) //IL_03d6: Unknown result type (might be due to invalid IL or missing references) //IL_03dc: Invalid comparison between Unknown and I4 if (!IsOpen) { return; } GiltFrameTheme.EnsureBuilt(GiltFrameTheme.Gold); GiltFrameTheme.DrawWindow(_rect, "ᚱ Sailwright: " + ShipTitle(_ship) + " ᚱ"); GUILayout.BeginArea(GiltFrameTheme.Body(_rect)); _scroll = GUILayout.BeginScrollView(_scroll, Array.Empty<GUILayoutOption>()); Section("Pattern"); Grid(SailDesign.Patterns, _design.Pattern, 5, delegate(string id) { _design.Pattern = id; MarkDirty(); }, Pretty); Section("Main colour"); ColourRow("main", _design.Main, delegate(Rgb c) { _design.Main = c; MarkDirty(); }, enabled: true); Section("Second colour"); ColourRow("second", _design.Second, delegate(Rgb c) { _design.Second = c; MarkDirty(); }, _design.Pattern != "solid"); Section("Emblem"); Grid(SailDesign.Emblems, _design.Emblem, 4, delegate(string id) { _design.Emblem = id; MarkDirty(); }, Pretty); bool enabled = _design.Emblem != "none"; Section("Emblem colour"); ColourRow("emblem", _design.EmblemColour, delegate(Rgb c) { _design.EmblemColour = c; MarkDirty(); }, enabled); Section("Emblem size"); GUI.enabled = enabled; GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); string[] array = new string[3] { "Small", "Medium", "Large" }; for (int num = 0; num < 3; num++) { int size = num + 1; if (GUILayout.Button(array[num], (_design.EmblemSize == size) ? GiltFrameTheme.Primary : GiltFrameTheme.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(110f) })) { _pending = delegate { _design.EmblemSize = size; MarkDirty(); }; } } GUILayout.EndHorizontal(); GUI.enabled = true; GUILayout.EndScrollView(); GUILayout.Space(6f); GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); if (GUILayout.Button("Apply", GiltFrameTheme.Primary, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { _pending = Apply; } if (GUILayout.Button("Vanilla sail", GiltFrameTheme.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { _pending = ResetToVanilla; } if (GUILayout.Button("Cancel", GiltFrameTheme.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(150f) })) { _pending = delegate { Close(); }; } GUILayout.EndHorizontal(); if (!string.IsNullOrEmpty(_message)) { GUILayout.Label(_message, GiltFrameTheme.Note, Array.Empty<GUILayoutOption>()); } GUILayout.EndArea(); GUI.Label(GiltFrameTheme.FooterLine(_rect), "Picks show on your sail at once; Apply shows them to everyone. Esc closes.", GiltFrameTheme.Footer); if (_pending == null || (int)Event.current.type != 7) { return; } Action pending = _pending; _pending = null; try { pending(); } catch (Exception ex) { SailwrightPlugin.Log.LogWarning((object)("Painter: " + ex.Message)); } } private static void Section(string title) { GUILayout.Space(8f); GUILayout.Label(title, GiltFrameTheme.Header, Array.Empty<GUILayoutOption>()); } private static void Grid(string[] ids, string selected, int columns, Action<string> pick, Func<string, string> label) { for (int i = 0; i < ids.Length; i += columns) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int j = i; j < Math.Min(ids.Length, i + columns); j++) { string id = ids[j]; if (GUILayout.Button(label(id), (id == selected) ? GiltFrameTheme.Primary : GiltFrameTheme.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(118f) })) { _pending = delegate { pick(id); }; } } GUILayout.EndHorizontal(); } } private static void ColourRow(string slot, Rgb current, Action<Rgb> pick, bool enabled) { //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0086: Unknown result type (might be due to invalid IL or missing references) //IL_0088: 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_00cc: 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_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: Unknown result type (might be due to invalid IL or missing references) //IL_00e2: Unknown result type (might be due to invalid IL or missing references) GUI.enabled = enabled; Rgb[] palette = SailDesign.Palette; for (int i = 0; i < 2; i++) { GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>()); for (int j = i * 8; j < i * 8 + 8 && j < palette.Length; j++) { Rgb c = palette[j]; Rect rect = GUILayoutUtility.GetRect(34f, 26f, (GUILayoutOption[])(object)new GUILayoutOption[2] { GUILayout.Width(34f), GUILayout.Height(26f) }); GiltFrameTheme.DrawFill(rect, ToColor(c, enabled ? 1f : 0.35f)); if (c.Equals(current)) { GiltFrameTheme.DrawOutline(rect, GiltFrameTheme.GoldBright, 3f); } else { GiltFrameTheme.DrawOutline(rect, GiltFrameTheme.MetalDeep(0.9f), 1f); } if (GUI.Button(rect, GUIContent.none, GUIStyle.none)) { _pending = delegate { pick(c); HexBuffers[slot] = c.Hex; }; } GUILayout.Space(4f); } if (i == 0) { GUILayout.Space(10f); if (!HexBuffers.TryGetValue(slot, out var value)) { value = current.Hex; } string text = GUILayout.TextField(value, 7, GiltFrameTheme.Field, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(96f) }); if (text != value) { HexBuffers[slot] = text; if (Rgb.TryParse(text, out var typed)) { _pending = delegate { pick(typed); }; } } } GUILayout.EndHorizontal(); GUILayout.Space(3f); } GUI.enabled = true; } private static void Apply() { if ((Object)(object)_ship == (Object)null || (Object)(object)_tracker == (Object)null) { return; } if (!SailNet.LocalMayPaint(_ship)) { _message = "You may no longer paint this sail."; return; } string text = _design.Format(); _tracker.SetPreview(text); SailNet.Request(_ship, text); Applied.RemoveAll(((SailTracker tracker, string design, float until) a) => (Object)(object)a.tracker == (Object)(object)_tracker); Applied.Add((_tracker, text, Time.unscaledTime + 6f)); Player localPlayer = Player.m_localPlayer; if (localPlayer != null) { ((Character)localPlayer).Message((MessageType)1, "Sail painted.", 0, (Sprite)null, false); } Close(keepPreview: true); } private static void ResetToVanilla() { if (!((Object)(object)_ship == (Object)null) && !((Object)(object)_tracker == (Object)null)) { SailNet.Request(_ship, ""); _tracker.SetPreview(""); Applied.RemoveAll(((SailTracker tracker, string design, float until) a) => (Object)(object)a.tracker == (Object)(object)_tracker); Applied.Add((_tracker, "", Time.unscaledTime + 6f)); Close(keepPreview: true); } } private static string ShipTitle(Ship ship) { if ((Object)(object)ship == (Object)null) { return ""; } ZNetView component = ((Component)ship).GetComponent<ZNetView>(); string text = (((Object)(object)component != (Object)null && component.IsValid()) ? component.GetZDO().GetString("NjordShipName", "") : ""); if (!string.IsNullOrEmpty(text)) { return text; } Piece component2 = ((Component)ship).GetComponent<Piece>(); string text2 = (((Object)(object)component2 != (Object)null) ? component2.m_name : ((Object)ship).name.Replace("(Clone)", "")); if (Localization.instance == null) { return text2; } return Localization.instance.Localize(text2); } private static string Pretty(string id) { if (!(id == "none")) { if (id == "sunwheel") { return "Sun wheel"; } return char.ToUpperInvariant(id[0]) + id.Substring(1); } return "None"; } private static Color ToColor(Rgb c, float a) { //IL_0028: Unknown result type (might be due to invalid IL or missing references) return new Color((float)(int)c.R / 255f, (float)(int)c.G / 255f, (float)(int)c.B / 255f, a); } } } namespace Sailwright.Game { [HarmonyPatch(typeof(Ship), "Start")] internal static class Ship_Start_Patch { [HarmonyPostfix] private static void Postfix(Ship __instance) { try { SailNet.Register(__instance); SailTracker.Attach(__instance); } catch (Exception ex) { SailwrightPlugin.Log.LogWarning((object)("Could not set up " + ((__instance != null) ? ((Object)__instance).name : null) + ": " + ex.Message)); } } } [HarmonyPatch(typeof(ShipControlls), "GetHoverText")] internal static class ShipControlls_GetHoverText_Patch { [HarmonyPostfix] private static void Postfix(ShipControlls __instance, ref string __result) { //IL_004f: Unknown result type (might be due to invalid IL or missing references) try { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.m_ship == (Object)null) && !((Object)(object)localPlayer == (Object)null) && PainterPanel.InHelmReach(__instance, localPlayer) && SailNet.LocalMayPaint(__instance.m_ship)) { __result += $"\n[<color=yellow><b>{SailwrightPlugin.PaintKey.Value}</b></color>] Paint sail"; } } catch (Exception ex) { SailwrightPlugin.Debug("Hover text: " + ex.Message); } } } [HarmonyPatch(typeof(StoreGui), "IsVisible")] internal static class StoreGui_IsVisible_Patch { [HarmonyPostfix] private static void Postfix(ref bool __result) { if (PainterPanel.IsOpen) { __result = true; } } } [HarmonyPatch(typeof(ZNetScene), "Awake")] internal static class ZNetScene_Awake_Patch { [HarmonyPostfix] private static void Postfix() { SailTextures.RetryShaderSearch(); } } internal static class SailNet { public const string DesignKey = "Sailwright_Design"; public const string ClaimKey = "Sailwright_Painter"; public const string RpcName = "Sailwright_SetDesign"; public static void Register(Ship ship) { ZNetView nview = (((Object)(object)ship != (Object)null) ? ((Component)ship).GetComponent<ZNetView>() : null); if ((Object)(object)nview == (Object)null || !nview.IsValid()) { return; } try { nview.Register<string>("Sailwright_SetDesign", (Action<long, string>)delegate(long sender, string design) { OnRequest(ship, nview, sender, design); }); } catch (ArgumentException) { } } public static void Request(Ship ship, string design) { ZNetView val = (((Object)(object)ship != (Object)null) ? ((Component)ship).GetComponent<ZNetView>() : null); if (!((Object)(object)val == (Object)null) && val.IsValid()) { string text = (string.IsNullOrEmpty(design) ? "" : SailDesign.Normalise(design)); if (val.IsOwner()) { OnRequest(ship, val, ZDOMan.GetSessionID(), text); return; } val.InvokeRPC("Sailwright_SetDesign", new object[1] { text }); } } private static void OnRequest(Ship ship, ZNetView nview, long sender, string design) { if ((Object)(object)nview == (Object)null || !nview.IsValid() || !nview.IsOwner()) { return; } if (!Identify(sender, out var playerId, out var admin)) { SailwrightPlugin.Debug($"Paint request from unknown peer {sender} ignored."); return; } if (!MayPaint(ship, playerId, admin)) { SailwrightPlugin.Debug($"Paint request from player {playerId} on {((Object)ship).name} refused (not builder/painter/admin)."); return; } ZDO zDO = nview.GetZDO(); string text = (string.IsNullOrEmpty(design) ? "" : SailDesign.Normalise(design)); zDO.Set("Sailwright_Design", text); if (!admin && Creator(ship) == 0L && zDO.GetLong("Sailwright_Painter", 0L) == 0L && text.Length > 0) { zDO.Set("Sailwright_Painter", playerId); } SailwrightPlugin.Debug(string.Format("{0} painted by {1}{2}: {3}", ((Object)ship).name, playerId, admin ? " (admin)" : "", (text.Length > 0) ? text : "vanilla")); } public static bool LocalMayPaint(Ship ship) { if ((Object)(object)Player.m_localPlayer == (Object)null || (Object)(object)ZNet.instance == (Object)null) { return false; } return MayPaint(ship, Player.m_localPlayer.GetPlayerID(), ZNet.instance.LocalPlayerIsAdminOrHost()); } public static bool MayPaint(Ship ship, long playerId, bool admin) { if ((Object)(object)ship == (Object)null) { return false; } if (admin) { return true; } if (playerId == 0L) { return false; } long num = Creator(ship); if (num != 0L) { return num == playerId; } long num2 = Claim(ship); if (num2 != 0L) { return num2 == playerId; } return true; } public static long Creator(Ship ship) { Piece val = (((Object)(object)ship != (Object)null) ? ((Component)ship).GetComponent<Piece>() : null); if (!((Object)(object)val != (Object)null)) { return 0L; } return val.GetCreator(); } public static long Claim(Ship ship) { ZNetView val = (((Object)(object)ship != (Object)null) ? ((Component)ship).GetComponent<ZNetView>() : null); if (!((Object)(object)val != (Object)null) || !val.IsValid()) { return 0L; } return val.GetZDO().GetLong("Sailwright_Painter", 0L); } private static bool Identify(long sender, out long playerId, out bool admin) { //IL_005c: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_007c: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_010a: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) playerId = 0L; admin = false; if ((Object)(object)ZNet.instance == (Object)null) { return false; } if (sender == ZDOMan.GetSessionID() && (Object)(object)Player.m_localPlayer != (Object)null) { playerId = Player.m_localPlayer.GetPlayerID(); admin = ZNet.instance.LocalPlayerIsAdminOrHost(); return true; } foreach (PlayerInfo player in ZNet.instance.GetPlayerList()) { ZDOID characterID = player.m_characterID; if (((ZDOID)(ref characterID)).UserID != sender) { continue; } ZDO zDO = ZDOMan.instance.GetZDO(player.m_characterID); if (zDO != null) { playerId = zDO.GetLong(ZDOVars.s_playerID, 0L); } if (playerId == 0L) { foreach (Player allPlayer in Player.GetAllPlayers()) { ZNetView component = ((Component)allPlayer).GetComponent<ZNetView>(); if ((Object)(object)component != (Object)null && component.IsValid() && component.GetZDO().GetOwner() == sender) { playerId = allPlayer.GetPlayerID(); break; } } } PlatformUserID id = player.m_userInfo.m_id; admin = ZNet.instance.PlayerIsAdmin(id); return (playerId != 0) | admin; } return false; } } internal static class SailTextures { internal sealed class Entry { public string Key; public Material Original; public Texture2D Texture; public Material Painted; public Material SeeThrough; public int Refs; public Material Solid { get { if (!((Object)(object)Painted != (Object)null)) { return Original; } return Painted; } } } private static readonly Dictionary<string, Entry> Entries = new Dictionary<string, Entry>(); private static readonly Dictionary<int, (byte[] px, int w, int h)> SourcePixels = new Dictionary<int, (byte[], int, int)>(); private static Shader _seeThroughShader; private static bool _seeThroughShaderSearched; internal static int LiveEntries => Entries.Count; internal static int LiveTextures => Entries.Values.Count((Entry e) => (Object)(object)e.Texture != (Object)null); public static Entry Acquire(Material original, string design, SailLayout layout) { //IL_00ad: 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_00cd: Expected O, but got Unknown if ((Object)(object)original == (Object)null) { return null; } string key = ((Object)original).GetInstanceID() + "|" + design + "|" + SailwrightPlugin.TextureSize.Value; if (!Entries.TryGetValue(key, out var value)) { value = new Entry { Key = key, Original = original }; if (!string.IsNullOrEmpty(design) && SailDesign.TryParse(design, out var d)) { try { value.Texture = Paint(original, d, layout); if ((Object)(object)value.Texture != (Object)null) { value.Painted = new Material(original) { name = ((Object)original).name + " (Sailwright)" }; value.Painted.SetTexture("_MainTex", (Texture)(object)value.Texture); } } catch (Exception ex) { SailwrightPlugin.Log.LogWarning((object)("Could not paint " + ((Object)original).name + " with " + design + ": " + ex.Message)); } } Entries[key] = value; } value.Refs++; return value; } public static void Release(Entry e) { if (e != null && --e.Refs <= 0) { Entries.Remove(e.Key); if ((Object)(object)e.Painted != (Object)null) { Object.Destroy((Object)(object)e.Painted); } if ((Object)(object)e.SeeThrough != (Object)null) { Object.Destroy((Object)(object)e.SeeThrough); } if ((Object)(object)e.Texture != (Object)null) { Object.Destroy((Object)(object)e.Texture); } } } public static void Clear() { foreach (Entry item in Entries.Values.ToList()) { item.Refs = 1; Release(item); } SourcePixels.Clear(); } public static Material GetSeeThrough(Entry e) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Expected O, but got Unknown //IL_008c: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) if (e == null) { return null; } if ((Object)(object)e.SeeThrough != (Object)null) { return e.SeeThrough; } Shader val = FindSeeThroughShader(); if ((Object)(object)val == (Object)null) { return null; } Texture val2 = (Texture)(((Object)(object)e.Texture != (Object)null) ? ((object)e.Texture) : ((object)e.Original.mainTexture)); Material val3 = new Material(val) { name = ((Object)e.Original).name + " (Sailwright see-through)" }; val3.SetTexture("_MainTex", val2); val3.SetTextureScale("_MainTex", e.Original.GetTextureScale("_MainTex")); val3.SetTextureOffset("_MainTex", e.Original.GetTextureOffset("_MainTex")); val3.SetFloat("_Cutoff", 0.1f); val3.SetColor("_Color", new Color(1f, 1f, 1f, Mathf.Clamp01(SailwrightPlugin.SeeThroughIntensity.Value))); e.SeeThrough = val3; return val3; } public static void RefreshSeeThroughOpacity() { //IL_0053: Unknown result type (might be due to invalid IL or missing references) float num = Mathf.Clamp01(SailwrightPlugin.SeeThroughIntensity.Value); foreach (Entry value in Entries.Values) { if ((Object)(object)value.SeeThrough != (Object)null) { value.SeeThrough.SetColor("_Color", new Color(1f, 1f, 1f, num)); } } } internal static Shader FindSeeThroughShader() { if ((Object)(object)_seeThroughShader != (Object)null || _seeThroughShaderSearched) { return _seeThroughShader; } _seeThroughShaderSearched = true; _seeThroughShader = Shader.Find("Custom/LitParticles"); if ((Object)(object)_seeThroughShader == (Object)null) { _seeThroughShader = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader s) => (Object)(object)s != (Object)null && ((Object)s).name == "Custom/LitParticles")); } if ((Object)(object)_seeThroughShader == (Object)null) { SailwrightPlugin.Log.LogWarning((object)"Shader Custom/LitParticles not found: see-through sails are off this session."); } else { SailwrightPlugin.Debug("See-through shader found: Custom/LitParticles"); } return _seeThroughShader; } internal static void RetryShaderSearch() { if ((Object)(object)_seeThroughShader == (Object)null) { _seeThroughShaderSearched = false; } } private static Texture2D Paint(Material original, SailDesign d, SailLayout layout) { //IL_004e: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_006b: Expected O, but got Unknown //IL_006e: Unknown result type (might be due to invalid IL or missing references) Texture mainTexture = original.mainTexture; if ((Object)(object)mainTexture == (Object)null) { return null; } (byte[] px, int w, int h) tuple = ReadSource(mainTexture); byte[] item = tuple.px; int item2 = tuple.w; int item3 = tuple.h; int value = SailwrightPlugin.TextureSize.Value; byte[] array = SailRaster.Compose(item, item2, item3, value, value, layout, d); Texture2D val = new Texture2D(value, value, (TextureFormat)4, true) { name = "Sailwright " + d.Format() }; ((Texture)val).wrapMode = mainTexture.wrapMode; ((Texture)val).filterMode = (FilterMode)2; ((Texture)val).anisoLevel = 4; val.SetPixelData<byte>(array, 0, 0); val.Apply(true, true); SailwrightPlugin.Debug($"Painted {((Object)original).name} {value}px {d.Format()} layout {layout}"); return val; } private static (byte[] px, int w, int h) ReadSource(Texture src) { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0061: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Expected O, but got Unknown int instanceID = ((Object)src).GetInstanceID(); if (SourcePixels.TryGetValue(instanceID, out (byte[], int, int) value)) { return value; } int width = src.width; int height = src.height; RenderTexture temporary = RenderTexture.GetTemporary(width, height, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); RenderTexture active = RenderTexture.active; try { Graphics.Blit(src, temporary); RenderTexture.active = temporary; Texture2D val = new Texture2D(width, height, (TextureFormat)4, false, false); val.ReadPixels(new Rect(0f, 0f, (float)width, (float)height), 0, 0, false); val.Apply(false, false); byte[] rawTextureData = val.GetRawTextureData(); Object.Destroy((Object)val); (byte[], int, int) tuple = ((byte[])rawTextureData.Clone(), width, height); SourcePixels[instanceID] = tuple; return tuple; } finally { RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); } } } internal sealed class SailTracker : MonoBehaviour { internal static readonly HashSet<SailTracker