Decompiled source of TextureMod v2.2.7

plugins/TextureMod/TextureMod.dll

Decompiled 11 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using Abilities;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameplayEntities;
using HarmonyLib;
using LLBML;
using LLBML.GameEvents;
using LLBML.Math;
using LLBML.Messages;
using LLBML.Networking;
using LLBML.Players;
using LLBML.States;
using LLBML.Texture;
using LLBML.Utils;
using LLGUI;
using LLHandlers;
using LLScreen;
using Multiplayer;
using TextureMod.CustomSkins;
using TextureMod.Effects;
using TextureMod.Showcase;
using TextureMod.TMPlayer;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c2070354-d05f-4ed9-b31f-ad07edbbb360")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyTitle("TextureMod (no.mrgentle.plugins.llb.texturemod)")]
[assembly: AssemblyProduct("TextureMod")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.7.0")]
[module: UnverifiableCode]
namespace TextureMod
{
	public static class CustomStyle
	{
		private static Dictionary<string, Texture2D> texColors = new Dictionary<string, Texture2D>();

		public static GUIStyle border = new GUIStyle
		{
			padding = new RectOffset(10, 10, 24, 10),
			fontSize = 136
		};

		public static GUIStyle mainStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Expected O, but got Unknown
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					padding = new RectOffset(4, 4, 4, 4)
				};
				val.normal.background = texColors["Black"];
				return val;
			}
		}

		public static GUIStyle labStyle
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_003e: Expected O, but got Unknown
				GUIStyle val = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					alignment = (TextAnchor)4
				};
				val.normal.textColor = new Color(1f, 0.968f, 0.3f);
				return val;
			}
		}

		public static GUIStyle windStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Expected O, but got Unknown
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: 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_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					padding = new RectOffset(4, 4, 4, 4),
					alignment = (TextAnchor)1,
					fontSize = 20,
					fontStyle = (FontStyle)1
				};
				val.normal.background = texColors["Black"];
				val.normal.textColor = new Color(1f, 1f, 1f);
				return val;
			}
		}

		public static GUIStyle button
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_0034: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				GUIStyle val = new GUIStyle(GUI.skin.button)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					padding = new RectOffset(4, 4, 4, 4)
				};
				val.normal.textColor = Color.black;
				val.hover.textColor = Color.black;
				val.active.textColor = Color.white;
				val.normal.background = texColors["Yellow"];
				val.hover.background = texColors["LightYellow"];
				return val;
			}
		}

		public static GUIStyle box
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_0034: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				GUIStyle val = new GUIStyle(GUI.skin.box)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					padding = new RectOffset(4, 4, 4, 4)
				};
				val.normal.textColor = Color.black;
				val.hover.textColor = Color.black;
				val.active.textColor = Color.white;
				val.normal.background = texColors["Yellow"];
				val.hover.background = texColors["Yellow"];
				return val;
			}
		}

		public static GUIStyle headerBox
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_0034: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				GUIStyle val = new GUIStyle(GUI.skin.box)
				{
					fontSize = 18,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					padding = new RectOffset(4, 4, 4, 4)
				};
				val.normal.textColor = Color.black;
				val.hover.textColor = Color.black;
				val.active.textColor = Color.white;
				val.normal.background = texColors["Yellow"];
				val.hover.background = texColors["Yellow"];
				return val;
			}
		}

		public static GUIStyle versionBox
		{
			get
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0017: Unknown result type (might be due to invalid IL or missing references)
				//IL_001e: 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_0034: Expected O, but got Unknown
				//IL_0034: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Expected O, but got Unknown
				GUIStyle val = new GUIStyle(GUI.skin.box)
				{
					fontSize = 15,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					padding = new RectOffset(4, 4, 4, 4)
				};
				val.normal.textColor = new Color(1f, 0.968f, 0.3f);
				val.hover.textColor = new Color(1f, 0.968f, 0.3f);
				val.active.textColor = new Color(1f, 0.968f, 0.3f);
				val.normal.background = texColors["Black"];
				val.hover.background = texColors["Black"];
				return val;
			}
		}

		public static GUIStyle _sliderThumbStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: 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_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_0061: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					fontSize = 24,
					fontStyle = (FontStyle)1,
					alignment = (TextAnchor)4,
					stretchHeight = true,
					fixedWidth = 40f
				};
				val.normal.background = texColors["Black"];
				val.hover.background = texColors["Black"];
				val.active.background = texColors["LightGray"];
				return val;
			}
		}

		public static GUIStyle _sliderBackgroundStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Expected O, but got Unknown
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0044: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: 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_0093: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					stretchWidth = true,
					padding = new RectOffset(2, 2, 2, 2),
					margin = new RectOffset(0, 0, 7, 0)
				};
				val.normal.background = texColors["Yellow"];
				val.hover.background = texColors["Yellow"];
				val.active.background = texColors["Yellow"];
				val.focused.background = texColors["Yellow"];
				return val;
			}
		}

		public static GUIStyle _textFieldStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_001c: Expected O, but got Unknown
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Expected O, but got Unknown
				//IL_002b: 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_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					fontSize = 16,
					padding = new RectOffset(4, 4, 4, 4),
					margin = new RectOffset(0, 0, 5, 0)
				};
				val.normal.textColor = new Color(1f, 0.968f, 0.3f);
				val.normal.background = texColors["Black"];
				return val;
			}
		}

		public static GUIStyle readStyle
		{
			get
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_0025: 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_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				GUIStyle val = new GUIStyle
				{
					alignment = (TextAnchor)3,
					fontSize = 16,
					margin = new RectOffset(25, 25, 0, 0),
					wordWrap = true
				};
				val.normal.textColor = Color.white;
				return val;
			}
		}

		public static void InitStyle()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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)
			texColors.Add("Yellow", ColorToTexture2D(Color32.op_Implicit(new Color(1f, 0.968f, 0.3f))));
			texColors.Add("LightYellow", ColorToTexture2D(Color32.op_Implicit(new Color(1f, 1f, 0.5f))));
			texColors.Add("DarkGray", ColorToTexture2D(Color32.op_Implicit(new Color(0.145f, 0.145f, 0.145f))));
			texColors.Add("LightGray", ColorToTexture2D(Color32.op_Implicit(new Color(0.5f, 0.5f, 0.5f))));
			texColors.Add("Black", ColorToTexture2D(new Color32((byte)12, (byte)12, (byte)12, (byte)100)));
			texColors.Add("White", ColorToTexture2D(new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue)));
		}

		private static Texture2D ColorToTexture2D(Color32 color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, Color32.op_Implicit(color));
			val.Apply();
			return val;
		}
	}
	public static class ExchangeClient
	{
		private enum TexModMessages
		{
			TEXMOD_SKINCHECK = 4040,
			TEXMOD_SKINNOTICE,
			TEXMOD_SKINREQUEST,
			TEXMOD_SKIN
		}

		private static int transactionIDCounter;

		private static ManualLogSource Logger => TextureMod.Log;

		public static void Init()
		{
			PluginInfo info = ((BaseUnityPlugin)TextureMod.Instance).Info;
			MessageApi.RegisterCustomMessage(info, (ushort)4042, TexModMessages.TEXMOD_SKINREQUEST.ToString(), (Action<Message>)ReceiveSkinRequest);
			MessageApi.RegisterCustomMessage(info, (ushort)4041, TexModMessages.TEXMOD_SKINNOTICE.ToString(), (Action<Message>)ReceiveSkinNotice);
			MessageApi.RegisterCustomMessage(info, (ushort)4043, TexModMessages.TEXMOD_SKIN.ToString(), (Action<Message>)ReceiveSkinFromMessage);
			PlayerLobbyState.RegisterPayload(info, (Func<PlayerLobbyState, byte[]>)OnSendPayload, (Action<PlayerLobbyState, byte[]>)OnReceivePayload);
			NetworkApi.RegisterModPacketCallback(info, (Action<Peer, byte[]>)OnReceiveModPacket);
		}

		public static byte[] OnSendPayload(PlayerLobbyState pls)
		{
			if (!TextureMod.sendSkinsToOpponents.Value)
			{
				return null;
			}
			TexModPlayer player = TexModPlayerManager.GetPlayer(pls.playerNr);
			TextureMod.Log.LogDebug((object)("Test: " + ((object)pls).ToString()));
			if (player.Player.isLocal)
			{
				if (player.HasCustomSkin())
				{
					List<byte> list = new List<byte>();
					byte[] array = (byte[])(Hash<CustomSkin>)player.CustomSkin.SkinHash;
					list.Add((byte)array.Length);
					list.AddRange(array);
					return list.ToArray();
				}
				return null;
			}
			return null;
		}

		public static void OnReceivePayload(PlayerLobbyState pls, byte[] payload)
		{
			BinaryReader binaryReader = new BinaryReader(new MemoryStream(payload));
			int num = binaryReader.ReadByte();
			if (num == 0)
			{
				return;
			}
			byte[] data = binaryReader.ReadBytes(num);
			if (!TextureMod.receiveSkinsFromOpponents.Value)
			{
				return;
			}
			try
			{
				SkinHash skinHash = new SkinHash(data);
				ProcessSkinHash(pls.playerNr, skinHash);
			}
			catch (Exception ex)
			{
				Logger.LogError((object)("Caught Exception trying to receive lobby state: " + ex));
			}
		}

		public static void SendSkinNotice(SkinHash skinHash)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			TextureMod.Log.LogDebug((object)("Sending skin notice for hash: " + (object)skinHash));
			P2P.SendOthers(new Message((Msg)4041, ((Peer)P2P.localPeer).playerNr, 0, (object)((Hash<CustomSkin>)skinHash).Bytes, ((Hash<CustomSkin>)skinHash).Bytes.Length));
		}

		public static void ReceiveSkinNotice(Message msg)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			if (TextureMod.receiveSkinsFromOpponents.Value && msg.playerNr != ((Peer)P2P.localPeer).playerNr)
			{
				SkinHash skinHash = new SkinHash((byte[])msg.ob);
				TextureMod.Log.LogDebug((object)("Received skin notice for hash: " + (object)skinHash));
				ProcessSkinHash(msg.playerNr, skinHash);
			}
		}

		private static void ProcessSkinHash(int fromNr, SkinHash skinHash)
		{
			TexModPlayer player = TexModPlayerManager.GetPlayer(fromNr);
			Logger.LogDebug((object)($"Player {player.Player.nr} has custom skin: " + (object)skinHash));
			CustomSkinHandler handlerFromHash = SkinsManager.skinCache.GetHandlerFromHash(skinHash);
			if (handlerFromHash != null)
			{
				Logger.LogDebug((object)"Skin is known, applying.");
				player.SetCustomSkin(handlerFromHash);
				GameStatesLobbyUtils.RefreshPlayerState(player.Player);
			}
			else
			{
				Logger.LogDebug((object)"Skin is not known, requesting.");
				SendSkinRequest(player.Player.nr, skinHash);
			}
		}

		public static void SendSkinRequest(int playerNrToRequest, SkinHash skinHash)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			TextureMod.Log.LogDebug((object)("Requesting skin with hash: " + (object)skinHash));
			NetworkApi.SendMessageToPlayer(playerNrToRequest, new Message((Msg)4042, ((Peer)P2P.localPeer).playerNr, transactionIDCounter++, (object)((Hash<CustomSkin>)skinHash).Bytes, ((Hash<CustomSkin>)skinHash).Bytes.Length));
		}

		public static void ReceiveSkinRequest(Message msg)
		{
			//IL_0000: 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_0054: 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)
			if (msg.playerNr != ((Peer)P2P.localPeer).playerNr)
			{
				SkinHash skinHash = new SkinHash((byte[])msg.ob);
				TextureMod.Log.LogDebug((object)("Received skin request for hash: " + (object)skinHash));
				CustomSkin skinFromHash = SkinsManager.skinCache.GetSkinFromHash(skinHash);
				if (skinFromHash != null)
				{
					SendSkin(msg.playerNr, msg.index, skinFromHash);
				}
			}
		}

		public static void SendSkin(int playerNrToSendSkin, int requestID, CustomSkin skin)
		{
			TextureMod.Log.LogDebug((object)$"Sending skin {skin.Name} to player {playerNrToSendSkin}");
			byte[] array = skin.ToBytes();
			NetworkApi.SendModPacket(((BaseUnityPlugin)TextureMod.Instance).Info, Player.GetPlayer(playerNrToSendSkin), array);
		}

		public static void OnReceiveModPacket(Peer sender, byte[] data)
		{
			ReceiveSkin(Player.GetPlayer(sender.playerNr), CustomSkin.FromBytes(data));
		}

		public static void ReceiveSkinFromMessage(Message msg)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			ReceiveSkin(Player.GetPlayer(msg.playerNr), CustomSkin.FromBytes((byte[])msg.ob));
		}

		public static void ReceiveSkin(Player sender, CustomSkin receivedSkin)
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			TextureMod.Log.LogDebug((object)string.Format("Received skin from player {0}, is it null? {1}", sender.nr, (receivedSkin == null) ? "Yes" : "No"));
			if (receivedSkin != null)
			{
				TextureMod.Log.LogDebug((object)$"Successfuly received {receivedSkin.Name} from player {sender.nr}");
				CustomSkinHandler customSkinHandler = new CustomSkinHandler(receivedSkin)
				{
					IsRemote = true
				};
				((GenericCache<Character, CustomSkinHandler>)SkinsManager.skinCache).Add(customSkinHandler.CustomSkin.Character, customSkinHandler);
				TexModPlayerManager.Instance.tmPlayers[sender.nr].SetCustomSkin(customSkinHandler);
			}
		}
	}
	public class ModDebugging : MonoBehaviour
	{
		public Dictionary<string, Dictionary<string, string>> windows = new Dictionary<string, Dictionary<string, string>>();

		public Dictionary<string, Rect> windowRects = new Dictionary<string, Rect>();

		public bool showHud = true;

		public List<bool> enabledWindows = new List<bool>();

		public Rect windowSelectionWindowRect = new Rect(10f, 10f, 100f, 100f);

		private void OnGUI()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0065: 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_012d: Expected O, but got Unknown
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_018c: Expected O, but got Unknown
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fd: 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_0320: Expected O, but got Unknown
			//IL_031b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			if (!TextureMod.showDebugInfo.Value)
			{
				return;
			}
			GUIStyle window = new GUIStyle(GUIStyle.op_Implicit("Box"));
			GUI.skin.window = window;
			GUI.skin.window.fontSize = 20;
			GUI.skin.window.padding.top = 35;
			GUI.skin.window.contentOffset = new Vector2(0f, -25f);
			GUI.skin.window.alignment = (TextAnchor)1;
			if (enabledWindows.Count < windows.Count)
			{
				do
				{
					enabledWindows.Add(item: false);
					Debug.Log((object)"did it");
				}
				while (enabledWindows.Count < windows.Count);
			}
			int num = -1;
			string text = "";
			foreach (KeyValuePair<string, Dictionary<string, string>> window2 in windows)
			{
				string text2 = window2.Key + ": ";
				if (text2.Length > num)
				{
					num = text2.Length;
					text = text2;
				}
			}
			GUIContent val = new GUIContent(text);
			if (showHud)
			{
				windowSelectionWindowRect = GUILayout.Window(909089, new Rect(0f, 0f, GUI.skin.window.CalcSize(val).x + 100f, ((Rect)(ref windowSelectionWindowRect)).height), new WindowFunction(WindowSelectionWindow), "Debug Windows (Shift + D)", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			int num2 = 909090;
			foreach (KeyValuePair<string, Dictionary<string, string>> window3 in windows)
			{
				if (enabledWindows[num2 - 909090])
				{
					int num3 = -1;
					string text3 = "";
					foreach (KeyValuePair<string, string> item in window3.Value)
					{
						string text4 = item.Key + " = " + item.Value;
						if (text4.Length > num3)
						{
							num3 = text4.Length;
							text3 = text4;
						}
					}
					GUIContent val2 = new GUIContent(text3);
					if (!windowRects.ContainsKey(window3.Key))
					{
						windowRects.Add(window3.Key, new Rect(0f, 0f, 100f, 20f));
					}
					Dictionary<string, Rect> dictionary = windowRects;
					string key = window3.Key;
					int num4 = num2;
					Rect val3 = windowRects[window3.Key];
					float x = ((Rect)(ref val3)).x;
					val3 = windowRects[window3.Key];
					float y = ((Rect)(ref val3)).y;
					float num5 = GUI.skin.window.CalcSize(val2).x + 50f;
					val3 = windowRects[window3.Key];
					dictionary[key] = GUILayout.Window(num4, new Rect(x, y, num5, ((Rect)(ref val3)).height), new WindowFunction(DebugWindow), window3.Key, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				}
				num2++;
			}
		}

		private void Update()
		{
			if ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) && Input.GetKeyDown((KeyCode)100))
			{
				showHud = !showHud;
			}
		}

		private void WindowSelectionWindow(int _windowId)
		{
			GUI.skin.label.fontSize = 16;
			GUI.skin.label.alignment = (TextAnchor)3;
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			int num = 0;
			if (windows.Count > 0)
			{
				foreach (KeyValuePair<string, Dictionary<string, string>> window in windows)
				{
					GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
					GUILayout.FlexibleSpace();
					GUILayout.Label(window.Key + ": ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
					if (GUILayout.Button(enabledWindows[num].ToString(), (GUILayoutOption[])(object)new GUILayoutOption[0]))
					{
						enabledWindows[num] = !enabledWindows[num];
					}
					GUILayout.FlexibleSpace();
					GUILayout.EndHorizontal();
					num++;
				}
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
		}

		private void DebugWindow(int _windowId)
		{
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			Dictionary<string, string> value = windows.ElementAt(_windowId - 909090).Value;
			GUI.skin.label.fontSize = 16;
			GUI.skin.label.alignment = (TextAnchor)3;
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			foreach (KeyValuePair<string, string> item in value)
			{
				GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(item.Key + " = " + item.Value, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.EndHorizontal();
			}
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 10000f));
		}

		public void AddToWindow(string windowName, string varName, string varValue)
		{
			if (windows.ContainsKey(windowName))
			{
				if (windows[windowName].ContainsKey(varName))
				{
					windows[windowName][varName] = varValue;
				}
				else
				{
					windows[windowName].Add(varName, varValue);
				}
			}
			else
			{
				windows.Add(windowName, new Dictionary<string, string>());
				windows[windowName].Add(varName, varValue);
			}
		}

		private Texture2D ColorToTexture2D(Color color)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			Texture2D val = new Texture2D(1, 1, (TextureFormat)4, false);
			val.SetPixel(0, 0, color);
			val.Apply();
			return val;
		}
	}
	public class SmoothMouseLook : MonoBehaviour
	{
		public enum RotationAxes
		{
			MouseXAndY,
			MouseX,
			MouseY
		}

		public float speed = 3f;

		private Vector3 moveDirection = Vector3.zero;

		public Vector3 movementMultiplier;

		public RotationAxes axes;

		public float sensitivityX = 1f;

		public float sensitivityY = 1f;

		public float minimumX = -360f;

		public float maximumX = 360f;

		public float minimumY = -60f;

		public float maximumY = 60f;

		private float rotationX;

		private float rotationY;

		private List<float> rotArrayX = new List<float>();

		private float rotAverageX;

		private List<float> rotArrayY = new List<float>();

		private float rotAverageY;

		public float frameCounter = 20f;

		private Quaternion originalRotation;

		public bool isActive;

		private void Update()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: 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_0551: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0462: Unknown result type (might be due to invalid IL or missing references)
			//IL_046b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_034d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			if (!isActive)
			{
				return;
			}
			moveDirection = new Vector3(movementMultiplier.x, movementMultiplier.y, movementMultiplier.z);
			moveDirection = ((Component)this).transform.TransformDirection(moveDirection);
			moveDirection *= speed;
			movementMultiplier.x = 0f;
			movementMultiplier.z = 0f;
			movementMultiplier.y = 0f;
			if (Input.GetKey((KeyCode)100))
			{
				movementMultiplier.x += 1f;
				movementMultiplier.z += 0f;
			}
			if (Input.GetKey((KeyCode)97))
			{
				movementMultiplier.x += -1f;
				movementMultiplier.z += 0f;
			}
			if (Input.GetKey((KeyCode)115))
			{
				movementMultiplier.x += 0f;
				movementMultiplier.z += -1f;
			}
			if (Input.GetKey((KeyCode)119))
			{
				movementMultiplier.x += 0f;
				movementMultiplier.z += 1f;
			}
			if (Input.GetKey((KeyCode)113))
			{
				movementMultiplier.y += 0.5f;
			}
			if (Input.GetKey((KeyCode)101))
			{
				movementMultiplier.y -= 0.5f;
			}
			Transform transform = ((Component)this).transform;
			transform.position += moveDirection * Time.deltaTime;
			if (axes == RotationAxes.MouseXAndY)
			{
				rotAverageY = 0f;
				rotAverageX = 0f;
				rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
				rotationX += Input.GetAxis("Mouse X") * sensitivityX;
				rotArrayY.Add(rotationY);
				rotArrayX.Add(rotationX);
				if ((float)rotArrayY.Count >= frameCounter)
				{
					rotArrayY.RemoveAt(0);
				}
				if ((float)rotArrayX.Count >= frameCounter)
				{
					rotArrayX.RemoveAt(0);
				}
				for (int i = 0; i < rotArrayY.Count; i++)
				{
					rotAverageY += rotArrayY[i];
				}
				for (int j = 0; j < rotArrayX.Count; j++)
				{
					rotAverageX += rotArrayX[j];
				}
				rotAverageY /= rotArrayY.Count;
				rotAverageX /= rotArrayX.Count;
				rotAverageY = ClampAngle(rotAverageY, minimumY, maximumY);
				rotAverageX = ClampAngle(rotAverageX, minimumX, maximumX);
				Quaternion val = Quaternion.AngleAxis(rotAverageY, Vector3.left);
				Quaternion val2 = Quaternion.AngleAxis(rotAverageX, Vector3.up);
				((Component)this).transform.localRotation = originalRotation * val2 * val;
			}
			else if (axes == RotationAxes.MouseX)
			{
				rotAverageX = 0f;
				rotationX += Input.GetAxis("Mouse X") * sensitivityX;
				rotArrayX.Add(rotationX);
				if ((float)rotArrayX.Count >= frameCounter)
				{
					rotArrayX.RemoveAt(0);
				}
				for (int k = 0; k < rotArrayX.Count; k++)
				{
					rotAverageX += rotArrayX[k];
				}
				rotAverageX /= rotArrayX.Count;
				rotAverageX = ClampAngle(rotAverageX, minimumX, maximumX);
				Quaternion val3 = Quaternion.AngleAxis(rotAverageX, Vector3.up);
				((Component)this).transform.localRotation = originalRotation * val3;
			}
			else
			{
				rotAverageY = 0f;
				rotationY += Input.GetAxis("Mouse Y") * sensitivityY;
				rotArrayY.Add(rotationY);
				if ((float)rotArrayY.Count >= frameCounter)
				{
					rotArrayY.RemoveAt(0);
				}
				for (int l = 0; l < rotArrayY.Count; l++)
				{
					rotAverageY += rotArrayY[l];
				}
				rotAverageY /= rotArrayY.Count;
				rotAverageY = ClampAngle(rotAverageY, minimumY, maximumY);
				Quaternion val4 = Quaternion.AngleAxis(rotAverageY, Vector3.left);
				((Component)this).transform.localRotation = originalRotation * val4;
			}
		}

		private void Start()
		{
			//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)
			Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				component.freezeRotation = true;
			}
			originalRotation = ((Component)this).transform.localRotation;
		}

		public static float ClampAngle(float angle, float min, float max)
		{
			angle %= 360f;
			if (angle >= -360f && angle <= 360f)
			{
				if (angle < -360f)
				{
					angle += 360f;
				}
				if (angle > 360f)
				{
					angle -= 360f;
				}
			}
			return Mathf.Clamp(angle, min, max);
		}
	}
	[BepInPlugin("no.mrgentle.plugins.llb.texturemod", "TextureMod", "2.2.7")]
	[BepInProcess("LLBlaze.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class TextureMod : BaseUnityPlugin
	{
		private const string modVersion = "2.2.7";

		private const string repositoryOwner = "Daioutzu";

		private const string repositoryName = "LLBMM-TextureMod";

		public TexModPlayerManager tmpl;

		public SkinsManager sm;

		public ModDebugging md;

		public EffectChanger effectChanger;

		public ShowcaseStudio showcaseStudio;

		public static string loadingText = "TextureMod is loading External Textures...";

		public static ConfigEntry<KeyCode> holdKey1;

		public static ConfigEntry<KeyCode> nextSkin;

		public static ConfigEntry<KeyCode> previousSkin;

		public static ConfigEntry<KeyCode> cancelKey;

		public static ConfigEntry<KeyCode> reloadCustomSkin;

		public static ConfigEntry<KeyCode> reloadEntireSkinLibrary;

		public static ConfigEntry<bool> useOnlySetKey;

		public static ConfigEntry<bool> sendSkinsToOpponents;

		public static ConfigEntry<bool> receiveSkinsFromOpponents;

		public static ConfigEntry<bool> showDebugInfo;

		public static ConfigEntry<bool> randomSkinOnRandomSelect;

		public static ConfigEntry<bool> reloadCustomSkinOnInterval;

		public static ConfigEntry<int> skinReloadIntervalInFrames;

		public static ConfigEntry<bool> assignFirstSkinOnCharacterSelection;

		public static TextureMod Instance { get; private set; } = null;


		public static ManualLogSource Log { get; private set; } = null;


		public static string ResourceFolder { get; private set; }

		public static DirectoryInfo ModdingFolder { get; private set; }

		internal static bool IsSkinKeyDown()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			return Input.GetKey(holdKey1.Value);
		}

		public void Awake()
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Hello, World!");
			ResourceFolder = Utility.CombinePaths(new string[2]
			{
				Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location),
				"TextureModResources"
			});
			ModdingFolder = ModdingFolder.GetModSubFolder(((BaseUnityPlugin)this).Info);
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			InitConfig();
			Harmony val = new Harmony("no.mrgentle.plugins.llb.texturemod");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Patching SkinSelect_Patches");
			val.PatchAll(typeof(SkinSelect_Patches));
		}

		private void Start()
		{
			SkinsManager.LoadLibrary();
			EffectsHandler.Init();
			ExchangeClient.Init();
			ModDependenciesUtils.RegisterToModMenu(((BaseUnityPlugin)this).Info, new List<string> { "Wondering how to assign skins and in what part of the game you can do so?", "Simply hold the 'Enable Skin Changer' button and press either the `Next skin` or the `Previous Skin` buttons to cycle skins", "Skins can be assigned in Ranked Lobbies, 1v1 Lobbies, FFA Lobbies(Only for player 1 and 2) and in the skin unlock screen for a character or in ShowcaseStudio", "If you select random in the lobby and try to assign a custom skin you will be given a random character and random skin. In online lobbies you will be set to ready, and your buttons will become unavailable unless you've deactivated 'Lock Buttons On Random'", " ", "If you wish to real time edit your skins, use the F5 button to reload your skin whenever you're in training mode or in the character skin unlock screen", "You can also enable the interval mode and have it automatically reload the current custom skin every so often. Great for dual screen, or windowed mode setups (Does not work in training mode)", "This mod was written by MrGentle" });
			tmpl = ((Component)this).gameObject.AddComponent<TexModPlayerManager>();
			sm = ((Component)this).gameObject.AddComponent<SkinsManager>();
		}

		private void Update()
		{
			if ((Object)(object)md == (Object)null)
			{
				md = ((Component)this).gameObject.AddComponent<ModDebugging>();
			}
			if ((Object)(object)effectChanger == (Object)null)
			{
				effectChanger = ((Component)this).gameObject.AddComponent<EffectChanger>();
			}
			if ((Object)(object)showcaseStudio == (Object)null)
			{
				showcaseStudio = ((Component)this).gameObject.AddComponent<ShowcaseStudio>();
			}
		}

		private void OnGUI()
		{
		}

		private void InitConfig()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: 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
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Expected O, but got Unknown
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Expected O, but got Unknown
			ConfigFile config = ((BaseUnityPlugin)Instance).Config;
			config.Bind<string>("TextureChanger", "lobby_settings_header", "Lobby Settings:", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
			holdKey1 = config.Bind<KeyCode>("TextureChanger", "holdKey1", (KeyCode)304, (ConfigDescription)null);
			nextSkin = config.Bind<KeyCode>("TextureChanger", "nextSkin", (KeyCode)323, (ConfigDescription)null);
			previousSkin = config.Bind<KeyCode>("TextureChanger", "previousSkin", (KeyCode)324, (ConfigDescription)null);
			cancelKey = config.Bind<KeyCode>("TextureChanger", "cancelKey", (KeyCode)97, (ConfigDescription)null);
			useOnlySetKey = config.Bind<bool>("TextureChanger", "useOnlySetKey", false, (ConfigDescription)null);
			sendSkinsToOpponents = config.Bind<bool>("TextureChanger", "sendSkinsToOpponents", true, (ConfigDescription)null);
			receiveSkinsFromOpponents = config.Bind<bool>("TextureChanger", "receiveSkinsFromOpponents", true, (ConfigDescription)null);
			randomSkinOnRandomSelect = config.Bind<bool>("TextureChanger", "randomSkinOnRandomSelect", true, (ConfigDescription)null);
			assignFirstSkinOnCharacterSelection = config.Bind<bool>("TextureChanger", "assignFirstSkinOnCharacterSelection", false, (ConfigDescription)null);
			config.Bind<int>("TextureChanger", "gap1", 20, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_gap" }));
			config.Bind<string>("TextureChanger", "rt_skin_edit_header", "Real-time Skin editing:", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
			reloadCustomSkin = config.Bind<KeyCode>("TextureChanger", "reloadCustomSkin", (KeyCode)286, (ConfigDescription)null);
			reloadEntireSkinLibrary = config.Bind<KeyCode>("TextureChanger", "reloadEntireSkinLibrary", (KeyCode)290, (ConfigDescription)null);
			reloadCustomSkinOnInterval = config.Bind<bool>("TextureChanger", "reloadCustomSkinOnInterval", false, (ConfigDescription)null);
			skinReloadIntervalInFrames = config.Bind<int>("TextureChanger", "skinReloadIntervalInFrames", 60, (ConfigDescription)null);
			config.Bind<int>("TextureChanger", "gap2", 20, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_gap" }));
			config.Bind<string>("TextureChanger", "general_header", "General:", new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_header" }));
			showDebugInfo = config.Bind<bool>("TextureChanger", "showDebugInfo", false, (ConfigDescription)null);
			config.Bind<int>("TextureChanger", "gap3", 20, new ConfigDescription("", (AcceptableValueBase)null, new object[1] { "modmenu_gap" }));
		}
	}
	internal static class PluginInfos
	{
		public const string PLUGIN_NAME = "TextureMod";

		public const string PLUGIN_ID = "no.mrgentle.plugins.llb.texturemod";

		public const string PLUGIN_VERSION = "2.2.7";
	}
	public static class VariantHelper
	{
		public static List<CharacterVariant> DefaultModelVariants = new List<CharacterVariant>
		{
			(CharacterVariant)0,
			(CharacterVariant)1,
			(CharacterVariant)2,
			(CharacterVariant)3,
			(CharacterVariant)4,
			(CharacterVariant)5,
			(CharacterVariant)6,
			(CharacterVariant)7,
			(CharacterVariant)8
		};

		public static List<CharacterVariant> AltModelVariants = new List<CharacterVariant>
		{
			(CharacterVariant)9,
			(CharacterVariant)10
		};

		public static List<CharacterVariant> DLCModelVariants = new List<CharacterVariant>
		{
			(CharacterVariant)11,
			(CharacterVariant)12
		};

		public static bool VariantMatch(CharacterVariant characterVariant, ModelVariant modelVariant)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Invalid comparison between Unknown and I4
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Invalid comparison between Unknown and I4
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Invalid comparison between Unknown and I4
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			switch (modelVariant)
			{
			case ModelVariant.Default:
				return (int)characterVariant < 8;
			case ModelVariant.Alternative:
				if ((int)characterVariant != 9)
				{
					return (int)characterVariant == 10;
				}
				return true;
			case ModelVariant.DLC:
				if ((int)characterVariant != 11)
				{
					return (int)characterVariant == 12;
				}
				return true;
			default:
				return false;
			}
		}

		public static ModelVariant GetModelVariantFromFilePath(string path)
		{
			string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(path);
			if (fileNameWithoutExtension.Contains("_ALT2"))
			{
				return ModelVariant.DLC;
			}
			if (fileNameWithoutExtension.Contains("_ALT"))
			{
				return ModelVariant.Alternative;
			}
			return ModelVariant.Default;
		}

		public static ModelVariant GetModelVariant(CharacterVariant characterVariant)
		{
			//IL_0005: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			if (DefaultModelVariants.Contains(characterVariant))
			{
				return ModelVariant.Default;
			}
			if (AltModelVariants.Contains(characterVariant))
			{
				return ModelVariant.Alternative;
			}
			if (DLCModelVariants.Contains(characterVariant))
			{
				return ModelVariant.DLC;
			}
			return ModelVariant.None;
		}

		public static CharacterVariant GetDefaultVariantForModel(ModelVariant variantType)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			return (CharacterVariant)(variantType switch
			{
				ModelVariant.Default => DefaultModelVariants[0], 
				ModelVariant.Alternative => AltModelVariants[0], 
				ModelVariant.DLC => DLCModelVariants[0], 
				_ => 0, 
			});
		}

		public static List<CharacterVariant> GetVariantsForModel(ModelVariant variantType)
		{
			return variantType switch
			{
				ModelVariant.Default => DefaultModelVariants, 
				ModelVariant.Alternative => AltModelVariants, 
				ModelVariant.DLC => DLCModelVariants, 
				_ => null, 
			};
		}

		public static CharacterVariant GetNextVariantForModel(ModelVariant variantType, CharacterVariant characterVariant)
		{
			//IL_0007: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			List<CharacterVariant> variantsForModel = GetVariantsForModel(variantType);
			if (VariantMatch(characterVariant, variantType))
			{
				int num = variantsForModel.IndexOf(characterVariant);
				return variantsForModel[(num + 1) % variantsForModel.Count];
			}
			return (CharacterVariant)8;
		}
	}
	public enum ModelVariant
	{
		None,
		Default,
		Alternative,
		DLC
	}
	public static class RendererHelper
	{
		public static void AssignTextureToHud(Texture2D texture, PlayerEntity playerEntity)
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			ScreenBase obj = ScreenApi.CurrentScreens[0];
			ScreenGameHud val = (ScreenGameHud)(object)((obj is ScreenGameHud) ? obj : null);
			if (val != null)
			{
				Player val2 = Player.op_Implicit(((AbilityEntity)playerEntity).player);
				Renderer[] componentsInChildren = ((Component)((Component)val.playerInfos[val2.nr]).gameObject.transform).GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					AssignTextureToRenderer(componentsInChildren[i], texture, ((MovableEntity)playerEntity).character, ((MovableEntity)playerEntity).variant);
				}
			}
		}

		public static void AssignTextureToIngameCharacter(PlayerEntity playerEntity, Texture2D texture)
		{
			//IL_0017: 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_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Invalid comparison between Unknown and I4
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			foreach (Renderer skinRenderer in ((VisualEntity)playerEntity).skinRenderers)
			{
				AssignTextureToRenderer(skinRenderer, texture, ((MovableEntity)playerEntity).character, ((MovableEntity)playerEntity).variant);
			}
			if ((int)((MovableEntity)playerEntity).character == 10)
			{
				EffectsHandler.AssignToxicEffectColors(((AbilityEntity)playerEntity).player.CJFLMDNNMIE, texture, ((MovableEntity)playerEntity).variant);
			}
		}

		public static void AssignSkinToWinnerModel(PostScreen postScreen, PlayerEntity playerEntity, Texture2D texture)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			AssignTextureToCharacterModelRenderers(postScreen.winnerModel, ((MovableEntity)playerEntity).character, ((MovableEntity)playerEntity).variant, texture);
		}

		public static void AssignTextureToPostGameHud(PostScreen postScreen, Texture2D texture, int playerNr)
		{
			//IL_0028: 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)
			Player player = Player.GetPlayer(playerNr);
			Renderer[] componentsInChildren = ((Component)((Component)postScreen.playerBarsByPlayer[playerNr]).gameObject.transform).GetComponentsInChildren<Renderer>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				AssignTextureToRenderer(componentsInChildren[i], texture, player.Character, player.CharacterVariant);
			}
		}

		public static void AssignTextureToCharacterModelRenderers(CharacterModel model, Character character, CharacterVariant variant, Texture2D texture)
		{
			//IL_002a: 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)
			GameObject curModel = model.curModel;
			Renderer[] array = (Renderer[])(((object)((curModel != null) ? ((Component)curModel.transform).GetComponentsInChildren<Renderer>() : null)) ?? ((object)new Renderer[0]));
			for (int i = 0; i < array.Length; i++)
			{
				AssignTextureToRenderer(array[i], texture, character, variant);
			}
		}

		public static void AssignTextureToRenderer(Renderer r, Texture2D texture, Character character, CharacterVariant characterVariant)
		{
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Invalid comparison between Unknown and I4
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Invalid comparison between Unknown and I4
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Invalid comparison between Unknown and I4
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Invalid comparison between Unknown and I4
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Invalid comparison between Unknown and I4
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Invalid comparison between Unknown and I4
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Invalid comparison between Unknown and I4
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Invalid comparison between Unknown and I4
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Invalid comparison between Unknown and I4
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Invalid comparison between Unknown and I4
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Invalid comparison between Unknown and I4
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Invalid comparison between Unknown and I4
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Invalid comparison between Unknown and I4
			//IL_0056: 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_0059: Invalid comparison between Unknown and I4
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Invalid comparison between Unknown and I4
			//IL_013b: 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_0139: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)((Component)r).gameObject).name.EndsWith("Outline"))
			{
				Texture mainTexture = r.material.mainTexture;
				string text = ((mainTexture != null) ? ((Object)mainTexture).name : null) ?? "";
				if ((int)characterVariant == 8 && ((Object)r.material).name.Contains("ScreenSpaceNoise"))
				{
					? val = character;
					int num;
					if ((int)characterVariant == 8)
					{
						num = 0;
						val = num;
						num = (int)val;
					}
					else
					{
						val = characterVariant;
						num = (int)val;
					}
					AOOJOMIECLD val2 = JPLELOFJOOH.NEBGBODHHCG((Character)num, (CharacterVariant)val);
					r.material = ((AOOJOMIECLD)(ref val2)).DMAMFHLFOJF(0, false);
				}
				if (!text.Contains("Silhouett") && text != "")
				{
					foreach (string item in from texName in r.material.GetTexturePropertyNames()
						where EffectsHandler.validMainTexNames.Contains(texName)
						select texName)
					{
						r.material.SetTexture(item, (Texture)(object)texture);
					}
				}
			}
			if ((int)character == 10)
			{
				if ((int)characterVariant == 11 || (int)characterVariant == 12)
				{
					EffectsHandler.AssignNurseToxicCanisters(r, texture);
				}
			}
			else if ((int)character == 9)
			{
				if ((int)characterVariant == 9 || (int)characterVariant == 10)
				{
					EffectsHandler.AssignJetScubaVisor(r, texture);
				}
			}
			else if ((int)character == 6)
			{
				if ((int)characterVariant == 9 || (int)characterVariant == 10)
				{
					EffectsHandler.AssignOmegaDoomboxSmearsAndArms(r, texture);
				}
				else if ((int)characterVariant == 11 || (int)characterVariant == 12)
				{
					EffectsHandler.AssignVisualizer(character, r, texture);
				}
			}
			else if ((int)character == 11)
			{
				EffectsHandler.AssignAshesOutlineColor(r, characterVariant, texture);
			}
			else if ((int)character == 3 && ((int)characterVariant == 11 || (int)characterVariant == 12))
			{
				EffectsHandler.AssignVisualizer(character, r, texture);
			}
		}
	}
	public static class SkinSelect_Patches
	{
		[HarmonyPatch(typeof(OGKPCMDOMPF), "ProcessMsg")]
		[HarmonyPrefix]
		public static bool GameStatesUnlocks_ProcessMsh_Prefix(JOFJHDJHJGI OHBPPCEFBHI, Message EIMJOIEPMNA)
		{
			if (!TextureMod.IsSkinKeyDown())
			{
				ShowcaseStudio.Instance.SetCustomSkin(null);
			}
			return true;
		}

		[HarmonyPatch(typeof(PlayersSelection), "<Init>m__4")]
		[HarmonyPrefix]
		public static bool BtSkin_OnClick_Prefix(int pNr)
		{
			if (!TextureMod.IsSkinKeyDown())
			{
				ClearSkinFor(pNr);
				return true;
			}
			NextSkinFor(pNr, (Character)101);
			return false;
		}

		[HarmonyPatch(typeof(PlayersCharacterButton), "<Init>m__0")]
		[HarmonyPrefix]
		public static bool BtCharacter_OnClick_Prefix(int pNr, PlayersCharacterButton __instance)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (!TextureMod.IsSkinKeyDown())
			{
				ClearSkinFor(pNr);
				return true;
			}
			NextSkinFor(pNr, __instance.character);
			return false;
		}

		[HarmonyPatch(typeof(ScreenPlayers), "<DoUpdate>m__5")]
		[HarmonyPrefix]
		public static bool Player_ForEach_Prefix(ALDOKEMAOMB p, ScreenPlayers __instance)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00cd: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			Player val = Player.op_Implicit(p);
			int nr = val.nr;
			Controller controller;
			if (!TextureMod.IsSkinKeyDown())
			{
				controller = val.controller;
				if (!((Controller)(ref controller)).GetButtonDown(InputAction.SHLEFT))
				{
					controller = val.controller;
					if (!((Controller)(ref controller)).GetButtonDown(InputAction.SHRIGHT))
					{
						goto IL_0045;
					}
				}
				ClearSkinFor(nr);
				goto IL_0045;
			}
			controller = val.controller;
			if (((Controller)(ref controller)).GetButtonDown(InputAction.SHLEFT) || (val.nr == Player.LocalPlayerNumber && Input.GetKeyDown(TextureMod.previousSkin.Value)))
			{
				PreviousSkinFor(nr, (Character)101);
			}
			controller = val.controller;
			if (((Controller)(ref controller)).GetButtonDown(InputAction.SHRIGHT) || (val.nr == Player.LocalPlayerNumber && Input.GetKeyDown(TextureMod.nextSkin.Value)))
			{
				NextSkinFor(nr, (Character)101);
			}
			if (CGLLJHHAJAK.GIGAKBJGFDI.hasMouseKeyboard)
			{
				controller = val.controller;
				if (((Controller)(ref controller)).IncludesMouse())
				{
					if (Input.mouseScrollDelta.y > 0.8f)
					{
						PreviousSkinFor(nr, (Character)101);
					}
					if (Input.mouseScrollDelta.y < -0.8f)
					{
						NextSkinFor(nr, (Character)101);
					}
				}
			}
			return false;
			IL_0045:
			if (CGLLJHHAJAK.GIGAKBJGFDI.hasMouseKeyboard)
			{
				controller = val.controller;
				if (((Controller)(ref controller)).IncludesMouse())
				{
					if (Input.mouseScrollDelta.y > 0.8f)
					{
						ClearSkinFor(nr);
					}
					if (Input.mouseScrollDelta.y < -0.8f)
					{
						ClearSkinFor(nr);
					}
				}
			}
			return true;
		}

		public static void ClearSkinFor(int nr)
		{
			int num = ((nr != -1) ? nr : Player.GetLocalPlayer().nr);
			TexModPlayer player = TexModPlayerManager.GetPlayer(num);
			if (player?.Player != null && player.Player.selected && player is LocalTexModPlayer localTexModPlayer)
			{
				TextureMod.Log.LogDebug((object)$"Removing skin from player {num}");
				localTexModPlayer.RemoveCustomSkin();
			}
		}

		public static void NextSkinFor(int nr, Character character = 101)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			int num = ((nr != -1) ? nr : Player.GetLocalPlayer().nr);
			TexModPlayer player = TexModPlayerManager.GetPlayer(num);
			if (player?.Player != null && player.Player.selected && player is LocalTexModPlayer localTexModPlayer)
			{
				TextureMod.Log.LogDebug((object)$"Selecting new skin for player {num}, next");
				localTexModPlayer.NextSkin(character);
			}
		}

		public static void PreviousSkinFor(int nr, Character character = 101)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			int num = ((nr != -1) ? nr : Player.GetLocalPlayer().nr);
			TexModPlayer player = TexModPlayerManager.GetPlayer(num);
			if (player?.Player != null && player.Player.selected && player is LocalTexModPlayer localTexModPlayer)
			{
				TextureMod.Log.LogDebug((object)$"Selecting new skin for player {num}, previous");
				localTexModPlayer.PreviousSkin(character);
			}
		}
	}
	public static class RandomSkinSelect_Patches
	{
	}
	public class ModelHandler
	{
		public readonly Character character;

		public readonly CharacterVariant variant;

		private List<CharacterModel> models = new List<CharacterModel>();

		public Texture2D texture;

		public ScreenType type;

		private ManualLogSource Logger => TextureMod.Log;

		public List<Renderer> Renderers { get; private set; } = new List<Renderer>();


		public ModelHandler(Character character, CharacterVariant variant, ScreenType type = 0)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			this.character = character;
			this.variant = variant;
			this.type = type;
		}

		public void Add(IEnumerable<Renderer> renderers)
		{
			Renderers.AddRange(renderers);
		}

		public void Add(Func<IEnumerable<Renderer>> renderersCallback)
		{
			((MonoBehaviour)TextureMod.Instance).StartCoroutine(WaitForRenderers(renderersCallback));
		}

		public void Add(CharacterModel model)
		{
			models.Add(model);
			((MonoBehaviour)TextureMod.Instance).StartCoroutine(WaitForRenderers(model));
		}

		public IEnumerator WaitForRenderers(CharacterModel model)
		{
			return WaitForRenderers((Func<IEnumerable<Renderer>>)delegate
			{
				CharacterModel obj = model;
				if (obj == null)
				{
					return null;
				}
				GameObject curModel = obj.curModel;
				if (curModel == null)
				{
					return null;
				}
				Transform transform = curModel.transform;
				return (transform == null) ? null : ((Component)transform).GetComponentsInChildren<Renderer>();
			});
		}

		public IEnumerator WaitForRenderers(Func<IEnumerable<Renderer>> renderersCallback)
		{
			IEnumerable<Renderer> rs = null;
			yield return (object)new WaitUntil((Func<bool>)delegate
			{
				if (IsObsolete())
				{
					return true;
				}
				rs = renderersCallback();
				if (rs != null)
				{
					foreach (Renderer item in rs)
					{
						if (item.enabled && item.isVisible)
						{
							return true;
						}
					}
				}
				return false;
			});
			Renderers.AddRange(rs);
		}

		public void Update()
		{
			//IL_006e: 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)
			if (GameStates.IsInLobby())
			{
				models.ForEach(delegate(CharacterModel model)
				{
					model.SetSilhouette(false);
				});
			}
			if (!((Object)(object)texture != (Object)null))
			{
				return;
			}
			foreach (Renderer renderer in Renderers)
			{
				if ((Object)(object)renderer != (Object)null && renderer.isVisible)
				{
					RendererHelper.AssignTextureToRenderer(renderer, texture, character, variant);
				}
			}
		}

		public bool IsObsolete()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (ScreenApi.CurrentScreens[0]?.screenType != (ScreenType?)type && ScreenApi.CurrentScreens[1]?.screenType != (ScreenType?)type)
			{
				return true;
			}
			return false;
		}

		public bool ValidCharacter(Character character, CharacterVariant variant = 0)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			if (character == this.character && VariantHelper.VariantMatch(variant, VariantHelper.GetModelVariant(this.variant)))
			{
				return true;
			}
			return false;
		}

		public static ModelHandler GetCurrentModelHandler(int playerNr = -1)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: 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_01c6: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			ScreenBase val = ScreenApi.CurrentScreens[0];
			ScreenBase val2 = ScreenApi.CurrentScreens[1];
			if (playerNr >= 0)
			{
				ScreenPlayers val3 = (ScreenPlayers)(object)((val is ScreenPlayers) ? val : null);
				if (val3 != null)
				{
					CharacterModel characterModel = val3.playerSelections[playerNr].characterModel;
					ModelHandler modelHandler = new ModelHandler(characterModel.character, characterModel.characterVariant, ((ScreenBase)val3).screenType);
					modelHandler.Add(characterModel);
					return modelHandler;
				}
				ScreenGameHud val4 = (ScreenGameHud)(object)((val is ScreenGameHud) ? val : null);
				if (val4 != null)
				{
					Player player = Player.GetPlayer(playerNr);
					GameHudPlayerInfo playerInfo = val4.playerInfos[player.nr];
					ModelHandler modelHandler2 = new ModelHandler(player.Character, player.CharacterVariant, ((ScreenBase)val4).screenType);
					modelHandler2.Add((Func<IEnumerable<Renderer>>)(() => ((Component)((Component)playerInfo).gameObject.transform).GetComponentsInChildren<Renderer>()));
					modelHandler2.Add((Func<IEnumerable<Renderer>>)(() => ((VisualEntity)player.playerEntity).skinRenderers));
					return modelHandler2;
				}
				PostScreen val5 = (PostScreen)(object)((val is PostScreen) ? val : null);
				if (val5 != null)
				{
					Player player2 = Player.GetPlayer(playerNr);
					PostSceenPlayerBar playerBar = val5.playerBarsByPlayer[player2.nr];
					ModelHandler modelHandler3 = new ModelHandler(player2.Character, player2.CharacterVariant, ((ScreenBase)val5).screenType);
					if (val5.winner.CJFLMDNNMIE == player2.nr)
					{
						modelHandler3.Add(val5.winnerModel);
					}
					modelHandler3.Add((Func<IEnumerable<Renderer>>)(() => ((Component)((Component)playerBar).gameObject.transform).GetComponentsInChildren<Renderer>()));
					return modelHandler3;
				}
			}
			else if (playerNr < 0)
			{
				ScreenUnlocksSkins val6 = (ScreenUnlocksSkins)(object)((val2 is ScreenUnlocksSkins) ? val2 : null);
				if (val6 != null)
				{
					ModelHandler modelHandler4 = new ModelHandler(val6.previewModel.character, val6.previewModel.characterVariant, ((ScreenBase)val6).screenType);
					modelHandler4.Add(val6.previewModel);
					return modelHandler4;
				}
				ScreenUnlocksCharacters val7 = (ScreenUnlocksCharacters)(object)((val2 is ScreenUnlocksCharacters) ? val2 : null);
				if (val7 != null)
				{
					ModelHandler modelHandler5 = new ModelHandler(val7.previewModel.character, val7.previewModel.characterVariant, ((ScreenBase)val7).screenType);
					modelHandler5.Add(val7.previewModel);
					return modelHandler5;
				}
			}
			return null;
		}
	}
	public enum ModelHandlerType
	{
		None,
		Lobby,
		Game,
		Results,
		ShowcasePreview,
		ShowcaseSkins
	}
}
namespace TextureMod.Showcase
{
	public class ShowcaseStudio : MonoBehaviour
	{
		private ConfigEntry<KeyCode> enterShowcaseStudio;

		private ConfigEntry<KeyCode> showcaseStudioHideHud;

		private ConfigEntry<KeyCode> showcaseStudioRotateCharacter;

		private ConfigEntry<KeyCode> showcaseStudioMoveLight;

		private ConfigEntry<KeyCode> showcaseStudioMoveCamera;

		public bool showUI = true;

		public int refreshTimer;

		private bool hideGUI;

		private bool showControls;

		private ScreenUnlocksSkins SUS;

		private List<GameObject> gameObjects = new List<GameObject>();

		private GameObject cameraController;

		private Camera camControllerCam;

		private Camera lightControllerCam;

		private GameObject lightController;

		private CharacterModel characterModel;

		private CustomSkinHandler skinHandler;

		private ModelHandler modelHandler;

		private Shader mainShader = Shader.Find("LethalLeague/GameplayOpaque");

		private Vector3 originalCharacterRendPos;

		private bool enableLight = true;

		private bool bgColorSelection;

		private byte bgR = 50;

		private byte bgG = 50;

		private byte bgB = 50;

		private Vector2 animSelectionPos = Vector2.zero;

		public List<string> animList = new List<string>();

		private string currentAnimation = "idle";

		private float animationSpeed = 60f;

		private int selectedGridAnim;

		private float animationTime;

		private float animationPos;

		private bool animate = true;

		public static ShowcaseStudio Instance { get; private set; }

		public string SkinName => CustomSkin?.Name ?? "N/A";

		public bool RefreshMode => TextureMod.reloadCustomSkinOnInterval.Value;

		private CustomSkin CustomSkin => skinHandler?.CustomSkin;

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			ConfigFile config = ((BaseUnityPlugin)TextureMod.Instance).Config;
			enterShowcaseStudio = config.Bind<KeyCode>("ShowcaseStudio", "enterShowcaseStudio", (KeyCode)9, (ConfigDescription)null);
			showcaseStudioHideHud = config.Bind<KeyCode>("ShowcaseStudio", "showcaseStudioHideHud", (KeyCode)284, (ConfigDescription)null);
			showcaseStudioRotateCharacter = config.Bind<KeyCode>("ShowcaseStudio", "showcaseStudioRotateCharacter", (KeyCode)323, (ConfigDescription)null);
			showcaseStudioMoveLight = config.Bind<KeyCode>("ShowcaseStudio", "showcaseStudioMoveLight", (KeyCode)326, (ConfigDescription)null);
			showcaseStudioMoveCamera = config.Bind<KeyCode>("ShowcaseStudio", "showcaseStudioMoveCamera", (KeyCode)325, (ConfigDescription)null);
			CustomStyle.InitStyle();
		}

		private void OnGUI()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_0072: 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_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			GUI.skin.box.alignment = (TextAnchor)4;
			if (!showUI && !hideGUI)
			{
				GUI.skin.box.fontSize = 18;
				GUI.Window(777, new Rect(10f, 10f, (float)(Screen.width / 7), (float)(Screen.height - 20)), new WindowFunction(AnimationSelectionWindow), "Showcase Studio", CustomStyle.windStyle);
				if (showControls)
				{
					GUI.Window(778, new Rect((float)(20 + Screen.width / 7), 10f, (float)(10 + Screen.width / 7 * 2), (float)(Screen.height / 3)), new WindowFunction(ControlsWindow), "Controls", CustomStyle.windStyle);
				}
			}
			else if ((Object)(object)SUS != (Object)null && !hideGUI)
			{
				GUI.skin.box.fontSize = 22;
				Rect val = new Rect(10f, 10f, 600f, 35f);
				KeyCode value = enterShowcaseStudio.Value;
				GUI.Box(val, "Press [" + ((object)(KeyCode)(ref value)).ToString() + "] to enter Showcase Studio");
			}
		}

		private void ShowStudio()
		{
			//IL_0351: 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_0036: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Expected O, but got Unknown
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Expected O, but got Unknown
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Expected O, but got Unknown
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: 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_01f9: Unknown result type (might be due to invalid IL or missing references)
			showUI = !showUI;
			GameObject[] array = Object.FindObjectsOfType<GameObject>();
			GameObject[] array2;
			if (!showUI)
			{
				originalCharacterRendPos = ((Component)SUS.characterRenderer).transform.position;
				((Component)SUS.characterRenderer).transform.position = new Vector3(0f, 0f, 0f);
				array2 = array;
				foreach (GameObject val in array2)
				{
					if (((Object)val).name.Contains("btFirst"))
					{
						gameObjects.Add(val);
					}
					if (((Object)val).name.Contains("btQuit"))
					{
						gameObjects.Add(val);
					}
					if (((Object)val).name.Contains("btPose"))
					{
						gameObjects.Add(val);
					}
					if (((Object)val).name.Contains("characterCamera"))
					{
						((Behaviour)val.GetComponent<Camera>()).enabled = false;
					}
					if (((Object)val).name.Contains("cameraController"))
					{
						cameraController = new GameObject("cameraControllerGentle");
						cameraController.transform.position = new Vector3(-2.5f, -302f, -4.4f);
						cameraController.transform.eulerAngles = new Vector3(3f, 132f, 0f);
						camControllerCam = cameraController.AddComponent<Camera>();
						((Behaviour)cameraController.GetComponent<Camera>()).enabled = true;
						cameraController.AddComponent<SmoothMouseLook>();
					}
					if (!((Object)val).name.Contains("characterLight"))
					{
						continue;
					}
					lightController = new GameObject("lightControllerGentle");
					GameObject[] array3 = array;
					foreach (GameObject val2 in array3)
					{
						if (((Object)val2).name.Contains("characterCamera"))
						{
							lightController.transform.position = val2.transform.position;
							lightController.transform.rotation = val2.transform.rotation;
						}
					}
					Light obj = lightController.AddComponent<Light>();
					Light component = val.GetComponent<Light>();
					obj.type = component.type;
					obj.color = component.color;
					lightControllerCam = lightController.AddComponent<Camera>();
					lightController.AddComponent<SmoothMouseLook>();
					((Behaviour)val.GetComponent<Light>()).enabled = false;
				}
				for (int k = 0; k < gameObjects.Count; k++)
				{
					gameObjects[k].SetActive(false);
				}
				if ((Object)(object)characterModel == (Object)null)
				{
					characterModel = SUS.previewModel;
					return;
				}
				Animation componentInChildren = ((Component)characterModel).gameObject.GetComponentInChildren<Animation>();
				int num = 0;
				{
					foreach (AnimationState item in componentInChildren)
					{
						AnimationState val3 = item;
						animList.Add(val3.name);
						if (val3.name == "idle")
						{
							selectedGridAnim = num;
						}
						num++;
					}
					return;
				}
			}
			((Component)SUS.characterRenderer).transform.position = originalCharacterRendPos;
			for (int l = 0; l < gameObjects.Count; l++)
			{
				gameObjects[l].SetActive(true);
			}
			gameObjects.Clear();
			animList.Clear();
			if ((Object)(object)lightController != (Object)null)
			{
				Object.Destroy((Object)(object)lightController);
			}
			if ((Object)(object)cameraController != (Object)null)
			{
				Object.Destroy((Object)(object)cameraController);
			}
			array2 = array;
			foreach (GameObject val4 in array2)
			{
				if (((Object)val4).name.Contains("characterCamera"))
				{
					((Behaviour)val4.GetComponent<Camera>()).enabled = true;
				}
				if (((Object)val4).name.Contains("characterLight"))
				{
					((Behaviour)val4.GetComponent<Light>()).enabled = true;
				}
			}
		}

		private void Update()
		{
			//IL_00a3: 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_0038: Invalid comparison between Unknown and I4
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_013f: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: 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)
			if ((Object)(object)SUS == (Object)null)
			{
				modelHandler = null;
				characterModel = null;
				skinHandler = null;
				ScreenBase obj = ScreenApi.CurrentScreens[1];
				if (obj != null && (int)obj.screenType == 11)
				{
					ref ScreenUnlocksSkins sUS = ref SUS;
					ScreenBase obj2 = ScreenApi.CurrentScreens[1];
					sUS = (ScreenUnlocksSkins)(object)((obj2 is ScreenUnlocksSkins) ? obj2 : null);
				}
				return;
			}
			ShowcaseSkinSelection.Update();
			if (RefreshMode && refreshTimer <= 0)
			{
				skinHandler?.ReloadSkin();
				refreshTimer = TextureMod.skinReloadIntervalInFrames.Value;
			}
			refreshTimer--;
			UpdateModel();
			if (Input.GetKeyDown(showcaseStudioHideHud.Value))
			{
				hideGUI = !hideGUI;
			}
			Renderer[] array = Object.FindObjectsOfType<Renderer>();
			foreach (Renderer val in array)
			{
				if ((Object)(object)val.material.shader != (Object)(object)mainShader && ((Object)val).name.Contains("Effect"))
				{
					val.material.shader = mainShader;
				}
			}
			if (!Input.GetKeyDown(enterShowcaseStudio.Value))
			{
				if (showUI)
				{
					goto IL_0179;
				}
				Controller all = Controller.all;
				if (!((Controller)(ref all)).GetButtonDown(InputAction.ESC))
				{
					all = Controller.all;
					if (!((Controller)(ref all)).GetButtonDown(InputAction.BACK))
					{
						all = Controller.all;
						if (!((Controller)(ref all)).GetButtonDown(InputAction.OK) && !Input.GetKeyDown((KeyCode)324))
						{
							goto IL_0179;
						}
					}
				}
			}
			ShowStudio();
			goto IL_0179;
			IL_0179:
			if ((Object)(object)characterModel == (Object)null)
			{
				characterModel = SUS.previewModel;
			}
			else
			{
				Animation componentInChildren = ((Component)characterModel).gameObject.GetComponentInChildren<Animation>();
				if (((Object)componentInChildren.clip).name != currentAnimation && !showUI)
				{
					componentInChildren.clip = componentInChildren[currentAnimation].clip;
				}
				if (animate)
				{
					if (animationTime >= componentInChildren[currentAnimation].length)
					{
						animationTime = 0f;
					}
					animationTime += animationSpeed / 60f * Time.deltaTime;
					componentInChildren[currentAnimation].normalizedTime = animationTime / componentInChildren[currentAnimation].length;
				}
				else
				{
					componentInChildren[currentAnimation].normalizedTime = animationPos;
				}
			}
			if ((Object)(object)lightController != (Object)null)
			{
				((Behaviour)lightController.GetComponent<Light>()).enabled = enableLight;
			}
			if ((Object)(object)camControllerCam != (Object)null)
			{
				camControllerCam.backgroundColor = Color32.op_Implicit(new Color32(bgR, bgG, bgB, byte.MaxValue));
			}
			if ((Object)(object)lightControllerCam != (Object)null)
			{
				lightControllerCam.backgroundColor = new Color(0.5f, 0.5f, 0.5f);
			}
		}

		public void UpdateModel()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (modelHandler == null || modelHandler.IsObsolete() || !modelHandler.ValidCharacter(SUS.previewModel.character, SUS.previewModel.characterVariant))
			{
				modelHandler = ModelHandler.GetCurrentModelHandler();
			}
			if (modelHandler != null)
			{
				modelHandler.Update();
				modelHandler.texture = CustomSkin?.Texture;
			}
		}

		public void SetCustomSkin(CustomSkinHandler skinHandler)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected I4, but got Unknown
			this.skinHandler = skinHandler;
			if (CustomSkin != null)
			{
				GameStates.DirectProcess((Msg)55, -1, (int)VariantHelper.GetDefaultVariantForModel(CustomSkin.ModelVariant));
			}
		}

		private void FixedUpdate()
		{
			//IL_0014: 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_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: 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_01aa: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: 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_0215: 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_0221: 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)
			if ((Object)(object)cameraController != (Object)null)
			{
				if (Input.GetKey(showcaseStudioMoveCamera.Value))
				{
					cameraController.GetComponent<SmoothMouseLook>().isActive = true;
				}
				else
				{
					cameraController.GetComponent<SmoothMouseLook>().isActive = false;
				}
			}
			if ((Object)(object)lightController != (Object)null)
			{
				if (Input.GetKey(showcaseStudioMoveLight.Value))
				{
					((Behaviour)lightControllerCam).enabled = true;
					((Behaviour)camControllerCam).enabled = false;
					lightController.GetComponent<SmoothMouseLook>().isActive = true;
				}
				else
				{
					((Behaviour)lightControllerCam).enabled = false;
					((Behaviour)camControllerCam).enabled = true;
					lightController.GetComponent<SmoothMouseLook>().isActive = false;
				}
			}
			if ((Object)(object)characterModel != (Object)null && Input.GetKey(showcaseStudioRotateCharacter.Value))
			{
				int num = 3;
				if (Input.GetKey((KeyCode)97))
				{
					((Component)characterModel).transform.Rotate(Vector3.up * (float)num);
				}
				if (Input.GetKey((KeyCode)115))
				{
					((Component)characterModel).transform.Rotate(Vector3.right * (float)num);
					((Component)characterModel).transform.Rotate(Vector3.forward * (float)num);
				}
				if (Input.GetKey((KeyCode)119))
				{
					((Component)characterModel).transform.Rotate(-Vector3.right * (float)num);
					((Component)characterModel).transform.Rotate(-Vector3.forward * (float)num);
				}
				if (Input.GetKey((KeyCode)100))
				{
					((Component)characterModel).transform.Rotate(-Vector3.up * (float)num);
				}
				if (Input.GetKey((KeyCode)113))
				{
					((Component)characterModel).transform.Rotate(Vector3.right * (float)num);
					((Component)characterModel).transform.Rotate(-Vector3.forward * (float)num);
				}
				if (Input.GetKey((KeyCode)101))
				{
					((Component)characterModel).transform.Rotate(-Vector3.right * (float)num);
					((Component)characterModel).transform.Rotate(Vector3.forward * (float)num);
				}
			}
		}

		private void AnimationSelectionWindow(int winID)
		{
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046a: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Space(30f);
			GUILayout.Box("General Options", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Show controls: ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(showControls.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				showControls = !showControls;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Skin Name: ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label(SkinName, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Skin Refresh: ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (!RefreshMode)
			{
				GUILayout.Label("Off", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			else
			{
				GUILayout.Label("On [" + refreshTimer + "]", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			GUILayout.EndHorizontal();
			GUILayout.Space(20f);
			GUILayout.Box("BG and Lighting Options", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Enable Lighting: ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(enableLight.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				enableLight = !enableLight;
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Show BG Color select: ", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(bgColorSelection.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				bgColorSelection = !bgColorSelection;
			}
			GUILayout.EndHorizontal();
			if (bgColorSelection)
			{
				GUILayout.Label("RGB: [" + bgR + ", " + bgG + ", " + bgB + "]", (GUILayoutOption[])(object)new GUILayoutOption[0]);
				bgR = (byte)GUILayout.HorizontalSlider((float)(int)bgR, 0f, 255f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				bgG = (byte)GUILayout.HorizontalSlider((float)(int)bgG, 0f, 255f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				bgB = (byte)GUILayout.HorizontalSlider((float)(int)bgB, 0f, 255f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			GUILayout.Space(20f);
			GUILayout.Box("Animation Options", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Current Animation:", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label(currentAnimation, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			if ((Object)(object)characterModel != (Object)null)
			{
				Animation componentInChildren = ((Component)characterModel).gameObject.GetComponentInChildren<Animation>();
				GUILayout.Label("Animation time:", (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Label(decimal.Round((decimal)animationTime, 2) + "s / " + decimal.Round((decimal)componentInChildren[currentAnimation].length, 2) + "s", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Label("Play Animation", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (GUILayout.Button(animate.ToString(), (GUILayoutOption[])(object)new GUILayoutOption[0]))
			{
				animate = !animate;
			}
			GUILayout.EndHorizontal();
			if (animate)
			{
				GUILayout.Space(5f);
				GUILayout.Label("Animation speed: " + decimal.Round((decimal)animationSpeed) + " FPS", (GUILayoutOption[])(object)new GUILayoutOption[0]);
				animationSpeed = GUILayout.HorizontalSlider(animationSpeed, 0f, 60f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Space(5f);
			}
			else
			{
				GUILayout.Space(5f);
				GUILayout.Label("Animation step:", (GUILayoutOption[])(object)new GUILayoutOption[0]);
				animationPos = GUILayout.HorizontalSlider(animationPos, 0f, 1f, (GUILayoutOption[])(object)new GUILayoutOption[0]);
				GUILayout.Space(5f);
			}
			animSelectionPos = GUILayout.BeginScrollView(animSelectionPos, false, true, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			if (animList.Count > 0)
			{
				selectedGridAnim = GUILayout.SelectionGrid(selectedGridAnim, animList.ToArray(), 1, (GUILayoutOption[])(object)new GUILayoutOption[0]);
			}
			currentAnimation = animList[selectedGridAnim];
			GUILayout.EndScrollView();
			GUILayout.EndVertical();
		}

		private void ControlsWindow(int wid)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_00c7: 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_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: 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_0219: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.BeginVertical((GUILayoutOption[])(object)new GUILayoutOption[0]);
			GUILayout.Space(30f);
			GUILayout.Box("General", (GUILayoutOption[])(object)new GUILayoutOption[0]);
			KeyCode value = showcaseStudioHideHud.Value;
			GUILayout.Label("Hide GUI: [" + ((objec