Decompiled source of MovingPlatform v1.0.0

moving_platform.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MovingPlatform
{
	internal class HoleEffectController : MonoBehaviour
	{
		private const float VisibilityInterval = 0.25f;

		private const float VisibleRange = 25f;

		private static readonly List<HoleEffectController> Active = new List<HoleEffectController>();

		private Transform _fx;

		private Transform _beam;

		private Transform _lightTransform;

		private Light _light;

		private MeshFilter _beamFilter;

		private float _appliedLength = -1f;

		private bool _effectEnabled = true;

		private float _nextVisibilityCheck;

		private void Awake()
		{
			_fx = ((Component)this).transform.Find("hole_fx");
			if ((Object)(object)_fx == (Object)null)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			_lightTransform = _fx.Find("light");
			if ((Object)(object)_lightTransform != (Object)null)
			{
				_light = ((Component)_lightTransform).GetComponent<Light>();
			}
			_beam = _fx.Find("beam");
			if ((Object)(object)_beam != (Object)null)
			{
				_beamFilter = ((Component)_beam).GetComponent<MeshFilter>();
			}
		}

		private void OnEnable()
		{
			if (!Active.Contains(this))
			{
				Active.Add(this);
			}
			if ((Object)(object)_fx != (Object)null)
			{
				ApplyConfig();
			}
		}

		private void OnDisable()
		{
			Active.Remove(this);
		}

		private void Update()
		{
			if (!(Time.time < _nextVisibilityCheck))
			{
				_nextVisibilityCheck = Time.time + 0.25f;
				UpdateVisibility();
			}
		}

		internal static void ApplyAll()
		{
			HoleEffectController[] array = Active.ToArray();
			foreach (HoleEffectController holeEffectController in array)
			{
				if ((Object)(object)holeEffectController != (Object)null)
				{
					holeEffectController.ApplyConfig();
				}
			}
		}

		internal void ApplyConfig()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: 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_021c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_fx == (Object)null))
			{
				_effectEnabled = MovingPlatformPlugin.HoleEffect == null || MovingPlatformPlugin.HoleEffect.Value;
				PadBehaviour component = ((Component)this).GetComponent<PadBehaviour>();
				bool flag = (Object)(object)component == (Object)null || component.IsUp;
				float num = 0.0807f;
				float num2 = num - 0.0807f;
				float num3 = ((MovingPlatformPlugin.HoleEffectLength != null) ? MovingPlatformPlugin.HoleEffectLength.Value : 3.5f);
				Color beamColor = MovingPlatformPlugin.GetBeamColor();
				if ((Object)(object)_beam != (Object)null)
				{
					_beam.localPosition = new Vector3(0f, flag ? num : num2, 0f);
					_beam.localRotation = (flag ? Quaternion.identity : Quaternion.Euler(180f, 0f, 0f));
				}
				if ((Object)(object)_lightTransform != (Object)null)
				{
					_lightTransform.localPosition = new Vector3(0f, (flag ? num : num2) + (flag ? 0.3f : (-0.3f)), 0f);
				}
				if ((Object)(object)_beamFilter != (Object)null && !Mathf.Approximately(_appliedLength, num3))
				{
					_appliedLength = num3;
					_beamFilter.sharedMesh = MeshFactory.GetBeamMesh(num3);
				}
				Material beamMaterial = MovingPlatformPlugin.GetBeamMaterial();
				if ((Object)(object)beamMaterial != (Object)null && beamMaterial.HasProperty("_Color"))
				{
					float num4 = ((MovingPlatformPlugin.BeamOpacity != null) ? MovingPlatformPlugin.BeamOpacity.Value : 0.02f);
					beamMaterial.SetColor("_Color", new Color(beamColor.r, beamColor.g, beamColor.b, beamColor.a * num4));
				}
				if ((Object)(object)_light != (Object)null)
				{
					((Behaviour)_light).enabled = MovingPlatformPlugin.HoleLight == null || MovingPlatformPlugin.HoleLight.Value;
					_light.color = new Color(beamColor.r, beamColor.g, beamColor.b);
					_light.intensity = ((MovingPlatformPlugin.HoleEffectIntensity != null) ? MovingPlatformPlugin.HoleEffectIntensity.Value : 1f);
					_light.range = Mathf.Max(2f, num3 * 0.9f);
				}
				UpdateVisibility();
			}
		}

		private void UpdateVisibility()
		{
			//IL_0031: 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)
			if (!((Object)(object)_fx == (Object)null))
			{
				Player localPlayer = Player.m_localPlayer;
				bool flag = _effectEnabled && ((Object)(object)localPlayer == (Object)null || Vector3.Distance(((Component)localPlayer).transform.position, ((Component)this).transform.position) < 25f);
				if (((Component)_fx).gameObject.activeSelf != flag)
				{
					((Component)_fx).gameObject.SetActive(flag);
				}
			}
		}
	}
	internal static class Lang
	{
		private const string FileExtension = ".json";

		private const string TranslationsFolder = "translations";

		private const string UserConfigFolder = "moving_platform";

		internal const string FallbackLanguage = "English";

		private const float LanguagePollInterval = 0.5f;

		private static readonly Dictionary<string, Dictionary<string, string>> Tables = new Dictionary<string, Dictionary<string, string>>(StringComparer.Ordinal);

		private static readonly HashSet<string> MissingWarned = new HashSet<string>(StringComparer.Ordinal);

		private static bool _initialized;

		private static string _systemLanguage;

		private static string _rawLanguage;

		private static string _currentLanguage = "English";

		private static float _nextLanguagePoll;

		internal static string CurrentLanguage
		{
			get
			{
				if (Time.unscaledTime >= _nextLanguagePoll)
				{
					_nextLanguagePoll = Time.unscaledTime + 0.5f;
					string text = RawLanguage();
					if (!string.Equals(text, _rawLanguage, StringComparison.Ordinal))
					{
						_rawLanguage = text;
						_currentLanguage = NormalizeLanguage(text);
					}
				}
				return _currentLanguage;
			}
		}

		internal static string TranslationsFolderPath
		{
			get
			{
				string location = Assembly.GetExecutingAssembly().Location;
				string text = (string.IsNullOrEmpty(location) ? null : Path.GetDirectoryName(location));
				if (string.IsNullOrEmpty(text))
				{
					text = Path.Combine(Paths.PluginPath ?? ".", "moving_platform");
				}
				return Path.Combine(text, "translations");
			}
		}

		internal static string UserTranslationsFolderPath => Path.Combine(Paths.ConfigPath ?? ".", "moving_platform");

		internal static void Initialize()
		{
			if (!_initialized)
			{
				_initialized = true;
				Reload();
			}
		}

		internal static void Reload()
		{
			Tables.Clear();
			MissingWarned.Clear();
			EnsureUserTranslations();
			LoadExternalTables(TranslationsFolderPath, "插件默认");
			LoadExternalTables(UserTranslationsFolderPath, "用户自定义");
			Validate();
			LogSummary();
		}

		internal static string T(string key)
		{
			if (string.IsNullOrEmpty(key))
			{
				return string.Empty;
			}
			if (!_initialized)
			{
				Initialize();
			}
			string currentLanguage = CurrentLanguage;
			if (TryGet(currentLanguage, key, out var text))
			{
				return text;
			}
			if (string.Equals(currentLanguage, "ChineseTrad", StringComparison.Ordinal) && TryGet("Chinese", key, out text))
			{
				return text;
			}
			if (!string.Equals(currentLanguage, "English", StringComparison.Ordinal) && TryGet("English", key, out text))
			{
				return text;
			}
			if (MissingWarned.Add(key))
			{
				Warn("缺少翻译键 \"" + key + "\"(当前语言 " + currentLanguage + "),已回退为键名");
			}
			return key;
		}

		internal static string T(string key, params object[] args)
		{
			string text = T(key);
			if (args == null || args.Length == 0)
			{
				return text;
			}
			try
			{
				return string.Format(CultureInfo.InvariantCulture, text, args);
			}
			catch (FormatException)
			{
				return text;
			}
		}

		internal static string[] FontCandidates()
		{
			return CurrentLanguage switch
			{
				"Chinese" => new string[5] { "Microsoft YaHei", "SimHei", "Noto Sans CJK SC", "Source Han Sans SC", "Arial" }, 
				"ChineseTrad" => new string[5] { "Microsoft JhengHei", "PMingLiU", "MingLiU", "Microsoft YaHei", "Arial" }, 
				"Japanese" => new string[6] { "Yu Gothic UI", "Yu Gothic", "Meiryo", "MS Gothic", "Microsoft YaHei", "Arial" }, 
				"Korean" => new string[5] { "Malgun Gothic", "Gulim", "Batang", "Microsoft YaHei", "Arial" }, 
				_ => new string[4] { "Arial", "Segoe UI", "Noto Sans", "Microsoft YaHei" }, 
			};
		}

		internal static char SampleCharacter()
		{
			switch (CurrentLanguage)
			{
			case "Chinese":
			case "ChineseTrad":
				return '中';
			case "Japanese":
				return 'あ';
			case "Korean":
				return '가';
			case "Russian":
				return 'Я';
			default:
				return 'A';
			}
		}

		internal static string NormalizeLanguage(string language)
		{
			if (string.IsNullOrEmpty(language))
			{
				return "English";
			}
			string text = language.Trim();
			StringBuilder stringBuilder = new StringBuilder(text.Length);
			string text2 = text;
			foreach (char c in text2)
			{
				if (c != ' ' && c != '_' && c != '-' && c != '.' && c != '(' && c != ')')
				{
					stringBuilder.Append(char.ToLowerInvariant(c));
				}
			}
			switch (stringBuilder.ToString())
			{
			case "chinese":
			case "chinesesimplified":
			case "chinesesimp":
			case "chineseprc":
			case "zh":
			case "zhcn":
			case "zhhans":
			case "schinese":
			case "简体中文":
			case "中文":
				return "Chinese";
			case "chinesetraditional":
			case "chinesetrad":
			case "zhcht":
			case "zhtw":
			case "zhhant":
			case "tchinese":
			case "繁體中文":
			case "繁体中文":
				return "ChineseTrad";
			case "english":
			case "en":
			case "enus":
			case "engb":
			case "englishus":
				return "English";
			case "japanese":
			case "ja":
			case "jp":
			case "日本語":
				return "Japanese";
			case "korean":
			case "ko":
			case "kr":
			case "한국어":
				return "Korean";
			case "russian":
			case "ru":
			case "русский":
				return "Russian";
			case "german":
			case "de":
			case "deutsch":
				return "German";
			case "french":
			case "fr":
			case "francais":
			case "français":
				return "French";
			case "spanish":
			case "es":
			case "espanol":
			case "español":
				return "Spanish";
			case "italian":
			case "it":
			case "italiano":
				return "Italian";
			case "polish":
			case "pl":
			case "polski":
				return "Polish";
			case "portuguese":
			case "pt":
			case "ptbr":
			case "portuguesebrazilian":
			case "brazilianportuguese":
				return "Portuguese_Brazilian";
			case "turkish":
			case "tr":
			case "turkce":
			case "türkçe":
				return "Turkish";
			case "ukrainian":
			case "uk":
			case "ua":
			case "українська":
				return "Ukrainian";
			case "dutch":
			case "nl":
			case "nederlands":
				return "Dutch";
			case "swedish":
			case "sv":
			case "svenska":
				return "Swedish";
			case "danish":
			case "da":
			case "dansk":
				return "Danish";
			case "norwegian":
			case "no":
			case "nb":
			case "norsk":
				return "Norwegian";
			case "czech":
			case "cs":
			case "cestina":
			case "čeština":
				return "Czech";
			case "hungarian":
			case "hu":
			case "magyar":
				return "Hungarian";
			case "romanian":
			case "ro":
			case "romana":
			case "română":
				return "Romanian";
			case "thai":
			case "th":
			case "ไทย":
				return "Thai";
			case "vietnamese":
			case "vi":
			case "tiếngviệt":
				return "Vietnamese";
			case "indonesian":
			case "id":
			case "bahasaindonesia":
				return "Indonesian";
			case "finnish":
			case "fi":
			case "suomi":
				return "Finnish";
			case "greek":
			case "el":
			case "ελληνικά":
				return "Greek";
			default:
				return text;
			}
		}

		private static string RawLanguage()
		{
			try
			{
				Localization instance = Localization.instance;
				if (instance != null)
				{
					string selectedLanguage = instance.GetSelectedLanguage();
					if (!string.IsNullOrEmpty(selectedLanguage))
					{
						return selectedLanguage;
					}
				}
			}
			catch (Exception)
			{
			}
			return _systemLanguage ?? (_systemLanguage = DetectSystemLanguage());
		}

		private static string DetectSystemLanguage()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected I4, but got Unknown
			SystemLanguage systemLanguage = Application.systemLanguage;
			SystemLanguage val = systemLanguage;
			switch (val - 6)
			{
			case 0:
			case 34:
				return "Chinese";
			case 35:
				return "ChineseTrad";
			case 16:
				return "Japanese";
			case 17:
				return "Korean";
			case 24:
				return "Russian";
			case 9:
				return "German";
			case 8:
				return "French";
			case 28:
				return "Spanish";
			case 15:
				return "Italian";
			case 21:
				return "Polish";
			case 22:
				return "Portuguese_Brazilian";
			case 31:
				return "Turkish";
			case 32:
				return "Ukrainian";
			case 3:
				return "Dutch";
			case 29:
				return "Swedish";
			case 2:
				return "Danish";
			case 20:
				return "Norwegian";
			case 1:
				return "Czech";
			case 12:
				return "Hungarian";
			case 23:
				return "Romanian";
			case 30:
				return "Thai";
			case 33:
				return "Vietnamese";
			case 14:
				return "Indonesian";
			case 7:
				return "Finnish";
			case 10:
				return "Greek";
			default:
				return "English";
			}
		}

		private static bool TryGet(string language, string key, out string text)
		{
			text = null;
			if (string.IsNullOrEmpty(language) || !Tables.TryGetValue(language, out var value) || value == null || !value.TryGetValue(key, out text))
			{
				return false;
			}
			return !string.IsNullOrEmpty(text);
		}

		private static void LoadExternalTables(string folder, string label)
		{
			if (!Directory.Exists(folder))
			{
				Info("未找到" + label + "翻译目录(" + folder + ")");
				return;
			}
			string[] files;
			try
			{
				files = Directory.GetFiles(folder, "*.json");
			}
			catch (Exception ex)
			{
				Warn("枚举" + label + "翻译目录 " + folder + " 失败:" + ex.Message);
				return;
			}
			Array.Sort(files, (IComparer<string>?)StringComparer.OrdinalIgnoreCase);
			string[] array = files;
			foreach (string text in array)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
				try
				{
					AddTable(fileNameWithoutExtension, File.ReadAllText(text, Encoding.UTF8), text);
				}
				catch (Exception ex2)
				{
					Warn("读取" + label + "翻译 " + text + " 失败:" + ex2.Message);
				}
			}
		}

		private static void EnsureUserTranslations()
		{
			string userTranslationsFolderPath = UserTranslationsFolderPath;
			try
			{
				Directory.CreateDirectory(userTranslationsFolderPath);
			}
			catch (Exception ex)
			{
				Warn("创建用户翻译目录 " + userTranslationsFolderPath + " 失败:" + ex.Message);
				return;
			}
			string translationsFolderPath = TranslationsFolderPath;
			if (!Directory.Exists(translationsFolderPath))
			{
				return;
			}
			string[] files;
			try
			{
				files = Directory.GetFiles(translationsFolderPath, "*.json");
			}
			catch (Exception ex2)
			{
				Warn("枚举插件翻译目录 " + translationsFolderPath + " 失败:" + ex2.Message);
				return;
			}
			string[] array = files;
			foreach (string text in array)
			{
				string text2 = Path.Combine(userTranslationsFolderPath, Path.GetFileName(text));
				if (!File.Exists(text2))
				{
					try
					{
						File.Copy(text, text2);
						Info("已复制默认翻译到 " + text2);
					}
					catch (Exception ex3)
					{
						Warn("复制翻译 " + text + " → " + text2 + " 失败:" + ex3.Message);
					}
				}
			}
		}

		private static void AddTable(string rawLanguage, string text, string source)
		{
			if (string.IsNullOrEmpty(rawLanguage))
			{
				return;
			}
			string text2 = NormalizeLanguage(rawLanguage);
			if (!SimpleJson.TryParseStringMap(text, out var result, out var error))
			{
				Warn("翻译文件解析失败(" + source + ",语言 " + text2 + "):" + error);
				return;
			}
			if (!Tables.TryGetValue(text2, out var value))
			{
				value = new Dictionary<string, string>(StringComparer.Ordinal);
				Tables[text2] = value;
			}
			int num = 0;
			foreach (KeyValuePair<string, string> item in result)
			{
				if (!item.Key.StartsWith("//", StringComparison.Ordinal))
				{
					value[item.Key] = item.Value;
					num++;
				}
			}
			Info($"载入 {text2} ← {source}({num} 条)");
		}

		private static void Validate()
		{
			if (Tables.Count == 0)
			{
				Warn("没有加载到任何翻译(插件默认目录与用户自定义目录都为空)");
				return;
			}
			if (!TryGet("English", "base_name", out var _))
			{
				Warn("回退语言 English 没有有效翻译,其他语言缺键时会直接显示键名");
				return;
			}
			Dictionary<string, string> dictionary = Tables["English"];
			List<string> list = new List<string>();
			foreach (KeyValuePair<string, Dictionary<string, string>> table in Tables)
			{
				if (string.Equals(table.Key, "English", StringComparison.Ordinal))
				{
					continue;
				}
				list.Clear();
				foreach (string key in dictionary.Keys)
				{
					if (!table.Value.ContainsKey(key))
					{
						list.Add(key);
					}
				}
				if (list.Count != 0)
				{
					list.Sort(StringComparer.Ordinal);
					Warn(string.Format("{0} 缺少 {1} 个键(回退英文):{2}", table.Key, list.Count, string.Join(", ", list.ToArray())));
				}
			}
		}

		private static void LogSummary()
		{
			StringBuilder stringBuilder = new StringBuilder();
			foreach (KeyValuePair<string, Dictionary<string, string>> table in Tables)
			{
				if (stringBuilder.Length > 0)
				{
					stringBuilder.Append(",");
				}
				stringBuilder.Append(table.Key).Append(' ').Append(table.Value.Count)
					.Append(" 条");
			}
			Info("翻译表:" + ((stringBuilder.Length > 0) ? stringBuilder.ToString() : "空") + ";当前语言 " + CurrentLanguage + ";插件目录 " + TranslationsFolderPath + ";用户目录 " + UserTranslationsFolderPath);
		}

		private static void Info(string message)
		{
			ManualLogSource log = MovingPlatformPlugin.Log;
			if (log != null)
			{
				log.LogInfo((object)("[Lang] " + message));
			}
			else
			{
				Debug.Log((object)("[Lang] " + message));
			}
		}

		private static void Warn(string message)
		{
			ManualLogSource log = MovingPlatformPlugin.Log;
			if (log != null)
			{
				log.LogWarning((object)("[Lang] " + message));
			}
			else
			{
				Debug.LogWarning((object)("[Lang] " + message));
			}
		}
	}
	internal static class MeshFactory
	{
		public const float BaseSize = 2f;

		public const float HoleDiameter = 1.8f;

		public const float BaseBottomOffset = 0f;

		public const float BaseTopOffset = 0.0807f;

		public const float BaseThickness = 0.0807f;

		public const float PlateDiameter = 1.78f;

		public const float PlateThickness = 0.16f;

		private const int Segments = 48;

		private const float UvScale = 0.5f;

		public const float BeamDiameter = 1.7f;

		private static Mesh _baseMesh;

		private static Mesh _plateMesh;

		private static Mesh _beamMesh;

		private static float _beamMeshLength = -1f;

		public static Mesh BaseMesh
		{
			get
			{
				if ((Object)(object)_baseMesh == (Object)null)
				{
					_baseMesh = ObjLoader.LoadEmbedded("MovingPlatform.base.obj", "mp_base") ?? BuildBaseMesh();
				}
				return _baseMesh;
			}
		}

		public static Mesh PlateMesh
		{
			get
			{
				if ((Object)(object)_plateMesh == (Object)null)
				{
					_plateMesh = ObjLoader.LoadEmbedded("MovingPlatform.plate.obj", "mp_plate") ?? BuildPlateMesh();
				}
				return _plateMesh;
			}
		}

		public static Mesh CreateQuad(float size)
		{
			//IL_0018: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			float num = size * 0.5f;
			List<Vector3> verts = new List<Vector3>
			{
				new Vector3(0f - num, 0f, 0f - num),
				new Vector3(num, 0f, 0f - num),
				new Vector3(num, 0f, num),
				new Vector3(0f - num, 0f, num)
			};
			List<Vector2> uvs = new List<Vector2>
			{
				new Vector2(0f, 0f),
				new Vector2(1f, 0f),
				new Vector2(1f, 1f),
				new Vector2(0f, 1f)
			};
			List<int> tris = new List<int> { 0, 2, 1, 0, 3, 2 };
			return BuildMesh("mp_icon_quad", verts, uvs, tris);
		}

		public static Mesh GetBeamMesh(float length)
		{
			if ((Object)(object)_beamMesh != (Object)null && Mathf.Approximately(_beamMeshLength, length))
			{
				return _beamMesh;
			}
			_beamMeshLength = length;
			_beamMesh = BuildBeamMesh(length);
			return _beamMesh;
		}

		private static Mesh BuildBeamMesh(float length)
		{
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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)
			float num = 0.85f;
			List<Vector3> verts = new List<Vector3>(384);
			List<Vector2> uvs = new List<Vector2>(384);
			List<int> tris = new List<int>(576);
			Vector3 val = default(Vector3);
			Vector3 val2 = default(Vector3);
			Vector3 val3 = default(Vector3);
			Vector3 val4 = default(Vector3);
			for (int i = 0; i < 48; i++)
			{
				float num2 = (float)Math.PI * 2f * (float)i / 48f;
				float num3 = (float)Math.PI * 2f * (float)(i + 1) / 48f;
				float num4 = (float)i / 48f;
				float num5 = (float)(i + 1) / 48f;
				((Vector3)(ref val))..ctor(Mathf.Cos(num2) * num, 0f, Mathf.Sin(num2) * num);
				((Vector3)(ref val2))..ctor(Mathf.Cos(num3) * num, 0f, Mathf.Sin(num3) * num);
				((Vector3)(ref val3))..ctor(val.x, length, val.z);
				((Vector3)(ref val4))..ctor(val2.x, length, val2.z);
				AddQuad(verts, uvs, tris, val, val2, val4, val3, new Vector2(num4, 0f), new Vector2(num5, 0f), new Vector2(num5, 1f), new Vector2(num4, 1f));
				AddQuad(verts, uvs, tris, val2, val, val3, val4, new Vector2(num5, 0f), new Vector2(num4, 0f), new Vector2(num4, 1f), new Vector2(num5, 1f));
			}
			return BuildMesh("mp_beam", verts, uvs, tris);
		}

		private static Mesh BuildBaseMesh()
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: 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_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: 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_019f: 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_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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)
			//IL_021b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: 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_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f;
			float num2 = 0.9f;
			float num3 = 0.0807f;
			Vector3[] array = (Vector3[])(object)new Vector3[48];
			Vector3[] array2 = (Vector3[])(object)new Vector3[48];
			for (int i = 0; i < 48; i++)
			{
				float num4 = (float)Math.PI * 2f * (float)i / 48f;
				float num5 = Mathf.Cos(num4);
				float num6 = Mathf.Sin(num4);
				array[i] = new Vector3(num5 * num2, 0f, num6 * num2);
				float num7 = num / Mathf.Max(Mathf.Abs(num5), Mathf.Abs(num6));
				array2[i] = new Vector3(num5 * num7, 0f, num6 * num7);
			}
			List<Vector3> verts = new List<Vector3>(768);
			List<Vector2> uvs = new List<Vector2>(768);
			List<int> tris = new List<int>(1152);
			Vector3 val = Vector3.down * num3;
			Vector3 val2 = Vector3.up * 0.0807f;
			for (int j = 0; j < 48; j++)
			{
				ref Vector3 reference = ref array[j];
				reference += val2;
				ref Vector3 reference2 = ref array2[j];
				reference2 += val2;
			}
			for (int k = 0; k < 48; k++)
			{
				int num8 = (k + 1) % 48;
				float num9 = (float)k / 48f * 4f;
				float num10 = (float)(k + 1) / 48f * 4f;
				Vector3 val3 = array[k];
				Vector3 val4 = array[num8];
				Vector3 val5 = val3 + val;
				Vector3 val6 = val4 + val;
				Vector3 val7 = array2[k];
				Vector3 val8 = array2[num8];
				Vector3 val9 = val7 + val;
				Vector3 val10 = val8 + val;
				AddQuad(verts, uvs, tris, val3, val4, val8, val7, PlanarUv(val3), PlanarUv(val4), PlanarUv(val8), PlanarUv(val7));
				AddQuad(verts, uvs, tris, val5, val9, val10, val6, PlanarUv(val5), PlanarUv(val9), PlanarUv(val10), PlanarUv(val6));
				AddQuad(verts, uvs, tris, val3, val5, val6, val4, new Vector2(num9, 1f), new Vector2(num9, 0f), new Vector2(num10, 0f), new Vector2(num10, 1f));
				AddQuad(verts, uvs, tris, val7, val8, val10, val9, new Vector2(num9, 1f), new Vector2(num10, 1f), new Vector2(num10, 0f), new Vector2(num9, 0f));
			}
			return BuildMesh("mp_base_ring", verts, uvs, tris);
		}

		private static Mesh BuildPlateMesh()
		{
			//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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0129: 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_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.89f;
			float num2 = 0.16f;
			Vector3[] array = (Vector3[])(object)new Vector3[48];
			for (int i = 0; i < 48; i++)
			{
				float num3 = (float)Math.PI * 2f * (float)i / 48f;
				array[i] = new Vector3(Mathf.Cos(num3) * num, 0f, Mathf.Sin(num3) * num);
			}
			List<Vector3> verts = new List<Vector3>(576);
			List<Vector2> uvs = new List<Vector2>(576);
			List<int> tris = new List<int>(864);
			Vector3 val = Vector3.down * num2;
			Vector3 zero = Vector3.zero;
			Vector3 val2 = val;
			for (int j = 0; j < 48; j++)
			{
				int num4 = (j + 1) % 48;
				float num5 = (float)j / 48f * 4f;
				float num6 = (float)(j + 1) / 48f * 4f;
				Vector3 val3 = array[j];
				Vector3 val4 = array[num4];
				Vector3 val5 = val3 + val;
				Vector3 val6 = val4 + val;
				AddTri(verts, uvs, tris, zero, val3, val4, PlanarUv(zero), PlanarUv(val3), PlanarUv(val4));
				AddTri(verts, uvs, tris, val2, val5, val6, PlanarUv(val2), PlanarUv(val5), PlanarUv(val6));
				AddQuad(verts, uvs, tris, val3, val4, val6, val5, new Vector2(num5, 1f), new Vector2(num6, 1f), new Vector2(num6, 0f), new Vector2(num5, 0f));
			}
			return BuildMesh("mp_plate_disc", verts, uvs, tris);
		}

		private static Vector2 PlanarUv(Vector3 p)
		{
			//IL_0001: 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_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_0021: Unknown result type (might be due to invalid IL or missing references)
			return new Vector2(p.x * 0.5f, p.z * 0.5f);
		}

		private static void AddQuad(List<Vector3> verts, List<Vector2> uvs, List<int> tris, Vector3 a, Vector3 b, Vector3 c, Vector3 d, Vector2 ua, Vector2 ub, Vector2 uc, Vector2 ud)
		{
			//IL_0009: 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_001a: 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_002c: 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_003e: 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)
			int count = verts.Count;
			verts.Add(a);
			verts.Add(b);
			verts.Add(c);
			verts.Add(d);
			uvs.Add(ua);
			uvs.Add(ub);
			uvs.Add(uc);
			uvs.Add(ud);
			tris.Add(count);
			tris.Add(count + 1);
			tris.Add(count + 2);
			tris.Add(count);
			tris.Add(count + 2);
			tris.Add(count + 3);
		}

		private static void AddTri(List<Vector3> verts, List<Vector2> uvs, List<int> tris, Vector3 a, Vector3 b, Vector3 c, Vector2 ua, Vector2 ub, Vector2 uc)
		{
			//IL_0009: 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_001a: 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_002c: 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)
			int count = verts.Count;
			verts.Add(a);
			verts.Add(b);
			verts.Add(c);
			uvs.Add(ua);
			uvs.Add(ub);
			uvs.Add(uc);
			tris.Add(count);
			tris.Add(count + 1);
			tris.Add(count + 2);
		}

		private static Mesh BuildMesh(string name, List<Vector3> verts, List<Vector2> uvs, List<int> tris)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Expected O, but got Unknown
			Mesh val = new Mesh
			{
				name = name
			};
			val.SetVertices(verts);
			val.SetUVs(0, uvs);
			val.SetTriangles(tris, 0);
			val.RecalculateNormals();
			val.RecalculateBounds();
			return val;
		}
	}
	internal static class ObjLoader
	{
		private struct VertexKey : IEquatable<VertexKey>
		{
			private readonly int _position;

			private readonly int _uv;

			private readonly int _normal;

			public VertexKey(int position, int uv, int normal)
			{
				_position = position;
				_uv = uv;
				_normal = normal;
			}

			public bool Equals(VertexKey other)
			{
				return _position == other._position && _uv == other._uv && _normal == other._normal;
			}

			public override bool Equals(object obj)
			{
				return obj is VertexKey other && Equals(other);
			}

			public override int GetHashCode()
			{
				return (_position * 397) ^ (_uv * 31) ^ _normal;
			}
		}

		internal static Mesh LoadEmbedded(string resourceName, string meshName)
		{
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				using Stream stream = executingAssembly.GetManifestResourceStream(resourceName);
				if (stream == null)
				{
					ManualLogSource log = MovingPlatformPlugin.Log;
					if (log != null)
					{
						log.LogError((object)("找不到嵌入模型资源: " + resourceName));
					}
					return null;
				}
				using StreamReader reader = new StreamReader(stream);
				return Parse(reader, meshName);
			}
			catch (Exception ex)
			{
				ManualLogSource log2 = MovingPlatformPlugin.Log;
				if (log2 != null)
				{
					log2.LogError((object)("加载嵌入模型 " + resourceName + " 失败: " + ex.Message));
				}
				return null;
			}
		}

		private static Mesh Parse(TextReader reader, string meshName)
		{
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041f: Expected O, but got Unknown
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_033a: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0344: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Unknown result type (might be due to invalid IL or missing references)
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0375: 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)
			//IL_0379: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			List<Vector3> list = new List<Vector3>();
			List<Vector2> list2 = new List<Vector2>();
			List<Vector3> list3 = new List<Vector3>();
			List<Vector3> list4 = new List<Vector3>();
			List<Vector2> list5 = new List<Vector2>();
			List<Vector3> list6 = new List<Vector3>();
			List<int> list7 = new List<int>();
			Dictionary<VertexKey, int> dictionary = new Dictionary<VertexKey, int>();
			bool flag = false;
			string text;
			while ((text = reader.ReadLine()) != null)
			{
				text = text.Trim();
				if (text.Length == 0 || text[0] == '#')
				{
					continue;
				}
				string[] array = text.Split(new char[2] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
				if (array.Length == 0)
				{
					continue;
				}
				switch (array[0])
				{
				case "v":
					if (array.Length >= 4)
					{
						list.Add(new Vector3(F(array[1]), F(array[2]), F(array[3])));
					}
					break;
				case "vt":
					if (array.Length >= 3)
					{
						list2.Add(new Vector2(F(array[1]), F(array[2])));
					}
					break;
				case "vn":
					if (array.Length >= 4)
					{
						list3.Add(new Vector3(F(array[1]), F(array[2]), F(array[3])));
						flag = true;
					}
					break;
				case "f":
				{
					if (array.Length < 4)
					{
						break;
					}
					List<int> list8 = new List<int>(array.Length - 1);
					bool flag2 = true;
					for (int i = 1; i < array.Length; i++)
					{
						string[] array2 = array[i].Split(new char[1] { '/' });
						int num = ResolveIndex((array2.Length != 0) ? array2[0] : null, list.Count);
						int num2 = ((array2.Length > 1) ? ResolveIndex(array2[1], list2.Count) : (-1));
						int num3 = ((array2.Length > 2) ? ResolveIndex(array2[2], list3.Count) : (-1));
						if (num >= 0)
						{
							if (num3 < 0)
							{
								flag2 = false;
							}
							VertexKey key = new VertexKey(num, num2, num3);
							if (!dictionary.TryGetValue(key, out var value))
							{
								value = (dictionary[key] = list4.Count);
								list4.Add(list[num]);
								list5.Add((num2 >= 0) ? list2[num2] : Vector2.zero);
								list6.Add((num3 >= 0) ? list3[num3] : Vector3.up);
							}
							list8.Add(value);
						}
					}
					for (int j = 1; j + 1 < list8.Count; j++)
					{
						int num4 = list8[0];
						int num5 = list8[j];
						int num6 = list8[j + 1];
						if (flag2)
						{
							Vector3 val = list6[num4] + list6[num5] + list6[num6];
							Vector3 val2 = Vector3.Cross(list4[num5] - list4[num4], list4[num6] - list4[num4]);
							if (Vector3.Dot(val2, val) < 0f)
							{
								int num7 = num5;
								num5 = num6;
								num6 = num7;
							}
						}
						list7.Add(num4);
						list7.Add(num5);
						list7.Add(num6);
					}
					break;
				}
				}
			}
			if (list4.Count == 0 || list7.Count == 0)
			{
				return null;
			}
			Mesh val3 = new Mesh
			{
				name = meshName
			};
			val3.SetVertices(list4);
			val3.SetUVs(0, list5);
			if (flag)
			{
				val3.SetNormals(list6);
			}
			val3.SetTriangles(list7, 0);
			if (!flag)
			{
				val3.RecalculateNormals();
			}
			val3.RecalculateBounds();
			return val3;
		}

		private static int ResolveIndex(string text, int count)
		{
			if (string.IsNullOrEmpty(text))
			{
				return -1;
			}
			if (!int.TryParse(text, NumberStyles.Integer, CultureInfo.InvariantCulture, out var result))
			{
				return -1;
			}
			result = ((result >= 0) ? (result - 1) : (count + result));
			return (result >= 0 && result < count) ? result : (-1);
		}

		private static float F(string text)
		{
			return float.Parse(text, CultureInfo.InvariantCulture);
		}
	}
	public class PadBehaviour : MonoBehaviour, Hoverable, Interactable
	{
		internal const string PairKey = "mp_pair";

		internal const float DefaultStep = 2f;

		internal const float MinStep = 0f;

		internal const float MaxStep = 3f;

		internal const float StepIncrement = 0.5f;

		internal const string StepKey = "mp_step";

		internal const string StepFloatKey = "mp_step_f";

		internal const string IconKey = "mp_icon";

		internal const string IconXKey = "mp_icon_x";

		internal const string IconZKey = "mp_icon_z";

		internal const string TextKey = "mp_text";

		internal const string TextXKey = "mp_text_x";

		internal const string TextZKey = "mp_text_z";

		internal const string TextSizeKey = "mp_text_size";

		internal const string TextColorKey = "mp_text_color";

		internal static readonly List<PadBehaviour> All = new List<PadBehaviour>();

		internal const string DirectionKey = "mp_dir";

		private const float DamageStainThreshold = 0.7f;

		private const float DamageTintInterval = 0.3f;

		private ZNetView _nview;

		private bool _registered;

		private Material _ringMaterial;

		private int _damageLevel = -1;

		private WearNTear _wear;

		private float _nextDamageTint;

		private float _appliedHealth = -1f;

		internal int Direction
		{
			get
			{
				int num = 1;
				ZDO zdo = Zdo;
				if (zdo != null)
				{
					num = zdo.GetInt("mp_dir", num);
				}
				return (num >= 0) ? 1 : (-1);
			}
		}

		internal bool IsUp => Direction > 0;

		internal int LaunchSign => Direction;

		private ZNetView View
		{
			get
			{
				if ((Object)(object)_nview == (Object)null)
				{
					_nview = ((Component)this).GetComponent<ZNetView>();
				}
				return _nview;
			}
		}

		private ZDO Zdo
		{
			get
			{
				ZNetView view = View;
				return ((Object)(object)view != (Object)null && view.IsValid()) ? view.GetZDO() : null;
			}
		}

		internal static int CountPairName(string pairName, PadBehaviour except)
		{
			if (string.IsNullOrEmpty(pairName))
			{
				return 0;
			}
			int num = 0;
			foreach (PadBehaviour item in All)
			{
				if ((Object)(object)item != (Object)null && (Object)(object)item != (Object)(object)except && item.GetPairName() == pairName)
				{
					num++;
				}
			}
			return num;
		}

		private void Awake()
		{
			_nview = ((Component)this).GetComponent<ZNetView>();
		}

		private void Start()
		{
			if (IsGhostLayer())
			{
				RefreshAppearance();
				return;
			}
			BuildApproachSteps();
			ZDO zdo = Zdo;
			if (zdo != null)
			{
				if (!zdo.Persistent)
				{
					zdo.Persistent = true;
					ManualLogSource log = MovingPlatformPlugin.Log;
					if (log != null)
					{
						log.LogWarning((object)"[底座] ZDO 不是持久化的,已强制设为持久化");
					}
				}
				if (!View.IsOwner())
				{
					View.ClaimOwnership();
				}
			}
			RefreshAppearance();
			All.Add(this);
			_registered = true;
		}

		private void Update()
		{
			if ((Object)(object)_ringMaterial == (Object)null || Time.time < _nextDamageTint)
			{
				return;
			}
			_nextDamageTint = Time.time + 0.3f;
			if (!IsGhostLayer())
			{
				float healthFraction = GetHealthFraction();
				if (!(Mathf.Abs(healthFraction - _appliedHealth) < 0.002f))
				{
					_appliedHealth = healthFraction;
					ApplyDamageTint(healthFraction);
				}
			}
		}

		private float GetHealthFraction()
		{
			if ((Object)(object)_wear == (Object)null)
			{
				_wear = ((Component)this).GetComponent<WearNTear>();
			}
			return ((Object)(object)_wear != (Object)null) ? Mathf.Clamp01(_wear.GetHealthPercentage()) : 1f;
		}

		private void ApplyDamageTint(float health)
		{
			if ((Object)(object)_ringMaterial == (Object)null)
			{
				return;
			}
			int num = -1;
			if (health < 0.7f)
			{
				float num2 = Mathf.InverseLerp(0.7f, 0f, health);
				num = Mathf.Clamp(Mathf.FloorToInt(num2 * 8f), 0, 7);
			}
			if (num != _damageLevel)
			{
				_damageLevel = num;
				Texture2D val = ((num >= 0) ? MovingPlatformPlugin.GetDamageTexture(num) : MovingPlatformPlugin.GetPieceTexture());
				if (!((Object)(object)val == (Object)null) && _ringMaterial.HasProperty("_MainTex"))
				{
					_ringMaterial.mainTexture = (Texture)(object)val;
					_ringMaterial.SetTexture("_MainTex", (Texture)(object)val);
				}
			}
		}

		private void BuildApproachSteps()
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			float num = 0.0807f;
			float num2 = 0f;
			float num3 = num - num2;
			if (!(num3 <= 0.001f))
			{
				float num4 = 1f;
				for (int i = 0; i < 3; i++)
				{
					float num5 = num2 + num3 * (float)(i + 1) / 3f;
					float num6 = num5 - num2;
					float num7 = num4 + 0.06f * (float)(3 - i) - 0.03f;
					float num8 = num2 + num6 * 0.5f;
					AddStep(new Vector3(0f, num8, num7), new Vector3(2f, num6, 0.06f));
					AddStep(new Vector3(0f, num8, 0f - num7), new Vector3(2f, num6, 0.06f));
					AddStep(new Vector3(num7, num8, 0f), new Vector3(0.06f, num6, 2f));
					AddStep(new Vector3(0f - num7, num8, 0f), new Vector3(0.06f, num6, 2f));
				}
			}
		}

		private void AddStep(Vector3 localCenter, Vector3 size)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0037: 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_0055: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("approach_step");
			val.layer = ((Component)this).gameObject.layer;
			val.transform.SetParent(((Component)this).transform, false);
			val.transform.localPosition = localCenter;
			val.transform.localRotation = Quaternion.identity;
			val.transform.localScale = Vector3.one;
			BoxCollider val2 = val.AddComponent<BoxCollider>();
			val2.size = size;
			val2.center = Vector3.zero;
			((Collider)val2).isTrigger = false;
		}

		private void OnDisable()
		{
			if (_registered && !((Component)this).gameObject.activeSelf)
			{
				ManualLogSource log = MovingPlatformPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[底座" + (IsUp ? "上移" : "下移") + "] " + ((Object)this).name + " 被禁用/隐藏"));
				}
			}
		}

		private void OnDestroy()
		{
			All.Remove(this);
			if ((Object)(object)_ringMaterial != (Object)null)
			{
				MovingPlatformPlugin.DestroyMaterial(_ringMaterial);
				_ringMaterial = null;
			}
			if (_registered)
			{
				ManualLogSource log = MovingPlatformPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[底座" + (IsUp ? "上移" : "下移") + "] " + ((Object)this).name + " 被销毁(配对会失配)"));
				}
			}
		}

		private bool IsGhostLayer()
		{
			int layer = ((Component)this).gameObject.layer;
			return layer == LayerMask.NameToLayer("ghost") || layer == LayerMask.NameToLayer("character_ghost");
		}

		public Vector3 GetDeckPoint()
		{
			//IL_0007: 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_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_0020: 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)
			return ((Component)this).transform.position + Vector3.up * 0.0807f;
		}

		public string GetPairName()
		{
			return GetString("mp_pair");
		}

		public string GetHoverName()
		{
			return string.Empty;
		}

		public string GetHoverText()
		{
			return "[<color=yellow>E</color>] " + Lang.T("hover_set");
		}

		public float GetStep()
		{
			ZDO zdo = Zdo;
			if (zdo == null)
			{
				return 2f;
			}
			float num = zdo.GetFloat("mp_step_f", float.NaN);
			if (!float.IsNaN(num))
			{
				return ClampStep(num);
			}
			return ClampStep(zdo.GetInt("mp_step", 2));
		}

		internal static float ClampStep(float value)
		{
			return Mathf.Clamp(Mathf.Round(value / 0.5f) * 0.5f, 0f, 3f);
		}

		public float GetHoverOffset()
		{
			return 0f;
		}

		public bool Interact(Humanoid user, bool hold, bool alt)
		{
			if (hold)
			{
				return false;
			}
			PadEditPanel.Open(this);
			return true;
		}

		public bool UseItem(Humanoid user, ItemData item)
		{
			return false;
		}

		internal string GetIconName()
		{
			return GetString("mp_icon");
		}

		internal string GetPlateText()
		{
			return GetString("mp_text");
		}

		private string GetString(string key)
		{
			ZDO zdo = Zdo;
			return (zdo != null) ? (zdo.GetString(key, string.Empty) ?? string.Empty) : string.Empty;
		}

		private float GetFloat(string key, float fallback)
		{
			ZDO zdo = Zdo;
			return (zdo != null) ? zdo.GetFloat(key, fallback) : fallback;
		}

		internal float GetIconX()
		{
			return GetFloat("mp_icon_x", float.NaN);
		}

		internal float GetIconZ()
		{
			return GetFloat("mp_icon_z", float.NaN);
		}

		internal float GetTextX()
		{
			return GetFloat("mp_text_x", float.NaN);
		}

		internal float GetTextZ()
		{
			return GetFloat("mp_text_z", float.NaN);
		}

		internal float GetTextSize()
		{
			return GetFloat("mp_text_size", float.NaN);
		}

		internal string GetTextColorHex()
		{
			return GetString("mp_text_color");
		}

		internal void RefreshAppearance()
		{
			Transform val = ((Component)this).transform.Find("ring");
			MeshRenderer val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<MeshRenderer>() : ((Component)this).GetComponentInChildren<MeshRenderer>());
			if (!((Object)(object)val2 == (Object)null) && ((Object)(object)_ringMaterial == (Object)null || (Object)(object)((Renderer)val2).sharedMaterial != (Object)(object)_ringMaterial))
			{
				if ((Object)(object)_ringMaterial != (Object)null)
				{
					MovingPlatformPlugin.DestroyMaterial(_ringMaterial);
					_ringMaterial = null;
				}
				_ringMaterial = MovingPlatformPlugin.CreateRingMaterial();
				((Renderer)val2).sharedMaterial = _ringMaterial ?? MovingPlatformPlugin.GetNeutralMaterial();
				_appliedHealth = -1f;
				_damageLevel = -1;
			}
		}

		internal void ApplyEdit(string pairName, float step, string iconName, string plateText, int direction, float iconX, float iconZ, float textX, float textZ, float textSize, string textColorHex)
		{
			ZDO zdo = Zdo;
			if (zdo == null)
			{
				ManualLogSource log = MovingPlatformPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)"底座尚未就绪,无法保存设置");
				}
				return;
			}
			if (!View.IsOwner())
			{
				View.ClaimOwnership();
			}
			string text = (pairName ?? string.Empty).Trim();
			if (!string.IsNullOrEmpty(text) && CountPairName(text, this) >= 2)
			{
				ManualLogSource log2 = MovingPlatformPlugin.Log;
				if (log2 != null)
				{
					log2.LogWarning((object)("配对名 \"" + text + "\" 已有两个底座,拒绝保存"));
				}
				return;
			}
			float num = ClampStep(step);
			zdo.Set("mp_pair", text);
			zdo.Set("mp_step_f", num);
			zdo.Set("mp_icon", iconName ?? string.Empty);
			zdo.Set("mp_icon_x", iconX);
			zdo.Set("mp_icon_z", iconZ);
			zdo.Set("mp_text", (plateText ?? string.Empty).Trim());
			zdo.Set("mp_text_x", textX);
			zdo.Set("mp_text_z", textZ);
			zdo.Set("mp_text_size", textSize);
			zdo.Set("mp_text_color", textColorHex ?? string.Empty);
			zdo.Set("mp_dir", (direction >= 0) ? 1 : (-1));
			PadRegistry.RequestRefresh();
			RefreshAppearance();
			HoleEffectController component = ((Component)this).GetComponent<HoleEffectController>();
			if ((Object)(object)component != (Object)null)
			{
				component.ApplyConfig();
			}
		}
	}
	internal class PadEditPanel : MonoBehaviour
	{
		private class ItemIcon
		{
			internal string Name;

			internal string DisplayName;

			internal Sprite Sprite;

			internal string Type;
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateCamera")]
		internal static class FreezeCameraPatch
		{
			private static bool Prefix()
			{
				return !IsOpen;
			}
		}

		[HarmonyPatch(typeof(GameCamera), "UpdateMouseCapture")]
		internal static class MouseCapturePatch
		{
			private static bool Prefix()
			{
				return !IsOpen;
			}
		}

		[HarmonyPatch(typeof(Character), "TakeInput")]
		internal static class CharacterTakeInputPatch
		{
			private static bool Prefix(Character __instance, ref bool __result)
			{
				if (!IsOpen || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
				{
					return true;
				}
				__result = false;
				return false;
			}
		}

		private const float PanelWidth = 680f;

		private const float PanelHeight = 1000f;

		private const float PickerWidth = 780f;

		private const float PickerHeight = 600f;

		private const int PickerColumns = 7;

		private const float PickerCell = 100f;

		private static List<ItemIcon> _itemIcons;

		private static ObjectDB _itemIconsDb;

		private static readonly List<ItemIcon> _tabIcons = new List<ItemIcon>();

		private static ObjectDB _tabIconsDb;

		private static int _tabIconsTab = -1;

		private PadBehaviour _pad;

		private string _name = string.Empty;

		private string _nameError = string.Empty;

		private string _iconName = string.Empty;

		private string _plateText = string.Empty;

		private float _iconX;

		private float _iconZ = -0.2f;

		private float _textX;

		private float _textZ = 0.3f;

		private float _textSize = 0.04f;

		private string _textColorHex = "FFFFFF";

		private float _step = 2f;

		private int _direction = 1;

		private bool _open;

		private bool _picker;

		private int _pickerTab;

		private bool _focusRequested;

		private float _previousTimeScale = 1f;

		private Vector2 _scroll;

		private Keyboard _blockedKeyboard;

		private GUIStyle _labelStyle;

		private GUIStyle _titleStyle;

		private GUIStyle _fieldStyle;

		private GUIStyle _buttonStyle;

		private GUIStyle _smallStyle;

		private GUIStyle _errorStyle;

		private GUIStyle _sliderStyle;

		private GUIStyle _thumbStyle;

		private static readonly string[] PickerTabs = new string[5] { "tab_material", "tab_consumable", "tab_weapon", "tab_armor", "tab_other" };

		internal static PadEditPanel Instance { get; private set; }

		internal static bool IsOpen => (Object)(object)Instance != (Object)null && Instance._open;

		private void Awake()
		{
			Instance = this;
		}

		internal static void Open(PadBehaviour pad)
		{
			if (!((Object)(object)Instance == (Object)null) && !((Object)(object)pad == (Object)null))
			{
				Instance.Begin(pad);
				Instance._picker = false;
			}
		}

		private void Begin(PadBehaviour pad)
		{
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			_pad = pad;
			_name = pad.GetPairName();
			_nameError = string.Empty;
			_step = pad.GetStep();
			_direction = pad.Direction;
			_iconName = pad.GetIconName();
			_plateText = pad.GetPlateText();
			bool flag = (Object)(object)MovingPlatformPlugin.FindGameIcon(_iconName) != (Object)null;
			bool flag2 = !string.IsNullOrEmpty(_plateText);
			float iconX = pad.GetIconX();
			float iconZ = pad.GetIconZ();
			float textX = pad.GetTextX();
			float textZ = pad.GetTextZ();
			float textSize = pad.GetTextSize();
			_iconX = (float.IsNaN(iconX) ? 0f : iconX);
			_iconZ = ((!float.IsNaN(iconZ)) ? iconZ : (flag2 ? (-0.2f) : 0f));
			_textX = (float.IsNaN(textX) ? 0f : textX);
			_textZ = ((!float.IsNaN(textZ)) ? textZ : (flag ? 0.3f : 0f));
			_textSize = (float.IsNaN(textSize) ? 0.04f : textSize);
			_textColorHex = pad.GetTextColorHex();
			if (string.IsNullOrEmpty(_textColorHex))
			{
				_textColorHex = "FFFFFF";
			}
			_open = true;
			_focusRequested = false;
			_scroll = Vector2.zero;
			if (Time.timeScale > 0.01f)
			{
				_previousTimeScale = Time.timeScale;
			}
			Time.timeScale = 0f;
			Cursor.visible = true;
			Cursor.lockState = (CursorLockMode)0;
			if (MovingPlatformPlugin.BlockOtherModKeys == null || MovingPlatformPlugin.BlockOtherModKeys.Value)
			{
				_blockedKeyboard = Keyboard.current;
				if (_blockedKeyboard != null)
				{
					InputSystem.DisableDevice((InputDevice)(object)_blockedKeyboard, false);
				}
			}
		}

		private void Close()
		{
			if (_open)
			{
				_open = false;
				_picker = false;
				_pad = null;
				ReleaseKeyboard();
				Time.timeScale = ((_previousTimeScale > 0.01f) ? _previousTimeScale : 1f);
				Cursor.visible = false;
				Cursor.lockState = (CursorLockMode)1;
			}
		}

		private void Apply()
		{
			if ((Object)(object)_pad != (Object)null)
			{
				string text = (_name ?? string.Empty).Trim();
				if (!string.IsNullOrEmpty(text) && PadBehaviour.CountPairName(text, _pad) >= 2)
				{
					_nameError = Lang.T("err_pair_max");
					return;
				}
				bool flag = (Object)(object)MovingPlatformPlugin.FindGameIcon(_iconName) != (Object)null;
				bool flag2 = !string.IsNullOrEmpty(_plateText);
				float iconZ = ((!(Mathf.Abs(_iconZ) < 0.0001f)) ? _iconZ : (flag2 ? (-0.2f) : 0f));
				float textZ = ((!(Mathf.Abs(_textZ) < 0.0001f)) ? _textZ : (flag ? 0.3f : 0f));
				_pad.ApplyEdit(text, _step, _iconName, _plateText, _direction, _iconX, iconZ, _textX, textZ, _textSize, _textColorHex);
				PlateBehaviour plateForPad = PadRegistry.GetPlateForPad(_pad);
				if ((Object)(object)plateForPad != (Object)null)
				{
					plateForPad.RefreshIcon();
				}
			}
			Close();
		}

		private void OnDisable()
		{
			if (_open)
			{
				Close();
			}
		}

		private void ReleaseKeyboard()
		{
			if (_blockedKeyboard != null)
			{
				InputSystem.EnableDevice((InputDevice)(object)_blockedKeyboard);
				_blockedKeyboard = null;
			}
		}

		private void OnDestroy()
		{
			ReleaseKeyboard();
			if (Time.timeScale <= 0.01f)
			{
				Time.timeScale = 1f;
			}
		}

		private void OnGUI()
		{
			if (!_open)
			{
				return;
			}
			if ((Object)(object)_pad == (Object)null)
			{
				Close();
				return;
			}
			if (Time.timeScale > 0.01f)
			{
				Time.timeScale = 0f;
			}
			EnsureStyles();
			if (_picker)
			{
				DrawPicker();
			}
			else
			{
				DrawFields();
			}
		}

		private void DrawFields()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0345: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0533: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0627: Unknown result type (might be due to invalid IL or missing references)
			//IL_066a: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_073f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0786: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0807: Unknown result type (might be due to invalid IL or missing references)
			//IL_0844: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((float)Screen.width - 680f) * 0.5f, ((float)Screen.height - 1000f) * 0.5f, 680f, 1000f);
			DrawBackground(rect);
			float num = 24f;
			float num2 = ((Rect)(ref rect)).x + num;
			float num3 = ((Rect)(ref rect)).width - num * 2f;
			float num4 = ((Rect)(ref rect)).y + 16f;
			GUI.Label(new Rect(num2, num4, num3, 36f), Lang.T("panel_title"), _titleStyle);
			num4 += 48f;
			GUI.Label(new Rect(num2, num4, num3, 34f), Lang.T("label_pair_name"), _labelStyle);
			num4 += 38f;
			GUI.SetNextControlName("mp_name");
			string text = GUI.TextField(new Rect(num2, num4, num3, 42f), _name ?? string.Empty, 24, _fieldStyle);
			if (text != _name)
			{
				_name = text;
				_nameError = string.Empty;
			}
			num4 += 46f;
			if (!string.IsNullOrEmpty(_nameError))
			{
				GUI.Label(new Rect(num2, num4, num3, 24f), _nameError, _errorStyle);
				num4 += 28f;
			}
			num4 += 12f;
			GUI.Label(new Rect(num2, num4, 150f, 34f), Lang.T("label_direction"), _labelStyle);
			if (GUI.Button(new Rect(num2 + 120f, num4, 130f, 38f), Lang.T("dir_up"), (_direction > 0) ? _buttonStyle : GUI.skin.button))
			{
				_direction = 1;
			}
			if (GUI.Button(new Rect(num2 + 258f, num4, 130f, 38f), Lang.T("dir_down"), (_direction < 0) ? _buttonStyle : GUI.skin.button))
			{
				_direction = -1;
			}
			num4 += 52f;
			GUI.Label(new Rect(num2, num4, num3, 34f), Lang.T("label_height", _step.ToString("0.#", CultureInfo.InvariantCulture)), _labelStyle);
			num4 += 38f;
			float num5 = num3 - 110f;
			_step = PadBehaviour.ClampStep(GUI.HorizontalSlider(new Rect(num2, num4 + 8f, num5, 24f), _step, 0f, 3f, _sliderStyle, _thumbStyle));
			if (GUI.Button(new Rect(num2 + num5 + 12f, num4, 44f, 42f), "-", _buttonStyle))
			{
				_step = PadBehaviour.ClampStep(_step - 0.5f);
			}
			if (GUI.Button(new Rect(num2 + num5 + 62f, num4, 44f, 42f), "+", _buttonStyle))
			{
				_step = PadBehaviour.ClampStep(_step + 0.5f);
			}
			num4 += 58f;
			GUI.Label(new Rect(num2, num4 + 10f, 150f, 34f), Lang.T("label_icon"), _labelStyle);
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(num2 + 120f, num4, 56f, 56f);
			if (GUI.Button(val, GUIContent.none))
			{
				_picker = true;
				_pickerTab = 0;
				_scroll = Vector2.zero;
			}
			DrawSprite(val, ResolveIconSprite(_iconName));
			if (GUI.Button(new Rect(num2 + 184f, num4, 90f, 34f), Lang.T("btn_clear"), _buttonStyle))
			{
				_iconName = string.Empty;
			}
			num4 += 68f;
			GUI.Label(new Rect(num2, num4, num3, 30f), Lang.T("label_icon_x", _iconX.ToString("0.00", CultureInfo.InvariantCulture)), _labelStyle);
			_iconX = Round2(GUI.HorizontalSlider(new Rect(num2, num4 + 32f, num3, 20f), _iconX, -0.8f, 0.8f, _sliderStyle, _thumbStyle));
			num4 += 56f;
			GUI.Label(new Rect(num2, num4, num3, 30f), Lang.T("label_icon_z", _iconZ.ToString("0.00", CultureInfo.InvariantCulture)), _labelStyle);
			_iconZ = Round2(GUI.HorizontalSlider(new Rect(num2, num4 + 32f, num3, 20f), _iconZ, -0.8f, 0.8f, _sliderStyle, _thumbStyle));
			num4 += 56f;
			GUI.Label(new Rect(num2, num4, num3, 34f), Lang.T("label_plate_text"), _labelStyle);
			num4 += 38f;
			_plateText = GUI.TextField(new Rect(num2, num4, num3, 42f), _plateText ?? string.Empty, 40, _fieldStyle);
			num4 += 58f;
			GUI.Label(new Rect(num2, num4, num3, 30f), Lang.T("label_text_x", _textX.ToString("0.00", CultureInfo.InvariantCulture)), _labelStyle);
			_textX = Round2(GUI.HorizontalSlider(new Rect(num2, num4 + 32f, num3, 20f), _textX, -0.8f, 0.8f, _sliderStyle, _thumbStyle));
			num4 += 56f;
			GUI.Label(new Rect(num2, num4, num3, 30f), Lang.T("label_text_z", _textZ.ToString("0.00", CultureInfo.InvariantCulture)), _labelStyle);
			_textZ = Round2(GUI.HorizontalSlider(new Rect(num2, num4 + 32f, num3, 20f), _textZ, -0.8f, 0.8f, _sliderStyle, _thumbStyle));
			num4 += 56f;
			GUI.Label(new Rect(num2, num4, num3, 30f), Lang.T("label_text_size", _textSize.ToString("0.00", CultureInfo.InvariantCulture)), _labelStyle);
			_textSize = Round2(GUI.HorizontalSlider(new Rect(num2, num4 + 32f, num3, 20f), _textSize, 0.02f, 0.1f, _sliderStyle, _thumbStyle));
			num4 += 58f;
			GUI.Label(new Rect(num2, num4, 200f, 30f), Lang.T("label_text_color"), _labelStyle);
			_textColorHex = GUI.TextField(new Rect(num2 + 200f, num4, 180f, 34f), _textColorHex ?? "FFFFFF", 8, _fieldStyle);
			num4 += 44f;
			num4 += 16f;
			float num6 = (num3 - 12f) * 0.5f;
			if (GUI.Button(new Rect(num2, num4, num6, 46f), Lang.T("btn_ok"), _buttonStyle))
			{
				Apply();
				return;
			}
			if (GUI.Button(new Rect(num2 + num6 + 12f, num4, num6, 46f), Lang.T("btn_cancel"), _buttonStyle))
			{
				Close();
				return;
			}
			if (!_focusRequested)
			{
				_focusRequested = true;
				GUI.FocusControl("mp_name");
			}
			HandleKeys(inPicker: false);
		}

		private static float Round2(float value)
		{
			return Mathf.Round(value * 100f) / 100f;
		}

		private void DrawPicker()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0167: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((float)Screen.width - 780f) * 0.5f, ((float)Screen.height - 600f) * 0.5f, 780f, 600f);
			DrawBackground(rect);
			float num = 20f;
			float num2 = ((Rect)(ref rect)).x + num;
			float num3 = ((Rect)(ref rect)).width - num * 2f;
			float num4 = ((Rect)(ref rect)).y + 12f;
			GUI.Label(new Rect(num2, num4, num3 - 120f, 42f), Lang.T("picker_title"), _titleStyle);
			if (GUI.Button(new Rect(num2 + num3 - 110f, num4, 110f, 34f), Lang.T("btn_back"), _buttonStyle))
			{
				_picker = false;
				return;
			}
			num4 += 52f;
			string[] pickerTabs = PickerTabs;
			float num5 = 8f;
			float num6 = (num3 - num5 * (float)(pickerTabs.Length - 1)) / (float)pickerTabs.Length;
			Rect val = default(Rect);
			for (int i = 0; i < pickerTabs.Length; i++)
			{
				((Rect)(ref val))..ctor(num2 + (float)i * (num6 + num5), num4, num6, 34f);
				if (GUI.Button(val, Lang.T(pickerTabs[i]), (_pickerTab == i) ? _buttonStyle : GUI.skin.button))
				{
					_pickerTab = i;
					_scroll = Vector2.zero;
				}
			}
			num4 += 44f;
			List<ItemIcon> tabIcons = GetTabIcons(_pickerTab);
			if (tabIcons.Count == 0)
			{
				GUI.Label(new Rect(num2, num4, num3, 28f), Lang.T("picker_empty"), _smallStyle);
			}
			Rect val2 = default(Rect);
			((Rect)(ref val2))..ctor(num2, num4, num3, ((Rect)(ref rect)).yMax - num4 - num);
			int num7 = Mathf.CeilToInt((float)tabIcons.Count / 7f);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(0f, 0f, ((Rect)(ref val2)).width - 24f, Mathf.Max(((Rect)(ref val2)).height, (float)num7 * 100f + 8f));
			_scroll = GUI.BeginScrollView(val2, _scroll, val3);
			Rect val4 = default(Rect);
			Rect rect2 = default(Rect);
			for (int j = 0; j < tabIcons.Count; j++)
			{
				ItemIcon itemIcon = tabIcons[j];
				int num8 = j % 7;
				int num9 = j / 7;
				((Rect)(ref val4))..ctor((float)num8 * 100f, (float)num9 * 100f, 94f, 94f);
				if (GUI.Button(val4, GUIContent.none))
				{
					_iconName = itemIcon.Name;
					_picker = false;
					GUI.EndScrollView();
					return;
				}
				((Rect)(ref rect2))..ctor(((Rect)(ref val4)).x + (((Rect)(ref val4)).width - 56f) * 0.5f, ((Rect)(ref val4)).y + (((Rect)(ref val4)).height - 56f) * 0.5f, 56f, 56f);
				DrawSprite(rect2, itemIcon.Sprite);
			}
			GUI.EndScrollView();
			HandleKeys(inPicker: true);
		}

		private void HandleKeys(bool inPicker)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Invalid comparison between Unknown and I4
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Invalid comparison between Unknown and I4
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Invalid comparison between Unknown and I4
			Event current = Event.current;
			if (current == null || (int)current.type != 4)
			{
				return;
			}
			if ((int)current.keyCode == 27)
			{
				if (inPicker)
				{
					_picker = false;
				}
				else
				{
					Close();
				}
				current.Use();
			}
			else if (!inPicker && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
			{
				Apply();
				current.Use();
			}
		}

		private static int GetTab(string type)
		{
			type = type ?? string.Empty;
			switch (type)
			{
			case "Material":
				return 0;
			case "Consumable":
				return 1;
			default:
				if (!type.Contains("Weapon"))
				{
					switch (type)
					{
					default:
						if (!(type == "Hands"))
						{
							return 4;
						}
						goto case "Shield";
					case "Shield":
					case "Helmet":
					case "Chest":
					case "Legs":
						return 3;
					}
				}
				goto case "Bow";
			case "Bow":
			case "Ammo":
			case "Tool":
			case "Torch":
				return 2;
			}
		}

		private static List<ItemIcon> GetTabIcons(int tab)
		{
			if ((Object)(object)_tabIconsDb == (Object)(object)_itemIconsDb && _tabIconsTab == tab)
			{
				return _tabIcons;
			}
			_tabIcons.Clear();
			foreach (ItemIcon itemIcon in GetItemIcons())
			{
				if (GetTab(itemIcon.Type) == tab)
				{
					_tabIcons.Add(itemIcon);
				}
			}
			_tabIconsDb = _itemIconsDb;
			_tabIconsTab = tab;
			return _tabIcons;
		}

		private static List<ItemIcon> GetItemIcons()
		{
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			ObjectDB instance = ObjectDB.instance;
			if (_itemIcons != null && (Object)(object)_itemIconsDb != (Object)null && (Object)(object)_itemIconsDb == (Object)(object)instance)
			{
				return _itemIcons;
			}
			_itemIcons = new List<ItemIcon>();
			_itemIconsDb = null;
			if ((Object)(object)instance == (Object)null || instance.m_items == null || instance.m_items.Count == 0)
			{
				return _itemIcons;
			}
			_itemIconsDb = instance;
			HashSet<string> hashSet = new HashSet<string>();
			foreach (GameObject item2 in instance.m_items)
			{
				if ((Object)(object)item2 == (Object)null)
				{
					continue;
				}
				ItemDrop component = item2.GetComponent<ItemDrop>();
				SharedData val = (((Object)(object)component != (Object)null && component.m_itemData != null) ? component.m_itemData.m_shared : null);
				if (val == null || val.m_icons == null || val.m_icons.Length == 0)
				{
					continue;
				}
				Sprite val2 = val.m_icons[0];
				if (!((Object)(object)val2 == (Object)null))
				{
					Texture2D texture = val2.texture;
					Rect textureRect = val2.textureRect;
					string item = (((Object)(object)texture != (Object)null) ? $"{((Object)texture).GetInstanceID()}:{((Rect)(ref textureRect)).x}:{((Rect)(ref textureRect)).y}:{((Rect)(ref textureRect)).width}:{((Rect)(ref textureRect)).height}" : ((Object)val2).GetInstanceID().ToString());
					if (hashSet.Add(item))
					{
						_itemIcons.Add(new ItemIcon
						{
							Name = ((Object)item2).name,
							DisplayName = val.m_name,
							Sprite = val2,
							Type = ((object)Unsafe.As<ItemType, ItemType>(ref val.m_itemType)/*cast due to .constrained prefix*/).ToString()
						});
					}
				}
			}
			_itemIcons.Sort((ItemIcon a, ItemIcon b) => string.Compare(a.DisplayName, b.DisplayName, StringComparison.Ordinal));
			return _itemIcons;
		}

		private static Sprite ResolveIconSprite(string iconName)
		{
			return MovingPlatformPlugin.FindGameIcon(iconName);
		}

		private static void DrawSprite(Rect rect, Sprite sprite)
		{
			//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_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)sprite == (Object)null) && !((Object)(object)sprite.texture == (Object)null))
			{
				Texture2D texture = sprite.texture;
				Rect textureRect = sprite.textureRect;
				if (!(((Rect)(ref textureRect)).width <= 0f) && !(((Rect)(ref textureRect)).height <= 0f))
				{
					Rect val = default(Rect);
					((Rect)(ref val))..ctor(((Rect)(ref textureRect)).x / (float)((Texture)texture).width, ((Rect)(ref textureRect)).y / (float)((Texture)texture).height, ((Rect)(ref textureRect)).width / (float)((Texture)texture).width, ((Rect)(ref textureRect)).height / (float)((Texture)texture).height);
					GUI.DrawTextureWithTexCoords(rect, (Texture)(object)texture, val, true);
				}
			}
		}

		private static void DrawBackground(Rect rect)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = new Color(0.1f, 0.1f, 0.12f, 1f);
			GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
			GUI.color = color;
		}

		private void EnsureStyles()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Expected O, but got Unknown
			if (_labelStyle == null)
			{
				_labelStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 20
				};
				_labelStyle.normal.textColor = Color.white;
				_titleStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 24,
					fontStyle = (FontStyle)1
				};
				_titleStyle.normal.textColor = Color.white;
				_fieldStyle = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 22,
					alignment = (TextAnchor)3
				};
				_buttonStyle = new GUIStyle(GUI.skin.button)
				{
					fontSize = 20
				};
				_buttonStyle.normal.textColor = Color.white;
				_buttonStyle.hover.textColor = Color.white;
				_smallStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 13,
					alignment = (TextAnchor)4
				};
				_smallStyle.normal.textColor = new Color(0.85f, 0.85f, 0.85f);
				_errorStyle = new GUIStyle(_smallStyle)
				{
					alignment = (TextAnchor)3
				};
				_errorStyle.normal.textColor = new Color(1f, 0.45f, 0.45f);
				_sliderStyle = new GUIStyle(GUI.skin.horizontalSlider)
				{
					fixedHeight = 0f
				};
				_thumbStyle = new GUIStyle(GUI.skin.horizontalSliderThumb)
				{
					fixedWidth = 26f,
					fixedHeight = 26f
				};
			}
		}

		private void LateUpdate()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (_open)
			{
				Player localPlayer = Player.m_localPlayer;
				if (!((Object)(object)localPlayer == (Object)null))
				{
					localPlayer.SetControls(Vector3.zero, false, false, false, false, false, false, false, false, false, false, false);
				}
			}
		}
	}
	public static class PadRegistry
	{
		private const float ScanInterval = 0.5f;

		private static readonly Dictionary<string, PlateBehaviour> Plates = new Dictionary<string, PlateBehaviour>();

		private static float _nextScan;

		private static bool _dirty = true;

		internal static IEnumerable<PlateBehaviour> AllPlates => Plates.Values;

		internal static PlateBehaviour GetPlateForPad(PadBehaviour pad)
		{
			if ((Object)(object)pad == (Object)null)
			{
				return null;
			}
			foreach (PlateBehaviour value in Plates.Values)
			{
				if ((Object)(object)value != (Object)null && value.HasPad(pad))
				{
					return value;
				}
			}
			return null;
		}

		public static void RequestRefresh()
		{
			_dirty = true;
		}

		public static void Tick()
		{
			if (_dirty || !(Time.time < _nextScan))
			{
				_dirty = false;
				_nextScan = Time.time + 0.5f;
				Scan();
			}
		}

		private static void Scan()
		{
			if (!MovingPlatformPlugin.WorldReady || (Object)(object)ZNetScene.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			PadBehaviour[] array = PadBehaviour.All.ToArray();
			PadBehaviour[] array2 = array;
			foreach (PadBehaviour padBehaviour in array2)
			{
				if ((Object)(object)padBehaviour == (Object)null)
				{
					PadBehaviour.All.Remove(padBehaviour);
				}
				else if (!((Component)padBehaviour).gameObject.activeSelf)
				{
					ManualLogSource log = MovingPlatformPlugin.Log;
					if (log != null)
					{
						log.LogWarning((object)("[底座] " + ((Object)padBehaviour).name + " 处于未激活状态,重新激活"));
					}
					((Component)padBehaviour).gameObject.SetActive(true);
				}
			}
			Dictionary<string, List<PadBehaviour>> dictionary = new Dictionary<string, List<PadBehaviour>>(StringComparer.Ordinal);
			PadBehaviour[] array3 = array;
			foreach (PadBehaviour padBehaviour2 in array3)
			{
				if ((Object)(object)padBehaviour2 == (Object)null)
				{
					continue;
				}
				string pairName = padBehaviour2.GetPairName();
				if (!string.IsNullOrEmpty(pairName))
				{
					if (!dictionary.TryGetValue(pairName, out var value))
					{
						value = (dictionary[pairName] = new List<PadBehaviour>());
					}
					value.Add(padBehaviour2);
				}
			}
			HashSet<string> hashSet = new HashSet<string>(StringComparer.Ordinal);
			foreach (KeyValuePair<string, List<PadBehaviour>> item in dictionary)
			{
				if (item.Value.Count != 2)
				{
					continue;
				}
				hashSet.Add(item.Key);
				PadBehaviour a = item.Value[0];
				PadBehaviour b = item.Value[1];
				if (!Plates.TryGetValue(item.Key, out var value2) || (Object)(object)value2 == (Object)null)
				{
					value2 = PlateBehaviour.Create(a, b, item.Key);
					if ((Object)(object)value2 != (Object)null)
					{
						Plates[item.Key] = value2;
						continue;
					}
					ManualLogSource log2 = MovingPlatformPlugin.Log;
					if (log2 != null)
					{
						log2.LogWarning((object)("配对 \"" + item.Key + "\" 生成圆平台失败"));
					}
				}
				else
				{
					value2.SetPads(a, b);
				}
			}
			List<string> list2 = new List<string>();
			foreach (KeyValuePair<string, PlateBehaviour> plate in Plates)
			{
				if ((Object)(object)plate.Value == (Object)null || !hashSet.Contains(plate.Key))
				{
					list2.Add(plate.Key);
				}
			}
			foreach (string item2 in list2)
			{
				PlateBehaviour plateBehaviour = Plates[item2];
				if ((Object)(object)plateBehaviour != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)plateBehaviour).gameObject);
				}
				Plates.Remove(item2);
			}
		}
	}
	internal static class PlacementFixer
	{
		[HarmonyPatch(typeof(Player), "TryPlacePiece")]
		internal static class TryPlacePiecePatch
		{
			private static void Prefix(Player __instance, Piece __0)
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0071: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: 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_0093: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0110: 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)
				//IL_0282: Unknown result type (might be due to invalid IL or missing references)
				//IL_028d: Unknown result type (might be due to invalid IL or missing references)
				//IL_02aa: 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_02c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ee: 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_030c: Unknown result type (might be due to invalid IL or missing references)
				//IL_031b: Unknown result type (might be due to invalid IL or missing references)
				//IL_031c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0201: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0344: Unknown result type (might be due to invalid IL or missing references)
				//IL_0206: Unknown result type (might be due to invalid IL or missing references)
				//IL_0231: Unknown result type (might be due to invalid IL or missing references)
				//IL_0234: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0243: Unknown result type (might be due to invalid IL or missing references)
				//IL_0248: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_022e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: 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_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_019b: 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)
				if ((Object)(object)__instance == (Object)null || (Object)(object)__0 == (Object)null || (Object)(object)((Component)__0).GetComponent<PadBehaviour>() == (Object)null)
				{
					return;
				}
				GameObject val = PlacementGhost.Invoke(__instance);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				Vector3 position = ((Component)__instance).transform.position;
				Vector3 position2 = val.transform.position;
				float num = Vector3.Distance(position, position2);
				if (num <= 8f)
				{
					return;
				}
				Vector3 val2 = position2;
				string text = "keep";
				bool flag = false;
				GameCamera instance = GameCamera.instance;
				Transform val3 = (((Object)(object)instance != (Object)null) ? ((Component)instance).transform : null);
				if ((Object)(object)val3 != (Object)null)
				{
					Vector3 position3 = val3.position;
					Vector3 forward = val3.forward;
					RaycastHit[] array = Physics.RaycastAll(position3, forward, 8f, -1, (QueryTriggerInteraction)1);
					float num2 = float.MaxValue;
					RaycastHit[] array2 = array;
					for (int i = 0; i < array2.Length; i++)
					{
						RaycastHit val4 = array2[i];
						if (!((Object)(object)((RaycastHit)(ref val4)).collider == (Object)null) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(((Component)__instance).transform) && !((Component)((RaycastHit)(ref val4)).collider).transform.IsChildOf(val.transform) && ((RaycastHit)(ref val4)).distance < num2)
						{
							num2 = ((RaycastHit)(ref val4)).distance;
							val2 = ((RaycastHit)(ref val4)).point + ((RaycastHit)(ref val4)).normal * 0.02f;
							text = "cam-ray:" + ((Object)((RaycastHit)(ref val4)).collider).name;
							flag = true;
						}
					}
				}
				if (!flag || Vector3.Distance(position, val2) > 8f)
				{
					Vector3 val5 = (((Object)(object)val3 != (Object)null) ? val3.forward : Vector3.forward);
					val5.y = 0f;
					if (((Vector3)(ref val5)).sqrMagnitude < 0.01f)
					{
						val5 = Vector3.forward;
					}
					val2 = position + ((Vector3)(ref val5)).normalized * 2f;
					text = (flag ? (text + "→clamped") : "player-forward");
				}
				ManualLogSource log = MovingPlatformPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)($"[放置纠正] 玩家=({position.x:F1},{position.y:F1},{position.z:F1}) " + $"原ghost=({position2.x:F1},{position2.y:F1},{position2.z:F1}) 距玩家={num:F1}m " + $"→ 新位置=({val2.x:F2},{val2.y:F2},{val2.z:F2}) 距玩家={Vector3.Distance(position, val2):F1}m 方式={text}"));
				}
				val.transform.position = val2;
			}
		}

		private static readonly FieldRef<Player, GameObject> PlacementGhost = AccessTools.FieldRefAccess<Player, GameObject>("m_placementGhost");
	}
	public class PlateBehaviour : MonoBehaviour, Hove