Decompiled source of Personify v2.4.1

Personify.dll

Decompiled 19 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Net.Http;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using DooDesch.AvatarKit;
using DooDesch.Localization;
using HarmonyLib;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppScheduleOne;
using Il2CppScheduleOne.Avatar;
using Il2CppScheduleOne.Avatar.Tools;
using Il2CppScheduleOne.AvatarFramework;
using Il2CppScheduleOne.AvatarFramework.Animation;
using Il2CppScheduleOne.AvatarFramework.Customization;
using Il2CppScheduleOne.Core.Avatar;
using Il2CppScheduleOne.Core.Avatar.Properties;
using Il2CppScheduleOne.Core.Items.Framework;
using Il2CppScheduleOne.DevUtilities;
using Il2CppScheduleOne.Doors;
using Il2CppScheduleOne.Effects;
using Il2CppScheduleOne.GameTime;
using Il2CppScheduleOne.ItemFramework;
using Il2CppScheduleOne.Map;
using Il2CppScheduleOne.NPCs;
using Il2CppScheduleOne.Persistence;
using Il2CppScheduleOne.PlayerScripts;
using Il2CppScheduleOne.UI.MainMenu;
using Il2CppScheduleOne.UI.Phone.Map;
using Il2CppScheduleOne.Vehicles;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Personify;
using Personify.App;
using Personify.Cards;
using Personify.Editor;
using Personify.Editor.World;
using Personify.Host;
using Personify.Project;
using S1API.Entities.Appearances.AccessoryFields;
using S1API.Entities.Appearances.BodyLayerFields;
using S1API.Entities.Appearances.CustomizationFields;
using S1API.Entities.Appearances.FaceLayerFields;
using S1API.Rendering;
using S1API.UI;
using SideHustle;
using Sideload.Api;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Core), "Personify", "2.4.1", "DooDesch", "https://github.com/DooDesch-Mods/ScheduleOne-Personify")]
[assembly: MelonGame("TVGS", "Schedule I")]
[assembly: MelonOptionalDependencies(new string[] { "SideHustle" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("DooDesch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © DooDesch")]
[assembly: AssemblyDescription("In-game NPC editor for Schedule I, launched as a Side Hustle gamemode.")]
[assembly: AssemblyFileVersion("2.4.1.0")]
[assembly: AssemblyInformationalVersion("2.4.1+e2c76e59f2d1140c1d7fd0c2724758dfb57a164a")]
[assembly: AssemblyProduct("Personify")]
[assembly: AssemblyTitle("Personify")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.4.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Sideload.Api
{
	public static class Apps
	{
		private static bool _bound;

		private static int _probeAttempts;

		private static readonly List<Action> _pending = new List<Action>();

		private static Action<string, string, string, string, Assembly> _registerApp;

		private static Action<string, string, Func<string, string, string>> _handle;

		private static Action<string, string, string> _emit;

		private static Action<string, string> _allowHost;

		private static Action<string, string> _declareOrientations;

		private static Action<string, int> _setBadge;

		private static Action<string, string, string> _notify;

		private static Action<string, string, string, float> _notifyFor;

		private static Func<string, bool> _isOnScreen;

		private static Action<string, string, byte[]> _setImage;

		private static Action<string, bool> _setIconHidden;

		private static Action<string, bool> _setAppOpen;

		private static Func<string, bool> _isAppOpen;

		private static Func<bool, bool> _setPhoneRaised;

		private static Func<bool> _isPhoneRaised;

		private static Action<string, string, Func<string, string, bool>> _claimKeys;

		private static Func<object, string, string, Assembly, float, bool> _mountSurface;

		private static Action<string> _unmountSurface;

		private static Func<string, bool> _isSurfaceMounted;

		private static Action<string> _reloadApp;

		private static Action<string> _unregisterApp;

		private static Action<string, string> _allowGameWrites;

		public static bool Available
		{
			get
			{
				EnsureBound();
				return _bound;
			}
		}

		internal static bool HasLiveEditing
		{
			get
			{
				EnsureBound();
				if (_reloadApp != null)
				{
					return _unregisterApp != null;
				}
				return false;
			}
		}

		internal static bool HasSurfaces
		{
			get
			{
				EnsureBound();
				return _mountSurface != null;
			}
		}

		internal static bool HasKeys
		{
			get
			{
				EnsureBound();
				return _claimKeys != null;
			}
		}

		internal static bool HasPhone
		{
			get
			{
				EnsureBound();
				return _setPhoneRaised != null;
			}
		}

		internal static bool HasOpen
		{
			get
			{
				EnsureBound();
				if (_setAppOpen != null)
				{
					return _setIconHidden != null;
				}
				return false;
			}
		}

		public static AppHandle Register(string id, string bundlePrefix, string title = null, string iconLabel = null, Assembly hostAssembly = null)
		{
			AppHandle result = new AppHandle(id);
			if (string.IsNullOrEmpty(id))
			{
				return result;
			}
			Assembly asm = hostAssembly ?? Assembly.GetCallingAssembly();
			string t = title;
			string il = iconLabel;
			string prefix = bundlePrefix;
			EnsureBound();
			if (_registerApp != null)
			{
				_registerApp(id, t, il, prefix, asm);
			}
			else
			{
				_pending.Add(delegate
				{
					_registerApp?.Invoke(id, t, il, prefix, asm);
				});
			}
			return result;
		}

		internal static void WhenBound(Action work)
		{
			if (work != null)
			{
				EnsureBound();
				if (_bound)
				{
					work();
				}
				else
				{
					_pending.Add(work);
				}
			}
		}

		internal static void HandleCall(string appId, string name, Func<string, string> handler)
		{
			if (_handle != null && handler != null)
			{
				_handle(appId, name, (string app, string argument) => handler(argument));
			}
		}

		internal static void EmitEvent(string appId, string name, string payload)
		{
			_emit?.Invoke(appId, name, payload);
		}

		internal static void AllowNetHost(string appId, string host)
		{
			_allowHost?.Invoke(appId, host);
		}

		internal static void Orient(string appId, string orientations)
		{
			_declareOrientations?.Invoke(appId, orientations);
		}

		internal static void Badge(string appId, int count)
		{
			_setBadge?.Invoke(appId, count);
		}

		internal static void Notify(string appId, string title, string subtitle, float seconds)
		{
			if (_notifyFor != null)
			{
				_notifyFor(appId, title, subtitle, seconds);
			}
			else if (_notify != null)
			{
				_notify(appId, title, subtitle);
			}
		}

		internal static bool OnScreen(string appId)
		{
			if (_isOnScreen != null)
			{
				return _isOnScreen(appId);
			}
			return false;
		}

		internal static void SetImage(string appId, string name, byte[] png)
		{
			_setImage?.Invoke(appId, name, png);
		}

		internal static void HideIcon(string appId, bool hidden)
		{
			_setIconHidden?.Invoke(appId, hidden);
		}

		internal static void OpenApp(string appId, bool open)
		{
			_setAppOpen?.Invoke(appId, open);
		}

		internal static bool AppIsOpen(string appId)
		{
			if (_isAppOpen != null)
			{
				return _isAppOpen(appId);
			}
			return false;
		}

		internal static bool RaisePhone(bool raised)
		{
			if (_setPhoneRaised != null)
			{
				return _setPhoneRaised(raised);
			}
			return false;
		}

		internal static bool PhoneIsRaised()
		{
			if (_isPhoneRaised != null)
			{
				return _isPhoneRaised();
			}
			return false;
		}

		internal static void ClaimKeys(string appId, string keys, Func<string, string, bool> handler)
		{
			_claimKeys?.Invoke(appId, keys, handler);
		}

		internal static bool MountSurface(object rect, string id, string prefix, Assembly host, float shortSide)
		{
			if (_mountSurface != null)
			{
				return _mountSurface(rect, id, prefix, host, shortSide);
			}
			return false;
		}

		internal static void UnmountSurface(string id)
		{
			_unmountSurface?.Invoke(id);
		}

		internal static bool SurfaceIsMounted(string id)
		{
			if (_isSurfaceMounted != null)
			{
				return _isSurfaceMounted(id);
			}
			return false;
		}

		internal static void ReloadApp(string appId)
		{
			_reloadApp?.Invoke(appId);
		}

		internal static void UnregisterApp(string appId)
		{
			_unregisterApp?.Invoke(appId);
		}

		internal static void AllowGameWrites(string appId, string scope)
		{
			_allowGameWrites?.Invoke(appId, scope);
		}

		private static void EnsureBound()
		{
			if (_bound)
			{
				return;
			}
			try
			{
				Type type = FindBridge(_probeAttempts++ % 30 == 0);
				if (type == null || (type.GetField("AbiVersion", BindingFlags.Static | BindingFlags.Public)?.GetValue(null) is int num && num < 1))
				{
					return;
				}
				_registerApp = Get<Action<string, string, string, string, Assembly>>(type, "RegisterApp");
				if (_registerApp == null)
				{
					return;
				}
				_handle = Get<Action<string, string, Func<string, string, string>>>(type, "Handle");
				_emit = Get<Action<string, string, string>>(type, "Emit");
				_allowHost = Get<Action<string, string>>(type, "AllowHost");
				_declareOrientations = Get<Action<string, string>>(type, "DeclareOrientations");
				_setBadge = Get<Action<string, int>>(type, "SetBadge");
				_notify = Get<Action<string, string, string>>(type, "Notify");
				_notifyFor = Get<Action<string, string, string, float>>(type, "NotifyFor");
				_isOnScreen = Get<Func<string, bool>>(type, "IsAppOnScreen");
				_setImage = Get<Action<string, string, byte[]>>(type, "SetImage");
				_setIconHidden = Get<Action<string, bool>>(type, "SetIconHidden");
				_setAppOpen = Get<Action<string, bool>>(type, "SetAppOpen");
				_isAppOpen = Get<Func<string, bool>>(type, "IsAppOpen");
				_setPhoneRaised = Get<Func<bool, bool>>(type, "SetPhoneRaised");
				_isPhoneRaised = Get<Func<bool>>(type, "IsPhoneRaised");
				_claimKeys = Get<Action<string, string, Func<string, string, bool>>>(type, "ClaimKeys");
				_mountSurface = Get<Func<object, string, string, Assembly, float, bool>>(type, "MountSurface");
				_unmountSurface = Get<Action<string>>(type, "UnmountSurface");
				_isSurfaceMounted = Get<Func<string, bool>>(type, "IsSurfaceMounted");
				_reloadApp = Get<Action<string>>(type, "ReloadApp");
				_unregisterApp = Get<Action<string>>(type, "UnregisterApp");
				_allowGameWrites = Get<Action<string, string>>(type, "AllowGameWrites");
				_bound = true;
				for (int i = 0; i < _pending.Count; i++)
				{
					try
					{
						_pending[i]();
					}
					catch
					{
					}
				}
				_pending.Clear();
			}
			catch
			{
			}
		}

		private static T Get<T>(Type t, string field) where T : class
		{
			return t.GetField(field, BindingFlags.Static | BindingFlags.Public)?.GetValue(null) as T;
		}

		private static Type FindBridge(bool scan)
		{
			Type type = Type.GetType("Sideload.Bridge.SideloadBridge, Sideload", throwOnError: false);
			if (type != null || !scan)
			{
				return type;
			}
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				try
				{
					type = assembly.GetType("Sideload.Bridge.SideloadBridge", throwOnError: false);
					if (type != null)
					{
						return type;
					}
				}
				catch
				{
				}
			}
			return null;
		}
	}
	public sealed class AppHandle
	{
		private readonly string _id;

		public string Id => _id;

		public bool IsOnScreen
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.OnScreen(_id);
				}
				return false;
			}
		}

		public bool IsOpen
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.AppIsOpen(_id);
				}
				return false;
			}
		}

		public static bool CanOpenProgrammatically
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.HasOpen;
				}
				return false;
			}
		}

		public static bool CanClaimKeys
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.HasKeys;
				}
				return false;
			}
		}

		public static bool CanEditLive
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.HasLiveEditing;
				}
				return false;
			}
		}

		internal AppHandle(string id)
		{
			_id = id ?? "";
		}

		public AppHandle OnCall(string name, Func<string, string> handler)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.HandleCall(id, name, handler);
			});
			return this;
		}

		public void Emit(string name, string payload = "")
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.EmitEvent(id, name, payload);
			});
		}

		public AppHandle AllowHost(string host)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.AllowNetHost(id, host);
			});
			return this;
		}

		public AppHandle Orientation(params string[] supported)
		{
			string id = _id;
			string list = ((supported == null) ? "" : string.Join(",", supported));
			Apps.WhenBound(delegate
			{
				Apps.Orient(id, list);
			});
			return this;
		}

		public AppHandle Badge(int count)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.Badge(id, count);
			});
			return this;
		}

		public AppHandle Notify(string title, string subtitle = "", float seconds = 0f)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.Notify(id, title, subtitle, seconds);
			});
			return this;
		}

		public AppHandle Image(string name, byte[] png)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.SetImage(id, name, png);
			});
			return this;
		}

		public AppHandle Icon(bool visible)
		{
			Apps.HideIcon(_id, !visible);
			return this;
		}

		public AppHandle NoIcon()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.HideIcon(id, hidden: true);
			});
			return this;
		}

		public AppHandle Open()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.OpenApp(id, open: true);
			});
			return this;
		}

		public AppHandle Close()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.OpenApp(id, open: false);
			});
			return this;
		}

		public bool Show()
		{
			if (!Apps.RaisePhone(raised: true))
			{
				return false;
			}
			Apps.OpenApp(_id, open: true);
			return true;
		}

		public AppHandle OnKey(string keys, Func<string, bool> handler)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.ClaimKeys(id, keys, (handler == null) ? null : ((Func<string, string, bool>)((string _, string key) => handler(key))));
			});
			return this;
		}

		public AppHandle Reload()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.ReloadApp(id);
			});
			return this;
		}

		public void Unregister()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.UnregisterApp(id);
			});
		}

		public AppHandle AllowGameWrites(string scope)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.AllowGameWrites(id, scope);
			});
			return this;
		}

		public AppHandle Hide()
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.OpenApp(id, open: false);
				Apps.RaisePhone(raised: false);
			});
			return this;
		}
	}
	public static class Surfaces
	{
		public static bool Available
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.HasSurfaces;
				}
				return false;
			}
		}

		public static SurfaceHandle Mount(object hostRect, string id, string bundlePrefix, float designShortSide = 0f, Assembly hostAssembly = null)
		{
			SurfaceHandle result = new SurfaceHandle(id);
			if (string.IsNullOrEmpty(id) || hostRect == null)
			{
				return result;
			}
			Assembly host = hostAssembly ?? Assembly.GetCallingAssembly();
			Apps.MountSurface(hostRect, id, bundlePrefix, host, designShortSide);
			return result;
		}

		public static void Unmount(string id)
		{
			Apps.UnmountSurface(id);
		}

		public static bool IsMounted(string id)
		{
			return Apps.SurfaceIsMounted(id);
		}
	}
	public sealed class SurfaceHandle
	{
		private readonly string _id;

		public string Id => _id;

		internal SurfaceHandle(string id)
		{
			_id = id;
		}

		public SurfaceHandle OnCall(string name, Func<string, string> handler)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.HandleCall(id, name, handler);
			});
			return this;
		}

		public SurfaceHandle Emit(string name, string payload = "")
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.EmitEvent(id, name, payload);
			});
			return this;
		}

		public SurfaceHandle AllowHost(string host)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.AllowNetHost(id, host);
			});
			return this;
		}

		public SurfaceHandle Image(string name, byte[] png)
		{
			string id = _id;
			Apps.WhenBound(delegate
			{
				Apps.SetImage(id, name, png);
			});
			return this;
		}

		public void Unmount()
		{
			Apps.UnmountSurface(_id);
		}
	}
	public static class PhoneScreen
	{
		public static bool IsRaised
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.PhoneIsRaised();
				}
				return false;
			}
		}

		public static bool Available
		{
			get
			{
				if (Apps.Available)
				{
					return Apps.HasPhone;
				}
				return false;
			}
		}

		public static bool Raise()
		{
			return Apps.RaisePhone(raised: true);
		}

		public static bool Lower()
		{
			return Apps.RaisePhone(raised: false);
		}
	}
}
namespace DooDesch
{
	internal static class ModVersion
	{
		internal const string Current = "2.4.1";
	}
}
namespace DooDesch.Localization
{
	internal static class L10n
	{
		private static readonly Dictionary<string, Dictionary<string, string>> _tables = new Dictionary<string, Dictionary<string, string>>();

		private static Dictionary<string, string> _active;

		private static string _lang;

		internal static string Language => _lang ?? (_lang = Detect());

		private static string ModName => typeof(L10n).Assembly.GetName().Name;

		internal static void Register(string lang, Dictionary<string, string> table)
		{
			_tables[lang] = table;
			_active = null;
		}

		internal static string T(string en)
		{
			if (_active == null)
			{
				_active = BuildActiveTable();
			}
			if (!_active.TryGetValue(en, out var value))
			{
				return en;
			}
			return value;
		}

		internal static string T(string en, params object[] args)
		{
			return string.Format(T(en), args);
		}

		private static Dictionary<string, string> BuildActiveTable()
		{
			Dictionary<string, string> value;
			Dictionary<string, string> dictionary = (_tables.TryGetValue(Language, out value) ? new Dictionary<string, string>(value) : new Dictionary<string, string>());
			try
			{
				ExportTemplate();
				Overlay(dictionary, Path.Combine(PackDir(), Language + ".json"));
				Overlay(dictionary, Path.Combine(UserDir(), Language + ".json"));
			}
			catch (Exception ex)
			{
				MelonLogger.Warning("[L10n] user translations failed: " + ex.Message);
			}
			return dictionary;
		}

		private static void Overlay(Dictionary<string, string> table, string file)
		{
			if (!File.Exists(file))
			{
				return;
			}
			Dictionary<string, string> dictionary = ParseJsonObject(File.ReadAllText(file));
			if (dictionary == null)
			{
				MelonLogger.Warning("[L10n] ignoring invalid translation file (flat JSON object of \"english\": \"translated\" strings expected): " + file);
				return;
			}
			foreach (KeyValuePair<string, string> item in dictionary)
			{
				table[item.Key] = item.Value;
			}
		}

		private static string PackDir()
		{
			return Path.Combine(MelonEnvironment.ModsDirectory, "Localization", ModName);
		}

		private static string UserDir()
		{
			return Path.Combine(MelonEnvironment.UserDataDirectory, "DooDesch", "Localization", ModName);
		}

		private static void ExportTemplate()
		{
			if (_tables.Count == 0)
			{
				return;
			}
			SortedSet<string> sortedSet = new SortedSet<string>(StringComparer.Ordinal);
			foreach (Dictionary<string, string> value in _tables.Values)
			{
				foreach (string key in value.Keys)
				{
					sortedSet.Add(key);
				}
			}
			if (sortedSet.Count == 0)
			{
				return;
			}
			Directory.CreateDirectory(UserDir());
			WriteTemplate("en", sortedSet, null);
			foreach (string key2 in _tables.Keys)
			{
				if (key2 != "en")
				{
					WriteTemplate(key2, sortedSet, _tables[key2]);
				}
			}
		}

		private static void WriteTemplate(string lang, SortedSet<string> keys, Dictionary<string, string> table)
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.Append("{\n  ").Append(Quote("_readme")).Append(": ")
				.Append(Quote("This file is regenerated on every game start - do not edit it. To change or add a translation, copy it to <language code>.json (for example " + lang + ".json), keep only the lines you want to change, and translate the VALUES only - the keys are the mod's English source strings and must stay unchanged. Keep placeholders like {0}. Set Language in MelonPreferences.cfg under [DooDesch] to force a language (auto = OS language). To share your translation as an installable mod, see https://github.com/DooDesch-Mods/ScheduleOne-L10n/wiki"))
				.Append(",\n");
			foreach (string key in keys)
			{
				string value;
				string s = ((table != null && table.TryGetValue(key, out value)) ? value : key);
				stringBuilder.Append("  ").Append(Quote(key)).Append(": ")
					.Append(Quote(s))
					.Append(",\n");
			}
			stringBuilder.Length -= 2;
			stringBuilder.Append("\n}\n");
			File.WriteAllText(Path.Combine(UserDir(), "_template." + lang + ".json"), stringBuilder.ToString(), new UTF8Encoding(encoderShouldEmitUTF8Identifier: false));
		}

		private static string Detect()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Invalid comparison between Unknown and I4
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Invalid comparison between Unknown and I4
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Invalid comparison between Unknown and I4
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Invalid comparison between Unknown and I4
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Expected I4, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Invalid comparison between Unknown and I4
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Invalid comparison between Unknown and I4
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Invalid comparison between Unknown and I4
			string text = "auto";
			try
			{
				MelonPreferences_Category val = MelonPreferences.CreateCategory("DooDesch", "DooDesch Mods");
				text = ((val.GetEntry<string>("Language") ?? val.CreateEntry<string>("Language", "auto", "Language", "Language for all DooDesch mods: auto (= OS language), en, de, ...", false, false, (ValueValidator)null, (string)null)).Value ?? "auto").Trim().ToLowerInvariant();
			}
			catch
			{
			}
			if (text.Length > 0 && text != "auto")
			{
				return text;
			}
			SystemLanguage systemLanguage = Application.systemLanguage;
			if ((int)systemLanguage <= 15)
			{
				if ((int)systemLanguage == 6)
				{
					goto IL_0121;
				}
				if ((int)systemLanguage == 14)
				{
					return "fr";
				}
				if ((int)systemLanguage == 15)
				{
					return "de";
				}
			}
			else if ((int)systemLanguage <= 34)
			{
				switch (systemLanguage - 21)
				{
				default:
					if ((int)systemLanguage != 34)
					{
						break;
					}
					return "es";
				case 0:
					return "it";
				case 7:
					return "pt";
				case 6:
					return "pl";
				case 9:
					return "ru";
				case 1:
					return "ja";
				case 2:
					return "ko";
				case 3:
				case 4:
				case 5:
				case 8:
					break;
				}
			}
			else
			{
				if ((int)systemLanguage == 37)
				{
					return "tr";
				}
				if (systemLanguage - 40 <= 1)
				{
					goto IL_0121;
				}
			}
			return "en";
			IL_0121:
			return "zh";
		}

		private static Dictionary<string, string> ParseJsonObject(string json)
		{
			if (json == null)
			{
				return null;
			}
			int i = 0;
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			SkipWs(json, ref i);
			if (i >= json.Length || json[i] != '{')
			{
				return null;
			}
			i++;
			SkipWs(json, ref i);
			if (i < json.Length && json[i] == '}')
			{
				return dictionary;
			}
			while (true)
			{
				string text = ParseString(json, ref i);
				if (text == null)
				{
					return null;
				}
				SkipWs(json, ref i);
				if (i >= json.Length || json[i] != ':')
				{
					return null;
				}
				i++;
				SkipWs(json, ref i);
				string text2 = ParseString(json, ref i);
				if (text2 == null)
				{
					return null;
				}
				dictionary[text] = text2;
				SkipWs(json, ref i);
				if (i >= json.Length)
				{
					return null;
				}
				if (json[i] != ',')
				{
					break;
				}
				i++;
				SkipWs(json, ref i);
				if (i < json.Length && json[i] == '}')
				{
					return dictionary;
				}
			}
			if (json[i] != '}')
			{
				return null;
			}
			return dictionary;
		}

		private static void SkipWs(string s, ref int i)
		{
			while (i < s.Length && (char.IsWhiteSpace(s[i]) || s[i] == '\ufeff'))
			{
				i++;
			}
		}

		private static string ParseString(string s, ref int i)
		{
			SkipWs(s, ref i);
			if (i >= s.Length || s[i] != '"')
			{
				return null;
			}
			i++;
			StringBuilder stringBuilder = new StringBuilder();
			while (i < s.Length)
			{
				char c = s[i++];
				switch (c)
				{
				case '"':
					return stringBuilder.ToString();
				default:
					stringBuilder.Append(c);
					break;
				case '\\':
					if (i >= s.Length)
					{
						return null;
					}
					switch (s[i++])
					{
					case '"':
						stringBuilder.Append('"');
						break;
					case '\\':
						stringBuilder.Append('\\');
						break;
					case '/':
						stringBuilder.Append('/');
						break;
					case 'b':
						stringBuilder.Append('\b');
						break;
					case 'f':
						stringBuilder.Append('\f');
						break;
					case 'n':
						stringBuilder.Append('\n');
						break;
					case 'r':
						stringBuilder.Append('\r');
						break;
					case 't':
						stringBuilder.Append('\t');
						break;
					case 'u':
						if (i + 4 > s.Length)
						{
							return null;
						}
						try
						{
							stringBuilder.Append((char)Convert.ToInt32(s.Substring(i, 4), 16));
						}
						catch
						{
							return null;
						}
						i += 4;
						break;
					default:
						return null;
					}
					break;
				}
			}
			return null;
		}

		private static string Quote(string s)
		{
			StringBuilder stringBuilder = new StringBuilder(s.Length + 2);
			stringBuilder.Append('"');
			foreach (char c in s)
			{
				switch (c)
				{
				case '"':
					stringBuilder.Append("\\\"");
					continue;
				case '\\':
					stringBuilder.Append("\\\\");
					continue;
				case '\n':
					stringBuilder.Append("\\n");
					continue;
				case '\r':
					stringBuilder.Append("\\r");
					continue;
				case '\t':
					stringBuilder.Append("\\t");
					continue;
				}
				if (c < ' ')
				{
					StringBuilder stringBuilder2 = stringBuilder.Append("\\u");
					int num = c;
					stringBuilder2.Append(num.ToString("x4"));
				}
				else
				{
					stringBuilder.Append(c);
				}
			}
			stringBuilder.Append('"');
			return stringBuilder.ToString();
		}
	}
}
namespace DooDesch.AvatarKit
{
	public static class AvatarDistortion
	{
		public static readonly string[] BoneKeys = new string[9] { "HeadBone", "HipBone", "LeftFootBone", "RightFootBone", "LeftShoulder", "RightShoulder", "MiddleSpine", "LowerSpine", "LowestSpine" };

		public const string FaceMeshKey = "FaceMesh";

		public const string BodyMeshKeyPrefix = "BodyMesh";

		private static Transform BoneByName(Avatar avatar, string key)
		{
			AttachmentAnchorProviderComponent attachmentAnchorProvider = avatar._attachmentAnchorProvider;
			return (Transform)(key switch
			{
				"HeadBone" => ((Object)(object)attachmentAnchorProvider != (Object)null) ? attachmentAnchorProvider.Head : null, 
				"HipBone" => avatar.HipBone, 
				"LeftFootBone" => ((Object)(object)attachmentAnchorProvider != (Object)null) ? attachmentAnchorProvider.LeftFoot : null, 
				"RightFootBone" => ((Object)(object)attachmentAnchorProvider != (Object)null) ? attachmentAnchorProvider.RightFoot : null, 
				"LeftShoulder" => avatar.LeftShoulder, 
				"RightShoulder" => avatar.RightShoulder, 
				"MiddleSpine" => avatar.MiddleSpine, 
				"LowerSpine" => ((Object)(object)attachmentAnchorProvider != (Object)null) ? attachmentAnchorProvider.LowerSpine : null, 
				"LowestSpine" => avatar.LowestSpine, 
				_ => null, 
			});
		}

		public static SkinnedMeshRenderer FaceMesh(Avatar avatar)
		{
			if (!((Object)(object)avatar != (Object)null) || !((Object)(object)avatar.Appearance != (Object)null))
			{
				return null;
			}
			return avatar.Appearance._faceMesh;
		}

		public static int BodyMeshCount(Avatar avatar)
		{
			return ((Il2CppArrayBase<SkinnedMeshRenderer>)(object)(((Object)(object)avatar != (Object)null && (Object)(object)avatar.Appearance != (Object)null) ? avatar.Appearance._bodyMeshes : null))?.Length ?? 0;
		}

		public static void Apply(Avatar avatar, IReadOnlyDictionary<string, (Vector3 scale, bool hide)> entries)
		{
			//IL_0085: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)avatar == (Object)null)
			{
				return;
			}
			AvatarEffects component = ((Component)avatar).GetComponent<AvatarEffects>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = entries == null || entries.Count == 0;
			}
			string[] boneKeys = BoneKeys;
			foreach (string key in boneKeys)
			{
				Transform val = BoneByName(avatar, key);
				if (!((Object)(object)val == (Object)null))
				{
					if (entries != null && entries.TryGetValue(key, out (Vector3, bool) value))
					{
						val.localScale = (value.Item2 ? Vector3.zero : value.Item1);
					}
					else
					{
						val.localScale = Vector3.one;
					}
				}
			}
			SkinnedMeshRenderer val2 = FaceMesh(avatar);
			if ((Object)(object)val2 != (Object)null)
			{
				(Vector3, bool) value2;
				bool flag = entries != null && entries.TryGetValue("FaceMesh", out value2) && value2.Item2;
				((Renderer)val2).enabled = !flag;
			}
			Il2CppReferenceArray<SkinnedMeshRenderer> val3 = (((Object)(object)avatar.Appearance != (Object)null) ? avatar.Appearance._bodyMeshes : null);
			if (val3 == null)
			{
				return;
			}
			for (int j = 0; j < ((Il2CppArrayBase<SkinnedMeshRenderer>)(object)val3).Length; j++)
			{
				if (!((Object)(object)((Il2CppArrayBase<SkinnedMeshRenderer>)(object)val3)[j] == (Object)null))
				{
					(Vector3, bool) value3;
					bool flag2 = entries != null && entries.TryGetValue("BodyMesh" + j, out value3) && value3.Item2;
					((Renderer)((Il2CppArrayBase<SkinnedMeshRenderer>)(object)val3)[j]).enabled = !flag2;
				}
			}
		}
	}
	public static class AvatarLayerSlots
	{
		public const int BodySlots = 8;

		public const int VanillaClearedSlots = 6;

		public const int FaceSlots = 6;

		public const int FixedFaceEntries = 2;

		public const int FreeFaceEntries = 3;

		public const string EmptyFacePath = "Avatar/Layers/None";

		private const string MouthPrefix = "Avatar/Layers/Face/Face_";

		private const string FacialHairPrefix = "Avatar/Layers/Face/FacialHair";

		public static bool IsMouthLayer(string path)
		{
			return path?.StartsWith("Avatar/Layers/Face/Face_", StringComparison.OrdinalIgnoreCase) ?? false;
		}

		public static bool IsFacialHairLayer(string path)
		{
			return path?.StartsWith("Avatar/Layers/Face/FacialHair", StringComparison.OrdinalIgnoreCase) ?? false;
		}

		public static void OrderFaceLayers(List<LayerSetting> list)
		{
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if (list == null)
			{
				return;
			}
			List<(string, Color)> list2 = new List<(string, Color)>();
			List<(string, Color)> list3 = new List<(string, Color)>();
			List<(string, Color)> list4 = new List<(string, Color)>();
			for (int i = 0; i < list.Count; i++)
			{
				LayerSetting val = list[i];
				string layerPath = val.layerPath;
				if (!string.IsNullOrEmpty(layerPath) && !(layerPath == "Avatar/Layers/None"))
				{
					if (list2.Count == 0 && IsMouthLayer(layerPath))
					{
						list2.Add((layerPath, val.layerTint));
					}
					else if (list3.Count == 0 && IsFacialHairLayer(layerPath))
					{
						list3.Add((layerPath, val.layerTint));
					}
					else
					{
						list4.Add((layerPath, val.layerTint));
					}
				}
			}
			list.Clear();
			list.Add((list2.Count > 0) ? Setting(list2[0].Item1, list2[0].Item2) : Setting("Avatar/Layers/None", Color.white));
			list.Add((list3.Count > 0) ? Setting(list3[0].Item1, list3[0].Item2) : Setting("Avatar/Layers/None", Color.white));
			for (int j = 0; j < list4.Count; j++)
			{
				list.Add(Setting(list4[j].Item1, list4[j].Item2));
			}
		}

		public static List<LayerSetting> TrimFaceToBudget(List<LayerSetting> list, Func<string, int> rank)
		{
			List<LayerSetting> list2 = new List<LayerSetting>();
			if (list == null || rank == null || list.Count <= 5)
			{
				return list2;
			}
			for (int num = CountRenderable(list, 2) - 3; num > 0; num--)
			{
				int num2 = -1;
				int num3 = int.MaxValue;
				for (int i = 2; i < list.Count; i++)
				{
					if (Renders(list[i].layerPath))
					{
						int num4 = rank(list[i].layerPath);
						if (num4 < num3)
						{
							num3 = num4;
							num2 = i;
						}
					}
				}
				if (num2 < 0)
				{
					break;
				}
				list2.Add(list[num2]);
				list.RemoveAt(num2);
			}
			return list2;
		}

		private static LayerSetting Setting(string path, Color tint)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			return new LayerSetting
			{
				layerPath = path,
				layerTint = tint
			};
		}

		public static void LoadAndClean(Avatar avatar, AvatarSettings settings)
		{
			AvatarLook.Apply(avatar, settings);
		}

		public static int CountRenderable(List<LayerSetting> list, int startIndex = 0)
		{
			if (list == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = Math.Max(0, startIndex); i < list.Count; i++)
			{
				if (Renders(list[i].layerPath))
				{
					num++;
				}
			}
			return num;
		}

		public static List<LayerSetting> TrimToBudget(List<LayerSetting> list, Func<string, int> rank, int max = 8)
		{
			List<LayerSetting> list2 = new List<LayerSetting>();
			if (list == null || rank == null || list.Count <= max)
			{
				return list2;
			}
			for (int num = CountRenderable(list) - max; num > 0; num--)
			{
				int num2 = -1;
				int num3 = int.MaxValue;
				for (int i = 0; i < list.Count; i++)
				{
					if (Renders(list[i].layerPath))
					{
						int num4 = rank(list[i].layerPath);
						if (num4 < num3)
						{
							num3 = num4;
							num2 = i;
						}
					}
				}
				if (num2 < 0)
				{
					break;
				}
				list2.Add(list[num2]);
				list.RemoveAt(num2);
			}
			return list2;
		}

		public static bool AddOnce(List<LayerSetting> list, string path, Color tint)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if (list == null || string.IsNullOrEmpty(path))
			{
				return false;
			}
			for (int i = 0; i < list.Count; i++)
			{
				if (list[i].layerPath == path)
				{
					return false;
				}
			}
			LayerSetting val = new LayerSetting();
			val.layerPath = path;
			val.layerTint = tint;
			list.Add(val);
			return true;
		}

		private static bool Renders(string layerPath)
		{
			return AvatarLook.CanResolve(layerPath);
		}
	}
	public static class AvatarLook
	{
		public sealed class Snapshot
		{
			public NakedAppearance Naked;

			public List<SerializedAvatarObject> Worn = new List<SerializedAvatarObject>();
		}

		public const float HeightScale = 1.875f;

		private static readonly Dictionary<string, AvatarObject> _resolved = new Dictionary<string, AvatarObject>(StringComparer.OrdinalIgnoreCase);

		private static readonly Dictionary<string, AvatarObject> _custom = new Dictionary<string, AvatarObject>(StringComparer.OrdinalIgnoreCase);

		private static readonly HashSet<string> _warned = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static GameObject _holder;

		private static HashSet<string> _converterIds;

		private const int LowestPictureOrder = 21;

		public static bool LibraryReady
		{
			get
			{
				if (AvatarObjectLibrary._avatarObjects != null)
				{
					return AvatarObjectLibrary._avatarObjects.Count > 0;
				}
				return false;
			}
		}

		public static bool Apply(Avatar avatar, AvatarSettings settings)
		{
			if ((Object)(object)avatar == (Object)null)
			{
				MelonLogger.Warning("[AvatarKit] apply skipped: no avatar.");
				return false;
			}
			if ((Object)(object)settings == (Object)null)
			{
				MelonLogger.Warning("[AvatarKit] apply skipped: no settings.");
				return false;
			}
			AvatarAppearance appearance = avatar.Appearance;
			if ((Object)(object)appearance == (Object)null)
			{
				MelonLogger.Error("[AvatarKit] apply failed: avatar '" + ((Object)avatar).name + "' has no AvatarAppearance.");
				return false;
			}
			Build(settings, out var naked, out var outfit);
			try
			{
				appearance.ApplyNakedAppearance(naked);
				appearance.ApplyOutfit(outfit);
			}
			finally
			{
				Object.Destroy((Object)(object)outfit);
			}
			return true;
		}

		public static Snapshot Capture(Avatar avatar)
		{
			AvatarAppearance val = (((Object)(object)avatar != (Object)null) ? avatar.Appearance : null);
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Snapshot snapshot = new Snapshot();
			NakedAppearance appliedNakedAppearance = val.AppliedNakedAppearance;
			snapshot.Naked = ((appliedNakedAppearance != null) ? appliedNakedAppearance.Clone() : null);
			List<AvatarObject> wornObjects = val._wornObjects;
			if (wornObjects != null)
			{
				for (int i = 0; i < wornObjects.Count; i++)
				{
					if ((Object)(object)wornObjects[i] != (Object)null)
					{
						snapshot.Worn.Add(wornObjects[i].Serialize());
					}
				}
			}
			if (snapshot.Naked != null || snapshot.Worn.Count != 0)
			{
				return snapshot;
			}
			return null;
		}

		public static bool Restore(Avatar avatar, Snapshot shot)
		{
			AvatarAppearance val = (((Object)(object)avatar != (Object)null) ? avatar.Appearance : null);
			if ((Object)(object)val == (Object)null || shot == null)
			{
				MelonLogger.Warning("[AvatarKit] restore skipped: " + (((Object)(object)val == (Object)null) ? "no avatar." : "no snapshot."));
				return false;
			}
			val.ApplyNakedAppearance((shot.Naked != null) ? shot.Naked.Clone() : null);
			Outfit val2 = ToOutfit(shot.Worn);
			try
			{
				val.ApplyOutfit(val2);
			}
			finally
			{
				Object.Destroy((Object)(object)val2);
			}
			return true;
		}

		public static AvatarSettings CaptureSettings(Avatar avatar)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			AvatarAppearance val = (((Object)(object)avatar != (Object)null) ? avatar.Appearance : null);
			NakedAppearance val2 = (((Object)(object)val != (Object)null) ? val.AppliedNakedAppearance : null);
			if (val2 == null)
			{
				return null;
			}
			AvatarSettings obj = ScriptableObject.CreateInstance<AvatarSettings>();
			((Object)obj).hideFlags = (HideFlags)32;
			obj.Gender = val2.Gender;
			obj.Height = val2.Height / 1.875f;
			obj.Weight = val2.Weight;
			obj.SkinColor = val2.SkinColor;
			obj.HairColor = val2.HairColor;
			obj.LeftEyeLidColor = val2.SkinColor;
			obj.RightEyeLidColor = val2.SkinColor;
			obj.EyeBallTint = val2.LeftEyeSettings.EyeballColor;
			obj.PupilDilation = val2.LeftEyeSettings.PupilDilation;
			obj.EyeballMaterialIdentifier = "Default";
			obj.LeftEyeRestingState = new EyeLidConfiguration
			{
				topLidOpen = val2.LeftEyelidSettings.RestingState.TopLidOpenness,
				bottomLidOpen = val2.LeftEyelidSettings.RestingState.BottomLidOpenness
			};
			obj.RightEyeRestingState = new EyeLidConfiguration
			{
				topLidOpen = val2.RightEyelidSettings.RestingState.TopLidOpenness,
				bottomLidOpen = val2.RightEyelidSettings.RestingState.BottomLidOpenness
			};
			obj.EyebrowScale = val2.LeftEyebrowSettings.Scale;
			obj.EyebrowThickness = val2.LeftEyebrowSettings.Thickness;
			obj.EyebrowRestingHeight = val2.LeftEyebrowSettings.RestingHeight;
			obj.EyebrowRestingAngle = val2.LeftEyebrowSettings.RestingAngle;
			obj.HairPath = string.Empty;
			obj.FaceLayerSettings = new List<LayerSetting>();
			obj.BodyLayerSettings = new List<LayerSetting>();
			obj.AccessorySettings = new List<AccessorySetting>();
			HashSet<string> auto = ConverterIds();
			AddCaptured(obj, val._nakedObjects, auto);
			AddCaptured(obj, val._wornObjects, auto);
			return obj;
		}

		private static void AddCaptured(AvatarSettings s, List<AvatarObject> objects, HashSet<string> auto)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			//IL_00f1: 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: Expected O, but got Unknown
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (objects == null)
			{
				return;
			}
			for (int i = 0; i < objects.Count; i++)
			{
				AvatarObject val = objects[i];
				if ((Object)(object)val == (Object)null || string.IsNullOrEmpty(val.Id) || auto.Contains(val.Id))
				{
					continue;
				}
				SerializedAvatarObject val2 = val.Serialize();
				Color val3 = ((val2.Colors != null && ((Il2CppArrayBase<SerializedColorProperty>)(object)val2.Colors).Length > 0 && ((Il2CppArrayBase<SerializedColorProperty>)(object)val2.Colors)[0] != null) ? ((Il2CppArrayBase<SerializedColorProperty>)(object)val2.Colors)[0].Value : Color.white);
				if ((Object)(object)((Il2CppObjectBase)val).TryCast<HairAvatarObject>() != (Object)null)
				{
					s.HairPath = val.Id;
					s.HairColor = val3;
					continue;
				}
				if ((int)val.PrimaryType == 1)
				{
					AccessorySetting val4 = new AccessorySetting();
					val4.path = val.Id;
					val4.color = val3;
					s.AccessorySettings.Add(val4);
					continue;
				}
				LayerSetting val5 = new LayerSetting();
				val5.layerPath = val.Id;
				val5.layerTint = val3;
				if (IsFaceObject(val))
				{
					s.FaceLayerSettings.Add(val5);
				}
				else
				{
					s.BodyLayerSettings.Add(val5);
				}
			}
		}

		private static bool IsFaceObject(AvatarObject obj)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Invalid comparison between Unknown and I4
			if ((Object)(object)((Il2CppObjectBase)obj).TryCast<FaceAvatarObject>() != (Object)null)
			{
				return true;
			}
			List<AvatarLayer> layers = obj._layers;
			if (layers == null)
			{
				return false;
			}
			for (int i = 0; i < layers.Count; i++)
			{
				if ((Object)(object)layers[i] != (Object)null && (int)layers[i]._type == 1)
				{
					return true;
				}
			}
			return false;
		}

		public static HashSet<string> ConverterIds()
		{
			if (_converterIds != null)
			{
				return _converterIds;
			}
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			for (int i = 0; i <= 1; i++)
			{
				BasicAvatarSettings val = ScriptableObject.CreateInstance<BasicAvatarSettings>();
				val.Gender = i;
				try
				{
					NakedAppearance val2 = BasicAvatarSettingsConverter.ConvertToNakedAppearance(val, true, true, true);
					Il2CppReferenceArray<SerializedAvatarObject> val3 = ((val2 != null) ? val2.AvatarObjects : null);
					if (val3 == null)
					{
						continue;
					}
					for (int j = 0; j < ((Il2CppArrayBase<SerializedAvatarObject>)(object)val3).Length; j++)
					{
						if (((Il2CppArrayBase<SerializedAvatarObject>)(object)val3)[j] != null && !string.IsNullOrEmpty(((Il2CppArrayBase<SerializedAvatarObject>)(object)val3)[j].Id))
						{
							hashSet.Add(((Il2CppArrayBase<SerializedAvatarObject>)(object)val3)[j].Id);
						}
					}
				}
				catch (Exception ex)
				{
					MelonLogger.Warning("[AvatarKit] reading the converter's own pieces failed (" + ex.Message + ") - a captured look may list them twice.");
				}
				finally
				{
					Object.Destroy((Object)(object)val);
				}
			}
			MelonLogger.Msg("[AvatarKit] converter adds by itself: " + string.Join(", ", hashSet));
			_converterIds = hashSet;
			return hashSet;
		}

		public static void Build(AvatarSettings settings, out NakedAppearance naked, out Outfit outfit)
		{
			//IL_002a: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			BasicAvatarSettings val = ScriptableObject.CreateInstance<BasicAvatarSettings>();
			val.Gender = ((!(settings.Gender < 0.35f)) ? 1 : 0);
			val.Weight = settings.Weight;
			val.SkinColor = settings.SkinColor;
			val.HairStyle = settings.HairPath ?? string.Empty;
			val.HairColor = settings.HairColor;
			val.EyeballColor = settings.EyeBallTint;
			val.PupilDilation = settings.PupilDilation;
			val.UpperEyeLidRestingPosition = settings.UpperEyelidRestingPosition;
			val.LowerEyeLidRestingPosition = settings.LowerEyelidRestingPosition;
			val.EyebrowScale = settings.EyebrowScale;
			val.EyebrowThickness = settings.EyebrowThickness;
			val.EyebrowRestingHeight = settings.EyebrowRestingHeight;
			val.EyebrowRestingAngle = settings.EyebrowRestingAngle;
			naked = BasicAvatarSettingsConverter.ConvertToNakedAppearance(val, true, true, true);
			Object.Destroy((Object)(object)val);
			naked.Gender = settings.Gender;
			naked.Height = ((settings.Height > 0f) ? (settings.Height * 1.875f) : 1.875f);
			HashSet<string> hashSet = new HashSet<string>(StringComparer.OrdinalIgnoreCase);
			Il2CppReferenceArray<SerializedAvatarObject> avatarObjects = naked.AvatarObjects;
			if (avatarObjects != null)
			{
				for (int i = 0; i < ((Il2CppArrayBase<SerializedAvatarObject>)(object)avatarObjects).Length; i++)
				{
					if (((Il2CppArrayBase<SerializedAvatarObject>)(object)avatarObjects)[i] != null && !string.IsNullOrEmpty(((Il2CppArrayBase<SerializedAvatarObject>)(object)avatarObjects)[i].Id))
					{
						hashSet.Add(((Il2CppArrayBase<SerializedAvatarObject>)(object)avatarObjects)[i].Id);
					}
				}
			}
			List<SerializedAvatarObject> worn = new List<SerializedAvatarObject>();
			AddPiece(naked, worn, hashSet, settings.HairPath, settings.HairColor, forceWorn: false);
			List<LayerSetting> faceLayerSettings = settings.FaceLayerSettings;
			if (faceLayerSettings != null)
			{
				for (int j = 0; j < faceLayerSettings.Count; j++)
				{
					AddPiece(naked, worn, hashSet, faceLayerSettings[j].layerPath, faceLayerSettings[j].layerTint, forceWorn: false);
				}
			}
			List<LayerSetting> bodyLayerSettings = settings.BodyLayerSettings;
			if (bodyLayerSettings != null)
			{
				for (int k = 0; k < bodyLayerSettings.Count; k++)
				{
					AddPiece(naked, worn, hashSet, bodyLayerSettings[k].layerPath, bodyLayerSettings[k].layerTint, forceWorn: false);
				}
			}
			List<AccessorySetting> accessorySettings = settings.AccessorySettings;
			if (accessorySettings != null)
			{
				for (int l = 0; l < accessorySettings.Count; l++)
				{
					if (accessorySettings[l] != null)
					{
						AddPiece(naked, worn, hashSet, accessorySettings[l].path, accessorySettings[l].color, forceWorn: true);
					}
				}
			}
			outfit = ToOutfit(worn);
		}

		private static void AddPiece(NakedAppearance naked, List<SerializedAvatarObject> worn, HashSet<string> seen, string path, Color tint, bool forceWorn)
		{
			//IL_0031: 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_0044: Invalid comparison between Unknown and I4
			if (!string.IsNullOrWhiteSpace(path) && !(path == "Avatar/Layers/None") && TryResolve(path, out var obj) && seen.Add(obj.Id))
			{
				SerializedAvatarObject val = obj.SerializeWithPrimaryColor(tint);
				if (forceWorn || (int)obj.PrimaryType == 1)
				{
					worn.Add(val);
				}
				else
				{
					naked.AddAvatarObject(val);
				}
			}
		}

		private static Outfit ToOutfit(List<SerializedAvatarObject> worn)
		{
			Outfit val = ScriptableObject.CreateInstance<Outfit>();
			Il2CppReferenceArray<SerializedAvatarObject> val2 = new Il2CppReferenceArray<SerializedAvatarObject>((long)worn.Count);
			for (int i = 0; i < worn.Count; i++)
			{
				((Il2CppArrayBase<SerializedAvatarObject>)(object)val2)[i] = worn[i];
			}
			val.AvatarObjects = val2;
			return val;
		}

		public static bool TryResolve(string path, out AvatarObject obj)
		{
			obj = null;
			if (string.IsNullOrWhiteSpace(path))
			{
				return false;
			}
			if (_custom.TryGetValue(path, out obj) && (Object)(object)obj != (Object)null)
			{
				return true;
			}
			if (_resolved.TryGetValue(path, out obj) && (Object)(object)obj != (Object)null)
			{
				return true;
			}
			obj = Lookup(path);
			if ((Object)(object)obj != (Object)null)
			{
				_resolved[path] = obj;
				return true;
			}
			if (_warned.Add(path))
			{
				MelonLogger.Warning("[AvatarKit] no avatar object for '" + path + "' - that layer is left out.");
			}
			return false;
		}

		public static bool CanResolve(string path)
		{
			AvatarObject obj;
			if (!string.IsNullOrWhiteSpace(path) && path != "Avatar/Layers/None")
			{
				return TryResolve(path, out obj);
			}
			return false;
		}

		private static AvatarObject Lookup(string path)
		{
			AvatarObject val = default(AvatarObject);
			if (AvatarObjectLibrary.TryGetAvatarObjectById(path, ref val) && (Object)(object)val != (Object)null)
			{
				return val;
			}
			GameObject val2 = Resources.Load<GameObject>(path);
			Accessory val3 = (((Object)(object)val2 != (Object)null) ? val2.GetComponent<Accessory>() : null);
			if ((Object)(object)val3 != (Object)null && (Object)(object)val3.AvatarObjectEquivalent != (Object)null)
			{
				return val3.AvatarObjectEquivalent;
			}
			AvatarLayer val4 = Resources.Load<AvatarLayer>(path);
			if ((Object)(object)val4 != (Object)null && (Object)(object)val4.AvatarObjectEquivalent != (Object)null)
			{
				return val4.AvatarObjectEquivalent;
			}
			string text = path.Substring(path.LastIndexOf('/') + 1);
			AvatarObject val5 = default(AvatarObject);
			if (text.Length > 0 && text != path && AvatarObjectLibrary.TryGetAvatarObjectById(text, ref val5) && (Object)(object)val5 != (Object)null)
			{
				return val5;
			}
			return null;
		}

		public static bool RegisterCustomLayer(string sourcePath, string id, string displayName, Texture2D texture)
		{
			if (string.IsNullOrWhiteSpace(id))
			{
				MelonLogger.Error("[AvatarKit] custom layer: empty id.");
				return false;
			}
			if (_custom.ContainsKey(id))
			{
				return true;
			}
			if ((Object)(object)texture == (Object)null)
			{
				MelonLogger.Error("[AvatarKit] custom layer '" + id + "': no texture.");
				return false;
			}
			if (!TryResolve(sourcePath, out var obj))
			{
				MelonLogger.Error("[AvatarKit] custom layer '" + id + "': source '" + sourcePath + "' has no avatar object to clone.");
				return false;
			}
			List<AvatarLayer> layers = obj._layers;
			if (layers == null || layers.Count == 0 || (Object)(object)layers[0] == (Object)null)
			{
				MelonLogger.Error("[AvatarKit] custom layer '" + id + "': source '" + obj.Id + "' carries no texture layer.");
				return false;
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)obj).gameObject, Holder().transform);
			((Object)val).name = "AvatarKit " + id;
			AvatarObject component = val.GetComponent<AvatarObject>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val);
				MelonLogger.Error("[AvatarKit] custom layer '" + id + "': clone lost its AvatarObject.");
				return false;
			}
			component._id = id;
			component._name = (string.IsNullOrEmpty(displayName) ? id : displayName);
			AvatarLayer val2 = Object.Instantiate<AvatarLayer>(layers[0]);
			((Object)val2).name = id;
			((Object)val2).hideFlags = (HideFlags)32;
			val2._texture = texture;
			val2._normal = null;
			List<AvatarLayer> val3 = new List<AvatarLayer>();
			val3.Add(val2);
			component._layers = val3;
			Dictionary<string, AvatarObject> avatarObjects = AvatarObjectLibrary._avatarObjects;
			if (avatarObjects == null)
			{
				Object.Destroy((Object)(object)val);
				MelonLogger.Error("[AvatarKit] custom layer '" + id + "': the avatar object library is not loaded yet.");
				return false;
			}
			avatarObjects[id] = component;
			_custom[id] = component;
			_resolved.Remove(id);
			_warned.Remove(id);
			MelonLogger.Msg("[AvatarKit] registered custom layer '" + id + "' (cloned from " + obj.Id + ", " + ((Texture)texture).width + "x" + ((Texture)texture).height + ").");
			return true;
		}

		public static bool IsCustomLayer(string id)
		{
			if (!string.IsNullOrEmpty(id))
			{
				return _custom.ContainsKey(id);
			}
			return false;
		}

		public static void OrderCustomBodyLayers(IEnumerable<string> pathsInListOrder)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			if (pathsInListOrder == null)
			{
				return;
			}
			int num = 21;
			foreach (string item in pathsInListOrder)
			{
				if (!TryResolve(item, out var obj) || (Object)(object)obj == (Object)null || obj._layers == null)
				{
					continue;
				}
				bool flag = IsCustomLayer(item);
				Enumerator<AvatarLayer> enumerator2 = obj._layers.GetEnumerator();
				while (enumerator2.MoveNext())
				{
					AvatarLayer current2 = enumerator2.Current;
					if (!((Object)(object)current2 == (Object)null))
					{
						if (flag)
						{
							current2._layeringOrder = (short)num;
						}
						else if ((int)current2.Type == 0)
						{
							num = Math.Max(num, current2.LayeringOrder + 1);
						}
					}
				}
				if (flag)
				{
					num++;
				}
			}
		}

		private static GameObject Holder()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if ((Object)(object)_holder != (Object)null)
			{
				return _holder;
			}
			_holder = new GameObject("DooDesch.AvatarKit custom layers");
			_holder.SetActive(false);
			((Object)_holder).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)_holder);
			return _holder;
		}
	}
}
namespace DooDesch.UI
{
	public static class Theme
	{
		public static readonly Color BgDeep = new Color(0.043f, 0.047f, 0.063f, 1f);

		public static readonly Color BgBase = new Color(0.063f, 0.071f, 0.094f, 1f);

		public static readonly Color BgPanel = new Color(0.086f, 0.098f, 0.133f, 1f);

		public static readonly Color BgElevated = new Color(0.114f, 0.129f, 0.173f, 1f);

		public static readonly Color SurfaceInput = new Color(0.051f, 0.059f, 0.082f, 1f);

		public static readonly Color Clear = new Color(0f, 0f, 0f, 0f);

		public static readonly Color Hairline = new Color(1f, 1f, 1f, 0.08f);

		public static readonly Color HairlineStrong = new Color(1f, 1f, 1f, 0.14f);

		public static readonly Color ScrimPanel = new Color(0.063f, 0.071f, 0.094f, 0.82f);

		public static readonly Color ScrimRow = new Color(0.114f, 0.129f, 0.173f, 0.72f);

		public static readonly Color TextPrimary = new Color(0.925f, 0.929f, 0.945f, 1f);

		public static readonly Color TextMuted = new Color(0.541f, 0.561f, 0.62f, 1f);

		public static readonly Color TextDisabled = new Color(0.337f, 0.357f, 0.408f, 1f);

		public static readonly Color Accent = new Color(0.369f, 0.416f, 0.824f, 1f);

		public static readonly Color AccentHover = new Color(0.431f, 0.475f, 0.859f, 1f);

		public static readonly Color AccentPressed = new Color(0.298f, 0.341f, 0.737f, 1f);

		public static readonly Color AccentSubtle = new Color(0.125f, 0.133f, 0.227f, 1f);

		public static readonly Color AccentBorder = new Color(0.486f, 0.525f, 0.91f, 1f);

		public static readonly Color Button = new Color(0.2f, 0.212f, 0.263f, 1f);

		public static readonly Color Danger = new Color(0.784f, 0.29f, 0.329f, 1f);

		public static readonly Color DangerText = new Color(0.945f, 0.439f, 0.478f, 1f);

		public static readonly Color DangerSubtle = new Color(0.165f, 0.082f, 0.094f, 1f);

		public static readonly Color Warning = new Color(0.788f, 0.569f, 0.18f, 1f);

		public static readonly Color WarningText = new Color(0.902f, 0.706f, 0.314f, 1f);

		public static readonly Color WarningSubtle = new Color(0.165f, 0.133f, 0.071f, 1f);

		public static readonly Color Success = new Color(0.184f, 0.659f, 0.467f, 1f);

		public static readonly Color SuccessText = new Color(0.373f, 0.816f, 0.604f, 1f);

		public static readonly Color SuccessSubtle = new Color(0.071f, 0.165f, 0.125f, 1f);

		public static readonly Color Info = new Color(0.239f, 0.498f, 0.753f, 1f);

		public static readonly Color InfoText = new Color(0.435f, 0.659f, 0.902f, 1f);

		public static readonly Color InfoSubtle = new Color(0.071f, 0.125f, 0.192f, 1f);

		public const int RadiusMd = 6;

		public const float Fade = 0.12f;

		public const int Caption = 11;

		public const int Body = 13;

		public const int Label = 14;

		public const int H3 = 16;

		public const int H2 = 20;

		public const int H1 = 28;

		private static Sprite _rounded;

		private static Sprite _frame;

		public static Color Lighten(Color c, float amount)
		{
			//IL_0000: 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_001a: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			return new Color(Mathf.Clamp01(c.r + amount), Mathf.Clamp01(c.g + amount), Mathf.Clamp01(c.b + amount), c.a);
		}

		public static Color Darken(Color c, float amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			return Lighten(c, 0f - amount);
		}

		public static Color WithAlpha(Color c, float a)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			return new Color(c.r, c.g, c.b, a);
		}

		public static Sprite RoundedSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: 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_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rounded != (Object)null)
			{
				return _rounded;
			}
			Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false);
			((Object)val).hideFlags = (HideFlags)32;
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					bool flag = ((float)j < 6f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 6f)) > 6f) || ((float)j > 25f && (float)i < 6f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 6f)) > 6f) || ((float)j < 6f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(6f, 25f)) > 6f) || ((float)j > 25f && (float)i > 25f && Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(25f, 25f)) > 6f);
					val.SetPixel(j, i, Color32.op_Implicit(flag ? val2 : val3));
				}
			}
			val.Apply();
			_rounded = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(8f, 8f, 8f, 8f));
			return _rounded;
		}

		public static Sprite FrameSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_00b8: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			if ((Object)(object)_frame != (Object)null)
			{
				return _frame;
			}
			Texture2D val = new Texture2D(32, 32, (TextureFormat)5, false);
			((Object)val).hideFlags = (HideFlags)32;
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)0, (byte)0, (byte)0, (byte)0);
			Color32 val3 = default(Color32);
			((Color32)(ref val3))..ctor(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
			for (int i = 0; i < 32; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					bool flag = j < 3 || j >= 29 || i < 3 || i >= 29;
					val.SetPixel(j, i, Color32.op_Implicit(flag ? val3 : val2));
				}
			}
			val.Apply();
			_frame = Sprite.Create(val, new Rect(0f, 0f, 32f, 32f), new Vector2(0.5f, 0.5f), 100f, 0u, (SpriteMeshType)0, new Vector4(4f, 4f, 4f, 4f));
			return _frame;
		}
	}
	public static class Interactions
	{
		public static void PolishButtons(Transform root, bool round = true)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)root == (Object)null)
			{
				return;
			}
			Il2CppArrayBase<Button> componentsInChildren = ((Component)root).GetComponentsInChildren<Button>(true);
			if (componentsInChildren == null)
			{
				return;
			}
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Button val = componentsInChildren[i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Graphic targetGraphic = ((Selectable)val).targetGraphic;
				Image val2 = (Image)(((object)((targetGraphic is Image) ? targetGraphic : null)) ?? ((object)((Component)val).GetComponent<Image>()));
				if (!((Object)(object)val2 == (Object)null) && !(((Graphic)val2).color.a < 0.02f))
				{
					if (round)
					{
						val2.sprite = Theme.RoundedSprite();
						val2.type = (Type)1;
					}
					ApplyStates(val);
				}
			}
		}

		public static void ApplyStates(Button btn)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//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_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: 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_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			Graphic targetGraphic = ((Selectable)btn).targetGraphic;
			Image val = (Image)(((object)((targetGraphic is Image) ? targetGraphic : null)) ?? ((object)((Component)btn).GetComponent<Image>()));
			if (!((Object)(object)val == (Object)null))
			{
				Color color = ((Graphic)val).color;
				if (!(color.a < 0.02f))
				{
					Color val2 = Theme.Lighten(color, 0.06f);
					Color target = Theme.Darken(color, 0.06f);
					Color target2 = Color.Lerp(color, Theme.BgPanel, 0.55f);
					target2.a = color.a * 0.6f;
					((Graphic)val).color = val2;
					ColorBlock colors = ((Selectable)btn).colors;
					((ColorBlock)(ref colors)).normalColor = Ratio(color, val2);
					((ColorBlock)(ref colors)).highlightedColor = Color.white;
					((ColorBlock)(ref colors)).pressedColor = Ratio(target, val2);
					((ColorBlock)(ref colors)).selectedColor = Ratio(color, val2);
					((ColorBlock)(ref colors)).disabledColor = Ratio(target2, val2);
					((ColorBlock)(ref colors)).colorMultiplier = 1f;
					((ColorBlock)(ref colors)).fadeDuration = 0.12f;
					((Selectable)btn).colors = colors;
					((Selectable)btn).transition = (Transition)1;
				}
			}
		}

		private static Color Ratio(Color target, Color baseC)
		{
			//IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			return new Color((baseC.r <= 0.0001f) ? 0f : Mathf.Clamp01(target.r / baseC.r), (baseC.g <= 0.0001f) ? 0f : Mathf.Clamp01(target.g / baseC.g), (baseC.b <= 0.0001f) ? 0f : Mathf.Clamp01(target.b / baseC.b), (baseC.a <= 0.0001f) ? 0f : Mathf.Clamp01(target.a / baseC.a));
		}
	}
	public enum Severity
	{
		Info,
		Success,
		Warning,
		Danger
	}
	public static class Components
	{
		public static void SeverityColors(Severity s, out Color bar, out Color text, out Color bg)
		{
			//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_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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			switch (s)
			{
			case Severity.Success:
				bar = Theme.Success;
				text = Theme.SuccessText;
				bg = Theme.SuccessSubtle;
				break;
			case Severity.Warning:
				bar = Theme.Warning;
				text = Theme.WarningText;
				bg = Theme.WarningSubtle;
				break;
			case Severity.Danger:
				bar = Theme.Danger;
				text = Theme.DangerText;
				bg = Theme.DangerSubtle;
				break;
			default:
				bar = Theme.Info;
				text = Theme.InfoText;
				bg = Theme.InfoSubtle;
				break;
			}
		}

		public static GameObject Divider(Transform parent)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			GameObject obj = UIFactory.Panel("Divider", parent, Theme.Hairline, (Vector2?)null, (Vector2?)null, false);
			Image component = obj.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Graphic)component).raycastTarget = false;
			}
			return obj;
		}

		public static float Banner(Transform parent, Severity sev, string text, float y, float height = 30f, float gap = 6f, float inset = 16f)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			SeverityColors(sev, out var bar, out var text2, out var bg);
			GameObject val = UIFactory.Panel("banner", parent, bg, (Vector2?)null, (Vector2?)null, false);
			Image component = val.GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				component.sprite = Theme.RoundedSprite();
				component.type = (Type)1;
				((Graphic)component).raycastTarget = false;
			}
			RectTransform component2 = val.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 1f);
			component2.anchorMax = new Vector2(1f, 1f);
			component2.pivot = new Vector2(0.5f, 1f);
			component2.offsetMin = new Vector2(inset, y - height);
			component2.offsetMax = new Vector2(0f - inset, y);
			GameObject obj = UIFactory.Panel("bar", val.transform, bar, (Vector2?)null, (Vector2?)null, false);
			Image component3 = obj.GetComponent<Image>();
			if ((Object)(object)component3 != (Object)null)
			{
				((Graphic)component3).raycastTarget = false;
			}
			RectTransform component4 = obj.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(0f, 1f);
			component4.pivot = new Vector2(0f, 0.5f);
			component4.offsetMin = new Vector2(0f, 4f);
			component4.offsetMax = new Vector2(3f, -4f);
			Text obj2 = UIFactory.Text("t", text, val.transform, 13, (TextAnchor)3, (FontStyle)0);
			((Graphic)obj2).color = text2;
			((Graphic)obj2).raycastTarget = false;
			obj2.horizontalOverflow = (HorizontalWrapMode)0;
			obj2.verticalOverflow = (VerticalWrapMode)0;
			RectTransform rectTransform = ((Graphic)obj2).rectTransform;
			rectTransform.anchorMin = new Vector2(0f, 0f);
			rectTransform.anchorMax = new Vector2(1f, 1f);
			rectTransform.offsetMin = new Vector2(12f, 0f);
			rectTransform.offsetMax = new Vector2(-8f, 0f);
			return y - (height + gap);
		}

		public static GameObject Segmented(Transform parent, string[] labels, int active, Action<int> onSelect, out Button[] buttons, bool vertical = false, float spacing = 6f, Texture2D[] icons = null)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("segmented");
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			if (vertical)
			{
				VerticalLayoutGroup obj = val.AddComponent<VerticalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj).spacing = spacing;
				((HorizontalOrVerticalLayoutGroup)obj).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj).childForceExpandHeight = true;
			}
			else
			{
				HorizontalLayoutGroup obj2 = val.AddComponent<HorizontalLayoutGroup>();
				((HorizontalOrVerticalLayoutGroup)obj2).spacing = spacing;
				((HorizontalOrVerticalLayoutGroup)obj2).childControlWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj2).childControlHeight = true;
				((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandWidth = true;
				((HorizontalOrVerticalLayoutGroup)obj2).childForceExpandHeight = true;
			}
			Button[] btns = (Button[])(object)new Button[labels.Length];
			for (int i = 0; i < labels.Length; i++)
			{
				int idx = i;
				Texture2D val2 = ((icons != null && i < icons.Length) ? icons[i] : null);
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("seg_" + i, ((Object)(object)val2 != (Object)null) ? "" : labels[i], val.transform, (i == active) ? Theme.Accent : Theme.Button, 0f, 0f);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				Text item3 = valueTuple.Item3;
				LayoutElement obj3 = item.AddComponent<LayoutElement>();
				obj3.flexibleWidth = 1f;
				obj3.flexibleHeight = 1f;
				obj3.minHeight = 28f;
				if ((Object)(object)item3 != (Object)null)
				{
					item3.fontSize = 14;
				}
				if ((Object)(object)val2 != (Object)null)
				{
					AddCenterIcon(item.transform, val2, 20f);
				}
				((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					SetSegmentedActive(btns, idx);
					onSelect?.Invoke(idx);
				}));
				btns[i] = item2;
			}
			buttons = btns;
			return val;
		}

		public static void AddCenterIcon(Transform parent, Texture2D tex, float size)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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_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)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: 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)
			if (!((Object)(object)tex == (Object)null))
			{
				GameObject val = new GameObject("icon");
				val.transform.SetParent(parent, false);
				RectTransform obj = val.AddComponent<RectTransform>();
				obj.anchorMin = new Vector2(0.5f, 0.5f);
				obj.anchorMax = new Vector2(0.5f, 0.5f);
				obj.pivot = new Vector2(0.5f, 0.5f);
				obj.sizeDelta = new Vector2(size, size);
				obj.anchoredPosition = Vector2.zero;
				Image obj2 = val.AddComponent<Image>();
				obj2.sprite = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f), 100f);
				obj2.preserveAspect = true;
				((Graphic)obj2).raycastTarget = false;
			}
		}

		public static void ConfirmDialog(Transform canvasRoot, string title, string message, string confirmLabel, Action onConfirm)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0397: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			GameObject scrim;
			if (!((Object)(object)canvasRoot == (Object)null))
			{
				scrim = UIFactory.Panel("DD_ConfirmScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true);
				scrim.transform.SetAsLastSibling();
				GameObject val = UIFactory.Panel("catcher", scrim.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true);
				Button obj = val.AddComponent<Button>();
				((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
				((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					Close();
				}));
				GameObject val2 = UIFactory.Panel("card", scrim.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false);
				Image component = val2.GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					component.sprite = Theme.RoundedSprite();
					component.type = (Type)1;
				}
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0.5f, 0.5f);
				component2.anchorMax = new Vector2(0.5f, 0.5f);
				component2.pivot = new Vector2(0.5f, 0.5f);
				component2.sizeDelta = new Vector2(440f, 190f);
				Outline obj2 = val2.AddComponent<Outline>();
				((Shadow)obj2).effectColor = Theme.HairlineStrong;
				((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
				Text obj3 = UIFactory.Text("title", title, val2.transform, 16, (TextAnchor)0, (FontStyle)1);
				((Graphic)obj3).color = Theme.TextPrimary;
				((Graphic)obj3).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj3).rectTransform;
				rectTransform.anchorMin = new Vector2(0f, 1f);
				rectTransform.anchorMax = new Vector2(1f, 1f);
				rectTransform.pivot = new Vector2(0.5f, 1f);
				rectTransform.offsetMin = new Vector2(20f, -52f);
				rectTransform.offsetMax = new Vector2(-20f, -18f);
				Text obj4 = UIFactory.Text("msg", message, val2.transform, 13, (TextAnchor)0, (FontStyle)0);
				((Graphic)obj4).color = Theme.TextMuted;
				((Graphic)obj4).raycastTarget = false;
				RectTransform rectTransform2 = ((Graphic)obj4).rectTransform;
				rectTransform2.anchorMin = new Vector2(0f, 1f);
				rectTransform2.anchorMax = new Vector2(1f, 1f);
				rectTransform2.pivot = new Vector2(0.5f, 1f);
				rectTransform2.offsetMin = new Vector2(20f, -120f);
				rectTransform2.offsetMax = new Vector2(-20f, -58f);
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("Cancel", "Cancel", val2.transform, Theme.Button, 140f, 40f);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				RectTransform component3 = item.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(0f, 0f);
				component3.anchorMax = new Vector2(0f, 0f);
				component3.pivot = new Vector2(0f, 0f);
				component3.anchoredPosition = new Vector2(20f, 18f);
				component3.sizeDelta = new Vector2(140f, 40f);
				((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					Close();
				}));
				ValueTuple<GameObject, Button, Text> valueTuple2 = UIFactory.ButtonWithLabel("Confirm", confirmLabel, val2.transform, Theme.Danger, 180f, 40f);
				GameObject item3 = valueTuple2.Item1;
				Button item4 = valueTuple2.Item2;
				RectTransform component4 = item3.GetComponent<RectTransform>();
				component4.anchorMin = new Vector2(1f, 0f);
				component4.anchorMax = new Vector2(1f, 0f);
				component4.pivot = new Vector2(1f, 0f);
				component4.anchoredPosition = new Vector2(-20f, 18f);
				component4.sizeDelta = new Vector2(180f, 40f);
				((UnityEvent)item4.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					Close();
					onConfirm?.Invoke();
				}));
				Interactions.PolishButtons(val2.transform);
			}
			void Close()
			{
				Object.Destroy((Object)(object)scrim);
			}
		}

		public static void AlertDialog(Transform canvasRoot, string title, string message, string buttonLabel = "OK", Action onDismiss = null)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: 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_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0362: Unknown result type (might be due to invalid IL or missing references)
			GameObject scrim;
			if (!((Object)(object)canvasRoot == (Object)null))
			{
				scrim = UIFactory.Panel("DD_AlertScrim", canvasRoot, new Color(0f, 0f, 0f, 0.6f), (Vector2?)null, (Vector2?)null, true);
				scrim.transform.SetAsLastSibling();
				GameObject val = UIFactory.Panel("catcher", scrim.transform, new Color(0f, 0f, 0f, 0.01f), (Vector2?)null, (Vector2?)null, true);
				Button obj = val.AddComponent<Button>();
				((Selectable)obj).targetGraphic = (Graphic)(object)val.GetComponent<Image>();
				((UnityEvent)obj.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					Close();
				}));
				GameObject val2 = UIFactory.Panel("card", scrim.transform, Theme.BgElevated, (Vector2?)null, (Vector2?)null, false);
				Image component = val2.GetComponent<Image>();
				if ((Object)(object)component != (Object)null)
				{
					component.sprite = Theme.RoundedSprite();
					component.type = (Type)1;
				}
				RectTransform component2 = val2.GetComponent<RectTransform>();
				component2.anchorMin = new Vector2(0.5f, 0.5f);
				component2.anchorMax = new Vector2(0.5f, 0.5f);
				component2.pivot = new Vector2(0.5f, 0.5f);
				component2.sizeDelta = new Vector2(460f, 210f);
				Outline obj2 = val2.AddComponent<Outline>();
				((Shadow)obj2).effectColor = Theme.HairlineStrong;
				((Shadow)obj2).effectDistance = new Vector2(1f, -1f);
				Text obj3 = UIFactory.Text("title", title, val2.transform, 16, (TextAnchor)0, (FontStyle)1);
				((Graphic)obj3).color = Theme.TextPrimary;
				((Graphic)obj3).raycastTarget = false;
				RectTransform rectTransform = ((Graphic)obj3).rectTransform;
				rectTransform.anchorMin = new Vector2(0f, 1f);
				rectTransform.anchorMax = new Vector2(1f, 1f);
				rectTransform.pivot = new Vector2(0.5f, 1f);
				rectTransform.offsetMin = new Vector2(20f, -52f);
				rectTransform.offsetMax = new Vector2(-20f, -18f);
				Text obj4 = UIFactory.Text("msg", message, val2.transform, 13, (TextAnchor)0, (FontStyle)0);
				((Graphic)obj4).color = Theme.TextMuted;
				((Graphic)obj4).raycastTarget = false;
				RectTransform rectTransform2 = ((Graphic)obj4).rectTransform;
				rectTransform2.anchorMin = new Vector2(0f, 1f);
				rectTransform2.anchorMax = new Vector2(1f, 1f);
				rectTransform2.pivot = new Vector2(0.5f, 1f);
				rectTransform2.offsetMin = new Vector2(20f, -150f);
				rectTransform2.offsetMax = new Vector2(-20f, -58f);
				ValueTuple<GameObject, Button, Text> valueTuple = UIFactory.ButtonWithLabel("Dismiss", buttonLabel, val2.transform, Theme.Button, 180f, 40f);
				GameObject item = valueTuple.Item1;
				Button item2 = valueTuple.Item2;
				RectTransform component3 = item.GetComponent<RectTransform>();
				component3.anchorMin = new Vector2(0.5f, 0f);
				component3.anchorMax = new Vector2(0.5f, 0f);
				component3.pivot = new Vector2(0.5f, 0f);
				component3.anchoredPosition = new Vector2(0f, 18f);
				component3.sizeDelta = new Vector2(180f, 40f);
				((UnityEvent)item2.onClick).AddListener(UnityAction.op_Implicit((Action)delegate
				{
					Close();
				}));
				Interactions.PolishButtons(val2.transform);
			}
			void Close()
			{
				Object.Destroy((Object)(object)scrim);
				onDismiss?.Invoke();
			}
		}

		public static void ChoiceDialog(Transform canvasRoot, string title, string message, IReadOnlyList<string> items, params (string Label, Color Color, Action OnClick)[] choices)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: 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_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_062f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result typ