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 SuitTailor v0.2.0
plugins/SuitTailor/SuitTailor.dll
Decompiled 33 minutes 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.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text; using System.Threading.Tasks; using BepInEx; using BepInEx.Logging; using GameNetcodeStuff; using HarmonyLib; using Microsoft.CodeAnalysis; using MoreCompany.Cosmetics; using Newtonsoft.Json; using TMPro; using Unity.Collections; using Unity.Netcode; using UnityEngine; using UnityEngine.EventSystems; using UnityEngine.Events; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Controls; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: IgnoresAccessChecksTo("Assembly-CSharp")] [assembly: IgnoresAccessChecksTo("MoreCompany")] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SuitTailor")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("0.2.0.0")] [assembly: AssemblyInformationalVersion("0.2.0+b9dc982f787ae8ea4070a8480b270f3512b1526f")] [assembly: AssemblyProduct("SuitTailor")] [assembly: AssemblyTitle("SuitTailor")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("0.2.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 SuitTailor { internal class ColorPicker { private class Drag : MonoBehaviour, IPointerDownHandler, IEventSystemHandler, IDragHandler { public Action<Vector2> OnDrag; public void OnPointerDown(PointerEventData e) { Report(e); } void IDragHandler.OnDrag(PointerEventData e) { Report(e); } private void Report(PointerEventData e) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Expected O, but got Unknown //IL_000e: 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_0029: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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) RectTransform val = (RectTransform)((Component)this).transform; Vector2 val2 = default(Vector2); if (RectTransformUtility.ScreenPointToLocalPointInRectangle(val, e.position, e.pressEventCamera, ref val2)) { Rect rect = val.rect; OnDrag?.Invoke(new Vector2((val2.x - ((Rect)(ref rect)).xMin) / ((Rect)(ref rect)).width, (val2.y - ((Rect)(ref rect)).yMin) / ((Rect)(ref rect)).height)); } } } private float h; private float s; private float v; private readonly RawImage square; private readonly Texture2D squareTex; private readonly Texture2D hueTex; private readonly RectTransform squareCursor; private readonly RectTransform hueCursor; private readonly TMP_InputField hex; private readonly Image swatch; private bool quiet; private readonly List<GameObject> parts = new List<GameObject>(); private const int Tex = 64; public event Action<Color32> Changed; public ColorPicker(Transform parent, float left, float top, float size) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Expected O, but got Unknown //IL_00aa: 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_00b0: 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_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_014c: Expected O, but got Unknown //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Unknown result type (might be due to invalid IL or missing references) //IL_0202: Unknown result type (might be due to invalid IL or missing references) //IL_020f: 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) //IL_028a: 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_031e: Expected O, but got Unknown RectTransform val = Ui.TL("SV", parent, left, top, size, size); square = ((Component)val).gameObject.AddComponent<RawImage>(); squareTex = new Texture2D(64, 64, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; square.texture = (Texture)(object)squareTex; ((Component)val).gameObject.AddComponent<Drag>().OnDrag = delegate(Vector2 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) s = Mathf.Clamp01(p.x); v = Mathf.Clamp01(p.y); Moved(); }; squareCursor = Ui.Rect("Cursor", (Transform)(object)val, 0f, 0f, 12f, 12f); Vector2 val2 = (squareCursor.anchorMin = (squareCursor.anchorMax = Vector2.zero)); ((Graphic)Ui.Box(squareCursor, Color.white)).raycastTarget = false; ((Graphic)Ui.Box(Ui.Rect("In", (Transform)(object)squareCursor, 0f, 0f, 8f, 8f), Color.black)).raycastTarget = false; RectTransform val4 = Ui.TL("Hue", parent, left + size + 10f, top, 26f, size); RawImage val5 = ((Component)val4).gameObject.AddComponent<RawImage>(); hueTex = new Texture2D(1, 128, (TextureFormat)4, false) { wrapMode = (TextureWrapMode)1 }; for (int num = 0; num < 128; num++) { hueTex.SetPixel(0, num, Color.HSVToRGB((float)num / 127f, 1f, 1f)); } hueTex.Apply(); val5.texture = (Texture)(object)hueTex; ((Component)val4).gameObject.AddComponent<Drag>().OnDrag = delegate(Vector2 p) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) h = Mathf.Clamp01(p.y) * 0.9999f; Paint(); Moved(); }; hueCursor = Ui.Rect("Cursor", (Transform)(object)val4, 0f, 0f, 32f, 5f); RectTransform obj = hueCursor; RectTransform obj2 = hueCursor; ((Vector2)(ref val2))..ctor(0.5f, 0f); obj2.anchorMax = val2; obj.anchorMin = val2; ((Graphic)Ui.Box(hueCursor, Color.white)).raycastTarget = false; RectTransform val6 = Ui.TL("Swatch", parent, left + size + 46f, top, 110f, 50f); swatch = Ui.Box(val6, Color.white); RectTransform val7 = Ui.TL("HexLabel", parent, left + size + 46f, top + 60f, 110f, 20f); Ui.Text((Transform)(object)val7, "Hex", 13f, (TextAlignmentOptions)513, Ui.TextCol); hex = Ui.Input(Ui.TL("Hex", parent, left + size + 46f, top + 82f, 110f, 30f), "#RRGGBB", 7, delegate(string t) { //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0071: 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) Color val8 = default(Color); if (!quiet && t.Length >= 6 && ColorUtility.TryParseHtmlString(t.StartsWith("#") ? t : ("#" + t), ref val8)) { Color.RGBToHSV(val8, ref h, ref s, ref v); Paint(); Cursors(); ((Graphic)swatch).color = val8; this.Changed?.Invoke(Color32.op_Implicit(val8)); } }); Ui.Btn_ btn_ = Ui.Button(Ui.TL("Random", parent, left + size + 46f, top + 120f, 110f, 30f), "Random", (UnityAction)delegate { //IL_0023: 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_002d: 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_0040: Unknown result type (might be due to invalid IL or missing references) Color32 val8 = Color32.op_Implicit(Color.HSVToRGB(Random.value, Random.Range(0.45f, 1f), Random.Range(0.35f, 1f))); Set(val8); this.Changed?.Invoke(val8); }, 14f); parts.Add(((Component)val).gameObject); parts.Add(((Component)val4).gameObject); parts.Add(((Component)val6).gameObject); parts.Add(((Component)val7).gameObject); parts.Add(((Component)hex).gameObject); parts.Add(((Component)btn_.Button).gameObject); Paint(); } public void SetVisible(bool on) { foreach (GameObject part in parts) { part.SetActive(on); } } public void Set(Color32 c) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0001: 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) float num = default(float); Color.RGBToHSV(Color32.op_Implicit(c), ref num, ref s, ref v); if (s > 0.001f && v > 0.001f) { h = num; } Paint(); Cursors(); ShowHex(c); } private void Moved() { //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_001c: 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_0035: Unknown result type (might be due to invalid IL or missing references) Color32 val = Color32.op_Implicit(Color.HSVToRGB(h, s, v)); Cursors(); ShowHex(val); this.Changed?.Invoke(val); } private void ShowHex(Color32 c) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Unknown result type (might be due to invalid IL or missing references) ((Graphic)swatch).color = Color32.op_Implicit(c); quiet = true; hex.text = Design.ToHex(c); quiet = false; } private void Cursors() { //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001d: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0037: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007e: Unknown result type (might be due to invalid IL or missing references) Rect rect = ((RectTransform)((Component)square).transform).rect; Vector2 size = ((Rect)(ref rect)).size; squareCursor.anchoredPosition = new Vector2(s * size.x, v * size.y); rect = ((RectTransform)((Transform)hueCursor).parent).rect; Vector2 size2 = ((Rect)(ref rect)).size; hueCursor.anchoredPosition = new Vector2(0f, h * size2.y); } private void Paint() { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])(object)new Color32[4096]; for (int i = 0; i < 64; i++) { for (int j = 0; j < 64; j++) { array[i * 64 + j] = Color32.op_Implicit(Color.HSVToRGB(h, (float)j / 63f, (float)i / 63f)); } } squareTex.SetPixels32(array); squareTex.Apply(); } } internal enum Pattern : byte { Solid, Vertical, Horizontal, DiagonalL, DiagonalR, Checker, TwoTone, Rainbow, Texture } internal class Part { public Pattern Pattern; public Color32 A; public Color32 B; public float Glow; public byte Count = 28; public string Tex = ""; public Part Clone() { //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_001f: 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) return new Part { Pattern = Pattern, A = A, B = B, Glow = Glow, Count = Count, Tex = Tex }; } } internal class Design { public const string Prefix = "ST1-"; public const int MaxName = 24; public const int PartCount = 6; public const int Shirt = 0; public const int Pants = 1; public const int Straps = 2; public const int Helmet = 3; public const int Backpack = 4; public const int Gear = 5; public string Name = "New suit"; public Part[] Parts = new Part[6]; public bool PantsMatch = true; public Color32 Visor = new Color32((byte)130, (byte)150, (byte)190, byte.MaxValue); public float VisorAlpha; public float VisorGlow; public Part PantsEffective { get { if (!PantsMatch) { return Parts[1]; } return Parts[0]; } } public bool AnyGlow { get { if (VisorGlow > 0f && VisorAlpha > 0f) { return true; } for (int i = 0; i < 6; i++) { if ((i != 1 || !PantsMatch) && Parts[i].Glow > 0f) { return true; } } return false; } } public static Design Default() { //IL_0022: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0054: Unknown result type (might be due to invalid IL or missing references) //IL_005f: 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_007c: 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_008c: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: 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) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: Unknown result type (might be due to invalid IL or missing references) //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_011a: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) Design obj = new Design { Name = "New suit" }; obj.Parts[0] = new Part { A = Hex("#e8661c"), B = Hex("#f2f2f2") }; obj.Parts[1] = new Part { A = Hex("#e8661c"), B = Hex("#f2f2f2") }; obj.Parts[2] = new Part { A = Hex("#3a1010"), B = Hex("#d8d8d8") }; obj.Parts[3] = new Part { A = Hex("#5a5148"), B = Hex("#d8d8d8") }; obj.Parts[4] = new Part { Pattern = Pattern.TwoTone, A = Hex("#e8e27a"), B = Hex("#9a9ca0") }; obj.Parts[5] = new Part { A = Hex("#3a1010"), B = Hex("#d8d8d8") }; return obj; } public Design Clone() { //IL_001f: 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) Design design = new Design { Name = Name, PantsMatch = PantsMatch, Visor = Visor, VisorAlpha = VisorAlpha, VisorGlow = VisorGlow }; for (int i = 0; i < 6; i++) { design.Parts[i] = Parts[i].Clone(); } return design; } public string ToCode() { return "ST1-" + B64(ToBytes(withName: true)); } public string LookKey() { return B64(ToBytes(withName: false)); } private static byte Byte01(float x) { return (byte)Mathf.RoundToInt(Mathf.Clamp01(x) * 255f); } private byte[] ToBytes(bool withName) { MemoryStream memoryStream = new MemoryStream(); memoryStream.WriteByte(3); memoryStream.WriteByte(PantsMatch ? ((byte)1) : ((byte)0)); Part[] parts = Parts; foreach (Part part in parts) { memoryStream.WriteByte((byte)part.Pattern); memoryStream.WriteByte(part.A.r); memoryStream.WriteByte(part.A.g); memoryStream.WriteByte(part.A.b); memoryStream.WriteByte(part.B.r); memoryStream.WriteByte(part.B.g); memoryStream.WriteByte(part.B.b); memoryStream.WriteByte(Byte01(part.Glow)); memoryStream.WriteByte(part.Count); byte[] array = ((part.Pattern == Pattern.Texture) ? Encoding.UTF8.GetBytes(ClipTex(part.Tex)) : new byte[0]); memoryStream.WriteByte((byte)array.Length); memoryStream.Write(array, 0, array.Length); } memoryStream.WriteByte(Visor.r); memoryStream.WriteByte(Visor.g); memoryStream.WriteByte(Visor.b); memoryStream.WriteByte(Byte01(VisorAlpha)); memoryStream.WriteByte(Byte01(VisorGlow)); if (withName) { byte[] bytes = Encoding.UTF8.GetBytes(Clip(Name ?? "")); memoryStream.WriteByte((byte)bytes.Length); memoryStream.Write(bytes, 0, bytes.Length); } return memoryStream.ToArray(); } public static bool TryParse(string code, out Design d) { //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00d9: 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_00fe: Unknown result type (might be due to invalid IL or missing references) d = null; if (string.IsNullOrWhiteSpace(code)) { return false; } code = code.Trim(); if (code.StartsWith("ST1-", StringComparison.OrdinalIgnoreCase)) { code = code.Substring("ST1-".Length); } try { byte[] array = UnB64(code); int num = 0; int num2 = array[num++]; int num3; switch (num2) { default: return false; case 2: case 3: num3 = 6; break; case 1: num3 = 5; break; } int num4 = num3; bool flag = num2 >= 2; Design design = new Design { PantsMatch = ((array[num++] & 1) != 0) }; byte count = (byte)((num2 < 3) ? array[num++] : 28); for (int i = 0; i < num4; i++) { byte b = array[num++]; Part part = new Part { Pattern = (Pattern)((b <= 8) ? b : 0), A = new Color32(array[num++], array[num++], array[num++], byte.MaxValue), B = new Color32(array[num++], array[num++], array[num++], byte.MaxValue), Count = count }; if (flag) { part.Glow = (float)(int)array[num++] / 255f; } if (num2 >= 3) { part.Count = array[num++]; int num5 = array[num++]; part.Tex = ((num5 > 0) ? ClipTex(Encoding.UTF8.GetString(array, num, num5)) : ""); num += num5; } if (part.Count < 2) { part.Count = 2; } design.Parts[i] = part; } if (num4 < 6) { design.Parts[5] = design.Parts[2].Clone(); } design.Visor = new Color32(array[num++], array[num++], array[num++], byte.MaxValue); design.VisorAlpha = (float)(int)array[num++] / 255f; if (flag) { design.VisorGlow = (float)(int)array[num++] / 255f; } design.Name = "Shared suit"; if (num < array.Length) { int num6 = array[num++]; if (num6 > 0 && num + num6 <= array.Length) { design.Name = Clip(Encoding.UTF8.GetString(array, num, num6)); } } d = design; return true; } catch { return false; } } public static string ClipTex(string s) { s = (s ?? "").Replace('\\', '/'); s = s.Substring(s.LastIndexOf('/') + 1); if (s.EndsWith(".png", StringComparison.OrdinalIgnoreCase)) { s = s.Substring(0, s.Length - 4); } if (s.Length <= 32) { return s; } return s.Substring(0, 32); } private static string Clip(string s) { s = s.Replace("\n", " ").Replace("\r", " ").Trim(); while (Encoding.UTF8.GetByteCount(s) > 48 || s.Length > 24) { s = s.Substring(0, s.Length - 1); } return s; } private static string B64(byte[] b) { return Convert.ToBase64String(b).TrimEnd('=').Replace('+', '-') .Replace('/', '_'); } private static byte[] UnB64(string s) { s = s.Replace('-', '+').Replace('_', '/').Replace(" ", ""); switch (s.Length % 4) { case 2: s += "=="; break; case 3: s += "="; break; } return Convert.FromBase64String(s); } public static Color32 Hex(string hx) { //IL_003b: 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_0025: Unknown result type (might be due to invalid IL or missing references) Color val = default(Color); if (ColorUtility.TryParseHtmlString(hx.StartsWith("#") ? hx : ("#" + hx), ref val)) { return Color32.op_Implicit(val); } return new Color32(byte.MaxValue, (byte)0, byte.MaxValue, byte.MaxValue); } public static string ToHex(Color32 c) { //IL_0005: 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_001b: Unknown result type (might be due to invalid IL or missing references) return $"#{c.r:X2}{c.g:X2}{c.b:X2}"; } public static Design FromPreset(PresetJson p) { //IL_0024: 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_00aa: 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_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c2: Unknown result type (might be due to invalid IL or missing references) Design design = new Design { Name = p.name, PantsMatch = p.pantsMatch, Visor = Hex(p.visor), VisorAlpha = p.visorAlpha }; PresetPartJson[] array = new PresetPartJson[6] { p.shirt, p.pants, p.straps, p.helmet, p.backpack, p.gear ?? p.straps }; for (int i = 0; i < 6; i++) { design.Parts[i] = new Part { Pattern = (Pattern)array[i].pattern, A = Hex(array[i].a), B = Hex(array[i].b) }; } return design; } } internal class PresetPartJson { public int pattern; public string a; public string b; } internal class PresetJson { public string name; public string visor; public float visorAlpha; public bool pantsMatch; public PresetPartJson shirt; public PresetPartJson pants; public PresetPartJson straps; public PresetPartJson helmet; public PresetPartJson backpack; public PresetPartJson gear; } internal static class Library { private class SaveFile { public List<string> designs = new List<string>(); public string worn; public bool lastPresets; public string lastName; } public static bool LastPresets; public static string LastName; public static readonly List<Design> Mine = new List<Design>(); public static readonly List<Design> Presets = new List<Design>(); public static Design Worn { get; private set; } private static string Dir => Path.Combine(Application.persistentDataPath, "SuitTailor"); private static string FilePath => Path.Combine(Dir, "designs.json"); public static event Action WornChanged; public static void Load() { Presets.Clear(); try { using Stream stream = typeof(Library).Assembly.GetManifestResourceStream("SuitTailor.presets.json"); using StreamReader streamReader = new StreamReader(stream); foreach (PresetJson item in JsonConvert.DeserializeObject<List<PresetJson>>(streamReader.ReadToEnd())) { Presets.Add(Design.FromPreset(item)); } } catch (Exception arg) { Plugin.Log.LogError((object)$"Couldn't read the presets: {arg}"); } Mine.Clear(); Worn = null; try { if (File.Exists(FilePath)) { SaveFile saveFile = JsonConvert.DeserializeObject<SaveFile>(File.ReadAllText(FilePath)) ?? new SaveFile(); foreach (string design in saveFile.designs) { if (Design.TryParse(design, out var d)) { Mine.Add(d); } } if (Design.TryParse(saveFile.worn, out var d2)) { Worn = d2; } LastPresets = saveFile.lastPresets; LastName = saveFile.lastName; } } catch (Exception ex) { Plugin.Log.LogError((object)("Couldn't read " + FilePath + ": " + ex.Message)); } if (Worn == null) { Worn = ((Mine.Count > 0) ? Mine[0].Clone() : Design.Default()); } Plugin.Log.LogInfo((object)$"[ST] loaded {Mine.Count} saved designs, {Presets.Count} presets; wearing '{Worn.Name}'"); } public static void Save() { try { Directory.CreateDirectory(Dir); SaveFile saveFile = new SaveFile { worn = Worn?.ToCode(), lastPresets = LastPresets, lastName = LastName }; foreach (Design item in Mine) { saveFile.designs.Add(item.ToCode()); } string text = FilePath + ".tmp"; File.WriteAllText(text, JsonConvert.SerializeObject((object)saveFile, (Formatting)1)); if (File.Exists(FilePath)) { File.Delete(FilePath); } File.Move(text, FilePath); } catch (Exception ex) { Plugin.Log.LogError((object)("Couldn't save designs: " + ex.Message)); } } public static void Wear(Design d) { Worn = d.Clone(); Save(); Plugin.Log.LogInfo((object)("[ST] wearing '" + Worn.Name + "' " + Worn.ToCode())); Library.WornChanged?.Invoke(); } public static string FreeName(string want) { want = (string.IsNullOrWhiteSpace(want) ? "New suit" : want.Trim()); if (want.Length > 24) { want = want.Substring(0, 24); } if (!Mine.Exists((Design d) => d.Name == want)) { return want; } int num = 2; string n; while (true) { n = $"{want} {num}"; if (n.Length > 24) { n = want.Substring(0, 21) + $" {num}"; } if (!Mine.Exists((Design d) => d.Name == n)) { break; } num++; } return n; } } internal static class Net { [Serializable] [CompilerGenerated] private sealed class <>c { public static readonly <>c <>9 = new <>c(); public static HandleNamedMessageDelegate <>9__9_0; public static HandleNamedMessageDelegate <>9__9_1; public static Func<KeyValuePair<ulong, string>, string> <>9__10_0; public static Action<FastBufferWriter> <>9__12_0; internal void <Init>b__9_0(ulong sender, FastBufferReader r) { if (IsHost) { string text = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref text, false); Set(sender, text); Broadcast($"{sender}={text}"); } } internal void <Init>b__9_1(ulong sender, FastBufferReader r) { if (IsHost) { return; } string text = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref text, false); string[] array = text.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('='); if (array2.Length == 2 && ulong.TryParse(array2[0], out var result)) { Set(result, array2[1]); } } } internal string <OnConnected>b__10_0(KeyValuePair<ulong, string> kv) { return $"{kv.Key}={kv.Value}"; } internal void <SendMine>b__12_0(FastBufferWriter w) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) NM.CustomMessagingManager.SendNamedMessage("SuitTailor.Mine", 0uL, w, (NetworkDelivery)4); } } private const string MMine = "SuitTailor.Mine"; private const string MTable = "SuitTailor.Table"; private static readonly Dictionary<ulong, string> table = new Dictionary<ulong, string>(); private static readonly Dictionary<ulong, Design> parsed = new Dictionary<ulong, Design>(); private static bool hooked; private static NetworkManager NM => NetworkManager.Singleton; private static bool IsHost { get { if ((Object)(object)NM != (Object)null) { return NM.IsServer; } return false; } } public static void Init() { //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_0065: Expected O, but got Unknown //IL_0084: 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: Expected O, but got Unknown NetworkManager nM = NM; CustomMessagingManager val = ((nM != null) ? nM.CustomMessagingManager : null); if (val == null) { return; } table.Clear(); parsed.Clear(); val.UnregisterNamedMessageHandler("SuitTailor.Mine"); val.UnregisterNamedMessageHandler("SuitTailor.Table"); object obj = <>c.<>9__9_0; if (obj == null) { HandleNamedMessageDelegate val2 = delegate(ulong sender, FastBufferReader r) { if (IsHost) { string text = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref text, false); Set(sender, text); Broadcast($"{sender}={text}"); } }; <>c.<>9__9_0 = val2; obj = (object)val2; } val.RegisterNamedMessageHandler("SuitTailor.Mine", (HandleNamedMessageDelegate)obj); object obj2 = <>c.<>9__9_1; if (obj2 == null) { HandleNamedMessageDelegate val3 = delegate(ulong sender, FastBufferReader r) { if (!IsHost) { string text = default(string); ((FastBufferReader)(ref r)).ReadValueSafe(ref text, false); string[] array = text.Split(new char[1] { ';' }, StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < array.Length; i++) { string[] array2 = array[i].Split('='); if (array2.Length == 2 && ulong.TryParse(array2[0], out var result)) { Set(result, array2[1]); } } } }; <>c.<>9__9_1 = val3; obj2 = (object)val3; } val.RegisterNamedMessageHandler("SuitTailor.Table", (HandleNamedMessageDelegate)obj2); NM.OnClientConnectedCallback -= OnConnected; NM.OnClientConnectedCallback += OnConnected; NM.OnClientDisconnectCallback -= OnDisconnected; NM.OnClientDisconnectCallback += OnDisconnected; if (!hooked) { Library.WornChanged += SendMine; hooked = true; } SendMine(); } private static void OnConnected(ulong client) { if (!IsHost || client == NM.LocalClientId) { return; } string text = string.Join(";", table.Select((KeyValuePair<ulong, string> kv) => $"{kv.Key}={kv.Value}")); if (text.Length > 0) { Write("SuitTailor.Table", text, delegate(FastBufferWriter w) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) NM.CustomMessagingManager.SendNamedMessage("SuitTailor.Table", client, w, (NetworkDelivery)4); }); } } private static void OnDisconnected(ulong client) { if (IsHost) { table.Remove(client); parsed.Remove(client); } } public static void SendMine() { if ((Object)(object)NM == (Object)null || !NM.IsListening || Library.Worn == null) { return; } string text = Library.Worn.ToCode(); if (IsHost) { Set(NM.LocalClientId, text); Broadcast($"{NM.LocalClientId}={text}"); } else { Write("SuitTailor.Mine", text, delegate(FastBufferWriter w) { //IL_0011: Unknown result type (might be due to invalid IL or missing references) NM.CustomMessagingManager.SendNamedMessage("SuitTailor.Mine", 0uL, w, (NetworkDelivery)4); }); } } private static void Broadcast(string entries) { foreach (ulong c in NM.ConnectedClientsIds) { if (c != NM.LocalClientId) { Write("SuitTailor.Table", entries, delegate(FastBufferWriter w) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) NM.CustomMessagingManager.SendNamedMessage("SuitTailor.Table", c, w, (NetworkDelivery)4); }); } } } private static void Set(ulong client, string code) { if (code == null || code.Length > 200 || !Design.TryParse(code, out var d)) { return; } table[client] = code; parsed[client] = d; StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && val.actualClientId == client && (val.isPlayerControlled || val.isPlayerDead) && (Object)(object)val != (Object)(object)GameNetworkManager.Instance?.localPlayerController) { Suits.Apply(val); } } } public static Design DesignOf(ulong client) { if (!parsed.TryGetValue(client, out var value)) { return null; } return value; } private unsafe static void Write(string name, string payload, Action<FastBufferWriter> send) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) FastBufferWriter obj = default(FastBufferWriter); ((FastBufferWriter)(ref obj))..ctor(FastBufferWriter.GetWriteSize(payload, false) + 16, (Allocator)2, 65536); try { ((FastBufferWriter)(ref obj)).WriteValueSafe(payload, false); send(obj); } finally { ((IDisposable)(*(FastBufferWriter*)(&obj))/*cast due to .constrained prefix*/).Dispose(); } } } internal static class Painter { private class Painted { public Color32[] Albedo; public Color32[] Emis; } private class Entry { public Material Mat; public Task<Painted> Work; public List<Action<Material>> Waiting = new List<Action<Material>>(); public float Used; } private const int Size = 1024; private const int MaxCached = 16; private const int EmisSize = 512; private const float GlowStrength = 1f; private const int Regions = 10; private static byte[] region; private static ushort[] qUp; private static ushort[] qSide; private static int[] coordIndex; private static float upMin; private static float upMax; private static float sideMin; private static float sideMax; private static Color32[] basePx; private static float[] baseL; private static float[] refL = new float[10]; private static Material template; private static bool templateIsGame; private static readonly Dictionary<string, Entry> cache = new Dictionary<string, Entry>(); private static Texture2D previewTex; private static Texture2D previewEmis; private static Material previewMat; private static Task<Painted> previewJob; private static Design previewNext; private static Action<Material> previewDone; private static string[] plainKeywords; private static string[] glowKeywords; private static bool glowMenuNoted; public static bool Ready { get { if (basePx != null) { return (Object)(object)template != (Object)null; } return false; } } public static void LoadRegions() { using Stream stream = typeof(Painter).Assembly.GetManifestResourceStream("SuitTailor.regions.bin"); using GZipStream gZipStream = new GZipStream(stream, CompressionMode.Decompress); using MemoryStream memoryStream = new MemoryStream(); gZipStream.CopyTo(memoryStream); byte[] array = memoryStream.ToArray(); if (array[0] != 83 || array[1] != 84 || array[2] != 82 || array[3] != 49) { throw new Exception("regions.bin: bad header"); } int num = BitConverter.ToUInt16(array, 4); if (num != 1024) { throw new Exception($"regions.bin is {num}, expected {1024}"); } upMin = BitConverter.ToSingle(array, 6); upMax = BitConverter.ToSingle(array, 10); sideMin = BitConverter.ToSingle(array, 14); sideMax = BitConverter.ToSingle(array, 18); region = new byte[1048576]; Buffer.BlockCopy(array, 22, region, 0, region.Length); int num2 = region.Count((byte r) => r != 0); int num3 = 22 + region.Length; qUp = new ushort[num2]; qSide = new ushort[num2]; coordIndex = new int[region.Length]; int num4 = 0; for (int num5 = 0; num5 < region.Length; num5++) { if (region[num5] == 0) { coordIndex[num5] = -1; continue; } coordIndex[num5] = num4; qUp[num4] = BitConverter.ToUInt16(array, num3 + num4 * 4); qSide[num4] = BitConverter.ToUInt16(array, num3 + num4 * 4 + 2); num4++; } Plugin.Log.LogInfo((object)$"[ST] regions loaded: {num2} painted texels, body height {upMax - upMin:0.00}"); } public static void SetTemplate(Material m, bool gameSuit = false) { //IL_0085: 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_009f: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Unknown result type (might be due to invalid IL or missing references) //IL_00bd: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_0134: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)m == (Object)null) { return; } if (Ready) { if (gameSuit && !templateIsGame) { UseGameTemplate(m); } return; } Texture val = (m.HasProperty("_BaseColorMap") ? m.GetTexture("_BaseColorMap") : null) ?? m.mainTexture; if ((Object)(object)val == (Object)null) { return; } RenderTexture temporary = RenderTexture.GetTemporary(1024, 1024, 0, (RenderTextureFormat)0, (RenderTextureReadWrite)2); RenderTexture active = RenderTexture.active; Graphics.Blit(val, temporary); RenderTexture.active = temporary; Texture2D val2 = new Texture2D(1024, 1024, (TextureFormat)4, false, false); val2.ReadPixels(new Rect(0f, 0f, 1024f, 1024f), 0, 0); val2.Apply(); RenderTexture.active = active; RenderTexture.ReleaseTemporary(temporary); Color32[] pixels = val2.GetPixels32(); Object.Destroy((Object)val2); basePx = (Color32[])(object)new Color32[pixels.Length]; for (int i = 0; i < 1024; i++) { Array.Copy(pixels, (1023 - i) * 1024, basePx, i * 1024, 1024); } baseL = new float[basePx.Length]; for (int j = 0; j < basePx.Length; j++) { baseL[j] = Lum(basePx[j]); } List<float>[] array = new List<float>[10]; for (int k = 0; k < 10; k++) { array[k] = new List<float>(); } for (int l = 0; l < region.Length; l++) { if (region[l] != 0 && region[l] < 10) { array[region[l]].Add(baseL[l]); } } for (int n = 1; n < 10; n++) { array[n].Sort(); refL[n] = ((array[n].Count > 0) ? Math.Max(array[n][array[n].Count / 2], 0.02f) : 0.5f); } template = m; templateIsGame = gameSuit; Plugin.Log.LogInfo((object)($"[ST] template '{((Object)m).name}' texture '{((Object)val).name}' {val.width}x{val.height}; reference brightness " + string.Join(" ", from x in refL.Skip(1) select x.ToString("0.00")))); } private static float Lum(Color32 c) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) return (0.2126f * (float)(int)c.r + 0.7152f * (float)(int)c.g + 0.0722f * (float)(int)c.b) / 255f; } public static void Request(Design d, Action<Material> done) { if (!Ready || d == null) { return; } string key = d.LookKey(); if (cache.TryGetValue(key, out var value)) { value.Used = Time.realtimeSinceStartup; if ((Object)(object)value.Mat != (Object)null) { done(value.Mat); } else { value.Waiting.Add(done); } return; } Design copy = d.Clone(); value = new Entry { Used = Time.realtimeSinceStartup }; value.Waiting.Add(done); value.Work = Task.Run(() => Paint(copy)); cache[key] = value; } public static void Preview(Design d, Action<Material> done) { if (Ready && d != null) { previewNext = d.Clone(); previewDone = done; } } private static void PumpPreview() { //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Expected O, but got Unknown if (previewJob == null && previewNext != null) { Design d = previewNext; previewNext = null; previewJob = Task.Run(() => Paint(d)); } if (previewJob == null || !previewJob.IsCompleted) { return; } Task<Painted> task = previewJob; previewJob = null; if (task.IsFaulted) { Plugin.Log.LogError((object)$"[ST] preview failed: {task.Exception?.GetBaseException()}"); return; } if ((Object)(object)previewTex == (Object)null) { previewTex = NewTex(1024, "SuitTailor_preview"); previewEmis = NewTex(512, "SuitTailor_preview_glow"); previewMat = new Material(template) { name = "SuitTailor preview" }; SetAlbedo(previewMat, (Texture)(object)previewTex); } Painted result = task.Result; Upload(previewTex, result.Albedo, 1024, final: false); if (result.Emis != null) { Upload(previewEmis, result.Emis, 512, final: false); SetGlow(previewMat, (Texture)(object)previewEmis); } else { SetGlow(previewMat, null); } try { previewDone?.Invoke(previewMat); } catch (Exception arg) { Plugin.Log.LogError((object)$"[ST] {arg}"); } } public static void Pump() { //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Expected O, but got Unknown PumpPreview(); if (cache.Count == 0) { return; } foreach (KeyValuePair<string, Entry> item in cache.ToList()) { Entry value = item.Value; if ((Object)(object)value.Mat != (Object)null || value.Work == null || !value.Work.IsCompleted) { continue; } if (value.Work.IsFaulted) { Plugin.Log.LogError((object)$"[ST] painting failed: {value.Work.Exception?.GetBaseException()}"); cache.Remove(item.Key); continue; } Painted result = value.Work.Result; Texture2D val = NewTex(1024, "SuitTailor_" + item.Key.Substring(0, Math.Min(8, item.Key.Length))); Upload(val, result.Albedo, 1024, final: true); Material val2 = new Material(template) { name = "SuitTailor suit" }; SetAlbedo(val2, (Texture)(object)val); if (result.Emis != null) { Texture2D val3 = NewTex(512, ((Object)val).name + "_glow"); Upload(val3, result.Emis, 512, final: true); SetGlow(val2, (Texture)(object)val3); } else { SetGlow(val2, null); } value.Mat = val2; value.Work = null; foreach (Action<Material> item2 in value.Waiting) { try { item2(val2); } catch (Exception arg) { Plugin.Log.LogError((object)$"[ST] {arg}"); } } value.Waiting.Clear(); } Trim(); } private static void UseGameTemplate(Material m) { foreach (Entry value in cache.Values) { if ((Object)(object)value.Mat != (Object)null) { DestroyMat(value.Mat); } } cache.Clear(); if ((Object)(object)previewMat != (Object)null) { Object.Destroy((Object)(object)previewMat); previewMat = null; } if ((Object)(object)previewTex != (Object)null) { Object.Destroy((Object)(object)previewTex); previewTex = null; } if ((Object)(object)previewEmis != (Object)null) { Object.Destroy((Object)(object)previewEmis); previewEmis = null; } template = m; templateIsGame = true; plainKeywords = (glowKeywords = null); Plugin.Log.LogInfo((object)("[ST] now painting onto the game's own suit material '" + ((Object)m).name + "' (" + string.Join(" ", m.shaderKeywords) + ")")); } private static void DestroyMat(Material m) { Texture val = (m.HasProperty("_BaseColorMap") ? m.GetTexture("_BaseColorMap") : null); Texture val2 = (m.HasProperty("_EmissiveColorMap") ? m.GetTexture("_EmissiveColorMap") : null); Object.Destroy((Object)(object)m); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)val); } if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } } private static Texture2D NewTex(int size, string name) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Expected O, but got Unknown return new Texture2D(size, size, (TextureFormat)4, true, false) { name = name, wrapMode = (TextureWrapMode)1, anisoLevel = 4 }; } private static void Upload(Texture2D tex, Color32[] px, int size, bool final) { Color32[] array = (Color32[])(object)new Color32[px.Length]; for (int i = 0; i < size; i++) { Array.Copy(px, i * size, array, (size - 1 - i) * size, size); } tex.SetPixels32(array); tex.Apply(true, final); } private static void SetAlbedo(Material m, Texture tex) { if (m.HasProperty("_BaseColorMap")) { m.SetTexture("_BaseColorMap", tex); } if (m.HasProperty("_MainTex")) { m.SetTexture("_MainTex", tex); } } private static void SetGlow(Material m, Texture emis) { //IL_0142: 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_013b: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_016c: Unknown result type (might be due to invalid IL or missing references) if (!m.HasProperty("_EmissiveColor")) { return; } if (plainKeywords == null) { plainKeywords = template.shaderKeywords; glowKeywords = (from k in plainKeywords.Where((string k) => k != "_DOUBLESIDED_ON").Concat(new string[1] { "_EMISSIVE_COLOR_MAP" }).Distinct() orderby k select k).ToArray(); Plugin.Log.LogInfo((object)("[ST] suit keywords: " + string.Join(" ", plainKeywords) + "; glowing suits use: " + string.Join(" ", glowKeywords))); } bool flag = (Object)(object)emis != (Object)null && templateIsGame; if ((Object)(object)emis != (Object)null && !templateIsGame && !glowMenuNoted) { glowMenuNoted = true; Plugin.Log.LogInfo((object)"[ST] glow can't show on MoreCompany's menu model until the game's suit material has been loaded (it shows in a lobby)"); } m.shaderKeywords = (flag ? glowKeywords : plainKeywords); m.SetTexture("_EmissiveColorMap", flag ? emis : null); m.SetColor("_EmissiveColor", flag ? (Color.white * 1f) : Color.black); if (m.HasProperty("_EmissiveColorLDR")) { m.SetColor("_EmissiveColorLDR", flag ? Color.white : Color.black); } (string, float)[] array = new(string, float)[3] { ("_DoubleSidedEnable", 0f), ("_CullMode", 2f), ("_CullModeForward", 2f) }; for (int num = 0; num < array.Length; num++) { var (text, num2) = array[num]; if (m.HasProperty(text)) { m.SetFloat(text, flag ? num2 : template.GetFloat(text)); } } } private static void Trim() { if (cache.Count <= 16) { return; } HashSet<Material> inUse = new HashSet<Material>(); SkinnedMeshRenderer[] array = Object.FindObjectsOfType<SkinnedMeshRenderer>(); for (int i = 0; i < array.Length; i++) { Material[] sharedMaterials = ((Renderer)array[i]).sharedMaterials; foreach (Material val in sharedMaterials) { if ((Object)(object)val != (Object)null) { inUse.Add(val); } } } foreach (KeyValuePair<string, Entry> item in (from k in cache where (Object)(object)k.Value.Mat != (Object)null && !inUse.Contains(k.Value.Mat) orderby k.Value.Used select k).Take(cache.Count - 16).ToList()) { Material mat = item.Value.Mat; Texture val2 = (mat.HasProperty("_BaseColorMap") ? mat.GetTexture("_BaseColorMap") : null); Texture val3 = (mat.HasProperty("_EmissiveColorMap") ? mat.GetTexture("_EmissiveColorMap") : null); Object.Destroy((Object)(object)mat); if ((Object)(object)val2 != (Object)null) { Object.Destroy((Object)(object)val2); } if ((Object)(object)val3 != (Object)null) { Object.Destroy((Object)(object)val3); } cache.Remove(item.Key); } } private static Painted Paint(Design d) { //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b3: Unknown result type (might be due to invalid IL or missing references) //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_017d: Unknown result type (might be due to invalid IL or missing references) //IL_019a: Unknown result type (might be due to invalid IL or missing references) //IL_01b7: Unknown result type (might be due to invalid IL or missing references) //IL_01d9: Unknown result type (might be due to invalid IL or missing references) //IL_01de: Unknown result type (might be due to invalid IL or missing references) //IL_02c5: Unknown result type (might be due to invalid IL or missing references) //IL_02bc: Unknown result type (might be due to invalid IL or missing references) //IL_02e8: Unknown result type (might be due to invalid IL or missing references) //IL_02df: 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_030b: Unknown result type (might be due to invalid IL or missing references) //IL_0340: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Unknown result type (might be due to invalid IL or missing references) //IL_0370: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_038c: Unknown result type (might be due to invalid IL or missing references) //IL_0383: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_040f: Unknown result type (might be due to invalid IL or missing references) //IL_041f: Unknown result type (might be due to invalid IL or missing references) //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0439: 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) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03cb: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f5: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Unknown result type (might be due to invalid IL or missing references) //IL_02ca: Unknown result type (might be due to invalid IL or missing references) //IL_02ed: Unknown result type (might be due to invalid IL or missing references) //IL_0319: Unknown result type (might be due to invalid IL or missing references) //IL_0345: Unknown result type (might be due to invalid IL or missing references) //IL_0375: Unknown result type (might be due to invalid IL or missing references) //IL_0391: Unknown result type (might be due to invalid IL or missing references) //IL_03ef: Unknown result type (might be due to invalid IL or missing references) //IL_01fd: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0210: Unknown result type (might be due to invalid IL or missing references) //IL_0452: Unknown result type (might be due to invalid IL or missing references) //IL_045b: Unknown result type (might be due to invalid IL or missing references) //IL_0460: Unknown result type (might be due to invalid IL or missing references) Color32[] array = (Color32[])basePx.Clone(); bool anyGlow = d.AnyGlow; Color32[] array2 = (Color32[])(object)(anyGlow ? new Color32[basePx.Length] : null); float num = upMax - upMin; Part part = d.Parts[4]; Part[] array3 = new Part[10] { null, d.Parts[0], d.PantsEffective, d.Parts[2], d.Parts[3], part, null, part, d.Parts[2], d.Parts[5] }; float[] array4 = new float[10]; Textures.Tex[] array5 = new Textures.Tex[10]; for (int i = 1; i < 10; i++) { if (array3[i] != null) { array4[i] = num / (float)Math.Max(2, (int)array3[i].Count); if (array3[i].Pattern == Pattern.Texture) { array5[i] = Textures.Get(array3[i].Tex); } } } for (int j = 0; j < region.Length; j++) { int num2 = region[j]; if (num2 == 0 || num2 >= 10) { continue; } int num3 = coordIndex[j]; float x = (float)Math.Sqrt(baseL[j] / refL[num2]); if (num2 == 6) { float visorAlpha = d.VisorAlpha; if (!(visorAlpha <= 0f)) { x = Clamp(x, 0.5f, 1.6f); Color32 val = basePx[j]; array[j] = new Color32(Mix(val.r, (float)(int)d.Visor.r * x, visorAlpha), Mix(val.g, (float)(int)d.Visor.g * x, visorAlpha), Mix(val.b, (float)(int)d.Visor.b * x, visorAlpha), byte.MaxValue); if (anyGlow && d.VisorGlow > 0f) { array2[j] = Scale(d.Visor, d.VisorGlow * visorAlpha); } } continue; } x = Clamp(x, 0.6f, 1.35f); Part part2 = array3[num2]; float num4 = upMin + (float)(int)qUp[num3] / 65535f * num; float num5 = sideMin + (float)(int)qSide[num3] / 65535f * (sideMax - sideMin); float num6 = array4[num2]; Color32 val2; switch (part2.Pattern) { case Pattern.Vertical: val2 = (Odd(num5 / num6) ? part2.B : part2.A); break; case Pattern.Horizontal: val2 = (Odd(num4 / num6) ? part2.B : part2.A); break; case Pattern.DiagonalL: val2 = (Odd((num4 + num5) * 0.7071f / num6) ? part2.B : part2.A); break; case Pattern.DiagonalR: val2 = (Odd((num4 - num5) * 0.7071f / num6) ? part2.B : part2.A); break; case Pattern.Checker: val2 = (((Floor(num4 / num6) + Floor(num5 / num6)) % 2 != 0) ? part2.B : part2.A); break; case Pattern.TwoTone: val2 = ((num2 == 7) ? part2.B : part2.A); break; case Pattern.Rainbow: val2 = Rainbow((num4 - upMin + num5 - sideMin) / num * 2f); break; case Pattern.Texture: { Textures.Tex tex = array5[num2]; val2 = ((tex == null) ? part2.A : Lerp(part2.B, part2.A, Textures.Sample(tex, num5 / num6, num4 / num6))); break; } default: val2 = part2.A; break; } array[j] = new Color32(B((float)(int)val2.r * x), B((float)(int)val2.g * x), B((float)(int)val2.b * x), byte.MaxValue); if (anyGlow && part2.Glow > 0f) { array2[j] = Scale(val2, part2.Glow); } } return new Painted { Albedo = array, Emis = (anyGlow ? Shrink(array2) : null) }; } private static Color32 Lerp(Color32 a, Color32 b, float t) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_000d: Unknown result type (might be due to invalid IL or missing references) //IL_001d: 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_002a: Unknown result type (might be due to invalid IL or missing references) //IL_003a: Unknown result type (might be due to invalid IL or missing references) //IL_0041: 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_005c: Unknown result type (might be due to invalid IL or missing references) return new Color32(B((float)(int)a.r + (float)(b.r - a.r) * t), B((float)(int)a.g + (float)(b.g - a.g) * t), B((float)(int)a.b + (float)(b.b - a.b) * t), byte.MaxValue); } private static Color32 Scale(Color32 c, float k) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_001c: 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) return new Color32(B((float)(int)c.r * k), B((float)(int)c.g * k), B((float)(int)c.b * k), byte.MaxValue); } private static Color32[] Shrink(Color32[] px) { //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_0042: 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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0063: Unknown result type (might be due to invalid IL or missing references) int num = 2; Color32[] array = (Color32[])(object)new Color32[262144]; for (int i = 0; i < 512; i++) { for (int j = 0; j < 512; j++) { int num2 = 0; int num3 = 0; int num4 = 0; for (int k = 0; k < num; k++) { for (int l = 0; l < num; l++) { Color32 val = px[(i * num + k) * 1024 + j * num + l]; num2 += val.r; num3 += val.g; num4 += val.b; } } int num5 = num * num; array[i * 512 + j] = new Color32((byte)(num2 / num5), (byte)(num3 / num5), (byte)(num4 / num5), byte.MaxValue); } } return array; } private static int Floor(float x) { return (int)Math.Floor(x) & 0x7FFFFFFF; } private static bool Odd(float x) { return (Floor(x) & 1) == 1; } private static float Clamp(float x, float lo, float hi) { if (!(x < lo)) { if (!(x > hi)) { return x; } return hi; } return lo; } private static byte B(float x) { return (byte)((x < 0f) ? 0f : ((x > 255f) ? 255f : (x + 0.5f))); } private static byte Mix(byte o, float t, float a) { return B((float)(int)o * (1f - a) + t * a); } private static Color32 Rainbow(float h) { //IL_0017: 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) h -= (float)Math.Floor(h); return Color32.op_Implicit(Color.HSVToRGB(h, 0.85f, 1f)); } } [BepInPlugin("nine78.suittailor", "Suit Tailor", "0.2.0")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Plugin : BaseUnityPlugin { public const string Guid = "nine78.suittailor"; public const string Name = "Suit Tailor"; public const string Version = "0.2.0"; internal static ManualLogSource Log; private void Awake() { //IL_003f: Unknown result type (might be due to invalid IL or missing references) //IL_0045: Expected O, but got Unknown //IL_00c4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Expected O, but got Unknown //IL_00cf: Unknown result type (might be due to invalid IL or missing references) Log = ((BaseUnityPlugin)this).Logger; try { Painter.LoadRegions(); Library.Load(); Textures.Refresh(); Library.WornChanged += Suits.ApplyAll; Harmony val = new Harmony("nine78.suittailor"); Type[] types = typeof(Plugin).Assembly.GetTypes(); foreach (Type type in types) { if (type.GetCustomAttributes(typeof(HarmonyPatch), inherit: false).Length != 0) { try { val.CreateClassProcessor(type).Patch(); } catch (Exception ex) { Log.LogError((object)("[ST] patch " + type.Name + " failed: " + ex.GetBaseException().Message)); } } } GameObject val2 = new GameObject("SuitTailor"); Object.DontDestroyOnLoad((Object)val2); ((Object)val2).hideFlags = (HideFlags)61; val2.AddComponent<Pump>(); Log.LogInfo((object)"Suit Tailor 0.2.0 loaded"); } catch (Exception arg) { Log.LogError((object)$"[ST] failed to start: {arg}"); } } } internal class Pump : MonoBehaviour { private void Update() { Painter.Pump(); } } internal static class Suits { public const string SuitName = "Tailored Suit"; public static int SuitIndex = -1; private static UnlockableItem item; public static void Register(StartOfRound sor) { //IL_00d2: Unknown result type (might be due to invalid IL or missing references) //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e6: Unknown result type (might be due to invalid IL or missing references) List<UnlockableItem> unlockables = sor.unlockablesList.unlockables; UnlockableItem val = ((IEnumerable<UnlockableItem>)unlockables).FirstOrDefault((Func<UnlockableItem, bool>)((UnlockableItem u) => (Object)(object)u.suitMaterial != (Object)null && u.alreadyUnlocked)); if (val == null) { Plugin.Log.LogError((object)"[ST] no default suit found; the Tailored Suit can't be added"); return; } Painter.SetTemplate(val.suitMaterial, gameSuit: true); if (SuitIndex < 0 || SuitIndex >= unlockables.Count || !(unlockables[SuitIndex].unlockableName == "Tailored Suit")) { item = JsonUtility.FromJson<UnlockableItem>(JsonUtility.ToJson((object)val)); item.unlockableName = "Tailored Suit"; item.suitMaterial = Object.Instantiate<Material>(val.suitMaterial); item.alreadyUnlocked = true; item.hasBeenMoved = false; item.placedPosition = Vector3.zero; item.placedRotation = Vector3.zero; SuitIndex = unlockables.Count; unlockables.Add(item); Plugin.Log.LogInfo((object)$"[ST] Tailored Suit registered as unlockable #{SuitIndex}"); } } public static Design DesignFor(PlayerControllerB p) { if ((Object)(object)p == (Object)null) { return null; } if ((Object)(object)p == (Object)(object)GameNetworkManager.Instance?.localPlayerController) { return Library.Worn; } return Net.DesignOf(p.actualClientId) ?? Design.Default(); } public static void Apply(PlayerControllerB p) { if ((Object)(object)p == (Object)null || SuitIndex < 0 || p.currentSuitID != SuitIndex) { return; } Painter.Request(DesignFor(p), delegate(Material m) { if (!((Object)(object)p == (Object)null) && p.currentSuitID == SuitIndex) { SkinnedMeshRenderer[] array = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[4] { p.thisPlayerModel, p.thisPlayerModelLOD1, p.thisPlayerModelLOD2, p.thisPlayerModelArms }; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)val != (Object)null) { ((Renderer)val).sharedMaterial = m; } } if ((Object)(object)p.deadBody != (Object)null) { PaintBody(p.deadBody, m); } } }); } public static void ApplyAll() { StartOfRound instance = StartOfRound.Instance; if ((Object)(object)instance == (Object)null) { return; } PlayerControllerB[] allPlayerScripts = instance.allPlayerScripts; foreach (PlayerControllerB val in allPlayerScripts) { if ((Object)(object)val != (Object)null && (val.isPlayerControlled || val.isPlayerDead)) { Apply(val); } } RefreshRack(); } public static void RefreshRack() { if (SuitIndex < 0) { return; } Painter.Request(Library.Worn, delegate(Material m) { UnlockableSuit[] array = Object.FindObjectsOfType<UnlockableSuit>(); foreach (UnlockableSuit val in array) { if (val.syncedSuitID.Value == SuitIndex && (Object)(object)val.suitRenderer != (Object)null) { ((Renderer)val.suitRenderer).sharedMaterial = m; } } }); } private static void PaintBody(DeadBodyInfo body, Material m) { SkinnedMeshRenderer[] componentsInChildren = ((Component)body).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val in componentsInChildren) { if ((Object)(object)((Renderer)val).sharedMaterial != (Object)null && ((Object)(object)((Renderer)val).sharedMaterial == (Object)(object)item?.suitMaterial || ((Object)((Renderer)val).sharedMaterial).name.StartsWith("SuitTailor"))) { ((Renderer)val).sharedMaterial = m; } } } public static void PaintMasked(MaskedPlayerEnemy masked) { if ((Object)(object)masked == (Object)null) { return; } Painter.Request(DesignFor(masked.mimickingPlayer) ?? Design.Default(), delegate(Material m) { if (!((Object)(object)masked == (Object)null)) { SkinnedMeshRenderer[] array = (SkinnedMeshRenderer[])(object)new SkinnedMeshRenderer[3] { masked.rendererLOD0, masked.rendererLOD1, masked.rendererLOD2 }; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)val != (Object)null) { ((Renderer)val).sharedMaterial = m; } } } }); } } [HarmonyPatch(typeof(StartOfRound), "Start")] internal static class RegisterSuitPatch { [HarmonyPriority(200)] private static void Prefix(StartOfRound __instance) { try { Suits.Register(__instance); } catch (Exception arg) { Plugin.Log.LogError((object)$"[ST] {arg}"); } } private static void Postfix() { Net.Init(); Suits.RefreshRack(); } } [HarmonyPatch(typeof(UnlockableSuit), "SwitchSuitForPlayer")] internal static class SwitchSuitPatch { private static void Postfix(PlayerControllerB player, int suitID) { if (suitID == Suits.SuitIndex) { Suits.Apply(player); } } } [HarmonyPatch(typeof(StartOfRound), "PositionSuitsOnRack")] internal static class RackSuitPatch { private static void Postfix() { Suits.RefreshRack(); } } [HarmonyPatch(typeof(PlayerControllerB), "SpawnDeadBody")] internal static class DeadBodyPatch { private static void Postfix(PlayerControllerB __instance) { if (__instance.currentSuitID == Suits.SuitIndex) { Suits.Apply(__instance); } } } [HarmonyPatch(typeof(MaskedPlayerEnemy), "SetSuit")] internal static class MaskedSuitPatch { private static void Postfix(MaskedPlayerEnemy __instance, int suitId) { if (suitId == Suits.SuitIndex) { Suits.PaintMasked(__instance); } } } internal class TailorTab { [CompilerGenerated] private static class <>O { public static UnityAction <0>__OpenFolder; } private static TailorTab current; private readonly Transform screen; private readonly List<GameObject> cosmeticsBits = new List<GameObject>(); private readonly Dictionary<GameObject, bool> wasActive = new Dictionary<GameObject, bool>(); private readonly SkinnedMeshRenderer[] display; private RectTransform panel; private RectTransform listContent; private ScrollRect scroll; private readonly List<Ui.Btn_> rows = new List<Ui.Btn_>(); private Ui.Btn_ tabCos; private Ui.Btn_ tabSuits; private Ui.Btn_ folderMine; private Ui.Btn_ folderPresets; private Ui.Btn_ saveBtn; private Ui.Btn_ deleteBtn; private Ui.Btn_ slotA; private Ui.Btn_ slotB; private Ui.Btn_ matchBtn; private Image swatchA; private Image swatchB; private TMP_InputField nameField; private TextMeshProUGUI status; private TextMeshProUGUI optionLabel; private TextMeshProUGUI partNote; private Slider optionSlider; private Slider glowSlider; private TextMeshProUGUI glowLabel; private RectTransform optionSliderRt; private RectTransform patternRow; private RectTransform slotRow; private readonly Ui.Btn_[] partTabs = new Ui.Btn_[7]; private Ui.Btn_ patternBtn; private RectTransform dropList; private ColorPicker picker; private bool presets; private int sel = -1; private Design draft; private bool dirty; private bool quiet; private int part; private const int Visor = 6; private bool lastChanged; private float wearAt = -1f; private int slot; private static readonly string[] PartLabels = new string[7] { "Shirt", "Pants", "Straps", "Helmet", "Backpack", "Gloves &\nboots", "Visor" }; private static readonly string[] PatternLabels = new string[9] { "Solid", "Vertical stripes", "Horizontal stripes", "Diagonal stripes (left)", "Diagonal stripes (right)", "Checkerboard", "Tanks + bands", "Rainbow", "Texture" }; private List<Design> Folder { get { if (!presets) { return Library.Mine; } return Library.Presets; } } private static bool CanWear => (Object)(object)StartOfRound.Instance != (Object)null; private Part CurrentPart { get { if (part >= 6) { return null; } if (part != 1 || !draft.PantsMatch) { return draft.Parts[part]; } return draft.Parts[0]; } } private TailorTab(Transform screen) { this.screen = screen; Transform obj = screen.Find("DisableCosmeticsText"); object obj2; if (obj == null) { obj2 = null; } else { TextMeshProUGUI component = ((Component)obj).GetComponent<TextMeshProUGUI>(); obj2 = ((component != null) ? ((TMP_Text)component).font : null); } if (obj2 == null) { TextMeshProUGUI componentInChildren = ((Component)screen).GetComponentInChildren<TextMeshProUGUI>(true); obj2 = ((componentInChildren != null) ? ((TMP_Text)componentInChildren).font : null); } TMP_FontAsset val = (TMP_FontAsset)obj2; if ((Object)(object)val != (Object)null) { Ui.Font = val; } string[] array = new string[7] { "CosmeticsHolderBG", "CosmeticsHolderBorder", "Scrollbar", "CosmeticsHolder", "EnableButton", "DisableButton", "DisableCosmeticsText" }; foreach (string text in array) { Transform val2 = screen.Find(text); if ((Object)(object)val2 != (Object)null) { cosmeticsBits.Add(((Component)val2).gameObject); } } Transform val3 = (((Object)(object)CosmeticRegistry.displayGuy != (Object)null) ? CosmeticRegistry.displayGuy.transform.parent : screen.Find("ObjectHolder/ScavengerModel")); display = (SkinnedMeshRenderer[])(((Object)(object)val3 != (Object)null) ? ((Array)(from r in ((Component)val3).GetComponentsInChildren<SkinnedMeshRenderer>(true) where ((Object)r).name.StartsWith("LOD") select r).ToArray()) : ((Array)new SkinnedMeshRenderer[0])); Material val4 = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material x) => (Object)(object)x != (Object)null && ((Object)x).name == "DefaultPlayerSuit" && x.IsKeywordEnabled("_MASKMAP"))); if ((Object)(object)val4 != (Object)null) { Painter.SetTemplate(val4, gameSuit: true); } else if (display.Length != 0) { Painter.SetTemplate(((Renderer)display[0]).sharedMaterial); } Build(); ShowSuits(on: false); Painter.Request(Library.Worn, ShowOnModel); } public static void Attach() { try { Transform cosmeticGUIGlobalScale = CosmeticRegistry.cosmeticGUIGlobalScale; Transform val = ((cosmeticGUIGlobalScale != null) ? cosmeticGUIGlobalScale.Find("CosmeticsScreen") : null); if ((Object)(object)val == (Object)null) { Plugin.Log.LogWarning((object)"[ST] MoreCompany's cosmetics screen not found; no Suits tab"); } else if (!((Object)(object)val.Find("SuitTailorPanel") != (Object)null)) { current = new TailorTab(val); Plugin.Log.LogInfo((object)"[ST] Suits tab added to MoreCompany's cosmetics screen"); } } catch (Exception arg) { Plugin.Log.LogError((object)$"[ST] couldn't add the Suits tab: {arg}"); } } private void Build() { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) //IL_0085: Expected O, but got Unknown //IL_00ba: 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_0105: Expected O, but got Unknown //IL_013b: Unknown result type (might be due to invalid IL or missing references) //IL_014a: Expected O, but got Unknown //IL_0175: Unknown result type (might be due to invalid IL or missing references) //IL_01e5: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0337: Expected O, but got Unknown //IL_03ab: Unknown result type (might be due to invalid IL or missing references) //IL_03ba: Expected O, but got Unknown //IL_03f0: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Expected O, but got Unknown //IL_0434: Unknown result type (might be due to invalid IL or missing references) //IL_0443: Expected O, but got Unknown //IL_0474: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Expected O, but got Unknown //IL_04b8: Unknown result type (might be due to invalid IL or missing references) //IL_052f: Unknown result type (might be due to invalid IL or missing references) //IL_05a8: Unknown result type (might be due to invalid IL or missing references) //IL_05b7: Expected O, but got Unknown //IL_067b: Unknown result type (might be due to invalid IL or missing references) //IL_068a: Expected O, but got Unknown //IL_06be: Unknown result type (might be due to invalid IL or missing references) //IL_06fe: Unknown result type (might be due to invalid IL or missing references) //IL_070d: Expected O, but got Unknown //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_076c: Unknown result type (might be due to invalid IL or missing references) //IL_0773: Unknown result type (might be due to invalid IL or missing references) //IL_07ae: Unknown result type (might be due to invalid IL or missing references) //IL_07f3: Unknown result type (might be due to invalid IL or missing references) //IL_0802: Expected O, but got Unknown //IL_083b: Unknown result type (might be due to invalid IL or missing references) //IL_090c: Unknown result type (might be due to invalid IL or missing references) //IL_060a: Unknown result type (might be due to invalid IL or missing references) //IL_060f: Unknown result type (might be due to invalid IL or missing references) //IL_0615: Expected O, but got Unknown //IL_0544: Expected O, but got Unknown tabCos = Ui.Button(Ui.Rect("SuitTailorTabCosmetics", screen, -20f, 245f, 125f, 32f), "Cosmetics", (UnityAction)delegate { ShowSuits(on: false); }, 16f); tabSuits = Ui.Button(Ui.Rect("SuitTailorTabSuits", screen, 112f, 245f, 125f, 32f), "Suits", (UnityAction)delegate { ShowSuits(on: true); }, 16f); panel = Ui.Rect("SuitTailorPanel", screen, -140f, -20f, 600f, 480f); Ui.Box(panel, Ui.Panel); folderMine = Ui.Button(Ui.TL("Mine", (Transform)(object)panel, 10f, 10f, 82f, 30f), "My suits", (UnityAction)delegate { ShowFolder(showPresets: false); }, 14f); folderPresets = Ui.Button(Ui.TL("Presets", (Transform)(object)panel, 98f, 10f, 82f, 30f), "Presets", (UnityAction)delegate { ShowFolder(showPresets: true); }, 14f); RectTransform val = Ui.TL("List", (Transform)(object)panel, 10f, 46f, 152f, 384f); Ui.Box(val, Ui.Field); ((Component)val).gameObject.AddComponent<RectMask2D>(); listContent = Ui.TL("Content", (Transform)(object)val, 0f, 0f, 152f, 0f); VerticalLayoutGroup obj = ((Component)listContent).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 2f; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).padding = new RectOffset(3, 3, 3, 3); ((Component)listContent).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; ScrollRect val2 = ((Component)val).gameObject.AddComponent<ScrollRect>(); val2.content = listContent; val2.viewport = val; val2.horizontal = false; val2.vertical = true; val2.movementType = (MovementType)2; val2.scrollSensitivity = 0f; val2.inertia = false; ((Component)val).gameObject.AddComponent<WheelStep>().Init(val2, listContent, 84f); ((Component)panel).gameObject.AddComponent<ArrowKeys>().Step = delegate(int d) { if (sel >= 0) { Select(Mathf.Clamp(sel + d, 0, Folder.Count - 1)); } }; Ticker ticker = ((Component)panel).gameObject.AddComponent<Ticker>(); ticker.Tick = Tick; ticker.Stop = delegate { WearNow(); if (lastChanged) { lastChanged = false; Library.Save(); } }; val2.verticalScrollbar = Ui.Scrollbar(Ui.TL("ListScroll", (Transform)(object)panel, 164f, 46f, 16f, 384f)); val2.verticalScrollbarVisibility = (ScrollbarVisibility)0; scroll = val2; Ui.Button(Ui.TL("New", (Transform)(object)panel, 10f, 438f, 170f, 32f), "+ New suit", new UnityAction(NewDesign)); nameField = Ui.Input(Ui.TL("Name", (Transform)(object)panel, 192f, 10f, 230f, 30f), "Suit name", 24, delegate(string s) { if (!quiet && draft != null) { draft.Name = s; Dirty(); } }); saveBtn = Ui.Button(Ui.TL("Save", (Transform)(object)panel, 428f, 10f, 76f, 30f), "Save", new UnityAction(SaveDesign), 14f); deleteBtn = Ui.Button(Ui.TL("Delete", (Transform)(object)panel, 510f, 10f, 80f, 30f), "Delete", new UnityAction(DeleteDesign), 14f); Ui.Button(Ui.TL("Copy", (Transform)(object)panel, 192f, 46f, 196f, 30f), "Copy code", new UnityAction(CopyCode), 14f); Ui.Button(Ui.TL("Paste", (Transform)(object)panel, 394f, 46f, 196f, 30f), "Paste code", new UnityAction(PasteCode), 14f); status = Ui.Text((Transform)(object)Ui.TL("Status", (Transform)(object)panel, 192f, 80f, 398f, 22f), "", 13f, (TextAlignmentOptions)513, Ui.TextCol); for (int num = 0; num < 7; num++) { int k = num; partTabs[num] = Ui.Button(Ui.TL("Part" + num, (Transform)(object)panel, 192f + (float)(num * 57), 106f, 53f, 30f), PartLabels[num], (UnityAction)delegate { part = k; slot = 0; ShowEditor(); }, (num == 5) ? 10 : 12); } patternRow = Ui.TL("Patterns", (Transform)(object)panel, 192f, 144f, 398f, 30f); patternBtn = Ui.Button(Ui.TL("Pattern", (Transform)(object)patternRow, 0f, 0f, 260f, 30f), "", new UnityAction(ToggleDropdown), 13f); ((TMP_Text)patternBtn.Label).alignment = (TextAlignmentOptions)513; RectTransform rt = Ui.TL("TexFolder", (Transform)(object)patternRow, 266f, 0f, 132f, 30f); object obj2 = <>O.<0>__OpenFolder; if (obj2 == null) { UnityAction val3 = Textures.OpenFolder; <>O.<0>__OpenFolder = val3; obj2 = (object)val3; } Ui.Button(rt, "Textures folder", (UnityAction)obj2, 12f); slotRow = Ui.TL("Slots", (Transform)(object)panel, 192f, 182f, 398f, 30f); slotA = Ui.Button(Ui.TL("A", (Transform)(object)slotRow, 0f, 0f, 130f, 30f), "Colour 1", (UnityAction)delegate { slot = 0; ShowEditor(); }, 13f); swatchA = Ui.Box(Ui.TL("SwA", ((Component)slotA.Button).transform, 100f, 5f, 24f, 20f), Color.white); slotB = Ui.Button(Ui.TL("B", (Transform)(object)slotRow, 136f, 0f, 130f, 30f), "Colour 2", (UnityAction)delegate { slot = 1; ShowEditor(); }, 13f); swatchB = Ui.Box(Ui.TL("SwB", ((Component)slotB.Button).transform, 100f, 5f, 24f, 20f), Color.white); TextMeshProUGUI label = slotA.Label; TextMeshProUGUI label2 = slotB.Label; TextAlignmentOptions alignment = (TextAlignmentOptions)513; ((TMP_Text)label2).alignment = (TextAlignmentOptions)513; ((TMP_Text)label).alignment = alignment; partNote = Ui.Text((Transform)(object)Ui.TL("Note", (Transform)(object)panel, 192f, 182f, 398f, 30f), "", 13f, (TextAlignmentOptions)513, Ui.TextCol); matchBtn = Ui.Button(Ui.TL("Match", (Transform)(object)panel, 192f, 220f, 220f, 28f), "", new UnityAction(ToggleMatch), 13f); optionLabel = Ui.Text((Transform)(object)Ui.TL("OptLabel", (Transform)(object)panel, 192f, 220f, 150f, 28f), "", 13f, (TextAlignmentOptions)513, Ui.TextCol); optionSliderRt = Ui.TL("OptSlider", (Transform)(object)panel, 348f, 220f, 242f, 28f); optionSlider = Ui.Slider(optionSliderRt, 0f, 1f, whole: false, OptionChanged); picker = new ColorPicker((Transform)(object)panel, 192f, 258f, 200f); picker.Changed += delegate(Color32 c) { //IL_0009: Unknown result type (might be due to invalid IL or missing references) if (!quiet) { SetColour(c); } }; glowLabel = Ui.Text((Transform)(object)Ui.TL("GlowLabel", (Transform)(object)panel, 438f, 412f, 152f, 20f), "Glow", 13f, (TextAlignmentOptions)513, Ui.TextCol); glowSlider = Ui.Slider(Ui.TL("Glow", (Transform)(object)panel, 438f, 434f, 152f, 22f), 0f, 1f, whole: false, GlowChanged); } private void ShowSuits(bool on) { if (on) { foreach (GameObject cosmeticsBit in cosmeticsBits) { wasActive[cosmeticsBit] = cosmeticsBit.activeSelf; cosmeticsBit.SetActive(false); } ((Component)panel).gameObject.SetActive(true); if (draft == null) { sel = -1; List<Design> list = (Library.LastPresets ? Library.Presets : Library.Mine); if (Library.LastName != null && list.Exists((Design d) => d.Name == Library.LastName)) { ShowFolder(Library.LastPresets, selectWorn: false, Library.LastName); } else { ShowFolder(Library.Mine.Count == 0, selectWorn: true); } } else { Painter.Preview(draft, ShowOnModel); } } else { WearNow(); foreach (GameObject cosmeticsBit2 in cosmeticsBits) { if (wasActive.TryGetValue(cosmeticsBit2, out var value)) { cosmeticsBit2.SetActive(value); } } ((Component)panel).gameObject.SetActive(false); if (draft != null) { Painter.Preview(draft, ShowOnModel); } else { Painter.Request(Library.Worn, ShowOnModel); } } Ui.SetOn(tabCos, !on); Ui.SetOn(tabSuits, on); } private void ShowOnModel(Material m) { SkinnedMeshRenderer[] array = display; foreach (SkinnedMeshRenderer val in array) { if ((Object)(object)val != (Object)null) { ((Renderer)val).sharedMaterial = m; } } } private void ShowFolder(bool showPresets, bool selectWorn = false, string selectName = null) { presets = showPresets; Ui.SetOn(folderMine, !presets); Ui.SetOn(folderPresets, presets); int i = 0; if (selectName != null) { i = Math.Max(0, Folder.FindIndex((Design d) => d.Name == selectName)); } else if (selectWorn) { string key = Library.Worn.LookKey(); int num = Folder.FindIndex((Design d) => d.LookKey() == key && d.Name == Library.Worn.Name); if (num >= 0) { i = num; } } RebuildList(); scroll.verticalNormalizedPosition = 1f; if (Folder.Count > 0) { Select(i); return; } sel = -1; draft = Library.Worn.Clone(); dirty = false; ShowEditor(); Status(presets ? "" : "No saved suits yet: make one with + New suit, or save a copy of a preset."); } private void RebuildList() { //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Expected O, but got Unknown for (int num = ((Transform)listContent).childCount - 1; num >= 0; num--) { Object.Destroy((Object)(object)((Component)((Transform)listContent).GetChild(num)).gameObject); } rows.Clear(); string wornKey = Library.Worn.LookKey(); for (int i = 0; i < Folder.Count; i++) { int k = i; Design d = Folder[i]; RectTransform obj = Ui.Rect("Row" + i, (Transform)(object)listContent, 0f, 0f, 146f, 26f); ((Component)obj).gameObject.AddComponent<LayoutElement>().preferredHeight = 26f; Ui.Btn_ btn_ = Ui.Button(obj, RowText(d, wornKey), (UnityAction)delegate { Select(k); }, 13f); ((TMP_Text)btn_.Label).alignment = (TextAlignmentOptions)513; Ui.SetOn(btn_, i == sel); rows.Add(btn_); } } private static string RowText(Design d, string wornKey) { return ((d.LookKey() == wornKey && d.Name == Library.Worn.Name) ? "• " : "") + d.Name; } private void Highlight() { string wornKey = Library.Worn.LookKey(); for (int i = 0; i < rows.Count && i < Folder.Count; i++) { Ui.SetOn(rows[i], i == sel); ((TMP_Text)rows[i].Label).text = RowText(Folder[i], wornKey); } } private void ScrollToSelected() { //IL_002e: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Unknown result type (might be due to invalid IL or missing references) //IL_0048: 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) if (sel < 0 || (Object)(object)scroll == (Object)null) { return; } Canvas.ForceUpdateCanvases(); float num = 28f; Rect rect = scroll.viewport.rect; float height = ((Rect)(ref rect)).height; rect = listContent.rect; float num2 = Mathf.Max(((Rect)(ref rect)).height, (float)rows.Count * num + 6f); if (!(num2 <= height)) { float num3 = 3f + (float)sel * num; float num4 = listContent.anchoredPosition.y; if (num3 < num4) { num4 = num3; } else if (num3 + num > num4 + height) { num4 = num3 + num - height; } scroll.verticalNormalizedPosition = 1f - Mathf.Clamp01(num4 / (num2 - height)); } } private void Select(int i) { if (i >= 0 && i < Folder.Count) { sel = i; draft = Folder[i].Clone(); if (Library.LastPresets != presets || Library.LastName != draft.Name) { Library.LastPresets = presets; Library.LastName = draft.Name; lastChanged = true; } dirty = false; if (rows.Count != Folder.Count) { RebuildList(); } else { Highlight(); } ScrollToSelected(); ShowEditor(); Status(""); WearSoon(0.35f); } } private void WearSoon(float delay) { if (CanWear) { wearAt = Time.unscaledTime + delay; } } private void Tick() { if (wearAt >= 0f && Time.unscaledTime >= wearAt) { WearNow(); } } private void WearNow() { if (!(wearAt < 0f) && draft != null) { wearAt = -1f; Library.Wear(draft); Highlight(); } } private void ShowEditor() { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_0295: Unknown result type (might be due to invalid IL or missing references) //IL_02a7: 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_02c0: Unknown result type (might be due to invalid IL or missing references) //IL_0499: Unknown result type (might be due to invalid IL or missing references) //IL_048c: Unknown result type (might be due to invalid IL or missing references) //IL_0484: Unknown result type (might be due to invalid IL or missing references) if (draft != null) { quiet = true; nameField.text = draft.Name; ((TMP_Text)saveBtn.Label).text = (presets ? "Save copy" : (dirty ? "Save*" : "Save")); ((TMP_Text)saveBtn.Label).fontSize = (presets ? 12 : 14); ((Selectable)deleteBtn.Button).interactable = !presets && sel >= 0; ((Graphic)deleteBtn.Label).color = (Color)(((Selectable)deleteBtn.Button).interactable ? Ui.TextBright : new Color(1f, 1f, 1f, 0.3f)); for (int i = 0; i < 7; i++) { Ui.SetOn(partTabs[i], i == part); } bool flag = part == 6; bool flag2 = part == 1 && draft.PantsMatch; Part currentPart = CurrentPart; ((Component)patternRow).gameObject.SetActive(!flag && !flag2); ((Component)slotRow).gameObject.SetActive(!flag2); ((Component)partNote).gameObject.SetActive(flag2); ((TMP_Text)partNote).text = (flag2 ? "The pants use the shirt's design. Turn this off to style them separately." : ""); picker.SetVisible(!flag2); CloseDropdown(); if (!flag && !flag2) { ((TMP_Text)patternBtn.Label).text = "Pattern: " + PatternName(currentPart) + " ▾"; } bool flag3 = !flag && currentPart != null && currentPart.Pattern != Pattern.Solid && currentPart.Pattern != Pattern.Rainbow; ((Component)slotB.Button).gameObject.SetActive(flag3); if (!flag3) { slot = 0; } ((TMP_Text)slotA.Label).text = (flag ? "Visor colour" : ((currentPart != null && currentPart.Pattern == Pattern.TwoTone) ? "Tanks" : "Colour 1")); ((TMP_Text)slotB.Label).text = ((currentPart != null && currentPart.Pattern == Pattern.TwoTone) ? "Bands" : "Colour 2"); Ui.SetOn(slotA, slot == 0); Ui.SetOn(slotB, slot == 1); ((Graphic)swatchA).color = Color32.op_Implicit(flag ? draft.Visor : currentPart.A); if (currentPart != null) { ((Graphic)swatchB).color = Color32.op_Implicit(currentPart.B); } ((Component)matchBtn.Button).gameObject.SetActive(part == 1); ((TMP_Text)matchBtn.Label).text = "Same as shirt: " + (draft.PantsMatch ? "Yes" : "No"); Ui.SetOn(matchBtn, draft.PantsMatch); bool flag4 = !flag && !flag2 && currentPart != null && (((int)currentPart.Pattern >= 1 && (int)currentPart.Pattern <= 5) || currentPart.Pattern == Pattern.Texture); bool active = part != 1 && (flag || flag4); ((Component)optionLabel).gameObject.SetActive(active); ((Component)optionSliderRt).gameObject.SetActive(active); if (flag) { ((TMP_Text)optionLabel).text = $"Tint {Mathf.RoundToInt(draft.VisorAlpha * 100f)}%"; optionSlider.minValue = 0f; optionSlider.maxValue = 1f; optionSlider.wholeNumbers = false; optionSlider.value = draft.VisorAlpha; } else if (flag4) { ((TMP_Text)optionLabel).text = ((currentPart.Pattern == Pattern.Texture) ? "Texture size" : "Stripe size"); optionSlider.wholeNumbers = true; optionSlider.minValue = 2f; optionSlider.maxValue = 60f; optionSlider.value = 62 - currentPart.Count; } if (!flag2) { picker.Set(flag ? draft.Visor : ((slot == 0) ? currentPart.A : currentPart.B)); } ((Component)glowLabel).gameObject.SetActive(!flag2); ((Component)glowSlider).gameObject.SetActive(!flag2); float num = (flag ? draft.VisorGlow : (currentPart?.Glow ?? 0f)); glowSlider.value = num; ((TMP_Text)glowLabel).text = GlowText(num); quiet = false; if (currentPart != null && currentPart.Pattern == Pattern.Rainbow) { Status("This part uses the rainbow pattern (presets only); pick another pattern to change it."); } Painter.Preview(draft, ShowOnModel); } } private void Dirty() { dirty = true; if (!presets) { ((TMP_Text)saveBtn.Label).text = "Save*"; } Painter.Preview(draft, ShowOnModel); WearSoon(1f); } private static string GlowText(float g) { if (!(g <= 0f)) { return $"Glow {Mathf.RoundToInt(g * 100f)}%"; } return "Glow: off"; } private void GlowChanged(float v) { if (quiet || draft == null) { return; } if (part == 6) { draft.VisorGlow = v; } else { Part currentPart = CurrentPart; if (currentPart == null) { return; } currentPart.Glow = v; } ((TMP_Text)glowLabel).text = GlowText(v); Dirty(); } private void SetPattern(Pattern pat, string tex = "") { Part currentPart = CurrentPart; if (currentPart != null) { if (pat == Pattern.Texture && currentPart.Pattern != Pattern.Texture) { currentPart.Count = 10; } else if ((int)pat >= 1 && (int)pat <= 5 && currentPart.Pattern == Pattern.Texture) { currentPart.Count = 28; } currentPart.Pattern = pat; currentPart.Tex = ((pat == Pattern.Texture) ? tex : ""); Dirty(); ShowEditor(); } } private static string PatternName(Part p) { if (p.Pattern == Pattern.Texture) { if (Textures.Get(p.Tex) == null) { return "Texture: " + p.Tex + " (missing)"; } return "Texture: " + p.Tex; } int pattern = (int)p.Pattern; if (pattern >= PatternLabels.Length) { return "Solid"; } return PatternLabels[pattern]; } private void ToggleDropdown() { //IL_0140: Unknown result type (might be due to invalid IL or missing references) //IL_01b0: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Expected O, but got Unknown //IL_02b1: Unknown result type (might be due to invalid IL or missing references) //IL_02c0: Expected O, but got Unknown if ((Object)(object)dropList != (Object)null) { CloseDropdown(); return; } Part currentPart = CurrentPart; if (currentPart == null) { return; } Textures.Refresh(); List<(string, Pattern, string)> list = new List<(string, Pattern, string)>(); for (int i = 0; i <= 5; i++) { list.Add((PatternLabels[i], (Pattern)i, "")); } if (part == 4) { list.Add((PatternLabels[6], Pattern.TwoTone, "")); } if (currentPart.Pattern == Pattern.Rainbow) { list.Add((PatternLabels[7], Pattern.Rainbow, "")); } foreach (string name in Textures.Names) { list.Add(("Texture: " + name, Pattern.Texture, name)); } float h = Mathf.Min((float)list.Count * 28f + 6f, 300f); dropList = Ui.TL("PatternList", (Transform)(object)panel, 192f, 176f, 260f, h); Ui.Box(dropList, new Color(0.08f, 0.08f, 0.09f, 0.98f)); ((Component)dropList).gameObject.AddComponent<RectMask2D>(); RectTransform val = Ui.TL("Content", (Transform)(object)dropList, 0f, 0f, 260f, 0f); VerticalLayoutGroup obj = ((Component)val).gameObject.AddComponent<VerticalLayoutGroup>(); ((HorizontalOrVerticalLayoutGroup)obj).spacing = 2f; ((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = false; ((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true; ((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = false; ((LayoutGroup)obj).padding = new RectOffset(3, 3, 3, 3); ((Component)val).gameObject.AddComponent<ContentSizeFitter>().verticalFit = (FitMode)2; ScrollRect val2 = ((Component)dropList).gameObject.AddComponent<ScrollRect>(); val2.content = val; val2.viewport = dropList; val2.horizontal = false; val2.vertical = true; val2.movementType = (MovementType)2; val2.scrollSensitivity = 0f; val2.inertia = false; ((Component)dropList).gameObject.AddComponent<WheelStep>().Init(val2, val, 84f); foreach (var item in list) { (string label, Pattern pat, string tex) opt = item; RectTransform obj2 = Ui.Rect("Opt", (Transform)(object)val, 0f, 0f, 254f, 26f); ((Component)obj2).gameObject.AddComponent<LayoutElement>().preferredHeight = 26f; Ui.Btn_ btn_ = Ui.Button(obj2, opt.label, (UnityAction)delegate { CloseDropdown(); SetPattern(opt.pat, opt.tex); }, 13f); ((TMP_Text)btn_.Label).alignment = (TextAlignmentOptions)513; Ui.SetOn(btn_, currentPart.Pattern == opt.pat && (opt.pat != Pattern.Texture || string.Equals(currentPart.Tex, opt.tex, StringComparison.OrdinalIgnoreCase))); } if (Textures.Names.Count == 0) { Status("No textures yet: put black-and-white PNGs in the textures folder."); } } private void CloseDropdown() { if (!((Object)(object)dropList == (Object)null)) { Object.Destroy((Object)(object)((Component)dropList).gameObject); dropList = null; } } private void SetColour(Color32 c) { //IL_000f: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0034: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0051: 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_0064: 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) if (part == 6) { draft.Visor = c; } else { Part currentPart = CurrentPart; if (currentPart == null) { return; } if (slot == 0) { currentPart.A = c; } else { currentPart.B = c; } } if (part == 6 || slot == 0) { ((Graphic)swatchA).color = Color32.op_Implicit(c); } else { ((Graphic)swatchB).color = Color32.op_Implicit(c); } Dirty(); } private void ToggleMatch() { draft.PantsMatch = !draft.PantsMatch; if (!draft.PantsMatch) { draft.Parts[1] = draft.Parts[0].Clone(); } Dirty(); ShowEditor(); } private void OptionChanged(float v) { if (q