Decompiled source of Eye Color v1.0.0

EyeColor.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("EyeColor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("EyeColor")]
[assembly: AssemblyTitle("EyeColor")]
[assembly: AssemblyVersion("1.0.0.0")]
[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 EyeColor
{
	internal static class EyeChoice
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__10_0;

			public static ConsoleOptionsFetcher <>9__10_1;

			internal void <AddCommand>b__10_0(ConsoleEventArgs args)
			{
				Terminal context = args.Context;
				if (context != null)
				{
					context.AddString(Choose((args.Args.Length > 1) ? args.Args[1] : ""));
				}
			}

			internal List<string> <AddCommand>b__10_1()
			{
				return new List<string>(EyeColours.Names) { "default" };
			}
		}

		internal const string SaveKey = "com.skaket.valheim.eyecolor.colour";

		private static readonly int SharedKey = StringExtensionMethods.GetStableHashCode("EyeColor_colour");

		private const string Command = "eyecolor";

		internal static EyeColour Default = EyeColours.VanillaEyes;

		private static bool _commandAdded;

		internal static EyeColour For(VisEquipment character, ZNetView? view)
		{
			ZDO val = (((Object)(object)view != (Object)null && view.IsValid()) ? view.GetZDO() : null);
			Player playerComponent = character.m_playerComponent;
			string text = null;
			string text3 = default(string);
			if ((Object)(object)playerComponent != (Object)null && playerComponent.m_customData.TryGetValue("com.skaket.valheim.eyecolor.colour", out var value))
			{
				text = value;
				string text2 = default(string);
				if (val != null && view.IsOwner() && (!val.GetString(SharedKey, ref text2) || text2 != value))
				{
					val.Set(SharedKey, value);
				}
			}
			else if (val != null && val.GetString(SharedKey, ref text3))
			{
				text = text3;
			}
			if (string.IsNullOrEmpty(text) || !EyeColours.TryFind(text, out var colour))
			{
				return Default;
			}
			return colour;
		}

		internal static string NameFor(Player player)
		{
			if (!player.m_customData.TryGetValue("com.skaket.valheim.eyecolor.colour", out var value) || string.IsNullOrEmpty(value) || !EyeColours.TryFind(value, out var colour))
			{
				return Default.Name;
			}
			return colour.Name;
		}

		internal static string Step(Player player, int direction)
		{
			string[] names = EyeColours.Names;
			string current = NameFor(player);
			int num = Array.FindIndex(names, (string name) => string.Equals(name, current, StringComparison.OrdinalIgnoreCase));
			if (num < 0)
			{
				num = ((direction > 0) ? (-1) : 0);
			}
			num = ((num + direction) % names.Length + names.Length) % names.Length;
			player.m_customData["com.skaket.valheim.eyecolor.colour"] = names[num];
			return names[num];
		}

		internal static void Install(Harmony harmony)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(Terminal), "InitTerminal", (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				EyeColorPlugin.Log.LogWarning((object)"Terminal.InitTerminal was not found in this game version, so the 'eyecolor' console command is missing.");
			}
			else
			{
				harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(EyeChoice), "AddCommand", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			MethodInfo methodInfo2 = AccessTools.Method(typeof(Humanoid), "OnRagdollCreated", (Type[])null, (Type[])null);
			if (methodInfo2 != null)
			{
				harmony.Patch((MethodBase)methodInfo2, (HarmonyMethod)null, new HarmonyMethod(typeof(EyeChoice), "AfterRagdollCreated", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
		}

		private static void AfterRagdollCreated(Humanoid __instance, Ragdoll ragdoll)
		{
			try
			{
				if (Object.op_Implicit((Object)(object)ragdoll) && __instance is Player)
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					ZNetView component2 = ((Component)ragdoll).GetComponent<ZNetView>();
					string text = default(string);
					if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component2) && component.IsValid() && component2.IsValid() && component2.IsOwner() && component.GetZDO().GetString(SharedKey, ref text) && !string.IsNullOrEmpty(text))
					{
						component2.GetZDO().Set(SharedKey, text);
					}
				}
			}
			catch (Exception ex)
			{
				EyeColorPlugin.Log.LogDebug((object)("A fallen character's eye colour could not be passed on: " + ex.Message));
			}
		}

		private static void AddCommand()
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Expected O, but got Unknown
			if (_commandAdded)
			{
				return;
			}
			_commandAdded = true;
			try
			{
				object obj = <>c.<>9__10_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						Terminal context = args.Context;
						if (context != null)
						{
							context.AddString(Choose((args.Args.Length > 1) ? args.Args[1] : ""));
						}
					};
					<>c.<>9__10_0 = val;
					obj = (object)val;
				}
				object obj2 = <>c.<>9__10_1;
				if (obj2 == null)
				{
					ConsoleOptionsFetcher val2 = () => new List<string>(EyeColours.Names) { "default" };
					<>c.<>9__10_1 = val2;
					obj2 = (object)val2;
				}
				new ConsoleCommand("eyecolor", "[colour] gives your character an eye colour: a name, or any colour as a hex code such as #40C0A0. With nothing after it, it lists the names; 'default' forgets the choice.", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)obj2, false, false, false);
			}
			catch (Exception ex)
			{
				EyeColorPlugin.Log.LogWarning((object)("The 'eyecolor' console command could not be added: " + ex.Message));
			}
		}

		private static string Choose(string name)
		{
			string text = string.Join(", ", EyeColours.Names);
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return "Enter a world with a character first.";
			}
			string value;
			bool flag = localPlayer.m_customData.TryGetValue("com.skaket.valheim.eyecolor.colour", out value) && !string.IsNullOrEmpty(value);
			if (string.IsNullOrWhiteSpace(name))
			{
				return localPlayer.GetPlayerName() + " has " + (flag ? (value + " eyes") : ("no eye colour of its own, so the default, " + Default.Name)) + ". Colours: " + text + ", or a hex code such as #40C0A0. Type 'eyecolor <colour>' to choose one, or 'eyecolor default' to forget the choice.";
			}
			if (string.Equals(name, "default", StringComparison.OrdinalIgnoreCase))
			{
				localPlayer.m_customData["com.skaket.valheim.eyecolor.colour"] = "";
				return localPlayer.GetPlayerName() + " now has no eye colour of its own, so the default, " + Default.Name + ".";
			}
			if (!EyeColours.TryFind(name, out var colour))
			{
				return "There is no eye colour called '" + name + "'. Colours: " + text + ", or a hex code such as #40C0A0.";
			}
			localPlayer.m_customData["com.skaket.valheim.eyecolor.colour"] = colour.Name;
			EyeColorPlugin.Log.LogInfo((object)(localPlayer.GetPlayerName() + " was given " + colour.Name + " eyes."));
			return localPlayer.GetPlayerName() + " now has " + colour.Name + " eyes. It is saved with the character.";
		}
	}
	[BepInPlugin("com.skaket.valheim.eyecolor", "Eye Color", "1.0.0")]
	public class EyeColorPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.skaket.valheim.eyecolor";

		public const string PluginName = "Eye Color";

		public const string PluginVersion = "1.0.0";

		private const string Section = "Eyes";

		internal static ManualLogSource Log;

		private Harmony? _harmony;

		private ConfigEntry<bool> _enabled;

		private ConfigEntry<string> _default;

		private ConfigEntry<bool> _level;

		private ConfigEntry<float> _tilt;

		private ConfigEntry<int> _detail;

		private FileSystemWatcher? _watcher;

		private long _reloadAt;

		private bool _settingsChanged;

		private string _applied = "";

		private bool _painting;

		private void Awake()
		{
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Paint eye colours. Off shows the game's own eyes on everyone and hides the Eyes row. Takes effect at once.");
			_default = ((BaseUnityPlugin)this).Config.Bind<string>("Eyes", "DefaultColor", "Vanilla", "The eye colour of a character that has not been given one of its own: your characters until you choose a colour for them, and other players who do not have this mod. Vanilla is the game's own pale blue. The others are " + string.Join(", ", EyeColours.Names, 1, EyeColours.Names.Length - 1) + ", or any colour as a hex code such as #40C0A0. To choose a character's own colour, use the Eyes row when making it, or play it and type 'eyecolor' in the console. Takes effect at once, also when this file is saved while the game runs.");
			_level = ((BaseUnityPlugin)this).Config.Bind<bool>("Eyes", "LevelEyes", true, "Draw coloured eyes level. The game's eye is a slanted slab, and Feminine Figure turns its outer end down, which with an iris and a lash line can look sad. On: the eye keeps its size, outline and paint but is turned until its upper edge is level, and is drawn as a patch of its own in place of the game's. Off: the eye is painted in the game's own slab, slant and all. Takes effect at once, also when this file is saved while the game runs.");
			_tilt = ((BaseUnityPlugin)this).Config.Bind<float>("Eyes", "Tilt", 0f, new ConfigDescription("With LevelEyes on: how far the outer end of the eye is raised from level, in degrees. 0 is level; below 0 the outer end droops. Takes effect within a few seconds, also when this file is saved while the game runs.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(-15f, 15f), Array.Empty<object>()));
			_detail = ((BaseUnityPlugin)this).Config.Bind<int>("Eyes", "Detail", 4, new ConfigDescription("With LevelEyes off: how finely the eye is painted. The game's eye is a patch of about 9 by 4 dots of the skin picture; this is how many times finer the painted one is each way. 4 shows an iris and a pupil; 8 is sharper in close-ups; 1 is as coarse as the game. Each step up takes four times the memory: about 5 MB at 4 and 21 MB at 8, for each eye colour and skin on screen. Takes effect at once.", (AcceptableValueBase)(object)new AcceptableValueList<int>(new int[4] { 1, 2, 4, 8 }), Array.Empty<object>()));
			((BaseUnityPlugin)this).Config.SettingChanged += delegate
			{
				_settingsChanged = true;
			};
			ApplySettings();
			_harmony = new Harmony("com.skaket.valheim.eyecolor");
			_painting = EyeSkin.Install(_harmony);
			if (_painting)
			{
				Log.LogInfo((object)"Watching for characters. 'Built level eyes' and 'Painted ... eyes' lines follow when the first one with a colour is drawn.");
			}
			EyeChoice.Install(_harmony);
			EyeRow.Install(_harmony);
			WatchConfigFile();
		}

		private void Update()
		{
			long num = Interlocked.Read(in _reloadAt);
			if (num != 0L && DateTime.UtcNow.Ticks >= num)
			{
				Interlocked.Exchange(ref _reloadAt, 0L);
				try
				{
					((BaseUnityPlugin)this).Config.Reload();
					_settingsChanged = true;
				}
				catch (Exception ex)
				{
					Log.LogWarning((object)("The config file could not be read again; keeping the current settings. " + ex.Message));
				}
			}
			if (_settingsChanged)
			{
				_settingsChanged = false;
				ApplySettings();
			}
			if (_painting)
			{
				EyeSkin.Sweep();
			}
		}

		private void OnDestroy()
		{
			_watcher?.Dispose();
			Harmony? harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		private void ApplySettings()
		{
			EyeColour colour;
			bool flag = EyeColours.TryFind(_default.Value, out colour);
			string text = ((!_enabled.Value) ? "off" : (_level.Value ? $"default {colour.Name}, level eyes tilted {_tilt.Value:0.#} degrees" : $"default {colour.Name}, painted in the game's eye at detail {_detail.Value}"));
			if (!flag)
			{
				text = text + " ('" + _default.Value + "' is not a colour this mod knows)";
			}
			if (!(text == _applied))
			{
				_applied = text;
				if (!flag)
				{
					Log.LogWarning((object)("DefaultColor '" + _default.Value + "' is neither one of " + string.Join(", ", EyeColours.Names) + " nor a hex code such as #40C0A0, so the default is Vanilla."));
				}
				Log.LogInfo((object)(_enabled.Value ? ("Eye colours: " + text + ".") : "Eye colours are off (Enabled = false)."));
				EyeChoice.Default = colour;
				EyeRow.Enabled = _enabled.Value;
				EyeSkin.Set(_enabled.Value, _level.Value, _tilt.Value, _detail.Value);
			}
		}

		private void WatchConfigFile()
		{
			try
			{
				string configFilePath = ((BaseUnityPlugin)this).Config.ConfigFilePath;
				_watcher = new FileSystemWatcher(Path.GetDirectoryName(configFilePath), Path.GetFileName(configFilePath))
				{
					NotifyFilter = (NotifyFilters.FileName | NotifyFilters.Size | NotifyFilters.LastWrite | NotifyFilters.CreationTime)
				};
				FileSystemEventHandler value = delegate
				{
					Interlocked.Exchange(ref _reloadAt, DateTime.UtcNow.AddSeconds(0.5).Ticks);
				};
				_watcher.Changed += value;
				_watcher.Created += value;
				_watcher.Renamed += delegate
				{
					Interlocked.Exchange(ref _reloadAt, DateTime.UtcNow.AddSeconds(0.5).Ticks);
				};
				_watcher.EnableRaisingEvents = true;
			}
			catch (Exception ex)
			{
				Log.LogWarning((object)("Could not watch the config file, so changes to it apply on the next launch. " + ex.Message));
			}
		}
	}
	public sealed class EyeColour
	{
		public string Name = "";

		public Color Iris;

		public Color Inner;

		public Color Rim;

		public bool IsVanilla;
	}
	public static class EyeColours
	{
		public const string Vanilla = "Vanilla";

		public static readonly EyeColour VanillaEyes = new EyeColour
		{
			Name = "Vanilla",
			IsVanilla = true
		};

		public static readonly EyeColour[] All = new EyeColour[7]
		{
			Make("Blue", 0.2f, 0.47f, 0.92f, 0.52f, 0.76f, 1f, 0.05f, 0.13f, 0.38f),
			Make("Green", 0.2f, 0.66f, 0.27f, 0.62f, 0.9f, 0.42f, 0.04f, 0.24f, 0.09f),
			Make("Purple", 0.52f, 0.27f, 0.86f, 0.78f, 0.6f, 1f, 0.2f, 0.07f, 0.4f),
			Make("Pink", 0.95f, 0.36f, 0.68f, 1f, 0.7f, 0.86f, 0.52f, 0.1f, 0.33f),
			Make("Red", 0.84f, 0.08f, 0.06f, 1f, 0.36f, 0.18f, 0.32f, 0.01f, 0.01f),
			Make("Brown", 0.47f, 0.25f, 0.09f, 0.72f, 0.42f, 0.15f, 0.17f, 0.07f, 0.02f),
			Make("Hazel", 0.55f, 0.44f, 0.18f, 0.8f, 0.56f, 0.2f, 0.22f, 0.2f, 0.08f)
		};

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

		public static string[] Names
		{
			get
			{
				string[] array = new string[All.Length + 1];
				array[0] = "Vanilla";
				for (int i = 0; i < All.Length; i++)
				{
					array[i + 1] = All[i].Name;
				}
				return array;
			}
		}

		public static bool TryFind(string name, out EyeColour colour)
		{
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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)
			colour = VanillaEyes;
			if (string.IsNullOrWhiteSpace(name))
			{
				return false;
			}
			name = name.Trim();
			if (string.Equals(name, "Vanilla", StringComparison.OrdinalIgnoreCase))
			{
				return true;
			}
			EyeColour[] all = All;
			foreach (EyeColour eyeColour in all)
			{
				if (string.Equals(eyeColour.Name, name, StringComparison.OrdinalIgnoreCase))
				{
					colour = eyeColour;
					return true;
				}
			}
			if (Custom.TryGetValue(name, out var value))
			{
				colour = value;
				return true;
			}
			string text = (name.StartsWith("#", StringComparison.Ordinal) ? name.Substring(1) : name);
			if (text.Length != 6 || !int.TryParse(text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out var result))
			{
				return false;
			}
			Color val = default(Color);
			((Color)(ref val))..ctor((float)((result >> 16) & 0xFF) / 255f, (float)((result >> 8) & 0xFF) / 255f, (float)(result & 0xFF) / 255f, 1f);
			colour = new EyeColour
			{
				Name = "#" + text.ToUpperInvariant(),
				Iris = val,
				Inner = Color.Lerp(val, Color.white, 0.38f),
				Rim = new Color(val.r * 0.36f, val.g * 0.36f, val.b * 0.36f, 1f)
			};
			if (Custom.TryGetValue(colour.Name, out var value2))
			{
				colour = value2;
			}
			else
			{
				Custom[colour.Name] = colour;
			}
			Custom[name] = colour;
			return true;
		}

		public static EyeColour Find(string name)
		{
			if (!TryFind(name, out var colour))
			{
				return VanillaEyes;
			}
			return colour;
		}

		private static EyeColour Make(string name, float r, float g, float b, float innerR, float innerG, float innerB, float rimR, float rimG, float rimB)
		{
			//IL_0015: 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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			return new EyeColour
			{
				Name = name,
				Iris = new Color(r, g, b, 1f),
				Inner = new Color(innerR, innerG, innerB, 1f),
				Rim = new Color(rimR, rimG, rimB, 1f)
			};
		}
	}
	public sealed class EyeDecalData
	{
		public Vector3[] Vertices = (Vector3[])(object)new Vector3[0];

		public Vector3[] Normals = (Vector3[])(object)new Vector3[0];

		public Vector2[] Uv = (Vector2[])(object)new Vector2[0];

		public int[] Triangles = new int[0];

		public int Bone;

		public EyeShape Shape;

		public float Left;

		public float Right;

		public float Low;

		public float High;

		public float Slant;

		public Vector3[] Corners = (Vector3[])(object)new Vector3[0];
	}
	public static class EyeDecal
	{
		private const float BoxLeft = 117f;

		private const float BoxRight = 128.5f;

		private const float BoxBottom = 230.5f;

		private const float BoxTop = 236.5f;

		private const int Columns = 8;

		private const int Rows = 5;

		private const float Lift = 0.0008f;

		private const float Margin = 0.08f;

		public static EyeDecalData Build(Mesh mesh, Quaternion rotation, float metresPerUnit, float tiltDegrees, out string problem)
		{
			//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)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: 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_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: 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_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0373: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0422: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_042b: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_053c: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0573: Unknown result type (might be due to invalid IL or missing references)
			//IL_057a: Unknown result type (might be due to invalid IL or missing references)
			//IL_058b: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: 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_06a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06de: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_070c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_060f: Unknown result type (might be due to invalid IL or missing references)
			//IL_072a: Unknown result type (might be due to invalid IL or missing references)
			//IL_072c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0733: Unknown result type (might be due to invalid IL or missing references)
			//IL_073c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_0748: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_0758: Unknown result type (might be due to invalid IL or missing references)
			//IL_075d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0761: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			problem = "";
			if ((Object)(object)mesh == (Object)null || !mesh.isReadable)
			{
				problem = "the game does not let scripts read this body mesh";
				return null;
			}
			Vector2[] uv = mesh.uv;
			Vector3[] vertices = mesh.vertices;
			int[] array = ((mesh.subMeshCount > 0) ? mesh.GetTriangles(0) : mesh.triangles);
			BoneWeight[] boneWeights = mesh.boneWeights;
			if (uv.Length != vertices.Length || uv.Length == 0)
			{
				problem = "the body mesh has no texture coordinates";
				return null;
			}
			Vector3[] array2 = (Vector3[])(object)new Vector3[vertices.Length];
			for (int i = 0; i < array2.Length; i++)
			{
				array2[i] = rotation * (vertices[i] * metresPerUnit);
			}
			bool[] array3 = new bool[array.Length / 3];
			List<int>[] array4 = new List<int>[2]
			{
				new List<int>(),
				new List<int>()
			};
			for (int j = 0; j + 2 < array.Length; j += 3)
			{
				bool flag = true;
				float num = 0f;
				for (int k = 0; k < 3 && flag; k++)
				{
					Vector2 val = uv[array[j + k]] * 256f;
					flag = val.x >= 117f && val.x <= 128.5f && val.y >= 230.5f && val.y <= 236.5f;
					num += array2[array[j + k]].x;
				}
				if (flag)
				{
					array3[j / 3] = true;
					array4[(!(num >= 0f)) ? 1u : 0u].Add(j);
				}
			}
			if (array4[0].Count == 0 || array4[1].Count == 0)
			{
				problem = "the body mesh has no triangles where the game keeps the eyes in the skin texture";
				return null;
			}
			Quaternion val2 = Quaternion.Inverse(rotation);
			float num2 = 1f / Mathf.Max(1E-09f, metresPerUnit);
			float num3 = tiltDegrees * ((float)Math.PI / 180f);
			Vector2 val3 = default(Vector2);
			((Vector2)(ref val3))..ctor(Mathf.Cos(num3), Mathf.Sin(num3));
			Vector2 val4 = default(Vector2);
			((Vector2)(ref val4))..ctor(0f - val3.y, val3.x);
			EyeDecalData eyeDecalData = new EyeDecalData();
			List<Vector3> list = new List<Vector3>();
			List<Vector3> list2 = new List<Vector3>();
			List<Vector2> list3 = new List<Vector2>();
			List<int> list4 = new List<int>();
			List<Vector3> list5 = new List<Vector3>();
			if (boneWeights != null && boneWeights.Length == vertices.Length)
			{
				eyeDecalData.Bone = ((BoneWeight)(ref boneWeights[array[array4[0][0]]])).boneIndex0;
			}
			for (int l = 0; l < 2; l++)
			{
				float num4 = ((l == 0) ? 1f : (-1f));
				List<Vector2> list6 = new List<Vector2>();
				List<Vector2> list7 = new List<Vector2>();
				Vector3 val5 = Vector3.zero;
				Vector3 val6 = Vector3.zero;
				foreach (int item2 in array4[l])
				{
					for (int m = 0; m < 3; m++)
					{
						int num5 = array[item2 + m];
						list6.Add(uv[num5]);
						list7.Add(new Vector2(num4 * array2[num5].x, array2[num5].y));
						val5 += array2[num5];
						list5.Add(vertices[num5]);
					}
					Vector3 val7 = Vector3.Cross(array2[array[item2 + 1]] - array2[array[item2]], array2[array[item2 + 2]] - array2[array[item2]]);
					val6 += ((val7.z < 0f) ? (-val7) : val7);
				}
				val5 /= (float)list7.Count;
				val6 = ((((Vector3)(ref val6)).sqrMagnitude > 1E-20f) ? ((Vector3)(ref val6)).normalized : Vector3.forward);
				if (val6.z < 0.2f)
				{
					val6 = Vector3.forward;
				}
				EyeShape eyeShape = EyePaint.Measure(list6, list7, out problem);
				if (eyeShape == null)
				{
					return null;
				}
				if (l == 0)
				{
					float num6 = float.MaxValue;
					float num7 = float.MinValue;
					float num8 = float.MaxValue;
					float num9 = float.MinValue;
					Vector2[] face = eyeShape.Face;
					foreach (Vector2 val8 in face)
					{
						num6 = Mathf.Min(num6, val8.x);
						num7 = Mathf.Max(num7, val8.x);
						num8 = Mathf.Min(num8, val8.y);
						num9 = Mathf.Max(num9, val8.y);
					}
					float num10 = 0.08f * (num7 - num6);
					eyeDecalData.Shape = eyeShape;
					eyeDecalData.Left = num6 - num10;
					eyeDecalData.Right = num7 + num10;
					eyeDecalData.Low = num8 - num10;
					eyeDecalData.High = num9 + num10;
					eyeDecalData.Slant = Mathf.Atan2(eyeShape.Along.y, eyeShape.Along.x) * 57.29578f;
				}
				float num11 = eyeDecalData.Right - eyeDecalData.Left;
				List<int> list8 = new List<int>();
				for (int num12 = 0; num12 + 2 < array.Length; num12 += 3)
				{
					if (!array3[num12 / 3])
					{
						Vector3 val9 = array2[array[num12]];
						Vector3 val10 = array2[array[num12 + 1]];
						Vector3 val11 = array2[array[num12 + 2]];
						if (!(Mathf.Min(val9.x, Mathf.Min(val10.x, val11.x)) > val5.x + num11) && !(Mathf.Max(val9.x, Mathf.Max(val10.x, val11.x)) < val5.x - num11) && !(Mathf.Min(val9.y, Mathf.Min(val10.y, val11.y)) > val5.y + num11) && !(Mathf.Max(val9.y, Mathf.Max(val10.y, val11.y)) < val5.y - num11) && !(Mathf.Max(val9.z, Mathf.Max(val10.z, val11.z)) < val5.z - 0.03f))
						{
							list8.Add(num12);
						}
					}
				}
				int count = list.Count;
				for (int num13 = 0; num13 <= 5; num13++)
				{
					for (int num14 = 0; num14 <= 8; num14++)
					{
						float num15 = (float)num14 / 8f;
						float num16 = (float)num13 / 5f;
						Vector2 val12 = eyeShape.Origin + val3 * Mathf.Lerp(eyeDecalData.Left, eyeDecalData.Right, num15) + val4 * Mathf.Lerp(eyeDecalData.Low, eyeDecalData.High, num16);
						val12.x *= num4;
						float num17 = val5.z - (val6.x * (val12.x - val5.x) + val6.y * (val12.y - val5.y)) / val6.z + 0.0004f;
						if (SkinDepth(array2, array, list8, val12, out var depth))
						{
							num17 = Mathf.Max(num17, depth + 0.0008f);
						}
						list.Add(val2 * (new Vector3(val12.x, val12.y, num17) * num2));
						Vector3 val13 = val2 * val6;
						list2.Add(((Vector3)(ref val13)).normalized);
						list3.Add(new Vector2(num15, num16));
					}
				}
				for (int num18 = 0; num18 < 5; num18++)
				{
					for (int num19 = 0; num19 < 8; num19++)
					{
						int num20 = count + num18 * 9 + num19;
						int num21 = num20 + 1;
						int num22 = num20 + 8 + 1;
						int item = num22 + 1;
						if (Vector3.Dot(Vector3.Cross(list[num22] - list[num20], list[num21] - list[num20]), list2[num20]) < 0f)
						{
							list4.Add(num20);
							list4.Add(num21);
							list4.Add(num22);
							list4.Add(num21);
							list4.Add(item);
							list4.Add(num22);
						}
						else
						{
							list4.Add(num20);
							list4.Add(num22);
							list4.Add(num21);
							list4.Add(num21);
							list4.Add(num22);
							list4.Add(item);
						}
					}
				}
			}
			eyeDecalData.Vertices = list.ToArray();
			eyeDecalData.Normals = list2.ToArray();
			eyeDecalData.Uv = list3.ToArray();
			eyeDecalData.Triangles = list4.ToArray();
			eyeDecalData.Corners = list5.ToArray();
			return eyeDecalData;
		}

		public static bool SameCorners(Vector3[] a, Vector3[] b)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (a == null || b == null || a.Length != b.Length)
			{
				return false;
			}
			for (int i = 0; i < a.Length; i++)
			{
				Vector3 val = a[i] - b[i];
				if (((Vector3)(ref val)).sqrMagnitude > 1E-10f)
				{
					return false;
				}
			}
			return true;
		}

		private static bool SkinDepth(Vector3[] face, int[] triangles, List<int> skin, Vector2 at, out float depth)
		{
			//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_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0042: 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_0050: 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_005f: 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_006d: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00b2: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			depth = float.MinValue;
			bool result = false;
			foreach (int item in skin)
			{
				Vector3 val = face[triangles[item]];
				Vector3 val2 = face[triangles[item + 1]];
				Vector3 val3 = face[triangles[item + 2]];
				float num = (val2.x - val.x) * (val3.y - val.y) - (val2.y - val.y) * (val3.x - val.x);
				if (Mathf.Abs(num) < 1E-12f)
				{
					continue;
				}
				float num2 = ((at.x - val.x) * (val3.y - val.y) - (at.y - val.y) * (val3.x - val.x)) / num;
				float num3 = ((val2.x - val.x) * (at.y - val.y) - (val2.y - val.y) * (at.x - val.x)) / num;
				if (!(num2 < -0.001f) && !(num3 < -0.001f) && !(num2 + num3 > 1.001f))
				{
					float num4 = val.z + num2 * (val2.z - val.z) + num3 * (val3.z - val.z);
					if (num4 > depth)
					{
						depth = num4;
					}
					result = true;
				}
			}
			return result;
		}
	}
	public sealed class EyeShape
	{
		public Vector2[] Uv = (Vector2[])(object)new Vector2[0];

		public Vector2[] Face = (Vector2[])(object)new Vector2[0];

		public float HalfWidth;

		public float HalfHeight;

		public Vector2 Along = Vector2.right;

		public Vector2 Origin;
	}
	public static class EyePaint
	{
		private const float BoxLeft = 117f;

		private const float BoxRight = 128.5f;

		private const float BoxBottom = 230.5f;

		private const float BoxTop = 236.5f;

		private const float IrisPart = 0.58f;

		private const float PupilPart = 0.37f;

		private static readonly Color Sclera = new Color(0.87f, 0.86f, 0.85f);

		private static readonly Color ScleraCorner = new Color(0.74f, 0.62f, 0.58f);

		private static readonly Color Pupil = new Color(0.02f, 0.02f, 0.03f);

		private static readonly Color Lash = new Color(0.09f, 0.055f, 0.045f);

		public static EyeShape FindEye(Mesh mesh, Quaternion rotation, float metresPerUnit, out string problem)
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//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_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: 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)
			problem = "";
			if ((Object)(object)mesh == (Object)null || !mesh.isReadable)
			{
				problem = "the game does not let scripts read this body mesh";
				return null;
			}
			Vector2[] uv = mesh.uv;
			Vector3[] vertices = mesh.vertices;
			int[] array = ((mesh.subMeshCount > 0) ? mesh.GetTriangles(0) : mesh.triangles);
			if (uv.Length != vertices.Length || uv.Length == 0)
			{
				problem = "the body mesh has no texture coordinates";
				return null;
			}
			List<Vector2> list = new List<Vector2>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector2> list3 = new List<Vector2>();
			List<Vector2> list4 = new List<Vector2>();
			for (int i = 0; i + 2 < array.Length; i += 3)
			{
				bool flag = true;
				float num = 0f;
				for (int j = 0; j < 3 && flag; j++)
				{
					Vector2 val = uv[array[i + j]] * 256f;
					flag = val.x >= 117f && val.x <= 128.5f && val.y >= 230.5f && val.y <= 236.5f;
					num += (rotation * vertices[array[i + j]]).x;
				}
				if (!flag)
				{
					continue;
				}
				for (int k = 0; k < 3; k++)
				{
					Vector3 val2 = rotation * (vertices[array[i + k]] * metresPerUnit);
					if (num >= 0f)
					{
						list.Add(uv[array[i + k]]);
						list2.Add(new Vector2(val2.x, val2.y));
					}
					else
					{
						list4.Add(uv[array[i + k]]);
						list3.Add(new Vector2(0f - val2.x, val2.y));
					}
				}
			}
			if (list2.Count == 0)
			{
				list2 = list3;
				list = list4;
			}
			if (list2.Count == 0)
			{
				problem = "the body mesh has no triangles where the game keeps the eye in the skin texture";
				return null;
			}
			return Measure(list, list2, out problem);
		}

		public static EyeShape Measure(List<Vector2> uv, List<Vector2> points, out string problem)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: 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_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: 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_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: 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)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: 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_01dd: 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_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: 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_02c1: 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_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: 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_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_0337: Unknown result type (might be due to invalid IL or missing references)
			//IL_033c: Unknown result type (might be due to invalid IL or missing references)
			problem = "";
			Vector2 val = points[0];
			Vector2 val2 = points[0];
			bool flag = false;
			foreach (Vector2 point in points)
			{
				if (point.y > val.y)
				{
					val = point;
				}
			}
			Vector2 val3;
			foreach (Vector2 point2 in points)
			{
				val3 = point2 - val;
				if (!(((Vector2)(ref val3)).sqrMagnitude < 1E-12f) && (!flag || point2.y > val2.y))
				{
					val2 = point2;
					flag = true;
				}
			}
			Vector2 val4;
			if (!flag)
			{
				val4 = Vector2.right;
			}
			else
			{
				val3 = val2 - val;
				val4 = ((Vector2)(ref val3)).normalized;
			}
			Vector2 val5 = val4;
			if (Mathf.Abs(val5.x) < 0.7f)
			{
				val5 = Vector2.right;
			}
			if (val5.x < 0f)
			{
				val5 = -val5;
			}
			Vector2 val6 = default(Vector2);
			((Vector2)(ref val6))..ctor(0f - val5.y, val5.x);
			Vector2[] array = (Vector2[])(object)new Vector2[points.Count];
			float num = float.MaxValue;
			float num2 = float.MinValue;
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = new Vector2(Vector2.Dot(points[i], val5), Vector2.Dot(points[i], val6));
				num = Mathf.Min(num, array[i].y);
				num2 = Mathf.Max(num2, array[i].y);
			}
			float num3 = (num + num2) * 0.5f;
			float num4 = float.MaxValue;
			float num5 = float.MinValue;
			for (int j = 0; j + 2 < array.Length; j += 3)
			{
				for (int k = 0; k < 3; k++)
				{
					Vector2 val7 = array[j + k];
					Vector2 val8 = array[j + (k + 1) % 3];
					if (!((val7.y - num3) * (val8.y - num3) > 0f) && !Mathf.Approximately(val7.y, val8.y))
					{
						float num6 = Mathf.Lerp(val7.x, val8.x, (num3 - val7.y) / (val8.y - val7.y));
						num4 = Mathf.Min(num4, num6);
						num5 = Mathf.Max(num5, num6);
					}
				}
			}
			if (num5 - num4 < 1E-05f || num2 - num < 1E-05f)
			{
				problem = "the eye in the body mesh has no size";
				return null;
			}
			Vector2 val9 = default(Vector2);
			((Vector2)(ref val9))..ctor((num4 + num5) * 0.5f, num3);
			for (int l = 0; l < array.Length; l++)
			{
				ref Vector2 reference = ref array[l];
				reference -= val9;
			}
			return new EyeShape
			{
				Uv = uv.ToArray(),
				Face = array,
				HalfWidth = (num5 - num4) * 0.5f,
				HalfHeight = (num2 - num) * 0.5f,
				Along = val5,
				Origin = val5 * val9.x + val6 * val9.y
			};
		}

		public static Color32[] PaintSheet(int width, int height, EyeShape eye, float left, float right, float low, float high, EyeColour colour)
		{
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: 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_0270: 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_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_009e: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: 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)
			Color32[] array = (Color32[])(object)new Color32[width * height];
			bool[] array2 = new bool[array.Length];
			Vector2 at = default(Vector2);
			for (int i = 0; i < height; i++)
			{
				for (int j = 0; j < width; j++)
				{
					float num = 0f;
					float num2 = 0f;
					float num3 = 0f;
					int num4 = 0;
					for (int k = 0; k < 4; k++)
					{
						for (int l = 0; l < 4; l++)
						{
							((Vector2)(ref at))..ctor(Mathf.Lerp(left, right, ((float)j + ((float)l + 0.5f) / 4f) / (float)width), Mathf.Lerp(low, high, ((float)i + ((float)k + 0.5f) / 4f) / (float)height));
							if (InOutline(eye, at))
							{
								Color val = Shade(at, eye, colour);
								num += val.r;
								num2 += val.g;
								num3 += val.b;
								num4++;
							}
						}
					}
					if (num4 != 0)
					{
						int num5 = i * width + j;
						array[num5] = new Color32(Byte(num / (float)num4), Byte(num2 / (float)num4), Byte(num3 / (float)num4), Byte((float)num4 / 16f));
						array2[num5] = true;
					}
				}
			}
			for (int m = 0; m < 3; m++)
			{
				List<int> list = new List<int>();
				List<Color32> list2 = new List<Color32>();
				for (int n = 0; n < height; n++)
				{
					for (int num6 = 0; num6 < width; num6++)
					{
						int num7 = n * width + num6;
						if (array2[num7])
						{
							continue;
						}
						int num8 = 0;
						int num9 = 0;
						int num10 = 0;
						int num11 = 0;
						for (int num12 = -1; num12 <= 1; num12++)
						{
							for (int num13 = -1; num13 <= 1; num13++)
							{
								int num14 = num6 + num13;
								int num15 = n + num12;
								if (num14 >= 0 && num14 < width && num15 >= 0 && num15 < height && array2[num15 * width + num14])
								{
									Color32 val2 = array[num15 * width + num14];
									num8 += val2.r;
									num9 += val2.g;
									num10 += val2.b;
									num11++;
								}
							}
						}
						if (num11 != 0)
						{
							list.Add(num7);
							list2.Add(new Color32((byte)(num8 / num11), (byte)(num9 / num11), (byte)(num10 / num11), (byte)0));
						}
					}
				}
				for (int num16 = 0; num16 < list.Count; num16++)
				{
					array[list[num16]] = list2[num16];
					array2[list[num16]] = true;
				}
			}
			return array;
		}

		private static bool InOutline(EyeShape eye, Vector2 at)
		{
			//IL_000e: 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_001d: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: 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_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0078: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i + 2 < eye.Face.Length; i += 3)
			{
				Vector2 val = eye.Face[i];
				Vector2 val2 = eye.Face[i + 1];
				Vector2 val3 = eye.Face[i + 2];
				float num = (val2.x - val.x) * (at.y - val.y) - (val2.y - val.y) * (at.x - val.x);
				float num2 = (val3.x - val2.x) * (at.y - val2.y) - (val3.y - val2.y) * (at.x - val2.x);
				float num3 = (val.x - val3.x) * (at.y - val3.y) - (val.y - val3.y) * (at.x - val3.x);
				if ((num >= 0f && num2 >= 0f && num3 >= 0f) || (num <= 0f && num2 <= 0f && num3 <= 0f))
				{
					return true;
				}
			}
			return false;
		}

		public static int HideGameEye(Color32[] pixels, int width, int height)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			int num = 114 * width / 256;
			int num2 = 129 * width / 256;
			int num3 = 17 * height / 256;
			int num4 = 27 * height / 256;
			int num5 = 0;
			float num6 = 0f;
			float num7 = 0f;
			float num8 = 0f;
			int num9 = 0;
			for (int i = num3; i < num4; i++)
			{
				int num10 = (height - 1 - i) * width;
				for (int j = num; j < num2; j++)
				{
					Color32 val = pixels[num10 + j];
					if (val.b - val.r > 26)
					{
						num5++;
					}
					else if (val.a > 200)
					{
						num6 += (float)(int)val.r;
						num7 += (float)(int)val.g;
						num8 += (float)(int)val.b;
						num9++;
					}
				}
			}
			if (num5 == 0 || num9 == 0)
			{
				return 0;
			}
			Color32 val2 = default(Color32);
			((Color32)(ref val2))..ctor((byte)(num6 / (float)num9), (byte)(num7 / (float)num9), (byte)(num8 / (float)num9), (byte)0);
			for (int k = num3; k < num4; k++)
			{
				int num11 = (height - 1 - k) * width;
				for (int l = num; l < num2; l++)
				{
					if (pixels[num11 + l].b - pixels[num11 + l].r > 26)
					{
						pixels[num11 + l] = val2;
					}
				}
			}
			return num5;
		}

		public static Color32[] Paint(Color32[] source, int width, int height, int detail, EyeShape eye, EyeColour colour, out int painted)
		{
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_020f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: 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_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: 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_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_028e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ad: 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_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_059e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f7: 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_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			detail = Mathf.Max(1, detail);
			int num = width * detail;
			int num2 = height * detail;
			Color32[] array = (Color32[])(object)new Color32[num * num2];
			for (int i = 0; i < num2; i++)
			{
				int num3 = i / detail * width;
				int num4 = i * num;
				for (int j = 0; j < num; j++)
				{
					array[num4 + j] = source[num3 + j / detail];
				}
			}
			int num5 = eye.Uv.Length / 3;
			Vector2[] array2 = (Vector2[])(object)new Vector2[num5 * 3];
			Vector2[] array3 = (Vector2[])(object)new Vector2[num5];
			Vector2[] array4 = (Vector2[])(object)new Vector2[num5];
			Vector2[] array5 = (Vector2[])(object)new Vector2[num5];
			bool[] array6 = new bool[num5];
			float num6 = float.MaxValue;
			float num7 = float.MaxValue;
			float num8 = float.MinValue;
			float num9 = float.MinValue;
			Vector2 val = default(Vector2);
			for (int k = 0; k < num5; k++)
			{
				for (int l = 0; l < 3; l++)
				{
					((Vector2)(ref val))..ctor(eye.Uv[k * 3 + l].x * (float)num, eye.Uv[k * 3 + l].y * (float)num2);
					array2[k * 3 + l] = val;
					num6 = Mathf.Min(num6, val.x);
					num8 = Mathf.Max(num8, val.x);
					num7 = Mathf.Min(num7, val.y);
					num9 = Mathf.Max(num9, val.y);
				}
				Vector2 val2 = array2[k * 3];
				Vector2 val3 = array2[k * 3 + 1] - val2;
				Vector2 val4 = array2[k * 3 + 2] - val2;
				float num10 = val3.x * val4.y - val3.y * val4.x;
				if (!(Mathf.Abs(num10) < 1E-06f))
				{
					array6[k] = true;
					Vector2 val5 = eye.Face[k * 3];
					Vector2 val6 = eye.Face[k * 3 + 1] - val5;
					Vector2 val7 = eye.Face[k * 3 + 2] - val5;
					array4[k] = (val6 * val4.y - val7 * val3.y) / num10;
					array5[k] = (val7 * val3.x - val6 * val4.x) / num10;
					array3[k] = val5 - array4[k] * val2.x - array5[k] * val2.y;
				}
			}
			painted = 0;
			if (num6 > num8)
			{
				return array;
			}
			int num11 = Mathf.Max(0, Mathf.FloorToInt(num6) - 1);
			int num12 = Mathf.Min(num - 1, Mathf.CeilToInt(num8) + 1);
			int num13 = Mathf.Max(0, Mathf.FloorToInt(num7) - 1);
			int num14 = Mathf.Min(num2 - 1, Mathf.CeilToInt(num9) + 1);
			bool[] array7 = new bool[(num12 - num11 + 1) * (num14 - num13 + 1)];
			float num15 = 0f;
			float num16 = 0f;
			float num17 = 0f;
			for (int m = num13; m <= num14; m++)
			{
				for (int n = num11; n <= num12; n++)
				{
					if (Deepest(array2, array6, num5, (float)n + 0.5f, (float)m + 0.5f, out var _) < -0.75f)
					{
						continue;
					}
					float num18 = 0f;
					float num19 = 0f;
					float num20 = 0f;
					for (int num21 = 0; num21 < 4; num21++)
					{
						for (int num22 = 0; num22 < 4; num22++)
						{
							float num23 = (float)n + ((float)num22 + 0.5f) / 4f;
							float num24 = (float)m + ((float)num21 + 0.5f) / 4f;
							Deepest(array2, array6, num5, num23, num24, out var triangle2);
							Color val8 = Shade(array3[triangle2] + array4[triangle2] * num23 + array5[triangle2] * num24, eye, colour);
							num18 += val8.r;
							num19 += val8.g;
							num20 += val8.b;
						}
					}
					float num25 = 0.0625f;
					num18 *= num25;
					num19 *= num25;
					num20 *= num25;
					int num26 = m * num + n;
					array[num26] = new Color32(Byte(num18), Byte(num19), Byte(num20), array[num26].a);
					array7[(m - num13) * (num12 - num11 + 1) + (n - num11)] = true;
					num15 += num18;
					num16 += num19;
					num17 += num20;
					painted++;
				}
			}
			if (painted == 0)
			{
				return array;
			}
			Color32 val9 = default(Color32);
			((Color32)(ref val9))..ctor(Byte(num15 / (float)painted), Byte(num16 / (float)painted), Byte(num17 / (float)painted), byte.MaxValue);
			int num27 = 3 * detail;
			for (int num28 = Mathf.Max(0, num13 - num27); num28 <= Mathf.Min(num2 - 1, num14 + num27); num28++)
			{
				for (int num29 = Mathf.Max(0, num11 - num27); num29 <= Mathf.Min(num - 1, num12 + num27); num29++)
				{
					if (num29 < num11 || num29 > num12 || num28 < num13 || num28 > num14 || !array7[(num28 - num13) * (num12 - num11 + 1) + (num29 - num11)])
					{
						int num30 = num28 * num + num29;
						Color32 val10 = array[num30];
						if (val10.b - val10.r > 26)
						{
							array[num30] = new Color32(val9.r, val9.g, val9.b, val10.a);
						}
					}
				}
			}
			return array;
		}

		private static float Deepest(Vector2[] corners, bool[] usable, int count, float x, float y, out int triangle)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: 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)
			float num = float.MinValue;
			triangle = 0;
			for (int i = 0; i < count; i++)
			{
				if (usable[i])
				{
					Vector2 val = corners[i * 3];
					Vector2 val2 = corners[i * 3 + 1];
					Vector2 val3 = corners[i * 3 + 2];
					bool num2 = (val2.x - val.x) * (val3.y - val.y) - (val2.y - val.y) * (val3.x - val.x) > 0f;
					float num3 = Edge(val, val2, x, y);
					float num4 = Edge(val2, val3, x, y);
					float num5 = Edge(val3, val, x, y);
					float num6 = (num2 ? Mathf.Min(num3, Mathf.Min(num4, num5)) : (0f - Mathf.Max(num3, Mathf.Max(num4, num5))));
					if (num6 > num)
					{
						num = num6;
						triangle = i;
					}
				}
			}
			return num;
		}

		private static float Edge(Vector2 a, Vector2 b, float x, float y)
		{
			//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_000e: 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_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			float num = b.x - a.x;
			float num2 = b.y - a.y;
			float num3 = Mathf.Sqrt(num * num + num2 * num2);
			if (!(num3 < 1E-09f))
			{
				return (num * (y - a.y) - num2 * (x - a.x)) / num3;
			}
			return 0f;
		}

		private static Color Shade(Vector2 at, EyeShape eye, EyeColour colour)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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_0064: 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_007e: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: 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_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: 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_02b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.58f * eye.HalfWidth, 1.06f * eye.HalfHeight);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0f, 0.1f * eye.HalfHeight);
			Vector2 val2 = at - val;
			float num2 = ((Vector2)(ref val2)).magnitude / num;
			float value = Mathf.Abs(at.x) / eye.HalfWidth;
			Color val3;
			if (num2 >= 1f)
			{
				val3 = Color.Lerp(Sclera, ScleraCorner, Smooth(0.5f, 1.15f, value));
				val3 *= Mathf.Lerp(0.86f, 1f, Smooth(1f, 1.22f, num2));
			}
			else if (num2 <= 0.37f)
			{
				val3 = Pupil;
			}
			else
			{
				float num3 = (num2 - 0.37f) / 0.63f;
				val3 = Color.Lerp(colour.Inner, colour.Iris, Smooth(0.05f, 0.62f, num3));
				val3 = Color.Lerp(val3, colour.Rim, 0.92f * Smooth(0.66f, 1f, num3));
				float num4 = Mathf.Atan2(at.y - val.y, at.x);
				float num5 = 0.65f * Spokes(num4, 31) + 0.35f * Spokes(num4 + 0.4f, 67);
				val3 *= 1f + 0.2f * num5 * Mathf.Sin((float)Math.PI * Mathf.Clamp01(num3 * 1.15f));
				val3 *= Mathf.Lerp(0.7f, 1f, Smooth(0f, 0.16f, num3));
			}
			float num6 = (eye.HalfHeight - at.y) / (2f * eye.HalfHeight);
			val3 *= Mathf.Lerp(0.5f, 1f, Smooth(0.02f, 0.45f, num6));
			val3 *= Mathf.Lerp(0.82f, 1f, Smooth(0f, 0.14f, 1f - num6));
			float num7 = Mathf.Min(val.y + 0.37f * num, 0.5f * eye.HalfHeight);
			val2 = at - new Vector2(0f, num7);
			float value2 = ((Vector2)(ref val2)).magnitude / num;
			val3 = Color.Lerp(val3, Color.white, 0.95f * (1f - Smooth(0.09f, 0.17f, value2)));
			return Color.Lerp(Lash, val3, Smooth(0.02f, 0.13f, num6));
		}

		private static float Spokes(float angle, int spokes)
		{
			float num = angle / ((float)Math.PI * 2f);
			float num2 = (num - Mathf.Floor(num)) * (float)spokes;
			int num3 = Mathf.FloorToInt(num2);
			float num4 = num2 - (float)num3;
			num4 = num4 * num4 * (3f - 2f * num4);
			return Mathf.Lerp(Random(num3 % spokes, spokes), Random((num3 + 1) % spokes, spokes), num4) * 2f - 1f;
		}

		private static float Random(int index, int seed)
		{
			float num = Mathf.Sin((float)index * 12.9898f + (float)seed * 78.233f) * 43758.547f;
			return num - Mathf.Floor(num);
		}

		private static float Smooth(float from, float to, float value)
		{
			float num = Mathf.Clamp01((value - from) / (to - from));
			return num * num * (3f - 2f * num);
		}

		private static byte Byte(float value)
		{
			return (byte)Mathf.Clamp(Mathf.RoundToInt(value * 255f), 0, 255);
		}
	}
	internal static class EyeRow
	{
		private sealed class Row
		{
			public GameObject Panel;

			public RectTransform Rect;

			public TMP_Text Selected;

			public bool InLayout;

			public Vector2 Step;

			public bool Placed;
		}

		private const string FeminineFigureId = "com.skaket.valheim.femininefigure";

		private const string FeminineFigureRow = "FeminineFigure_Face";

		private static readonly Dictionary<PlayerCustomizaton, Row> Rows = new Dictionary<PlayerCustomizaton, Row>();

		private static readonly HashSet<PlayerCustomizaton> GaveUp = new HashSet<PlayerCustomizaton>();

		internal static bool Enabled = true;

		internal static void Install(Harmony harmony)
		{
			Patch(harmony, "OnEnable", "AfterOnEnable");
			Patch(harmony, "Update", "AfterUpdate");
		}

		private static void Patch(Harmony harmony, string method, string postfix)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			MethodInfo methodInfo = AccessTools.Method(typeof(PlayerCustomizaton), method, (Type[])null, (Type[])null);
			if (methodInfo == null)
			{
				EyeColorPlugin.Log.LogWarning((object)("PlayerCustomizaton." + method + " was not found in this game version, so the character screen has no Eyes row. The 'eyecolor' console command still works."));
				return;
			}
			HarmonyMethod val = new HarmonyMethod(typeof(EyeRow), postfix, (Type[])null);
			val.before = new string[1] { "com.skaket.valheim.femininefigure" };
			harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, val, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
		}

		private static void AfterOnEnable(PlayerCustomizaton __instance)
		{
			if (!Enabled || GaveUp.Contains(__instance))
			{
				return;
			}
			try
			{
				Add(__instance);
			}
			catch (Exception arg)
			{
				GaveUp.Add(__instance);
				EyeColorPlugin.Log.LogWarning((object)$"The Eyes row could not be added to the character screen. The 'eyecolor' console command still works. {arg}");
			}
		}

		private static void AfterUpdate(PlayerCustomizaton __instance)
		{
			if (!Rows.TryGetValue(__instance, out Row value) || !Object.op_Implicit((Object)(object)value.Panel))
			{
				return;
			}
			try
			{
				Player val = PlayerOf(__instance);
				bool flag = Enabled && (Object)(object)val != (Object)null;
				if (flag && !value.Placed && !Place(__instance, value))
				{
					Rows.Remove(__instance);
					GaveUp.Add(__instance);
					value.Panel.SetActive(false);
					return;
				}
				if (value.Panel.activeSelf != flag)
				{
					value.Panel.SetActive(flag);
				}
				if (flag)
				{
					string text = EyeChoice.NameFor(val);
					if (value.Selected.text != text)
					{
						value.Selected.text = text;
					}
				}
			}
			catch (Exception arg)
			{
				Rows.Remove(__instance);
				GaveUp.Add(__instance);
				EyeColorPlugin.Log.LogWarning((object)$"The Eyes row stopped working and was left as it is. The 'eyecolor' console command still works. {arg}");
			}
		}

		private static void Add(PlayerCustomizaton screen)
		{
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Expected O, but got Unknown
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0301: Expected O, but got Unknown
			//IL_030f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0319: Expected O, but got Unknown
			//IL_03b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Expected O, but got Unknown
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)screen.m_femaleToggle) || !Object.op_Implicit((Object)(object)screen.m_beardPanel) || !Object.op_Implicit((Object)(object)screen.m_selectedBeard) || (Rows.TryGetValue(screen, out Row value) && Object.op_Implicit((Object)(object)value.Panel)))
			{
				return;
			}
			foreach (PlayerCustomizaton item in Rows.Keys.Where((PlayerCustomizaton key) => !Object.op_Implicit((Object)(object)key)).ToList())
			{
				Rows.Remove(item);
			}
			GaveUp.RemoveWhere((PlayerCustomizaton key) => !Object.op_Implicit((Object)(object)key));
			RectTransform beardPanel = screen.m_beardPanel;
			List<int> list = PathTo((Transform)(object)beardPanel, screen.m_selectedBeard.transform);
			if (list == null)
			{
				throw new InvalidOperationException("the beard row does not hold the beard's name, so the screen is not laid out as expected");
			}
			GameObject val = Object.Instantiate<GameObject>(((Component)beardPanel).gameObject, ((Transform)beardPanel).parent);
			try
			{
				((Object)val).name = "EyeColor_Eyes";
				Transform val2 = ((Transform)beardPanel).parent.Find("FeminineFigure_Face");
				val.transform.SetSiblingIndex((Object.op_Implicit((Object)(object)val2) ? val2.GetSiblingIndex() : ((Transform)beardPanel).GetSiblingIndex()) + 1);
				Transform val3 = val.transform;
				foreach (int item2 in list)
				{
					val3 = val3.GetChild(item2);
				}
				TMP_Text component = ((Component)val3).GetComponent<TMP_Text>();
				if (!Object.op_Implicit((Object)(object)component))
				{
					throw new InvalidOperationException("the copy of the beard row has no text for the chosen name");
				}
				Button[] componentsInChildren = val.GetComponentsInChildren<Button>(true);
				Button val4 = null;
				Button val5 = null;
				Button[] array = componentsInChildren;
				foreach (Button val6 in array)
				{
					for (int num2 = 0; num2 < ((UnityEventBase)val6.onClick).GetPersistentEventCount(); num2++)
					{
						string persistentMethodName = ((UnityEventBase)val6.onClick).GetPersistentMethodName(num2);
						if (persistentMethodName == "OnBeardLeft")
						{
							val4 = val6;
						}
						else if (persistentMethodName == "OnBeardRight")
						{
							val5 = val6;
						}
					}
				}
				if (((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null) && componentsInChildren.Length >= 2)
				{
					Button[] array2 = componentsInChildren.OrderBy((Button button) => ((Component)button).transform.position.x).ToArray();
					val4 = array2[0];
					val5 = array2[^1];
				}
				if ((Object)(object)val4 == (Object)null || (Object)(object)val5 == (Object)null)
				{
					throw new InvalidOperationException("the beard row has no pair of arrow buttons");
				}
				val4.onClick = new ButtonClickedEvent();
				((UnityEvent)val4.onClick).AddListener((UnityAction)delegate
				{
					Turn(screen, -1);
				});
				val5.onClick = new ButtonClickedEvent();
				((UnityEvent)val5.onClick).AddListener((UnityAction)delegate
				{
					Turn(screen, 1);
				});
				int num3 = 0;
				TMP_Text[] componentsInChildren2 = val.GetComponentsInChildren<TMP_Text>(true);
				foreach (TMP_Text val7 in componentsInChildren2)
				{
					if (!((Object)(object)val7 == (Object)(object)component) && !((Object)(object)((Component)val7).GetComponentInParent<Button>(true) != (Object)null))
					{
						val7.text = "Eyes";
						num3++;
					}
				}
				Transform? obj = (Object.op_Implicit((Object)(object)screen.m_selectedHair) ? RowOf(screen.m_selectedHair.transform, ((Transform)beardPanel).parent) : null);
				RectTransform val8 = (RectTransform)(object)((obj is RectTransform) ? obj : null);
				Row obj2 = new Row
				{
					Panel = val,
					Rect = (RectTransform)val.transform,
					Selected = component,
					InLayout = ((Object)(object)((Component)((Transform)beardPanel).parent).GetComponent<LayoutGroup>() != (Object)null)
				};
				? step;
				if (!((Object)(object)val8 != (Object)null) || !((Object)(object)val8 != (Object)(object)beardPanel))
				{
					Rect rect = beardPanel.rect;
					step = new Vector2(0f, 0f - ((Rect)(ref rect)).height);
				}
				else
				{
					step = beardPanel.anchoredPosition - val8.anchoredPosition;
				}
				obj2.Step = (Vector2)step;
				Row row = obj2;
				val.SetActive(false);
				Rows[screen] = row;
				EyeColorPlugin.Log.LogInfo((object)("Added an Eyes row to the character screen: a copy of '" + ((Object)beardPanel).name + "' under '" + ((Object)((Transform)beardPanel).parent).name + "', " + (row.InLayout ? "placed by the screen's own layout" : "placed by this mod") + ", arrows '" + ((Object)val4).name + "' and '" + ((Object)val5).name + "', " + $"{num3} title text(s) renamed, {componentsInChildren.Length} button(s) in the row, one row is {row.Step}."));
			}
			catch
			{
				Object.Destroy((Object)(object)val);
				throw;
			}
		}

		private static bool Place(PlayerCustomizaton screen, Row row)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			row.Placed = true;
			if (row.InLayout)
			{
				return true;
			}
			RectTransform beardPanel = screen.m_beardPanel;
			if (!Object.op_Implicit((Object)(object)beardPanel))
			{
				return false;
			}
			Transform obj = ((Transform)beardPanel).parent.Find("FeminineFigure_Face");
			RectTransform val = (RectTransform)(object)((obj is RectTransform) ? obj : null);
			if ((Object)(object)val != (Object)null)
			{
				if (!((Component)val).gameObject.activeSelf)
				{
					Vector2 val2 = val.anchoredPosition - beardPanel.anchoredPosition;
					if (!(((Vector2)(ref val2)).sqrMagnitude > 1f))
					{
						goto IL_007f;
					}
				}
				EyeColorPlugin.Log.LogWarning((object)"The Eyes row was left off the character screen, because Feminine Figure had already made room for its Face row. Start the game again to get it. The 'eyecolor' console command still works.");
				return false;
			}
			goto IL_007f;
			IL_007f:
			if (!MakeRoom(beardPanel, row))
			{
				row.Rect.anchoredPosition = beardPanel.anchoredPosition + row.Step;
				EyeColorPlugin.Log.LogInfo((object)"The character screen could not be made taller for the Eyes row, so the row sits over whatever is under the beard row.");
			}
			return true;
		}

		private static bool MakeRoom(RectTransform beard, Row row)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_021d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0248: Expected O, but got Unknown
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0309: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: 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_0340: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Expected O, but got Unknown
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_044c: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0488: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Transform)beard).parent;
			RectTransform val = (RectTransform)(object)((parent is RectTransform) ? parent : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			Rect rect;
			float num;
			if (!(Mathf.Abs(row.Step.y) > 1f))
			{
				rect = beard.rect;
				num = ((Rect)(ref rect)).height;
			}
			else
			{
				num = Mathf.Abs(row.Step.y);
			}
			float num2 = num;
			if (num2 < 1f)
			{
				return false;
			}
			Vector3 val2 = -((Transform)val).up * (num2 * ((Transform)val).lossyScale.y);
			List<RectTransform> list = new List<RectTransform> { val };
			if ((Object)(object)((Component)val).GetComponent<Graphic>() == (