Decompiled source of Crawl Braised Ducks UC Kit v1.0.0

ClothingEquipEditor.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using DM;
using HarmonyLib;
using Landfall.TABS;
using Landfall.TABS.UnitEditor;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.SceneManagement;

[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 = "")]
[assembly: AssemblyVersion("0.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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 ClothingEquipEditor
{
	[BepInPlugin("com.clothingequipeditor.mod", "Clothing Equip Editor", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		[CompilerGenerated]
		private sealed class <InitUI>d__4 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Plugin <>4__this;

			private GameObject <uiObj>5__1;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <InitUI>d__4(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<uiObj>5__1 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_006b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0075: Expected O, but got Unknown
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Expected O, but got Unknown
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)Object.FindObjectOfType<ServiceLocator>() != (Object)null));
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<>2__current = (object)new WaitForSecondsRealtime(1f);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					<uiObj>5__1 = new GameObject("ClothingEquipEditorUI");
					Object.DontDestroyOnLoad((Object)(object)<uiObj>5__1);
					EditorUI = <uiObj>5__1.AddComponent<EquipEditorUI>();
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		public static ManualLogSource Log;

		private Harmony harmony;

		public static EquipEditorUI EditorUI;

		private void Awake()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			harmony = new Harmony("com.clothingequipeditor.mod");
			harmony.PatchAll();
			((MonoBehaviour)this).StartCoroutine(InitUI());
		}

		[IteratorStateMachine(typeof(<InitUI>d__4))]
		private IEnumerator InitUI()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <InitUI>d__4(0)
			{
				<>4__this = this
			};
		}

		private void OnDestroy()
		{
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
	}
	public class EquipEditorUI : MonoBehaviour
	{
		private bool showUI = false;

		private Rect windowRect = new Rect(0f, 0f, 360f, 620f);

		private const float BASE_WIDTH = 1920f;

		private const float BASE_HEIGHT = 1080f;

		private float uiScale = 1f;

		private int lastScreenWidth = 0;

		private int lastScreenHeight = 0;

		private EquipedClothingWrapper currentWrapper;

		private string[] equipTypeNames = new string[3] { "CEE_EQUIP_BOTH", "CEE_EQUIP_LEFT", "CEE_EQUIP_RIGHT" };

		private EquipType[] equipTypes = (EquipType[])(object)new EquipType[3]
		{
			default(EquipType),
			(EquipType)1,
			(EquipType)2
		};

		private int selectedEquipIndex = 0;

		private Vector3 positionOffset = Vector3.zero;

		private Vector3 scale = Vector3.one;

		private Vector3 rotation = Vector3.zero;

		private bool showPositionSection = true;

		private bool showRotationSection = true;

		private bool showScaleSection = true;

		private bool showEquipSection = true;

		private bool memoryMode = false;

		private Texture2D texWindowBg;

		private Texture2D texHeaderBg;

		private Texture2D texSectionBg;

		private Texture2D texBtnNormal;

		private Texture2D texBtnHover;

		private Texture2D texBtnActive;

		private Texture2D texBtnSelected;

		private Texture2D texCloseNormal;

		private Texture2D texCloseHover;

		private Texture2D texInputBg;

		private Texture2D texSliderBg;

		private Texture2D texSliderFill;

		private Texture2D texSepLine;

		private GUIStyle styleWindow;

		private GUIStyle styleHeaderLabel;

		private GUIStyle styleSectionToggle;

		private GUIStyle styleAxisLabel;

		private GUIStyle styleTextField;

		private GUIStyle styleCloseBtn;

		private GUIStyle styleActionBtn;

		private GUIStyle styleEquipBtn;

		private GUIStyle styleEquipBtnSel;

		private GUIStyle styleClothingName;

		private GUIStyle styleSlider;

		private GUIStyle styleSliderThumb;

		private bool stylesInitialized = false;

		private bool translationsInjected = false;

		private static readonly string L_TITLE = "CEE_TITLE";

		private static readonly string L_CURR_CLOTHING = "CEE_CURR_CLOTHING";

		private static readonly string L_UNKNOWN = "CEE_UNKNOWN";

		private static readonly string L_SEC_EQUIP = "CEE_SEC_EQUIP";

		private static readonly string L_SEC_ROTATION = "CEE_SEC_ROTATION";

		private static readonly string L_SEC_POSITION = "CEE_SEC_POSITION";

		private static readonly string L_SEC_SCALE = "CEE_SEC_SCALE";

		private static readonly string L_EQUIP_BOTH = "CEE_EQUIP_BOTH";

		private static readonly string L_EQUIP_LEFT = "CEE_EQUIP_LEFT";

		private static readonly string L_EQUIP_RIGHT = "CEE_EQUIP_RIGHT";

		private static readonly string L_RESET_ROT = "CEE_RESET_ROTATION";

		private static readonly string L_RESET_POS = "CEE_RESET_POSITION";

		private static readonly string L_RESET_SCALE = "CEE_RESET_SCALE";

		private static readonly string L_RESET_ALL = "CEE_RESET_ALL";

		private static readonly string L_CLOSE = "CEE_CLOSE";

		private string[] textFieldValues = new string[9];

		private bool[] textFieldFocused = new bool[9];

		private bool IsInUnitEditor
		{
			get
			{
				//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)
				for (int i = 0; i < SceneManager.sceneCount; i++)
				{
					Scene sceneAt = SceneManager.GetSceneAt(i);
					if (((Scene)(ref sceneAt)).name == "UnitCreator_GamepadUI")
					{
						return true;
					}
				}
				return false;
			}
		}

		private void InjectTranslations()
		{
			//IL_0aa1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab8: Unknown result type (might be due to invalid IL or missing references)
			if (translationsInjected)
			{
				return;
			}
			try
			{
				FieldInfo field = typeof(Localizer).GetField("m_localization", BindingFlags.Static | BindingFlags.NonPublic);
				if (field == null)
				{
					return;
				}
				Dictionary<Language, Dictionary<string, string>> dictionary = (Dictionary<Language, Dictionary<string, string>>)field.GetValue(null);
				if (dictionary == null)
				{
					return;
				}
				Dictionary<Language, Dictionary<string, string>> dictionary2 = new Dictionary<Language, Dictionary<string, string>>();
				Dictionary<string, string> value = new Dictionary<string, string>
				{
					{ L_TITLE, "Clothing Equip Editor" },
					{ L_CURR_CLOTHING, "Current Clothing:" },
					{ L_UNKNOWN, "Unknown Clothing" },
					{ L_SEC_EQUIP, "Equip Type (m_equip)" },
					{ L_SEC_ROTATION, "Rotation" },
					{ L_SEC_POSITION, "Position Offset (m_positionOffset)" },
					{ L_SEC_SCALE, "Scale (m_scale)" },
					{ L_EQUIP_BOTH, "Both" },
					{ L_EQUIP_LEFT, "Left" },
					{ L_EQUIP_RIGHT, "Right" },
					{ L_RESET_ROT, "Reset Rotation" },
					{ L_RESET_POS, "Reset Position" },
					{ L_RESET_SCALE, "Reset Scale" },
					{ L_RESET_ALL, "Reset All" },
					{ L_CLOSE, "Close Editor" },
					{ "CEE_MEMORY_MODE", "Memory Mode (keep values when switching)" }
				};
				dictionary2[(Language)0] = value;
				Dictionary<string, string> value2 = new Dictionary<string, string>
				{
					{ L_TITLE, "服装属性编辑器" },
					{ L_CURR_CLOTHING, "当前服装:" },
					{ L_UNKNOWN, "未知服装" },
					{ L_SEC_EQUIP, "装备位置 (m_equip)" },
					{ L_SEC_ROTATION, "旋转" },
					{ L_SEC_POSITION, "位置偏移 (m_positionOffset)" },
					{ L_SEC_SCALE, "缩放大小 (m_scale)" },
					{ L_EQUIP_BOTH, "双手" },
					{ L_EQUIP_LEFT, "左手" },
					{ L_EQUIP_RIGHT, "右手" },
					{ L_RESET_ROT, "重置旋转" },
					{ L_RESET_POS, "重置位置" },
					{ L_RESET_SCALE, "重置缩放" },
					{ L_RESET_ALL, "重置全部" },
					{ L_CLOSE, "关闭编辑器" },
					{ "CEE_MEMORY_MODE", "记忆模式(切换服装时保持数值)" }
				};
				dictionary2[(Language)7] = value2;
				Dictionary<string, string> value3 = new Dictionary<string, string>
				{
					{ L_TITLE, "装備エディター" },
					{ L_CURR_CLOTHING, "現在の装備:" },
					{ L_UNKNOWN, "不明な装備" },
					{ L_SEC_EQUIP, "装備位置 (m_equip)" },
					{ L_SEC_ROTATION, "回転" },
					{ L_SEC_POSITION, "位置オフセット (m_positionOffset)" },
					{ L_SEC_SCALE, "スケール (m_scale)" },
					{ L_EQUIP_BOTH, "両手" },
					{ L_EQUIP_LEFT, "左手" },
					{ L_EQUIP_RIGHT, "右手" },
					{ L_RESET_ROT, "回転リセット" },
					{ L_RESET_POS, "位置リセット" },
					{ L_RESET_SCALE, "スケールリセット" },
					{ L_RESET_ALL, "全リセット" },
					{ L_CLOSE, "エディターを閉じる" },
					{ "CEE_MEMORY_MODE", "メモリモード(切り替え時に値を保持)" }
				};
				dictionary2[(Language)8] = value3;
				Dictionary<string, string> value4 = new Dictionary<string, string>
				{
					{ L_TITLE, "Editeur d'Equipement" },
					{ L_CURR_CLOTHING, "Vetement actuel :" },
					{ L_UNKNOWN, "Vetement inconnu" },
					{ L_SEC_EQUIP, "Type d'equipement (m_equip)" },
					{ L_SEC_ROTATION, "Rotation" },
					{ L_SEC_POSITION, "Decalage de position (m_positionOffset)" },
					{ L_SEC_SCALE, "Echelle (m_scale)" },
					{ L_EQUIP_BOTH, "Les deux" },
					{ L_EQUIP_LEFT, "Gauche" },
					{ L_EQUIP_RIGHT, "Droite" },
					{ L_RESET_ROT, "Reinitialiser rotation" },
					{ L_RESET_POS, "Reinitialiser position" },
					{ L_RESET_SCALE, "Reinitialiser echelle" },
					{ L_RESET_ALL, "Tout reinitialiser" },
					{ L_CLOSE, "Fermer l'editeur" },
					{ "CEE_MEMORY_MODE", "Mode memoire (garder les valeurs au changement)" }
				};
				dictionary2[(Language)1] = value4;
				Dictionary<string, string> value5 = new Dictionary<string, string>
				{
					{ L_TITLE, "Ausruestungs-Editor" },
					{ L_CURR_CLOTHING, "Aktuelle Kleidung:" },
					{ L_UNKNOWN, "Unbekannte Kleidung" },
					{ L_SEC_EQUIP, "Ausruestungstyp (m_equip)" },
					{ L_SEC_ROTATION, "Rotation" },
					{ L_SEC_POSITION, "Positionsversatz (m_positionOffset)" },
					{ L_SEC_SCALE, "Skalierung (m_scale)" },
					{ L_EQUIP_BOTH, "Beide" },
					{ L_EQUIP_LEFT, "Links" },
					{ L_EQUIP_RIGHT, "Rechts" },
					{ L_RESET_ROT, "Rotation zuruecksetzen" },
					{ L_RESET_POS, "Position zuruecksetzen" },
					{ L_RESET_SCALE, "Skalierung zuruecksetzen" },
					{ L_RESET_ALL, "Alles zuruecksetzen" },
					{ L_CLOSE, "Editor schliessen" },
					{ "CEE_MEMORY_MODE", "Speichermodus (Werte beim Wechseln behalten)" }
				};
				dictionary2[(Language)3] = value5;
				Dictionary<string, string> value6 = new Dictionary<string, string>
				{
					{ L_TITLE, "Editor de Equipamiento" },
					{ L_CURR_CLOTHING, "Ropa actual:" },
					{ L_UNKNOWN, "Ropa desconocida" },
					{ L_SEC_EQUIP, "Tipo de equipamiento (m_equip)" },
					{ L_SEC_ROTATION, "Rotacion" },
					{ L_SEC_POSITION, "Desplazamiento de posicion (m_positionOffset)" },
					{ L_SEC_SCALE, "Escala (m_scale)" },
					{ L_EQUIP_BOTH, "Ambos" },
					{ L_EQUIP_LEFT, "Izquierdo" },
					{ L_EQUIP_RIGHT, "Derecho" },
					{ L_RESET_ROT, "Reiniciar rotacion" },
					{ L_RESET_POS, "Reiniciar posicion" },
					{ L_RESET_SCALE, "Reiniciar escala" },
					{ L_RESET_ALL, "Reiniciar todo" },
					{ L_CLOSE, "Cerrar editor" },
					{ "CEE_MEMORY_MODE", "Modo memoria (mantener valores al cambiar)" }
				};
				dictionary2[(Language)4] = value6;
				Dictionary<string, string> value7 = new Dictionary<string, string>
				{
					{ L_TITLE, "Editor Equipaggiamento" },
					{ L_CURR_CLOTHING, "Vestito attuale:" },
					{ L_UNKNOWN, "Vestito sconosciuto" },
					{ L_SEC_EQUIP, "Tipo equipaggiamento (m_equip)" },
					{ L_SEC_ROTATION, "Rotazione" },
					{ L_SEC_POSITION, "Scostamento posizione (m_positionOffset)" },
					{ L_SEC_SCALE, "Scala (m_scale)" },
					{ L_EQUIP_BOTH, "Entrambi" },
					{ L_EQUIP_LEFT, "Sinistro" },
					{ L_EQUIP_RIGHT, "Destro" },
					{ L_RESET_ROT, "Reimposta rotazione" },
					{ L_RESET_POS, "Reimposta posizione" },
					{ L_RESET_SCALE, "Reimposta scala" },
					{ L_RESET_ALL, "Reimposta tutto" },
					{ L_CLOSE, "Chiudi editor" },
					{ "CEE_MEMORY_MODE", "Modalita memoria (mantieni valori al cambio)" }
				};
				dictionary2[(Language)2] = value7;
				Dictionary<string, string> value8 = new Dictionary<string, string>
				{
					{ L_TITLE, "Editor de Equipamento" },
					{ L_CURR_CLOTHING, "Roupa atual:" },
					{ L_UNKNOWN, "Roupa desconhecida" },
					{ L_SEC_EQUIP, "Tipo de equipamento (m_equip)" },
					{ L_SEC_ROTATION, "Rotacao" },
					{ L_SEC_POSITION, "Deslocamento de posicao (m_positionOffset)" },
					{ L_SEC_SCALE, "Escala (m_scale)" },
					{ L_EQUIP_BOTH, "Ambos" },
					{ L_EQUIP_LEFT, "Esquerdo" },
					{ L_EQUIP_RIGHT, "Direito" },
					{ L_RESET_ROT, "Reiniciar rotacao" },
					{ L_RESET_POS, "Reiniciar posicao" },
					{ L_RESET_SCALE, "Reiniciar escala" },
					{ L_RESET_ALL, "Reiniciar tudo" },
					{ L_CLOSE, "Fechar editor" },
					{ "CEE_MEMORY_MODE", "Modo memoria (manter valores ao trocar)" }
				};
				dictionary2[(Language)5] = value8;
				Dictionary<string, string> value9 = new Dictionary<string, string>
				{
					{ L_TITLE, "Редактор экипировки" },
					{ L_CURR_CLOTHING, "Текущая одежда:" },
					{ L_UNKNOWN, "Неизвестная одежда" },
					{ L_SEC_EQUIP, "Тип экипировки (m_equip)" },
					{ L_SEC_ROTATION, "Вращение" },
					{ L_SEC_POSITION, "Смещение позиции (m_positionOffset)" },
					{ L_SEC_SCALE, "Масштаб (m_scale)" },
					{ L_EQUIP_BOTH, "Обе руки" },
					{ L_EQUIP_LEFT, "Левая" },
					{ L_EQUIP_RIGHT, "Правая" },
					{ L_RESET_ROT, "Сбросить вращение" },
					{ L_RESET_POS, "Сбросить позицию" },
					{ L_RESET_SCALE, "Сбросить масштаб" },
					{ L_RESET_ALL, "Сбросить все" },
					{ L_CLOSE, "Закрыть редактор" },
					{ "CEE_MEMORY_MODE", "Режим памяти (сохранять значения при переключении)" }
				};
				dictionary2[(Language)6] = value9;
				foreach (KeyValuePair<Language, Dictionary<string, string>> item in dictionary2)
				{
					if (!dictionary.ContainsKey(item.Key))
					{
						continue;
					}
					Dictionary<string, string> dictionary3 = dictionary[item.Key];
					foreach (KeyValuePair<string, string> item2 in item.Value)
					{
						if (!dictionary3.ContainsKey(item2.Key))
						{
							dictionary3.Add(item2.Key, item2.Value);
						}
						else
						{
							dictionary3[item2.Key] = item2.Value;
						}
					}
				}
				field.SetValue(null, dictionary);
				translationsInjected = true;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditorUI] Failed to inject translations: " + ex.Message));
			}
		}

		private string T(string key)
		{
			try
			{
				string singlePhrase = Localizer.GetSinglePhrase(key, Array.Empty<string>());
				if (!string.IsNullOrEmpty(singlePhrase) && singlePhrase != key)
				{
					return singlePhrase;
				}
			}
			catch
			{
			}
			return key;
		}

		private void InitTextures()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: 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_01ed: Unknown result type (might be due to invalid IL or missing references)
			texWindowBg = MakeTex(2, 2, new Color(0.06f, 0.09f, 0.18f, 0.98f));
			texHeaderBg = MakeTex(2, 2, new Color(0.08f, 0.14f, 0.3f, 1f));
			texSectionBg = MakeTex(2, 2, new Color(0.07f, 0.11f, 0.24f, 1f));
			texBtnNormal = MakeTex(2, 2, new Color(0.1f, 0.16f, 0.34f, 1f));
			texBtnHover = MakeTex(2, 2, new Color(0.15f, 0.22f, 0.42f, 1f));
			texBtnActive = MakeTex(2, 2, new Color(0.2f, 0.28f, 0.5f, 1f));
			texBtnSelected = MakeTex(2, 2, new Color(0.15f, 0.4f, 0.8f, 1f));
			texCloseNormal = MakeTex(2, 2, new Color(0.5f, 0.14f, 0.14f, 1f));
			texCloseHover = MakeTex(2, 2, new Color(0.65f, 0.2f, 0.2f, 1f));
			texInputBg = MakeTex(2, 2, new Color(0.03f, 0.05f, 0.12f, 1f));
			texSliderBg = MakeTex(2, 2, new Color(0.06f, 0.1f, 0.22f, 1f));
			texSliderFill = MakeTex(2, 2, new Color(0.15f, 0.4f, 0.8f, 1f));
			texSepLine = MakeTex(2, 2, new Color(0.12f, 0.18f, 0.34f, 1f));
		}

		private void InitStyles()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0105: 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_0140: Expected O, but got Unknown
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Expected O, but got Unknown
			//IL_01a0: 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: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Expected O, but got Unknown
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dc: Expected O, but got Unknown
			//IL_0407: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Expected O, but got Unknown
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Expected O, but got Unknown
			//IL_051e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Expected O, but got Unknown
			//IL_0534: Unknown result type (might be due to invalid IL or missing references)
			//IL_053e: Expected O, but got Unknown
			//IL_055f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Expected O, but got Unknown
			//IL_0585: Unknown result type (might be due to invalid IL or missing references)
			//IL_058f: Expected O, but got Unknown
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Expected O, but got Unknown
			//IL_05de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0610: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0656: Expected O, but got Unknown
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_066c: Expected O, but got Unknown
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0706: Unknown result type (might be due to invalid IL or missing references)
			//IL_0729: Unknown result type (might be due to invalid IL or missing references)
			//IL_0733: Expected O, but got Unknown
			//IL_073e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0748: Expected O, but got Unknown
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_075a: Expected O, but got Unknown
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_07da: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e4: Expected O, but got Unknown
			//IL_0843: Unknown result type (might be due to invalid IL or missing references)
			//IL_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_087e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Expected O, but got Unknown
			//IL_08b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Expected O, but got Unknown
			//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Expected O, but got Unknown
			//IL_0928: Unknown result type (might be due to invalid IL or missing references)
			//IL_0952: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Unknown result type (might be due to invalid IL or missing references)
			//IL_097e: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: Expected O, but got Unknown
			//IL_09c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cf: Expected O, but got Unknown
			if (!stylesInitialized)
			{
				stylesInitialized = true;
				InitTextures();
				styleWindow = new GUIStyle(GUI.skin.window);
				styleWindow.normal.background = texWindowBg;
				styleWindow.onNormal.background = texWindowBg;
				styleWindow.hover.background = texWindowBg;
				styleWindow.onHover.background = texWindowBg;
				styleWindow.active.background = texWindowBg;
				styleWindow.onActive.background = texWindowBg;
				styleWindow.focused.background = texWindowBg;
				styleWindow.onFocused.background = texWindowBg;
				styleWindow.normal.textColor = new Color(0.85f, 0.9f, 1f);
				styleWindow.fontSize = 16;
				styleWindow.fontStyle = (FontStyle)1;
				styleWindow.padding = new RectOffset(6, 6, 24, 6);
				styleWindow.border = new RectOffset(4, 4, 4, 4);
				styleHeaderLabel = new GUIStyle(GUI.skin.label);
				styleHeaderLabel.fontSize = 14;
				styleHeaderLabel.fontStyle = (FontStyle)1;
				styleHeaderLabel.normal.textColor = new Color(0.92f, 0.94f, 1f);
				styleHeaderLabel.alignment = (TextAnchor)3;
				styleClothingName = new GUIStyle(GUI.skin.label);
				styleClothingName.fontSize = 15;
				styleClothingName.fontStyle = (FontStyle)1;
				styleClothingName.normal.textColor = new Color(0.7f, 0.82f, 1f);
				styleClothingName.alignment = (TextAnchor)3;
				styleSectionToggle = new GUIStyle(GUI.skin.toggle);
				styleSectionToggle.fontSize = 13;
				styleSectionToggle.fontStyle = (FontStyle)1;
				styleSectionToggle.normal.textColor = new Color(0.55f, 0.72f, 1f);
				styleSectionToggle.hover.textColor = new Color(0.65f, 0.8f, 1f);
				styleSectionToggle.active.textColor = new Color(0.75f, 0.88f, 1f);
				styleSectionToggle.onNormal.textColor = new Color(0.55f, 0.72f, 1f);
				styleSectionToggle.onHover.textColor = new Color(0.65f, 0.8f, 1f);
				styleSectionToggle.onActive.textColor = new Color(0.75f, 0.88f, 1f);
				styleSectionToggle.normal.background = texSectionBg;
				styleSectionToggle.onNormal.background = texSectionBg;
				styleSectionToggle.hover.background = texSectionBg;
				styleSectionToggle.onHover.background = texSectionBg;
				styleSectionToggle.active.background = texSectionBg;
				styleSectionToggle.onActive.background = texSectionBg;
				styleSectionToggle.border = new RectOffset(4, 4, 4, 4);
				styleSectionToggle.padding = new RectOffset(14, 8, 6, 6);
				styleSectionToggle.alignment = (TextAnchor)3;
				styleSectionToggle.imagePosition = (ImagePosition)0;
				styleSectionToggle.contentOffset = new Vector2(0f, 0f);
				styleAxisLabel = new GUIStyle(GUI.skin.label);
				styleAxisLabel.fontSize = 12;
				styleAxisLabel.fontStyle = (FontStyle)1;
				styleAxisLabel.alignment = (TextAnchor)4;
				styleTextField = new GUIStyle(GUI.skin.textField);
				styleTextField.normal.background = texInputBg;
				styleTextField.focused.background = texInputBg;
				styleTextField.hover.background = texInputBg;
				styleTextField.normal.textColor = new Color(0.9f, 0.92f, 1f);
				styleTextField.focused.textColor = Color.white;
				styleTextField.fontSize = 12;
				styleTextField.alignment = (TextAnchor)4;
				styleTextField.border = new RectOffset(2, 2, 2, 2);
				styleTextField.padding = new RectOffset(4, 4, 3, 3);
				styleSlider = new GUIStyle(GUI.skin.horizontalSlider);
				styleSlider.normal.background = texSliderBg;
				styleSlider.border = new RectOffset(3, 3, 3, 3);
				styleSlider.fixedHeight = 16f;
				styleSlider.padding = new RectOffset(4, 4, 4, 4);
				styleSliderThumb = new GUIStyle(GUI.skin.horizontalSliderThumb);
				styleSliderThumb.normal.background = texBtnSelected;
				styleSliderThumb.hover.background = MakeTex(2, 2, new Color(0.2f, 0.5f, 0.9f, 1f));
				styleSliderThumb.active.background = MakeTex(2, 2, new Color(0.25f, 0.55f, 0.95f, 1f));
				styleSliderThumb.fixedWidth = 14f;
				styleSliderThumb.fixedHeight = 18f;
				styleSliderThumb.border = new RectOffset(3, 3, 3, 3);
				styleEquipBtn = new GUIStyle(GUI.skin.button);
				styleEquipBtn.normal.background = texBtnNormal;
				styleEquipBtn.hover.background = texBtnHover;
				styleEquipBtn.active.background = texBtnActive;
				styleEquipBtn.normal.textColor = new Color(0.76f, 0.81f, 0.92f);
				styleEquipBtn.hover.textColor = new Color(0.88f, 0.92f, 1f);
				styleEquipBtn.active.textColor = Color.white;
				styleEquipBtn.fontSize = 12;
				styleEquipBtn.padding = new RectOffset(8, 8, 6, 6);
				styleEquipBtn.border = new RectOffset(3, 3, 3, 3);
				styleEquipBtnSel = new GUIStyle(styleEquipBtn);
				styleEquipBtnSel.normal.background = texBtnSelected;
				styleEquipBtnSel.hover.background = MakeTex(2, 2, new Color(0.2f, 0.48f, 0.88f, 1f));
				styleEquipBtnSel.normal.textColor = Color.white;
				styleEquipBtnSel.hover.textColor = Color.white;
				styleActionBtn = new GUIStyle(GUI.skin.button);
				styleActionBtn.normal.background = texBtnNormal;
				styleActionBtn.hover.background = texBtnHover;
				styleActionBtn.active.background = texBtnActive;
				styleActionBtn.normal.textColor = new Color(0.76f, 0.81f, 0.92f);
				styleActionBtn.hover.textColor = new Color(0.88f, 0.92f, 1f);
				styleActionBtn.active.textColor = Color.white;
				styleActionBtn.fontSize = 12;
				styleActionBtn.padding = new RectOffset(10, 10, 5, 5);
				styleActionBtn.border = new RectOffset(3, 3, 3, 3);
				styleCloseBtn = new GUIStyle(GUI.skin.button);
				styleCloseBtn.normal.background = texCloseNormal;
				styleCloseBtn.hover.background = texCloseHover;
				styleCloseBtn.active.background = MakeTex(2, 2, new Color(0.75f, 0.25f, 0.25f, 1f));
				styleCloseBtn.normal.textColor = new Color(0.95f, 0.85f, 0.85f);
				styleCloseBtn.hover.textColor = Color.white;
				styleCloseBtn.active.textColor = Color.white;
				styleCloseBtn.fontSize = 13;
				styleCloseBtn.fontStyle = (FontStyle)1;
				styleCloseBtn.padding = new RectOffset(10, 10, 6, 6);
				styleCloseBtn.border = new RectOffset(3, 3, 3, 3);
			}
		}

		public void SetCurrentWrapper(EquipedClothingWrapper wrapper)
		{
			//IL_007b: 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_00a1: 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)
			currentWrapper = wrapper;
			showUI = wrapper != null && IsInUnitEditor;
			if (wrapper != null && ((EquipedWrapper)wrapper).propData != null)
			{
				if (memoryMode)
				{
					selectedEquipIndex = GetEquipTypeIndex(((EquipedWrapper)wrapper).propData.m_equip);
					ApplyRotation();
					ApplyPosition();
					ApplyScale();
					ApplyEquipType();
				}
				else
				{
					selectedEquipIndex = GetEquipTypeIndex(((EquipedWrapper)wrapper).propData.m_equip);
					scale = ((EquipedWrapper)wrapper).propData.m_scale;
					DecodePositionOffset(((EquipedWrapper)wrapper).propData.m_positionOffset, out rotation, out positionOffset);
				}
			}
		}

		private string GetLocalizedName(EquipedClothingWrapper wrapper)
		{
			if (wrapper == null || (Object)(object)((EquipedWrapper)wrapper).prop == (Object)null)
			{
				return T(L_UNKNOWN);
			}
			string displayName = ((EquipedWrapper)wrapper).prop.DisplayName;
			try
			{
				string singlePhrase = Localizer.GetSinglePhrase(displayName, Array.Empty<string>());
				if (!string.IsNullOrEmpty(singlePhrase) && singlePhrase != displayName)
				{
					return singlePhrase;
				}
			}
			catch
			{
			}
			return displayName;
		}

		public static void DecodePositionOffset(Vector3 encoded, out Vector3 rot, out Vector3 pos)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			rot = Vector3.zero;
			pos = encoded;
			rot.x = DecodeAxis(encoded.x, out pos.x, "X");
			rot.y = DecodeAxis(encoded.y, out pos.y, "Y");
			rot.z = DecodeAxis(encoded.z, out pos.z, "Z");
		}

		private static float DecodeAxis(float encoded, out float pos, string axisName)
		{
			pos = encoded;
			float result = 0f;
			float num = Mathf.Abs(encoded);
			if (num < 1000f)
			{
				return result;
			}
			int num2 = (int)num;
			int num3 = num2 - 1000;
			int num4 = num3 / 1000;
			int num5 = num3 % 1000;
			result = num4;
			if (result > 180f)
			{
				result -= 360f;
			}
			pos = ((encoded < 0f) ? (0f - (float)num5 / 100f) : ((float)num5 / 100f));
			return result;
		}

		public static Vector3 EncodePositionOffset(Vector3 rot, Vector3 pos)
		{
			//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_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			Vector3 zero = Vector3.zero;
			zero.x = EncodeAxis(rot.x, pos.x, "X");
			zero.y = EncodeAxis(rot.y, pos.y, "Y");
			zero.z = EncodeAxis(rot.z, pos.z, "Z");
			return zero;
		}

		private static float EncodeAxis(float rot, float pos, string axisName)
		{
			if (Mathf.Abs(rot) < 0.001f)
			{
				return pos;
			}
			float num = rot % 360f;
			if (num < 0f)
			{
				num += 360f;
			}
			int num2 = (int)num;
			int num3 = (int)(Mathf.Abs(pos) * 100f);
			float num4 = ((pos < 0f) ? (-1f) : 1f);
			return num4 * (float)(1000 + num2 * 1000 + num3);
		}

		private void OnGUI()
		{
			//IL_00cf: 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_00e5: 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_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: 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_011d: 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_0153: Expected O, but got Unknown
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (showUI && currentWrapper != null && IsInUnitEditor)
			{
				if (Screen.width != lastScreenWidth || Screen.height != lastScreenHeight)
				{
					lastScreenWidth = Screen.width;
					lastScreenHeight = Screen.height;
					uiScale = Mathf.Min((float)Screen.width / 1920f, (float)Screen.height / 1080f);
					((Rect)(ref windowRect)).x = (float)Screen.width / uiScale - ((Rect)(ref windowRect)).width - 20f;
					((Rect)(ref windowRect)).y = 60f;
				}
				InjectTranslations();
				InitStyles();
				GUI.backgroundColor = Color.white;
				GUI.color = Color.white;
				Matrix4x4 matrix = GUI.matrix;
				GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(uiScale, uiScale, 1f));
				windowRect = GUILayout.Window(123456, windowRect, new WindowFunction(DrawWindow), "  " + T(L_TITLE), styleWindow, Array.Empty<GUILayoutOption>());
				GUI.matrix = matrix;
			}
		}

		private void DrawWindow(int windowID)
		{
			//IL_0085: 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_00ce: 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_02a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_0395: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			//IL_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0563: Unknown result type (might be due to invalid IL or missing references)
			//IL_0569: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0508: Unknown result type (might be due to invalid IL or missing references)
			//IL_050d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Invalid comparison between Unknown and I4
			//IL_0603: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Invalid comparison between Unknown and I4
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0612: Invalid comparison between Unknown and I4
			GUILayout.Space(4f);
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUILayout.Label(T(L_CURR_CLOTHING), styleHeaderLabel, Array.Empty<GUILayoutOption>());
			GUILayout.Label(GetLocalizedName(currentWrapper), styleClothingName, Array.Empty<GUILayoutOption>());
			GUILayout.FlexibleSpace();
			GUILayout.EndHorizontal();
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			GUI.backgroundColor = (Color)(memoryMode ? new Color(0.3f, 1f, 0.3f) : Color.white);
			bool flag = GUILayout.Toggle(memoryMode, "  " + T("CEE_MEMORY_MODE"), GUI.skin.button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) });
			GUI.backgroundColor = Color.white;
			GUILayout.EndHorizontal();
			if (flag != memoryMode)
			{
				memoryMode = flag;
				if (memoryMode && currentWrapper != null && ((EquipedWrapper)currentWrapper).propData != null)
				{
					ApplyRotation();
					ApplyPosition();
					ApplyScale();
				}
			}
			DrawSep();
			showEquipSection = GUILayout.Toggle(showEquipSection, "  ▼ " + T(L_SEC_EQUIP), styleSectionToggle, Array.Empty<GUILayoutOption>());
			if (showEquipSection)
			{
				GUILayout.Space(4f);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				for (int i = 0; i < equipTypeNames.Length; i++)
				{
					GUIStyle val = ((i == selectedEquipIndex) ? styleEquipBtnSel : styleEquipBtn);
					if (GUILayout.Button(T(equipTypeNames[i]), val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
					{
						selectedEquipIndex = i;
						ApplyEquipType();
					}
				}
				GUILayout.EndHorizontal();
			}
			DrawSep();
			showRotationSection = GUILayout.Toggle(showRotationSection, "  ▼ " + T(L_SEC_ROTATION), styleSectionToggle, Array.Empty<GUILayoutOption>());
			if (showRotationSection)
			{
				GUILayout.Space(4f);
				DrawVector3Control(ref rotation, -180f, 180f, ApplyRotation, 0, new Color(0.95f, 0.4f, 0.4f), new Color(0.4f, 0.9f, 0.4f), new Color(0.4f, 0.6f, 0.95f));
				GUILayout.Space(2f);
				if (GUILayout.Button(T(L_RESET_ROT), styleActionBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
				{
					rotation = Vector3.zero;
					ApplyRotation();
				}
			}
			DrawSep();
			showPositionSection = GUILayout.Toggle(showPositionSection, "  ▼ " + T(L_SEC_POSITION), styleSectionToggle, Array.Empty<GUILayoutOption>());
			if (showPositionSection)
			{
				GUILayout.Space(4f);
				DrawVector3Control(ref positionOffset, -10f, 10f, ApplyPosition, 3, new Color(0.95f, 0.4f, 0.4f), new Color(0.4f, 0.9f, 0.4f), new Color(0.4f, 0.6f, 0.95f), useDynamicRange: true);
				GUILayout.Space(2f);
				if (GUILayout.Button(T(L_RESET_POS), styleActionBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
				{
					positionOffset = Vector3.zero;
					ApplyPosition();
				}
			}
			DrawSep();
			showScaleSection = GUILayout.Toggle(showScaleSection, "  ▼ " + T(L_SEC_SCALE), styleSectionToggle, Array.Empty<GUILayoutOption>());
			if (showScaleSection)
			{
				GUILayout.Space(4f);
				DrawVector3Control(ref scale, 0.1f, 10f, ApplyScale, 6, new Color(0.95f, 0.4f, 0.4f), new Color(0.4f, 0.9f, 0.4f), new Color(0.4f, 0.6f, 0.95f), useDynamicRange: true);
				GUILayout.Space(2f);
				if (GUILayout.Button(T(L_RESET_SCALE), styleActionBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(26f) }))
				{
					scale = Vector3.one;
					ApplyScale();
				}
			}
			DrawSep();
			if (GUILayout.Button(T(L_RESET_ALL), styleCloseBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				rotation = Vector3.zero;
				positionOffset = Vector3.zero;
				scale = Vector3.one;
				ApplyRotation();
				ApplyPosition();
				ApplyScale();
			}
			GUILayout.Space(8f);
			if (GUILayout.Button(T(L_CLOSE), styleActionBtn, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(30f) }))
			{
				showUI = false;
			}
			GUI.DragWindow(new Rect(0f, 0f, 10000f, 30f));
			Event current = Event.current;
			if ((int)current.type == 0 || (int)current.type == 3 || (int)current.type == 1 || (int)current.type == 6)
			{
				current.Use();
			}
		}

		private void DrawVector3Control(ref Vector3 value, float defaultMin, float defaultMax, Action applyAction, int baseIndex, Color colorX, Color colorY, Color colorZ, bool useDynamicRange = false)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			//IL_00f3: 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_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Invalid comparison between Unknown and I4
			//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_033c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0343: Invalid comparison between Unknown and I4
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: Invalid comparison between Unknown and I4
			//IL_0317: 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_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_038b: Unknown result type (might be due to invalid IL or missing references)
			string[] array = new string[3] { "X", "Y", "Z" };
			Color[] array2 = (Color[])(object)new Color[3] { colorX, colorY, colorZ };
			float[] array3 = new float[3] { value.x, value.y, value.z };
			for (int i = 0; i < 3; i++)
			{
				int num = baseIndex + i;
				float num2 = Mathf.Abs(array3[i]);
				float num3 = ((num2 >= 1f) ? Mathf.Pow(10f, Mathf.Floor(Mathf.Log10(num2))) : 1f);
				float num4 = (useDynamicRange ? ((0f - num3) * 10f) : defaultMin);
				float num5 = (useDynamicRange ? (num3 * 10f) : defaultMax);
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				GUILayout.Space(4f);
				GUIStyle val = new GUIStyle(styleAxisLabel);
				val.normal.textColor = array2[i];
				GUILayout.Label(array[i], val, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(18f) });
				Event current = Event.current;
				int num6;
				if ((int)current.type == 0 || (int)current.type == 3)
				{
					Rect lastRect = GUILayoutUtility.GetLastRect();
					num6 = (((Rect)(ref lastRect)).Contains(current.mousePosition) ? 1 : 0);
				}
				else
				{
					num6 = 0;
				}
				bool flag = (byte)num6 != 0;
				float num7 = GUILayout.HorizontalSlider(array3[i], num4, num5, styleSlider, styleSliderThumb, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Height(18f) });
				if (Mathf.Abs(num7 - array3[i]) > 0.001f)
				{
					array3[i] = num7;
					value = new Vector3(array3[0], array3[1], array3[2]);
					textFieldValues[num] = array3[i].ToString("F2");
					applyAction();
				}
				GUI.SetNextControlName("TextField_" + num);
				bool flag2 = textFieldFocused[num];
				textFieldFocused[num] = GUI.GetNameOfFocusedControl() == "TextField_" + num;
				if (!flag2 && textFieldFocused[num])
				{
					textFieldValues[num] = array3[i].ToString("F2");
				}
				if (string.IsNullOrEmpty(textFieldValues[num]) || !textFieldFocused[num])
				{
					textFieldValues[num] = array3[i].ToString("F2");
				}
				string text = GUILayout.TextField(textFieldValues[num], styleTextField, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(58f),
					GUILayout.Height(22f)
				});
				textFieldValues[num] = text;
				if (!textFieldFocused[num])
				{
					if (float.TryParse(text, out var result) && Mathf.Abs(result - array3[i]) > 0.001f)
					{
						array3[i] = result;
						value = new Vector3(array3[0], array3[1], array3[2]);
						applyAction();
					}
				}
				else if (current.isKey && ((int)current.keyCode == 13 || (int)current.keyCode == 271))
				{
					GUI.FocusControl((string)null);
					if (float.TryParse(text, out var result2))
					{
						array3[i] = result2;
						value = new Vector3(array3[0], array3[1], array3[2]);
						textFieldValues[num] = array3[i].ToString("F2");
						applyAction();
					}
				}
				GUILayout.Space(4f);
				GUILayout.EndHorizontal();
				GUILayout.Space(2f);
			}
		}

		private void DrawSep()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			GUILayout.Space(4f);
			GUIStyle val = new GUIStyle();
			val.normal.background = texSepLine;
			val.fixedHeight = 1f;
			val.margin = new RectOffset(4, 4, 0, 0);
			GUILayout.Box("", val, (GUILayoutOption[])(object)new GUILayoutOption[2]
			{
				GUILayout.ExpandWidth(true),
				GUILayout.Height(1f)
			});
			GUILayout.Space(4f);
		}

		private void ApplyEquipType()
		{
			//IL_0032: 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_003f: 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)
			if (currentWrapper == null || ((EquipedWrapper)currentWrapper).propData == null)
			{
				return;
			}
			try
			{
				EquipType val = equipTypes[selectedEquipIndex];
				((EquipedWrapper)currentWrapper).propData.m_equip = val;
				CharacterItem spawnedProp = ((EquipedWrapper)currentWrapper).spawnedProp;
				if ((Object)(object)spawnedProp != (Object)null)
				{
					CharacterItem component = ((Component)spawnedProp).GetComponent<CharacterItem>();
					if ((Object)(object)component != (Object)null)
					{
						component.SetEquipType(val);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditorUI] ApplyEquipType error: " + ex.Message));
			}
		}

		private void ApplyRotation()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: 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_005e: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			if (currentWrapper == null || ((EquipedWrapper)currentWrapper).propData == null)
			{
				return;
			}
			try
			{
				Vector3 val = EncodePositionOffset(rotation, positionOffset);
				((EquipedWrapper)currentWrapper).propData.m_positionOffset = val;
				Plugin.Log.LogInfo((object)$"[EquipEditor] ApplyRotation: rotation={rotation}, positionOffset={positionOffset}, encoded={val}");
				CharacterItem spawnedProp = ((EquipedWrapper)currentWrapper).spawnedProp;
				if ((Object)(object)spawnedProp != (Object)null)
				{
					((Component)spawnedProp).transform.localEulerAngles = rotation;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditorUI] ApplyRotation error: " + ex.Message));
			}
		}

		private void ApplyPosition()
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (currentWrapper == null || ((EquipedWrapper)currentWrapper).propData == null)
			{
				return;
			}
			try
			{
				Vector3 val = EncodePositionOffset(rotation, positionOffset);
				((EquipedWrapper)currentWrapper).propData.m_positionOffset = val;
				CharacterItem spawnedProp = ((EquipedWrapper)currentWrapper).spawnedProp;
				if ((Object)(object)spawnedProp != (Object)null)
				{
					((Component)spawnedProp).transform.localPosition = positionOffset;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditorUI] ApplyPosition error: " + ex.Message));
			}
		}

		private void ApplyScale()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (currentWrapper == null || ((EquipedWrapper)currentWrapper).propData == null)
			{
				return;
			}
			try
			{
				((EquipedWrapper)currentWrapper).propData.m_scale = scale;
				CharacterItem spawnedProp = ((EquipedWrapper)currentWrapper).spawnedProp;
				if ((Object)(object)spawnedProp != (Object)null)
				{
					((Component)spawnedProp).transform.localScale = scale;
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditorUI] ApplyScale error: " + ex.Message));
			}
		}

		private int GetEquipTypeIndex(EquipType equipType)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Invalid comparison between I4 and Unknown
			for (int i = 0; i < equipTypes.Length; i++)
			{
				if ((int)equipTypes[i] == (int)equipType)
				{
					return i;
				}
			}
			return 0;
		}

		private Texture2D MakeTex(int width, int height, Color color)
		{
			//IL_0010: 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_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			Color[] array = (Color[])(object)new Color[width * height];
			for (int i = 0; i < array.Length; i++)
			{
				array[i] = color;
			}
			Texture2D val = new Texture2D(width, height);
			val.SetPixels(array);
			val.Apply();
			return val;
		}

		private void Update()
		{
			if (!IsInUnitEditor)
			{
				if (showUI)
				{
					showUI = false;
					currentWrapper = null;
				}
			}
			else if (Input.GetKeyDown((KeyCode)289) && currentWrapper != null)
			{
				showUI = !showUI;
			}
		}
	}
	[HarmonyPatch]
	public static class Patches
	{
		public static UnitEditorManager CurrentManager;

		public static EquipedClothingWrapper CurrentClothingWrapper;

		private static bool databaseLoaded;

		[HarmonyPatch(typeof(UnitEditorEquipedClothing), "Setup")]
		[HarmonyPostfix]
		public static void Setup_Postfix(EquipedWrapper equiped)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Invalid comparison between Unknown and I4
			if (equiped == null)
			{
				return;
			}
			try
			{
				WrapperType wrapperType = equiped.GetWrapperType();
				if ((int)wrapperType == 0)
				{
					CurrentClothingWrapper = (EquipedClothingWrapper)(object)((equiped is EquipedClothingWrapper) ? equiped : null);
					CurrentManager = GetManagerFromWrapper(equiped);
					if ((Object)(object)Plugin.EditorUI != (Object)null)
					{
						Plugin.EditorUI.SetCurrentWrapper(CurrentClothingWrapper);
					}
				}
				else
				{
					CurrentClothingWrapper = null;
					CurrentManager = null;
					if ((Object)(object)Plugin.EditorUI != (Object)null)
					{
						Plugin.EditorUI.SetCurrentWrapper(null);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] Setup_Postfix error: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		private static UnitEditorManager GetManagerFromWrapper(EquipedWrapper wrapper)
		{
			try
			{
				UnitEditorUIManager val = Object.FindObjectOfType<UnitEditorUIManager>();
				if ((Object)(object)val != (Object)null)
				{
					FieldInfo field = typeof(UnitEditorUIManager).GetField("unitEditorManager", BindingFlags.Instance | BindingFlags.NonPublic);
					if (field != null)
					{
						object? value = field.GetValue(val);
						return (UnitEditorManager)((value is UnitEditorManager) ? value : null);
					}
				}
			}
			catch
			{
			}
			return null;
		}

		[HarmonyPatch(typeof(UnitEditorEquipedClothing), "OnClose")]
		[HarmonyPostfix]
		public static void OnClose_Postfix()
		{
			CurrentClothingWrapper = null;
			CurrentManager = null;
			if ((Object)(object)Plugin.EditorUI != (Object)null)
			{
				Plugin.EditorUI.SetCurrentWrapper(null);
			}
		}

		[HarmonyPatch(typeof(CharacterItem), "Equip", new Type[]
		{
			typeof(GameObject),
			typeof(PropItemData),
			typeof(TransformCatalog),
			typeof(Team),
			typeof(bool)
		})]
		[HarmonyPostfix]
		public static void Equip_Postfix(CharacterItem __instance, PropItemData propData)
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)__instance == (Object)null || propData == null)
				{
					return;
				}
				float num = Mathf.Abs(propData.m_positionOffset.x);
				float num2 = Mathf.Abs(propData.m_positionOffset.y);
				float num3 = Mathf.Abs(propData.m_positionOffset.z);
				if (!(num < 1000f) || !(num2 < 1000f) || !(num3 < 1000f))
				{
					EquipEditorUI.DecodePositionOffset(propData.m_positionOffset, out var rot, out var pos);
					((Component)__instance).transform.localPosition = pos;
					if (rot != Vector3.zero)
					{
						((Component)__instance).transform.localEulerAngles = rot;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] Equip_Postfix error: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(UnitEditorManager), "EquipNewProp", new Type[] { typeof(CharacterItem) })]
		[HarmonyPostfix]
		public static void EquipNewProp_Postfix(CharacterItem prop)
		{
			//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_019a: 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_01b8: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				UnitEditorManager val = Object.FindObjectOfType<UnitEditorManager>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				FieldInfo field = typeof(UnitEditorManager).GetField("equipedClothes", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null || !(field.GetValue(val) is IList list) || list.Count == 0)
				{
					return;
				}
				for (int i = 0; i < list.Count; i++)
				{
					object obj = list[i];
					if (obj == null)
					{
						continue;
					}
					FieldInfo field2 = obj.GetType().GetField("propData", BindingFlags.Instance | BindingFlags.Public);
					if (field2 == null)
					{
						continue;
					}
					object? value = field2.GetValue(obj);
					PropItemData val2 = (PropItemData)((value is PropItemData) ? value : null);
					if (val2 == null)
					{
						continue;
					}
					float num = Mathf.Abs(val2.m_positionOffset.x);
					float num2 = Mathf.Abs(val2.m_positionOffset.y);
					float num3 = Mathf.Abs(val2.m_positionOffset.z);
					bool flag = num >= 1000f || num2 >= 1000f || num3 >= 1000f;
					bool flag2 = val2.m_scale != Vector3.one;
					if (!flag && !flag2)
					{
						continue;
					}
					object? obj2 = obj.GetType().GetField("spawnedProp", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
					CharacterItem val3 = (CharacterItem)((obj2 is CharacterItem) ? obj2 : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						EquipEditorUI.DecodePositionOffset(val2.m_positionOffset, out var rot, out var pos);
						((Component)val3).transform.localPosition = pos;
						if (rot != Vector3.zero)
						{
							((Component)val3).transform.localEulerAngles = rot;
						}
						if (flag2)
						{
							((Component)val3).transform.localScale = val2.m_scale;
						}
						Plugin.Log.LogInfo((object)$"[EquipEditor] 同步服装 {i} 的变换: 位置={pos}, 旋转={rot}, 缩放={val2.m_scale}");
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] EquipNewProp_Postfix error: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(UnitEditorManager), "RespawnProps")]
		[HarmonyPostfix]
		public static void RespawnProps_Postfix()
		{
			//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_019a: 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_01b8: 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_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: 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_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				UnitEditorManager val = Object.FindObjectOfType<UnitEditorManager>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				FieldInfo field = typeof(UnitEditorManager).GetField("equipedClothes", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null || !(field.GetValue(val) is IList list) || list.Count == 0)
				{
					return;
				}
				for (int i = 0; i < list.Count; i++)
				{
					object obj = list[i];
					if (obj == null)
					{
						continue;
					}
					FieldInfo field2 = obj.GetType().GetField("propData", BindingFlags.Instance | BindingFlags.Public);
					if (field2 == null)
					{
						continue;
					}
					object? value = field2.GetValue(obj);
					PropItemData val2 = (PropItemData)((value is PropItemData) ? value : null);
					if (val2 == null)
					{
						continue;
					}
					float num = Mathf.Abs(val2.m_positionOffset.x);
					float num2 = Mathf.Abs(val2.m_positionOffset.y);
					float num3 = Mathf.Abs(val2.m_positionOffset.z);
					bool flag = num >= 1000f || num2 >= 1000f || num3 >= 1000f;
					bool flag2 = val2.m_scale != Vector3.one;
					if (!flag && !flag2)
					{
						continue;
					}
					object? obj2 = obj.GetType().GetField("spawnedProp", BindingFlags.Instance | BindingFlags.Public)?.GetValue(obj);
					CharacterItem val3 = (CharacterItem)((obj2 is CharacterItem) ? obj2 : null);
					if (!((Object)(object)val3 == (Object)null))
					{
						EquipEditorUI.DecodePositionOffset(val2.m_positionOffset, out var rot, out var pos);
						((Component)val3).transform.localPosition = pos;
						if (rot != Vector3.zero)
						{
							((Component)val3).transform.localEulerAngles = rot;
						}
						if (flag2)
						{
							((Component)val3).transform.localScale = val2.m_scale;
						}
						Plugin.Log.LogInfo((object)$"[EquipEditor] Respawn后同步服装 {i} 的变换: 位置={pos}, 旋转={rot}, 缩放={val2.m_scale}");
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] RespawnProps_Postfix error: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(UnitBlueprint), "SerializedUnit")]
		[HarmonyPostfix]
		public static void SerializedUnit_Postfix(UnitBlueprint __instance, ref SerializedUnitBlueprint __result)
		{
			//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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			try
			{
				if (__result == null || (Object)(object)__instance == (Object)null || __result.m_propData == null || __instance.m_propData == null)
				{
					return;
				}
				for (int i = 0; i < __result.m_propData.Length; i++)
				{
					if (i < __instance.m_propData.Length)
					{
						__result.m_propData[i].m_equip = __instance.m_propData[i].m_equip;
						__result.m_propData[i].m_positionOffset = __instance.m_propData[i].m_positionOffset;
						__result.m_propData[i].m_scale = __instance.m_propData[i].m_scale;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] SerializedUnit_Postfix error: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(UnitBlueprint), "DeserializedUnit")]
		[HarmonyPrefix]
		public static void DeserializedUnit_Prefix()
		{
			//IL_01ae: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: 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_01ed: 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_0239: 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_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_039f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			if (databaseLoaded)
			{
				return;
			}
			try
			{
				Resources.Load<LandfallUnitDatabase>("Landfall Unit Database");
				WeaponItem[] array = Resources.FindObjectsOfTypeAll<WeaponItem>();
				PropItem[] array2 = Resources.FindObjectsOfTypeAll<PropItem>();
				SpecialAbility[] array3 = Resources.FindObjectsOfTypeAll<SpecialAbility>();
				ProjectileEntity[] array4 = Resources.FindObjectsOfTypeAll<ProjectileEntity>();
				LandfallContentDatabase landfallContentDatabase = ContentDatabase.Instance().LandfallContentDatabase;
				AssetLoader assetLoader = ContentDatabase.Instance().AssetLoader;
				FieldInfo field = typeof(LandfallContentDatabase).GetField("m_weapons", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field2 = typeof(LandfallContentDatabase).GetField("m_characterProps", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field3 = typeof(LandfallContentDatabase).GetField("m_combatMoves", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field4 = typeof(LandfallContentDatabase).GetField("m_projectiles", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field5 = typeof(AssetLoader).GetField("m_nonStreamableAssets", BindingFlags.Instance | BindingFlags.NonPublic);
				FieldInfo field6 = typeof(CharacterItem).GetField("m_showInEditor", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null || field2 == null || field3 == null || field4 == null || field5 == null || field6 == null)
				{
					Plugin.Log.LogError((object)"[EquipEditor] LoadDatabase: Failed to find required reflection fields");
					return;
				}
				IDictionary<DatabaseID, GameObject> dictionary = field.GetValue(landfallContentDatabase) as IDictionary<DatabaseID, GameObject>;
				IDictionary<DatabaseID, GameObject> dictionary2 = field2.GetValue(landfallContentDatabase) as IDictionary<DatabaseID, GameObject>;
				IDictionary<DatabaseID, GameObject> dictionary3 = field3.GetValue(landfallContentDatabase) as IDictionary<DatabaseID, GameObject>;
				IDictionary<DatabaseID, GameObject> dictionary4 = field4.GetValue(landfallContentDatabase) as IDictionary<DatabaseID, GameObject>;
				IDictionary<DatabaseID, Object> dictionary5 = field5.GetValue(assetLoader) as IDictionary<DatabaseID, Object>;
				WeaponItem[] array5 = array;
				foreach (WeaponItem val in array5)
				{
					field6.SetValue(val, true);
					DatabaseID gUID = ((CharacterItem)val).Entity.GUID;
					if (!dictionary.ContainsKey(gUID))
					{
						dictionary.Add(gUID, ((Component)val).gameObject);
						if (!dictionary5.ContainsKey(gUID))
						{
							dictionary5.Add(gUID, (Object)(object)((Component)val).gameObject);
						}
					}
				}
				PropItem[] array6 = array2;
				foreach (PropItem val2 in array6)
				{
					field6.SetValue(val2, true);
					DatabaseID gUID2 = ((CharacterItem)val2).Entity.GUID;
					if (!dictionary2.ContainsKey(gUID2))
					{
						dictionary2.Add(gUID2, ((Component)val2).gameObject);
						if (!dictionary5.ContainsKey(gUID2))
						{
							dictionary5.Add(gUID2, (Object)(object)((Component)val2).gameObject);
						}
					}
				}
				SpecialAbility[] array7 = array3;
				foreach (SpecialAbility val3 in array7)
				{
					CharacterItem val4 = (CharacterItem)(object)val3;
					Dictionary<string, string> language = Localizer.GetLanguage((Language)0);
					if (val4.Entity.Name == null || val4.Entity.Name == string.Empty)
					{
						val4.Entity.Name = ((Object)((Component)val3).gameObject).name;
					}
					if (language.Keys.Contains(val4.Entity.Name) && (language[val4.Entity.Name] == string.Empty || language[val4.Entity.Name] == null))
					{
						val4.Entity.Name = ((Object)((Component)val3).gameObject).name;
					}
					field6.SetValue(val4, true);
					DatabaseID gUID3 = ((CharacterItem)val3).Entity.GUID;
					if (!dictionary3.ContainsKey(gUID3))
					{
						dictionary3.Add(gUID3, ((Component)val3).gameObject);
						if (!dictionary5.ContainsKey(gUID3))
						{
							dictionary5.Add(gUID3, (Object)(object)((Component)val3).gameObject);
						}
					}
				}
				List<string> list = new List<string>();
				ProjectileEntity[] array8 = array4;
				foreach (ProjectileEntity val5 in array8)
				{
					if (list.Contains(((Object)((Component)val5).gameObject).name) || list.Contains(val5.Entity.Name))
					{
						continue;
					}
					list.Add(((Object)((Component)val5).gameObject).name);
					list.Add(val5.Entity.Name);
					DatabaseID gUID4 = val5.Entity.GUID;
					if (!dictionary4.ContainsKey(gUID4))
					{
						dictionary4.Add(gUID4, ((Component)val5).gameObject);
						if (!dictionary5.ContainsKey(gUID4))
						{
							dictionary5.Add(gUID4, (Object)(object)((Component)val5).gameObject);
						}
					}
				}
				databaseLoaded = true;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] LoadDatabase error: " + ex.Message + "\n" + ex.StackTrace));
			}
		}

		[HarmonyPatch(typeof(UnitBlueprint), "DeserializedUnit")]
		[HarmonyPostfix]
		public static void DeserializedUnit_Postfix(SerializedUnitBlueprint data, ref UnitBlueprint __result)
		{
			//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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)__result == (Object)null || data == null || __result.m_propData == null || data.m_propData == null)
				{
					return;
				}
				for (int i = 0; i < __result.m_propData.Length; i++)
				{
					if (i < data.m_propData.Length)
					{
						__result.m_propData[i].m_equip = data.m_propData[i].m_equip;
						__result.m_propData[i].m_positionOffset = data.m_propData[i].m_positionOffset;
						__result.m_propData[i].m_scale = data.m_propData[i].m_scale;
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] DeserializedUnit_Postfix error: " + ex.Message));
			}
		}

		[HarmonyPatch(typeof(UnitEditorManager), "GetBlueprint")]
		[HarmonyPostfix]
		public static void GetBlueprint_Postfix(ref UnitBlueprint __result)
		{
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_0128: 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)
			try
			{
				if ((Object)(object)__result == (Object)null)
				{
					return;
				}
				UnitEditorManager val = Object.FindObjectOfType<UnitEditorManager>();
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				FieldInfo field = typeof(UnitEditorManager).GetField("equipedClothes", BindingFlags.Instance | BindingFlags.NonPublic);
				if (field == null || !(field.GetValue(val) is IList list))
				{
					return;
				}
				for (int i = 0; i < list.Count && i < __result.m_propData.Length; i++)
				{
					object obj = list[i];
					if (obj == null)
					{
						continue;
					}
					FieldInfo field2 = obj.GetType().GetField("propData", BindingFlags.Instance | BindingFlags.Public);
					if (!(field2 == null))
					{
						object? value = field2.GetValue(obj);
						PropItemData val2 = (PropItemData)((value is PropItemData) ? value : null);
						if (val2 != null)
						{
							__result.m_propData[i].m_equip = val2.m_equip;
							__result.m_propData[i].m_positionOffset = val2.m_positionOffset;
							__result.m_propData[i].m_scale = val2.m_scale;
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("[EquipEditor] GetBlueprint_Postfix error: " + ex.Message));
			}
		}
	}
}