Decompiled source of ItemDisplayPlacementHelper v1.8.2

plugins/ItemDisplayPlacementHelper/ItemDisplayPlacementHelper.dll

Decompiled 5 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Generics.Dynamics;
using HG;
using IDRSJsonLoader;
using IDRSJsonLoader.Models;
using ItemDisplayPlacementHelper.AnimatorEditing;
using ItemDisplayPlacementHelper.Assets.ItemDisplayPlacementHelper;
using ItemDisplayPlacementHelper.AxisEditing;
using ItemDisplayPlacementHelper.Dialogs;
using ItemDisplayPlacementHelper.Editable;
using ItemDisplayPlacementHelper.Native;
using ItemDisplayPlacementHelper.Native.Structs;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RoR2;
using RoR2.AddressableAssets;
using RoR2.ContentManagement;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.AddressableAssets.ResourceLocators;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.ResourceLocations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class IsUnmanagedAttribute : Attribute
	{
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NativeIntegerAttribute : Attribute
	{
		public readonly bool[] TransformFlags;

		public NativeIntegerAttribute()
		{
			TransformFlags = new bool[1] { true };
		}

		public NativeIntegerAttribute(bool[] P_0)
		{
			TransformFlags = P_0;
		}
	}
}
public class InvariatCultureDecimalValidator : MonoBehaviour
{
	private void Awake()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Expected O, but got Unknown
		((Component)this).GetComponent<TMP_InputField>().onValidateInput = new OnValidateInput(Validate);
	}

	private char Validate(string text, int pos, char ch)
	{
		if ((pos != 0 || text.Length <= 0 || text[0] != '-') && ((ch >= '0' && ch <= '9') || (ch == '-' && pos == 0) || (ch == '.' && !text.Contains("."))))
		{
			return ch;
		}
		return '\0';
	}
}
namespace ItemDisplayPlacementHelper
{
	public class AnimatorParametersController : MonoBehaviour
	{
		private CharacterModel currentModel;

		private Animator currentAnimator;

		public Transform container;

		private readonly List<AnimatorParameterField> rows = new List<AnimatorParameterField>();

		[Space]
		public Button toggleButton;

		public GameObject itemPanel;

		public GameObject parametersPanel;

		[Space]
		public GameObject boolRowPrefab;

		public GameObject intRowPrefab;

		public GameObject floatRowPrefab;

		private void Awake()
		{
			ModelPicker.OnModelChanged += OnModelChanged;
			ModelPicker.OnModelWillChange += OnModelWillChange;
		}

		private void OnDestroy()
		{
			ModelPicker.OnModelChanged -= OnModelChanged;
			ModelPicker.OnModelWillChange -= OnModelWillChange;
		}

		private void OnModelWillChange()
		{
			foreach (AnimatorParameterField row in rows)
			{
				Object.Destroy((Object)(object)((Component)row).gameObject);
			}
			rows.Clear();
			currentAnimator = null;
		}

		private void OnModelChanged(CharacterModel model)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected I4, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			currentModel = model;
			if (Object.op_Implicit((Object)(object)currentModel))
			{
				currentAnimator = ((Component)currentModel).GetComponent<Animator>();
			}
			if (!Object.op_Implicit((Object)(object)currentAnimator))
			{
				return;
			}
			AnimatorControllerParameter[] parameters = currentAnimator.parameters;
			foreach (AnimatorControllerParameter val in parameters)
			{
				GameObject val2 = null;
				AnimatorControllerParameterType type = val.type;
				switch (type - 1)
				{
				default:
					if ((int)type == 9)
					{
						continue;
					}
					break;
				case 0:
					val2 = Object.Instantiate<GameObject>(floatRowPrefab, container);
					break;
				case 2:
					val2 = Object.Instantiate<GameObject>(intRowPrefab, container);
					break;
				case 3:
					val2 = Object.Instantiate<GameObject>(boolRowPrefab, container);
					break;
				case 1:
					break;
				}
				AnimatorParameterField component = val2.GetComponent<AnimatorParameterField>();
				component.animator = currentAnimator;
				component.parameter = val;
				rows.Add(component);
				val2.SetActive(true);
			}
		}

		public void Toggle()
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			if (parametersPanel.activeSelf)
			{
				parametersPanel.SetActive(false);
				itemPanel.SetActive(true);
			}
			else
			{
				parametersPanel.SetActive(true);
				itemPanel.SetActive(false);
			}
			Vector3 localScale = ((Component)toggleButton).transform.localScale;
			localScale.y *= -1f;
			((Component)toggleButton).transform.localScale = localScale;
		}
	}
	internal static class AssetsHelper
	{
		public static AssetBundle SceneBundle { get; private set; }

		public static void LoadAssetBundle()
		{
			SceneBundle = AssetBundle.LoadFromFile(GetBundlePath("kingenderbrine_idrs_editor"));
		}

		private static string GetBundlePath(string bundleName)
		{
			return Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)ItemDisplayPlacementHelperPlugin.Instance).Info.Location), bundleName);
		}
	}
	public class BepInExConfigController : MonoBehaviour
	{
		public SensitivityController sensitivityController;

		public ParentedPrefabDisplayController parentedPrefabDisplayController;

		private void Start()
		{
			sensitivityController.fastCoefficientInput.Value = ConfigHelper.FastCoefficient.Value;
			sensitivityController.slowCoefficientInput.Value = ConfigHelper.SlowCoefficient.Value;
			parentedPrefabDisplayController.CopyFormat = ConfigHelper.CopyFormat.Value;
			parentedPrefabDisplayController.customFormatInput.text = FromConfigFriendly(ConfigHelper.CustomFormat.Value);
			((MonoBehaviour)this).StartCoroutine(SaveCurrentValues());
		}

		private void OnDestroy()
		{
			((MonoBehaviour)this).StopAllCoroutines();
		}

		private IEnumerator SaveCurrentValues()
		{
			while (true)
			{
				yield return (object)new WaitForSeconds(10f);
				ConfigHelper.FastCoefficient.Value = sensitivityController.fastCoefficientInput.Value;
				ConfigHelper.SlowCoefficient.Value = sensitivityController.slowCoefficientInput.Value;
				ConfigHelper.CopyFormat.Value = parentedPrefabDisplayController.CopyFormat;
				ConfigHelper.CustomFormat.Value = ToConfigFriendly(parentedPrefabDisplayController.customFormatInput.text);
			}
		}

		private static string ToConfigFriendly(string str)
		{
			return Convert.ToBase64String(Encoding.UTF8.GetBytes(str)).Replace('=', '-');
		}

		private static string FromConfigFriendly(string str)
		{
			return Encoding.UTF8.GetString(Convert.FromBase64String(str.Replace('-', '=')));
		}
	}
	public class CameraPostprocessEventHandler : MonoBehaviour
	{
		public static EventHandler onPostRender;

		private void OnPostRender()
		{
			onPostRender?.Invoke(this, null);
		}
	}
	public static class ConfigHelper
	{
		public static ConfigFile ConfigFile { get; private set; }

		public static ConfigEntry<float> FastCoefficient { get; private set; }

		public static ConfigEntry<float> SlowCoefficient { get; private set; }

		public static ConfigEntry<CopyFormat> CopyFormat { get; private set; }

		public static ConfigEntry<string> CustomFormat { get; private set; }

		public static ConfigEntry<string> FilePickerLastPath { get; private set; }

		public static ConfigEntry<string> ExportNamespace { get; private set; }

		public static ConfigEntry<bool> ExportGenerateClass { get; private set; }

		public static ConfigEntry<AssetsToExport> ExportAssetsToExport { get; private set; }

		public static ConfigEntry<ImportType> ImportImportType { get; private set; }

		public static ConfigEntry<bool> ExportWithSkin { get; private set; }

		internal static void InitConfigs(ConfigFile config)
		{
			ConfigFile = config;
			config.SaveOnConfigSet = false;
			FastCoefficient = config.Bind<float>("EditorInputs", "FastCoefficient", 2.5f, (ConfigDescription)null);
			SlowCoefficient = config.Bind<float>("EditorInputs", "SlowCoefficient", 0.1f, (ConfigDescription)null);
			CopyFormat = config.Bind<CopyFormat>("EditorInputs", "CopyFormat", ItemDisplayPlacementHelper.CopyFormat.Block, (ConfigDescription)null);
			CustomFormat = config.Bind<string>("EditorInputs", "CustomFormat", "", (ConfigDescription)null);
			FilePickerLastPath = config.Bind<string>("Cache", "FilePickerLastPath", "", (ConfigDescription)null);
			ExportGenerateClass = config.Bind<bool>("Cache", "ExportGenerateClass", false, (ConfigDescription)null);
			ExportNamespace = config.Bind<string>("Cache", "ExportNamespace", "", (ConfigDescription)null);
			ExportAssetsToExport = config.Bind<AssetsToExport>("Cache", "ExportAssetsToExport", AssetsToExport.All, (ConfigDescription)null);
			ExportWithSkin = config.Bind<bool>("Cache", "ExportWithSkin", false, (ConfigDescription)null);
			ImportImportType = config.Bind<ImportType>("Cache", "ImportImportType", ImportType.ReplaceSet, (ConfigDescription)null);
			config.SaveOnConfigSet = true;
			config.Save();
		}
	}
	public class DisplayRuleGroupEditingController : MonoBehaviour
	{
		public delegate void OnDisplayRuleGroupChangedHandler(EditableDisplayRuleGroup keyAssetRuleGroup);

		public GameObject rowPrefab;

		public Transform container;

		public Button reapplyButton;

		public Button addButton;

		public Button deleteButton;

		private CharacterModel characterModel;

		public static OnDisplayRuleGroupChangedHandler OnDisplayRuleGroupChanged;

		private readonly List<ItemDisplayRulePreviewController> rows = new List<ItemDisplayRulePreviewController>();

		public static DisplayRuleGroupEditingController Instance { get; private set; }

		public EditableDisplayRuleGroup DisplayRuleGroup { get; private set; }

		private void Awake()
		{
			Instance = this;
			ModelPicker.OnModelWillChange += OnModelWillChange;
			ModelPicker.OnModelChanged += OnModelChanged;
		}

		private void OnDestroy()
		{
			ModelPicker.OnModelWillChange -= OnModelWillChange;
			ModelPicker.OnModelChanged -= OnModelChanged;
			Instance = null;
		}

		private void Update()
		{
			bool flag = DisplayRuleGroup != null;
			((Selectable)reapplyButton).interactable = flag;
			((Selectable)addButton).interactable = flag;
			((Selectable)deleteButton).interactable = flag && ParentedPrefabDisplayController.Instance.ItemDisplayRule != null;
		}

		private void OnModelWillChange()
		{
			SetDisplayRuleGroup(null);
		}

		private void OnModelChanged(CharacterModel characterModel)
		{
			this.characterModel = characterModel;
		}

		public void SetDisplayRuleGroup(EditableDisplayRuleGroup displayRuleGroup)
		{
			if (DisplayRuleGroup == displayRuleGroup)
			{
				return;
			}
			DisplayRuleGroup = displayRuleGroup;
			foreach (ItemDisplayRulePreviewController row in rows)
			{
				Object.Destroy((Object)(object)((Component)row).gameObject);
			}
			rows.Clear();
			if (displayRuleGroup == null || !Object.op_Implicit((Object)(object)characterModel))
			{
				OnDisplayRuleGroupChanged(displayRuleGroup);
				return;
			}
			List<EditableItemDisplayRule> rules = displayRuleGroup.Rules;
			for (int i = 0; i < rules.Count; i++)
			{
				EditableItemDisplayRule rule = rules[i];
				CreateRow(rule);
			}
			OnDisplayRuleGroupChanged(displayRuleGroup);
		}

		private void CreateRow(EditableItemDisplayRule rule)
		{
			GameObject obj = Object.Instantiate<GameObject>(rowPrefab, container);
			ItemDisplayRulePreviewController component = obj.GetComponent<ItemDisplayRulePreviewController>();
			component.itemDisplayRule = rule;
			obj.SetActive(true);
			rows.Add(component);
		}

		public void ReapplyCurrentDisplayGroup()
		{
			DisplayRuleGroup.Disable(characterModel);
			DisplayRuleGroup.Enable(characterModel);
		}

		public void Add()
		{
			//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)
			EditableItemDisplayRule editableItemDisplayRule = new EditableItemDisplayRule();
			editableItemDisplayRule.localScale = Vector3.one;
			DisplayRuleGroup.Rules.Add(editableItemDisplayRule);
			CreateRow(editableItemDisplayRule);
			editableItemDisplayRule.Enable(characterModel);
		}

		public void Delete()
		{
			EditableItemDisplayRule itemDisplayRule = ParentedPrefabDisplayController.Instance.ItemDisplayRule;
			ParentedPrefabDisplayController.Instance.SetItemDisplayRule(null);
			for (int i = 0; i < rows.Count; i++)
			{
				ItemDisplayRulePreviewController itemDisplayRulePreviewController = rows[i];
				if (itemDisplayRulePreviewController.itemDisplayRule == itemDisplayRule)
				{
					itemDisplayRule.Disable(characterModel);
					rows.RemoveAt(i);
					DisplayRuleGroup.Rules.RemoveAt(i);
					Object.Destroy((Object)(object)((Component)itemDisplayRulePreviewController).gameObject);
					break;
				}
			}
		}
	}
	public class DisplayRuleGroupPreviewController : MonoBehaviour
	{
		[NonSerialized]
		[HideInInspector]
		public Sprite icon;

		[NonSerialized]
		[HideInInspector]
		public string nameText;

		[NonSerialized]
		[HideInInspector]
		public EditableDisplayRuleGroup displayRuleGroup;

		private CharacterModel characterModel;

		[SerializeField]
		private Image imageComponent;

		[SerializeField]
		private TextMeshProUGUI textComponent;

		[SerializeField]
		private Toggle toggleComponent;

		[SerializeField]
		private Button buttonComponent;

		[SerializeField]
		private ToggleGroup toggleGroupComponent;

		[SerializeField]
		private Image background;

		private void Awake()
		{
			characterModel = ModelPicker.Instance.CharacterModel;
			ModelPicker.OnModelChanged += OnModelChanged;
		}

		private void OnDestroy()
		{
			ModelPicker.OnModelChanged -= OnModelChanged;
		}

		private void OnModelChanged(CharacterModel characterModel)
		{
			this.characterModel = characterModel;
		}

		private void Start()
		{
			((TMP_Text)textComponent).text = nameText;
			imageComponent.sprite = icon;
			toggleComponent.isOn = displayRuleGroup.Enabled;
		}

		public void EditDisplayRuleGroup()
		{
			if (DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup)
			{
				DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(null);
				return;
			}
			toggleComponent.isOn = true;
			DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(displayRuleGroup);
		}

		public void ToggleDisplay(bool display)
		{
			if (toggleComponent.isOn != display)
			{
				toggleComponent.isOn = display;
				return;
			}
			if (display)
			{
				displayRuleGroup.Enable(characterModel);
				return;
			}
			displayRuleGroup.Disable(characterModel);
			if (DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup)
			{
				DisplayRuleGroupEditingController.Instance.SetDisplayRuleGroup(null);
			}
		}

		private void Update()
		{
			((Behaviour)background).enabled = DisplayRuleGroupEditingController.Instance.DisplayRuleGroup == displayRuleGroup;
		}
	}
	public class DropdownItem : MonoBehaviour, IEventSystemHandler, ICancelHandler
	{
		public TMP_Text text;

		public Image image;

		public RectTransform rectTransform;

		public Button button;

		[HideInInspector]
		public object Value { get; set; }

		public virtual void OnCancel(BaseEventData eventData)
		{
			SearchableDropdown componentInParent = ((Component)this).GetComponentInParent<SearchableDropdown>();
			if (Object.op_Implicit((Object)(object)componentInParent))
			{
				componentInParent.Hide();
			}
		}
	}
	public class EditorConfigPanel : MonoBehaviour
	{
		private static readonly MethodInfo dynamicBonesLateUpdateMethod = typeof(DynamicBone).GetMethod("LateUpdate", BindingFlags.Instance | BindingFlags.NonPublic);

		private static readonly MethodInfo timeGetUnscaledDeltaTimeMethod = typeof(Time).GetProperty("unscaledDeltaTime").GetGetMethod();

		public CameraRigController cameraRigController;

		[Space]
		public Toggle fadeToggle;

		public Toggle timeToggle;

		public Toggle dynamicBonesTimeToggle;

		[Space]
		public Button editorSpaceButton;

		public TextMeshProUGUI editorSpaceText;

		[Space]
		public Toggle editorModeMove;

		public Toggle editorModeRotate;

		public Toggle editorModeScale;

		private bool skipNotification;

		private ILHook dynamicBonesHook;

		private void OnDestroy()
		{
			if (dynamicBonesHook != null)
			{
				dynamicBonesHook.Undo();
			}
		}

		private void Update()
		{
			skipNotification = true;
			if (Object.op_Implicit((Object)(object)cameraRigController))
			{
				fadeToggle.isOn = cameraRigController.enableFading;
			}
			timeToggle.isOn = Time.timeScale > 0f;
			((Selectable)editorSpaceButton).interactable = !EditorAxisController.Instance.OverrideToLocalSpace;
			switch (EditorAxisController.Instance.EditSpace)
			{
			case EditSpace.Global:
				((TMP_Text)editorSpaceText).text = "Global";
				break;
			case EditSpace.Local:
				((TMP_Text)editorSpaceText).text = "Local";
				break;
			}
			editorModeMove.isOn = EditorAxisController.Instance.EditMode == EditMode.Move;
			editorModeRotate.isOn = EditorAxisController.Instance.EditMode == EditMode.Rotate;
			editorModeScale.isOn = EditorAxisController.Instance.EditMode == EditMode.Scale;
			skipNotification = false;
		}

		public void ToggleTime(bool enabled)
		{
			if (!skipNotification)
			{
				Time.timeScale = (enabled ? 1 : 0);
			}
		}

		public void ToggleFade(bool enabled)
		{
			if (!skipNotification && Object.op_Implicit((Object)(object)cameraRigController))
			{
				cameraRigController.enableFading = enabled;
			}
		}

		public void ToggleEditModeMove(bool value)
		{
			if (!skipNotification && value)
			{
				EditorAxisController.Instance.EditMode = EditMode.Move;
			}
		}

		public void ToggleEditModeScale(bool value)
		{
			if (!skipNotification && value)
			{
				EditorAxisController.Instance.EditMode = EditMode.Scale;
			}
		}

		public void ToggleEditModeRotate(bool value)
		{
			if (!skipNotification && value)
			{
				EditorAxisController.Instance.EditMode = EditMode.Rotate;
			}
		}

		public void ToggleEditSpace()
		{
			switch (EditorAxisController.Instance.ActualEditSpace)
			{
			case EditSpace.Global:
				EditorAxisController.Instance.ActualEditSpace = EditSpace.Local;
				break;
			case EditSpace.Local:
				EditorAxisController.Instance.ActualEditSpace = EditSpace.Global;
				break;
			}
		}

		public void ToggleDynamicBonesTimeScale(bool enabled)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			if (skipNotification)
			{
				return;
			}
			if (enabled)
			{
				if (dynamicBonesHook == null)
				{
					dynamicBonesHook = new ILHook((MethodBase)dynamicBonesLateUpdateMethod, new Manipulator(DynamicBonesLateUpdateIL));
				}
			}
			else if (dynamicBonesHook != null)
			{
				dynamicBonesHook.Undo();
				dynamicBonesHook = null;
			}
		}

		private void DynamicBonesLateUpdateIL(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0038: 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)
			ILCursor val = new ILCursor(il);
			val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Time>(x, "get_deltaTime")
			});
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Call, (MethodBase)timeGetUnscaledDeltaTimeMethod);
		}
	}
	public class EditorHUD : MonoBehaviour
	{
		public EditorSceneCameraController cameraController;

		public CameraRigController cameraRigController;

		private float oldTimeScale;

		public static EditorHUD Instance { get; private set; }

		private void Awake()
		{
			Instance = this;
			oldTimeScale = Time.timeScale;
			Time.timeScale = 1f;
			AkSoundEngine.PostEvent("Pause_All", (GameObject)null);
			PauseManager.onPauseEndGlobal = (Action)Delegate.Combine(PauseManager.onPauseEndGlobal, new Action(OnPauseEnd));
		}

		private void Start()
		{
			((Behaviour)((Component)this).GetComponent<CursorOpener>()).enabled = true;
		}

		private void OnDestroy()
		{
			Instance = null;
			PauseManager.onPauseEndGlobal = (Action)Delegate.Remove(PauseManager.onPauseEndGlobal, new Action(OnPauseEnd));
			Time.timeScale = oldTimeScale;
			AkSoundEngine.PostEvent("Unpause_All", (GameObject)null);
		}

		private void Update()
		{
			if ((double)Time.timeScale < 0.01)
			{
				Physics.SyncTransforms();
			}
		}

		private void OnPauseEnd()
		{
			AkSoundEngine.PostEvent("Pause_All", (GameObject)null);
		}
	}
	public class EditorKeysHandler : MonoBehaviour
	{
		public CameraRigController cameraRigController;

		private MPEventSystemLocator eventSystemLocator;

		private GameObject lastCheckedObject;

		private bool disallowKeyPress;

		private void Awake()
		{
			eventSystemLocator = ((Component)this).GetComponent<MPEventSystemLocator>();
		}

		private void Update()
		{
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)eventSystemLocator.eventSystem))
			{
				return;
			}
			GameObject currentSelectedGameObject = ((EventSystem)eventSystemLocator.eventSystem).currentSelectedGameObject;
			if (!Object.op_Implicit((Object)(object)currentSelectedGameObject))
			{
				disallowKeyPress = false;
				lastCheckedObject = null;
			}
			else if ((Object)(object)currentSelectedGameObject != (Object)(object)lastCheckedObject)
			{
				if (Object.op_Implicit((Object)(object)currentSelectedGameObject.GetComponent<TMP_InputField>()) || Object.op_Implicit((Object)(object)currentSelectedGameObject.GetComponent<InputField>()))
				{
					disallowKeyPress = true;
				}
				else
				{
					disallowKeyPress = false;
				}
				lastCheckedObject = currentSelectedGameObject;
			}
			if (disallowKeyPress)
			{
				return;
			}
			if (Input.GetKeyDown((KeyCode)119))
			{
				EditorAxisController.Instance.EditMode = EditMode.Move;
			}
			else if (Input.GetKeyDown((KeyCode)101))
			{
				EditorAxisController.Instance.EditMode = EditMode.Rotate;
			}
			else if (Input.GetKeyDown((KeyCode)114))
			{
				EditorAxisController.Instance.EditMode = EditMode.Scale;
			}
			if (Input.GetKeyDown((KeyCode)120))
			{
				switch (EditorAxisController.Instance.ActualEditSpace)
				{
				case EditSpace.Global:
					EditorAxisController.Instance.ActualEditSpace = EditSpace.Local;
					break;
				case EditSpace.Local:
					EditorAxisController.Instance.ActualEditSpace = EditSpace.Global;
					break;
				}
			}
			if (Input.GetKeyDown((KeyCode)116))
			{
				Time.timeScale = ((Time.timeScale == 0f) ? 1 : 0);
			}
			if (Input.GetKeyDown((KeyCode)102) && Object.op_Implicit((Object)(object)ParentedPrefabDisplayController.Instance) && Object.op_Implicit((Object)(object)ParentedPrefabDisplayController.Instance.ItemDisplayRule?.instance))
			{
				EditorSceneCameraController.Instance.FocusOnPoint(ParentedPrefabDisplayController.Instance.ItemDisplayRule.instance.transform.position);
			}
			if (Input.GetKeyDown((KeyCode)103) && Object.op_Implicit((Object)(object)cameraRigController))
			{
				cameraRigController.enableFading = !cameraRigController.enableFading;
			}
		}
	}
	public class EditorSceneCameraController : MonoBehaviour, ICameraStateProvider, IPointerEnterHandler, IEventSystemHandler, IPointerExitHandler
	{
		private enum ActionType
		{
			None,
			Rotation,
			Movement
		}

		private const float minFocusLength = 0.1f;

		private float focusLength = 4f;

		private const float rotationMultiplier = 0.15f;

		private const float sidewaysMovementMultiplier = 0.01f;

		private const float forwardMovementMultiplier = 0.3f;

		public float sidewaysMovementSensitivity = 1f;

		public float rotationSensitivity = 1f;

		public float forwardMovementSensitivity = 1f;

		public float slowCoefficient = 0.1f;

		public float fastCoefficient = 3f;

		[Space]
		public Transform cameraDefaultPosition;

		public CameraRigController CameraRigController;

		public static EditorSceneCameraController Instance;

		private Vector3 previousMousePosition;

		private ActionType currentActionType;

		private Vector3? lerpPosition;

		private float lerpCameraTime;

		public bool PointerInside { get; private set; }

		private void Awake()
		{
			//IL_0028: 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)
			Instance = this;
			CameraRigController.SetOverrideCam((ICameraStateProvider)(object)this, 0f);
			((Component)CameraRigController).transform.SetPositionAndRotation(cameraDefaultPosition.position, cameraDefaultPosition.rotation);
		}

		private void OnDestroy()
		{
			Instance = null;
			if (Object.op_Implicit((Object)(object)CameraRigController))
			{
				CameraRigController.SetOverrideCam((ICameraStateProvider)null, 0f);
			}
		}

		private void Update()
		{
			//IL_036e: 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_0384: 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_0243: 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_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: 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_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: 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_05b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0329: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_032f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0544: Unknown result type (might be due to invalid IL or missing references)
			//IL_0549: Unknown result type (might be due to invalid IL or missing references)
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0579: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04be: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0511: Unknown result type (might be due to invalid IL or missing references)
			//IL_0513: Unknown result type (might be due to invalid IL or missing references)
			//IL_0518: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0401: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: 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_0423: Unknown result type (might be due to invalid IL or missing references)
			//IL_0428: Unknown result type (might be due to invalid IL or missing references)
			//IL_043e: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0453: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0465: Unknown result type (might be due to invalid IL or missing references)
			//IL_046f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a4: 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_00b3: 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_00c2: 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_00d6: 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_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: 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_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_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			float num = (Input.GetKey((KeyCode)306) ? slowCoefficient : (Input.GetKey((KeyCode)304) ? fastCoefficient : 1f));
			if (PointerInside)
			{
				if (currentActionType == ActionType.None)
				{
					if (Input.GetMouseButtonDown(2))
					{
						if (Input.GetKey((KeyCode)308))
						{
							Vector3 val = default(Vector3);
							foreach (KeyValuePair<SkinnedMeshRenderer, MeshCollider> cachedSkinnedMeshRenderer in ModelPicker.Instance.CachedSkinnedMeshRenderers)
							{
								Vector3 localScale = ((Component)cachedSkinnedMeshRenderer.Key).transform.localScale;
								Vector3 lossyScale = ((Component)cachedSkinnedMeshRenderer.Key).transform.lossyScale;
								((Vector3)(ref val))..ctor(localScale.x / lossyScale.x, localScale.y / lossyScale.y, localScale.z / lossyScale.z);
								if (localScale != Vector3.one || val != Vector3.one)
								{
									((Component)cachedSkinnedMeshRenderer.Key).transform.localScale = val;
								}
								cachedSkinnedMeshRenderer.Key.BakeMesh(cachedSkinnedMeshRenderer.Value.sharedMesh);
								cachedSkinnedMeshRenderer.Value.sharedMesh = cachedSkinnedMeshRenderer.Value.sharedMesh;
								if (localScale != Vector3.one || val != Vector3.one)
								{
									((Component)cachedSkinnedMeshRenderer.Key).transform.localScale = localScale;
								}
							}
							RaycastHit val2 = default(RaycastHit);
							if (Physics.Raycast(Camera.main.ScreenPointToRay(Input.mousePosition), ref val2, 5000f, LayerMask.GetMask(new string[1] { "World" })))
							{
								lerpPosition = ((RaycastHit)(ref val2)).point + ((Component)CameraRigController).transform.forward * -1f * focusLength;
								lerpCameraTime = 0f;
							}
						}
						else
						{
							currentActionType = ActionType.Movement;
							lerpPosition = null;
						}
					}
					else if (Input.GetMouseButtonDown(1))
					{
						currentActionType = ActionType.Rotation;
						lerpPosition = null;
					}
				}
				Vector3 val3 = ((Component)CameraRigController).transform.forward * Input.mouseScrollDelta.y * forwardMovementSensitivity * 0.3f * num;
				if (Input.GetKey((KeyCode)308))
				{
					float num2 = Mathf.Sign(Input.mouseScrollDelta.y);
					if (num2 == 1f && focusLength <= 0.1f)
					{
						val3 = Vector3.zero;
						focusLength = 0.1f;
					}
					else
					{
						float num3 = Mathf.Max((float)Math.Log(focusLength), 0.5f);
						val3 *= num3;
						if (focusLength - num2 * ((Vector3)(ref val3)).magnitude <= 0.1f)
						{
							val3 = Vector3.zero;
						}
						focusLength -= num2 * ((Vector3)(ref val3)).magnitude;
					}
				}
				if (val3 != Vector3.zero)
				{
					lerpPosition = null;
				}
				Transform transform = ((Component)CameraRigController).transform;
				transform.position += val3;
			}
			if (lerpPosition.HasValue)
			{
				lerpCameraTime += Time.unscaledDeltaTime;
				((Component)CameraRigController).transform.position = Vector3.Lerp(((Component)CameraRigController).transform.position, lerpPosition.Value, lerpCameraTime);
				if (lerpCameraTime >= 1f)
				{
					lerpPosition = null;
				}
			}
			if (EditorAxisController.Instance.SelectedAxis == Axis.None)
			{
				Vector3 val4 = Input.mousePosition - previousMousePosition;
				switch (currentActionType)
				{
				case ActionType.Movement:
				{
					Transform transform2 = ((Component)CameraRigController).transform;
					transform2.position -= ((Component)CameraRigController).transform.up * val4.y * sidewaysMovementSensitivity * 0.01f * num;
					Transform transform3 = ((Component)CameraRigController).transform;
					transform3.position -= ((Component)CameraRigController).transform.right * val4.x * sidewaysMovementSensitivity * 0.01f * num;
					break;
				}
				case ActionType.Rotation:
					if (Input.GetKey((KeyCode)308))
					{
						Vector3 val5 = ((Component)CameraRigController).transform.position + ((Component)CameraRigController).transform.forward * focusLength;
						((Component)CameraRigController).transform.RotateAround(val5, ((Component)CameraRigController).transform.right, val4.y * rotationSensitivity * 0.15f * -2f);
						((Component)CameraRigController).transform.RotateAround(val5, Vector3.up, val4.x * rotationSensitivity * 0.15f * 2f);
					}
					else
					{
						((Component)CameraRigController).transform.Rotate(Vector3.right, val4.y * rotationSensitivity * 0.15f * -1f, (Space)1);
						((Component)CameraRigController).transform.Rotate(Vector3.up, val4.x * rotationSensitivity * 0.15f, (Space)0);
					}
					break;
				}
			}
			if (currentActionType != ActionType.None && Input.GetMouseButtonUp((int)currentActionType))
			{
				currentActionType = ActionType.None;
			}
			previousMousePosition = Input.mousePosition;
		}

		public void FocusOnPoint(Vector3 point)
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			lerpPosition = ((Component)CameraRigController).transform.forward * -1f * focusLength + point;
			lerpCameraTime = 0f;
		}

		public void GetCameraState(CameraRigController cameraRigController, ref CameraState cameraState)
		{
			//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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			cameraState.rotation = ((Component)cameraRigController).transform.rotation;
			cameraState.position = ((Component)cameraRigController).transform.position;
		}

		public bool IsHudAllowed(CameraRigController cameraRigController)
		{
			return false;
		}

		public bool IsUserControlAllowed(CameraRigController cameraRigController)
		{
			return false;
		}

		public bool IsUserLookAllowed(CameraRigController cameraRigController)
		{
			return false;
		}

		public void OnPointerExit(PointerEventData eventData)
		{
			PointerInside = false;
		}

		public void OnPointerEnter(PointerEventData eventData)
		{
			PointerInside = true;
		}
	}
	public enum EditMode
	{
		Move,
		Rotate,
		Scale,
		Combined
	}
	public enum EditSpace
	{
		Global,
		Local
	}
	public enum Axis
	{
		None = 0,
		X = 1,
		Y = 2,
		Z = 4,
		CameraPerpendicular = 8,
		CameraParallel = 16,
		XY = 3,
		XZ = 5,
		YZ = 6,
		XYZ = 7
	}
	public enum CopyFormat
	{
		Custom,
		Block,
		Inline,
		ForParsing
	}
	public enum PrefabSource
	{
		Addressables,
		AssetBundle
	}
	public enum ImportType
	{
		ReplaceSet,
		AddOrUpdateGroups
	}
	public enum AssetsToExport
	{
		All,
		Filtered,
		Enabled
	}
	public class FileRowController : MonoBehaviour
	{
		public TMP_Text text;

		public Image icon;

		public Button button;

		[NonSerialized]
		public bool isFile;

		[NonSerialized]
		public string part;
	}
	internal struct FloatTween
	{
		public class FloatTweenCallback : UnityEvent<float>
		{
		}

		private FloatTweenCallback m_Target;

		private float m_StartValue;

		private float m_TargetValue;

		private float m_Duration;

		private bool m_IgnoreTimeScale;

		public float startValue
		{
			get
			{
				return m_StartValue;
			}
			set
			{
				m_StartValue = value;
			}
		}

		public float targetValue
		{
			get
			{
				return m_TargetValue;
			}
			set
			{
				m_TargetValue = value;
			}
		}

		public float duration
		{
			get
			{
				return m_Duration;
			}
			set
			{
				m_Duration = value;
			}
		}

		public bool ignoreTimeScale
		{
			get
			{
				return m_IgnoreTimeScale;
			}
			set
			{
				m_IgnoreTimeScale = value;
			}
		}

		public void TweenValue(float floatPercentage)
		{
			if (ValidTarget())
			{
				((UnityEvent<float>)m_Target).Invoke(Mathf.Lerp(m_StartValue, m_TargetValue, floatPercentage));
			}
		}

		public void AddOnChangedCallback(UnityAction<float> callback)
		{
			if (m_Target == null)
			{
				m_Target = new FloatTweenCallback();
			}
			((UnityEvent<float>)m_Target).AddListener(callback);
		}

		public bool GetIgnoreTimescale()
		{
			return m_IgnoreTimeScale;
		}

		public float GetDuration()
		{
			return m_Duration;
		}

		public bool ValidTarget()
		{
			return m_Target != null;
		}
	}
	internal class FloatTweenRunner
	{
		protected MonoBehaviour m_CoroutineContainer;

		protected IEnumerator m_Tween;

		private static IEnumerator Start(FloatTween tweenInfo)
		{
			if (tweenInfo.ValidTarget())
			{
				float elapsedTime = 0f;
				while ((double)elapsedTime < (double)tweenInfo.duration)
				{
					elapsedTime += (tweenInfo.ignoreTimeScale ? Time.unscaledDeltaTime : Time.deltaTime);
					tweenInfo.TweenValue(Mathf.Clamp01(elapsedTime / tweenInfo.duration));
					yield return null;
				}
				tweenInfo.TweenValue(1f);
			}
		}

		public void Init(MonoBehaviour coroutineContainer)
		{
			m_CoroutineContainer = coroutineContainer;
		}

		public void StartTween(FloatTween info)
		{
			if ((Object)(object)m_CoroutineContainer == (Object)null)
			{
				Debug.LogWarning((object)"Coroutine container not configured... did you forget to call Init?");
				return;
			}
			StopTween();
			if (!((Component)m_CoroutineContainer).gameObject.activeInHierarchy)
			{
				info.TweenValue(1f);
				return;
			}
			m_Tween = Start(info);
			m_CoroutineContainer.StartCoroutine(m_Tween);
		}

		public void StopTween()
		{
			if (m_Tween != null)
			{
				m_CoroutineContainer.StopCoroutine(m_Tween);
				m_Tween = null;
			}
		}
	}
	[BepInPlugin("com.KingEnderBrine.ItemDisplayPlacementHelper", "Item Display Placement Helper", "1.8.2")]
	public class ItemDisplayPlacementHelperPlugin : BaseUnityPlugin
	{
		public const string Guid = "com.KingEnderBrine.ItemDisplayPlacementHelper";

		public const string Name = "Item Display Placement Helper";

		public const string Version = "1.8.2";

		internal static ItemDisplayPlacementHelperPlugin Instance { get; private set; }

		internal static ManualLogSource InstanceLogger
		{
			get
			{
				ItemDisplayPlacementHelperPlugin instance = Instance;
				if (instance == null)
				{
					return null;
				}
				return ((BaseUnityPlugin)instance).Logger;
			}
		}

		private void Awake()
		{
			Instance = this;
			NativeHelpers.Init();
			AssetsHelper.LoadAssetBundle();
			ConfigHelper.InitConfigs(((BaseUnityPlugin)this).Config);
		}

		private void OnDestroy()
		{
			Instance = null;
		}

		private void Update()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			if (Input.GetKeyDown((KeyCode)283))
			{
				Scene activeScene = SceneManager.GetActiveScene();
				if (((Scene)(ref activeScene)).name == "title")
				{
					((MonoBehaviour)this).StartCoroutine(StartSceneCoroutine());
				}
			}
		}

		private IEnumerator StartSceneCoroutine()
		{
			if (!(NetworkManager.networkSceneName == "KingEnderBrine_IDRS_Editor"))
			{
				Console.instance.SubmitCmd((NetworkUser)null, "host 0", false);
				yield return (object)new WaitUntil((Func<bool>)(() => (Object)(object)PreGameController.instance != (Object)null));
				NetworkManager.singleton.ServerChangeScene("KingEnderBrine_IDRS_Editor");
				if (Object.op_Implicit((Object)(object)ConsoleWindow.instance))
				{
					Object.Destroy((Object)(object)((Component)ConsoleWindow.instance).gameObject);
				}
			}
		}
	}
	public class ItemDisplayRulePreviewController : MonoBehaviour
	{
		[NonSerialized]
		[HideInInspector]
		public EditableItemDisplayRule itemDisplayRule;

		[SerializeField]
		private TMP_Text textComponent;

		[SerializeField]
		private Button buttonComponent;

		private void Update()
		{
			//IL_0006: 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_000c: 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_0011: Invalid comparison between Unknown and I4
			ItemDisplayRuleType ruleType = itemDisplayRule.ruleType;
			if ((int)ruleType != 0)
			{
				if ((int)ruleType == 1)
				{
					textComponent.text = "LimbMask";
				}
			}
			else
			{
				textComponent.text = (Object.op_Implicit((Object)(object)itemDisplayRule.followerPrefab) ? ((Object)itemDisplayRule.followerPrefab).name : "No prefab");
			}
			((Selectable)buttonComponent).interactable = ParentedPrefabDisplayController.Instance.ItemDisplayRule != itemDisplayRule;
		}

		public void EditItemDisplayRule()
		{
			ParentedPrefabDisplayController.Instance.SetItemDisplayRule(itemDisplayRule);
		}
	}
	public class ItemDisplayRuleSetController : MonoBehaviour
	{
		public GameObject rowPrefab;

		public Transform container;

		[Space]
		public Button enableAllButton;

		public Button disableAllButton;

		public TMP_InputField searchInput;

		public TMP_Dropdown showItemsMode;

		[Space]
		public Button addButton;

		public Button deleteButton;

		public Button importButton;

		public Button exportButton;

		private readonly List<DisplayRuleGroupPreviewController> previewRows = new List<DisplayRuleGroupPreviewController>();

		private readonly HashSet<Object> notPickedAssets = new HashSet<Object>();

		private CharacterModel characterModel;

		private EditableItemDisplayRuleSet itemDisplayRuleSet;

		private string filter;

		private Dictionary<string, string> pathToGuid;

		private Dictionary<string, AssetBundle> dirToBundle;

		private Dictionary<AssetBundle, Dictionary<int, string>> bundleToAssets;

		public static ItemDisplayRuleSetController Instance { get; private set; }

		private void Awake()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			Instance = this;
			showItemsMode.AddOptions((from el in (IEnumerable<ReadOnlyContentPack>)(object)ContentManager.allLoadedContentPacks
				where ((IEnumerable<EquipmentDef>)(object)((ReadOnlyContentPack)(ref el)).equipmentDefs).Any() || ((IEnumerable<ItemDef>)(object)((ReadOnlyContentPack)(ref el)).itemDefs).Any()
				select ((ReadOnlyContentPack)(ref el)).identifier).ToList());
			ModelPicker.OnModelChanged += OnModelChanged;
			ModelPicker.OnModelWillChange += OnModelWillChange;
		}

		private void OnDestroy()
		{
			Instance = null;
			ModelPicker.OnModelChanged -= OnModelChanged;
			ModelPicker.OnModelWillChange -= OnModelWillChange;
		}

		private void Update()
		{
			((Selectable)enableAllButton).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)disableAllButton).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)searchInput).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)showItemsMode).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)addButton).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)deleteButton).interactable = Object.op_Implicit((Object)(object)characterModel) && DisplayRuleGroupEditingController.Instance.DisplayRuleGroup != null;
			((Selectable)importButton).interactable = Object.op_Implicit((Object)(object)characterModel);
			((Selectable)exportButton).interactable = Object.op_Implicit((Object)(object)characterModel);
		}

		private void OnModelChanged(CharacterModel characterModel)
		{
			if (!Object.op_Implicit((Object)(object)characterModel))
			{
				return;
			}
			this.characterModel = characterModel;
			itemDisplayRuleSet = EditableItemDisplayRuleSet.From(characterModel.itemDisplayRuleSet);
			ItemDef[] itemDefs = ItemCatalog.itemDefs;
			foreach (ItemDef item in itemDefs)
			{
				notPickedAssets.Add((Object)(object)item);
			}
			EquipmentDef[] equipmentDefs = EquipmentCatalog.equipmentDefs;
			foreach (EquipmentDef item2 in equipmentDefs)
			{
				notPickedAssets.Add((Object)(object)item2);
			}
			foreach (EditableDisplayRuleGroup displayRuleGroup in itemDisplayRuleSet.DisplayRuleGroups)
			{
				notPickedAssets.Remove(displayRuleGroup.KeyAsset);
				CreateRowInstance(displayRuleGroup);
			}
			ApplyFilter(filter);
		}

		private void OnModelWillChange()
		{
			foreach (DisplayRuleGroupPreviewController previewRow in previewRows)
			{
				Object.Destroy((Object)(object)((Component)previewRow).gameObject);
			}
			previewRows.Clear();
			characterModel = null;
		}

		private void CreateRowInstance(EditableDisplayRuleGroup displayRuleGroup)
		{
			GameObject obj = Object.Instantiate<GameObject>(rowPrefab, container);
			DisplayRuleGroupPreviewController component = obj.GetComponent<DisplayRuleGroupPreviewController>();
			component.displayRuleGroup = displayRuleGroup;
			(component.icon, component.nameText) = GetItemInfo(displayRuleGroup.KeyAsset);
			obj.SetActive(true);
			previewRows.Add(component);
		}

		private (Sprite, string) GetItemInfo(Object keyAsset)
		{
			ItemDef val = (ItemDef)(object)((keyAsset is ItemDef) ? keyAsset : null);
			if (val != null)
			{
				return (val.pickupIconSprite, Language.GetString(val.nameToken));
			}
			EquipmentDef val2 = (EquipmentDef)(object)((keyAsset is EquipmentDef) ? keyAsset : null);
			if (val2 != null)
			{
				return (val2.pickupIconSprite, Language.GetString(val2.nameToken));
			}
			return default((Sprite, string));
		}

		public void ApplyFilter(string newFilter)
		{
			filter = newFilter;
			UpdateRowsVisibility();
		}

		public void ChangeShowMode(int value)
		{
			UpdateRowsVisibility();
		}

		public void EnableAll()
		{
			foreach (DisplayRuleGroupPreviewController previewRow in previewRows)
			{
				if (((Component)previewRow).gameObject.activeSelf)
				{
					previewRow.ToggleDisplay(display: true);
				}
			}
			characterModel.UpdateMaterials();
		}

		public void DisableAll()
		{
			foreach (DisplayRuleGroupPreviewController previewRow in previewRows)
			{
				if (((Component)previewRow).gameObject.activeSelf)
				{
					previewRow.ToggleDisplay(display: false);
				}
			}
		}

		public void Add()
		{
			DialogController.ShowKeyAssetPicker(notPickedAssets, delegate(Object asset)
			{
				EditableDisplayRuleGroup editableDisplayRuleGroup = new EditableDisplayRuleGroup
				{
					KeyAsset = asset
				};
				itemDisplayRuleSet.DisplayRuleGroups.Add(editableDisplayRuleGroup);
				notPickedAssets.Remove(asset);
				CreateRowInstance(editableDisplayRuleGroup);
				ApplyFilter(filter);
			});
		}

		public void Delete()
		{
			EditableDisplayRuleGroup displayRuleGroup = DisplayRuleGroupEditingController.Instance.DisplayRuleGroup;
			for (int i = 0; i < previewRows.Count; i++)
			{
				DisplayRuleGroupPreviewController displayRuleGroupPreviewController = previewRows[i];
				if (displayRuleGroupPreviewController.displayRuleGroup == displayRuleGroup)
				{
					notPickedAssets.Add(displayRuleGroup.KeyAsset);
					displayRuleGroupPreviewController.ToggleDisplay(display: false);
					itemDisplayRuleSet.DisplayRuleGroups.RemoveAt(i);
					previewRows.RemoveAt(i);
					Object.Destroy((Object)(object)((Component)displayRuleGroupPreviewController).gameObject);
					break;
				}
			}
		}

		public void Export()
		{
			DialogController.ShowExport(delegate(string path, AssetsToExport assetsToExport, bool generateClass, string @namespace, bool withSkin)
			{
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0087: Expected O, but got Unknown
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0100: Expected O, but got Unknown
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Expected O, but got Unknown
				//IL_017d: 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)
				//IL_018b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0190: Unknown result type (might be due to invalid IL or missing references)
				//IL_0199: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0215: Unknown result type (might be due to invalid IL or missing references)
				//IL_021a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0223: Unknown result type (might be due to invalid IL or missing references)
				//IL_0228: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					bool anyAssetBundle = false;
					bool refreshBundles = true;
					IEnumerable<DisplayRuleGroupPreviewController> enumerable = assetsToExport switch
					{
						AssetsToExport.All => previewRows, 
						AssetsToExport.Filtered => previewRows.Where((DisplayRuleGroupPreviewController r) => ((Component)r).gameObject.activeSelf), 
						AssetsToExport.Enabled => previewRows.Where((DisplayRuleGroupPreviewController r) => ((Component)r).gameObject.activeSelf && r.displayRuleGroup.Enabled), 
						_ => throw new NotSupportedException(), 
					};
					ExportItemDisplayRuleSet val = new ExportItemDisplayRuleSet();
					val.bodyName = ModelPicker.Instance.ModelInfo.bodyName;
					if (withSkin)
					{
						ModelSkinController modelSkinController = ModelPicker.Instance.ModelSkinController;
						SkinDef safe = ArrayUtils.GetSafe<SkinDef>(modelSkinController.skins, modelSkinController.currentSkinIndex);
						val.skinName = (Object.op_Implicit((Object)(object)safe) ? ((Object)safe).name : "");
					}
					foreach (DisplayRuleGroupPreviewController item in enumerable)
					{
						EditableDisplayRuleGroup displayRuleGroup = item.displayRuleGroup;
						ExportKeyAssetRuleGroup val2 = new ExportKeyAssetRuleGroup();
						val2.name = displayRuleGroup.KeyAsset.name;
						foreach (EditableItemDisplayRule rule in displayRuleGroup.Rules)
						{
							ExportItemDisplayRule val3 = new ExportItemDisplayRule();
							if (FillPrefabReference(rule, refreshBundles))
							{
								refreshBundles = false;
							}
							AssetReferenceGameObject followerPrefabAddress = rule.followerPrefabAddress;
							val3.guid = ((followerPrefabAddress != null) ? ((AssetReference)followerPrefabAddress).AssetGUID : null);
							val3.assetBundle = rule.assetBundle;
							val3.assetPath = rule.assetPath;
							val3.localScale = rule.localScale;
							val3.localPos = rule.localPos;
							val3.localAngles = rule.localAngles;
							val3.childName = rule.childName;
							if (!string.IsNullOrEmpty(rule.childName) && rule.childName.EndsWith(StringHelpers.NamePostfix))
							{
								CharacterModel val4 = ModelPicker.Instance.CharacterModel;
								Transform val5 = val4.childLocator.FindChild(val3.childName);
								if (Object.op_Implicit((Object)(object)val5))
								{
									val3.childPath = Utils.GetChildPath(((Component)val4).transform, val5);
								}
							}
							val3.limbMask = rule.limbMask;
							val3.ruleType = rule.ruleType;
							if (!string.IsNullOrEmpty(val3.assetBundle))
							{
								anyAssetBundle = true;
							}
							val2.rules.Add(val3);
						}
						if (displayRuleGroup.KeyAsset is ItemDef)
						{
							val.itemGroups.Add(val2);
						}
						else if (displayRuleGroup.KeyAsset is EquipmentDef)
						{
							val.equipmentGroups.Add(val2);
						}
					}
					val.itemGroups.Sort((ExportKeyAssetRuleGroup a, ExportKeyAssetRuleGroup b) => StringComparer.Ordinal.Compare(a.name, b.name));
					val.equipmentGroups.Sort((ExportKeyAssetRuleGroup a, ExportKeyAssetRuleGroup b) => StringComparer.Ordinal.Compare(a.name, b.name));
					string contents = JsonUtility.ToJson((object)val, true);
					File.WriteAllText(path, contents);
					if (generateClass)
					{
						string contents2 = GenerateClass(val, @namespace, Path.GetFileNameWithoutExtension(path), anyAssetBundle);
						File.WriteAllText(Path.ChangeExtension(path, ".cs"), contents2);
					}
				}
				catch (Exception ex)
				{
					ItemDisplayPlacementHelperPlugin.InstanceLogger.LogError((object)ex);
					DialogController.ShowError("Export failed, check log.");
				}
			});
		}

		private string GenerateClass(ExportItemDisplayRuleSet idrs, string @namespace, string @class, bool anyAssetBundle)
		{
			StringBuilder stringBuilder = new StringBuilder();
			int i = 0;
			stringBuilder.A("using System;").L(i).A("using System.Collections.Generic;")
				.L(i)
				.A("using RoR2;")
				.L(i)
				.A("using UnityEngine;")
				.L(i)
				.A("using UnityEngine.AddressableAssets;")
				.L(0);
			if (!string.IsNullOrEmpty(@namespace))
			{
				stringBuilder.L(i).A("namespace ").A(@namespace)
					.StartBlock(ref i);
			}
			stringBuilder.L(i).A("public class ").A(@class)
				.StartBlock(ref i);
			if (anyAssetBundle)
			{
				stringBuilder.L(i).A("private partial AssetBundle GetAssetBundle(string name);").L(0);
			}
			stringBuilder.L(i).A("public ItemDisplayRuleSet Create()").StartBlock(ref i)
				.L(i)
				.A("var idrs = ScriptableObject.CreateInstance<ItemDisplayRuleSet>();")
				.L(i)
				.A("ReplaceRules(idrs);")
				.L(i)
				.A("return idrs;")
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("public void ReplaceRules(ItemDisplayRuleSet idrs)")
				.StartBlock(ref i)
				.L(i)
				.A("var existingGroupsLength = idrs.keyAssetRuleGroups.Length;")
				.L(i)
				.A("var newRules = new List<ItemDisplayRuleSet.KeyAssetRuleGroup>();");
			foreach (ExportKeyAssetRuleGroup itemGroup in idrs.itemGroups)
			{
				GenerateRuleText(stringBuilder, itemGroup, "Item");
			}
			foreach (ExportKeyAssetRuleGroup equipmentGroup in idrs.equipmentGroups)
			{
				GenerateRuleText(stringBuilder, equipmentGroup, "Equipment");
			}
			stringBuilder.L(i).A("if (newRules.Count > 0)").StartBlock(ref i)
				.L(i)
				.A("Array.Resize(ref idrs.keyAssetRuleGroups, existingGroupsLength + newRules.Count);")
				.L(i)
				.A("for (var i = 0; i < newRules.Count; i++)")
				.StartBlock(ref i)
				.L(i)
				.A("idrs.keyAssetRuleGroups[existingGroupsLength + i] = newRules[i];")
				.EndBlock(ref i)
				.EndBlock(ref i)
				.L(0)
				.L(0)
				.L(i)
				.A("void AddOrReplaceGroup(ItemDisplayRuleSet.KeyAssetRuleGroup group)")
				.StartBlock(ref i)
				.L(i)
				.A("for (var i = 0; i < existingGroupsLength; i++)")
				.StartBlock(ref i)
				.L(i)
				.A("if (idrs.keyAssetRuleGroups[i].keyAsset == group.keyAsset)")
				.StartBlock(ref i)
				.L(i)
				.A("idrs.keyAssetRuleGroups[i] = group;")
				.L(i)
				.A("return;")
				.EndBlock(ref i)
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("newRules.Add(group);")
				.EndBlock(ref i)
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("private static ItemDisplayRule ParentedPrefabAddressables(string guid, string childName, Vector3 localPos, Vector3 localAngles, Vector3 localScale)")
				.StartBlock(ref i)
				.L(i)
				.A("return new ItemDisplayRule")
				.StartBlock(ref i)
				.L(i)
				.A("ruleType = ItemDisplayRuleType.ParentedPrefab,")
				.L(i)
				.A("followerPrefabAddress = new AssetReferenceGameObject(guid),")
				.L(i)
				.A("childName = childName,")
				.L(i)
				.A("localPos = localPos,")
				.L(i)
				.A("localAngles = localAngles,")
				.L(i)
				.A("localScale = localScale,")
				.EndBlock(ref i)
				.A(");")
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("private static ItemDisplayRule ParentedPrefabAssetBundle(AssetBundle assetBundle, string assetPath, string childName, Vector3 localPos, Vector3 localAngles, Vector3 localScale)")
				.StartBlock(ref i)
				.L(i)
				.A("return new ItemDisplayRule")
				.StartBlock(ref i)
				.L(i)
				.A("ruleType = ItemDisplayRuleType.ParentedPrefab,")
				.L(i)
				.A("followerPrefab = assetBundle.LoadAsset<GameObject>(assetPath),")
				.L(i)
				.A("followerPrefabAddress = new AssetReferenceGameObject(\"\"),")
				.L(i)
				.A("childName = childName,")
				.L(i)
				.A("localPos = localPos,")
				.L(i)
				.A("localAngles = localAngles,")
				.L(i)
				.A("localScale = localScale,")
				.EndBlock(ref i)
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("private static ItemDisplayRule LimbMask(LimbFlags limbMask)")
				.StartBlock(ref i)
				.L(i)
				.A("return new ItemDisplayRule")
				.StartBlock(ref i)
				.L(i)
				.A("ruleType = ItemDisplayRuleType.LimbMask,")
				.L(i)
				.A("limbMask = limbMask,")
				.EndBlock(ref i)
				.A(");")
				.EndBlock(ref i)
				.L(0)
				.L(i)
				.A("private static ItemDef GetItemDef(string itemDefName) => ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(itemDefName));")
				.L(i)
				.A("private static EquipmentDef GetEquipmentDef(string equipmentDefName) => EquipmentCatalog.GetEquipmentDef(EquipmentCatalog.FindEquipmentIndex(equipmentDefName));")
				.EndBlock(ref i);
			if (!string.IsNullOrEmpty(@namespace))
			{
				stringBuilder.EndBlock(ref i);
			}
			return stringBuilder.ToString();
			void GenerateRuleText(StringBuilder sb, ExportKeyAssetRuleGroup group, string type)
			{
				//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_00e7: 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: Invalid comparison between Unknown and I4
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_019e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c4: 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)
				sb.L(i).A("AddOrReplaceGroup(new ItemDisplayRuleSet.KeyAssetRuleGroup").StartBlock(ref i)
					.L(i)
					.A("keyAsset = Get")
					.A(type)
					.A("Def(\"")
					.A(group.name)
					.A("\"),")
					.L(i)
					.A("displayRuleGroup =")
					.StartBlock(ref i);
				if (group.rules.Count == 0)
				{
					sb.L(i).A("rules = Array.Empty<ItemDisplayRule>()");
				}
				else
				{
					sb.L(i).A("rules = new[]").StartBlock(ref i);
					foreach (ExportItemDisplayRule rule in group.rules)
					{
						ItemDisplayRuleType ruleType = rule.ruleType;
						if ((int)ruleType != 0)
						{
							if ((int)ruleType == 1)
							{
								sb.L(i).A("LimbMask(").A(TemplateHelpers.EnumFlagsValue<LimbFlags>(rule.limbMask, ""))
									.A("),");
							}
						}
						else
						{
							sb.L(i);
							if (!string.IsNullOrEmpty(rule.guid))
							{
								sb.A("ParentedPrefabAddressables(").A(TemplateHelpers.StringText(rule.guid, ""));
							}
							else
							{
								sb.A("ParentedPrefabAssetBundle(GetAssetBundle(").A(TemplateHelpers.StringText(rule.assetBundle, "")).A("), ")
									.A(TemplateHelpers.StringText(rule.assetPath, ""));
							}
							sb.A(", ").A(TemplateHelpers.StringText(rule.childName, "")).A(", ")
								.A(TemplateHelpers.Vector3Text(rule.localPos, 10, "", ""))
								.A(", ")
								.A(TemplateHelpers.Vector3Text(rule.localAngles, 10, "", ""))
								.A(", ")
								.A(TemplateHelpers.Vector3Text(rule.localScale, 10, "", ""))
								.A("),");
						}
					}
					sb.EndBlock(ref i);
				}
				sb.EndBlock(ref i).EndBlock(ref i).A(");");
			}
		}

		public void Import()
		{
			DialogController.ShowImport(delegate(string path, ImportType importType)
			{
				//IL_0101: 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_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e8: Expected O, but got Unknown
				try
				{
					ExportItemDisplayRuleSet val = JsonUtility.FromJson<ExportItemDisplayRuleSet>(File.ReadAllText(path));
					DisableAll();
					if (importType == ImportType.ReplaceSet)
					{
						for (int i = 0; i < previewRows.Count; i++)
						{
							DisplayRuleGroupPreviewController displayRuleGroupPreviewController = previewRows[i];
							notPickedAssets.Add(displayRuleGroupPreviewController.displayRuleGroup.KeyAsset);
							Object.Destroy((Object)(object)((Component)displayRuleGroupPreviewController).gameObject);
						}
						itemDisplayRuleSet.DisplayRuleGroups.Clear();
						previewRows.Clear();
					}
					Dictionary<string, AssetBundle> allBundles = AssetBundle.GetAllLoadedAssetBundles().ToDictionary((AssetBundle b) => ((Object)b).name);
					HashSet<string> childNames = characterModel.childLocator.transformPairs.Select((NameTransformPair p) => p.name).ToHashSet();
					new List<KeyAssetRuleGroup>();
					foreach (ExportKeyAssetRuleGroup itemGroup in val.itemGroups)
					{
						ItemDef itemDef = ItemCatalog.GetItemDef(ItemCatalog.FindItemIndex(itemGroup.name));
						if (!Object.op_Implicit((Object)(object)itemDef))
						{
							ItemDisplayPlacementHelperPlugin.InstanceLogger.LogError((object)("Couldn't get ItemDef name=\"" + itemGroup.name + "\""));
						}
						else
						{
							EditableDisplayRuleGroup editableDisplayRuleGroup = MapGroup(allBundles, childNames, itemGroup);
							editableDisplayRuleGroup.KeyAsset = (Object)(object)itemDef;
							AddKeyAsset(editableDisplayRuleGroup);
						}
					}
					foreach (ExportKeyAssetRuleGroup equipmentGroup in val.equipmentGroups)
					{
						EquipmentDef equipmentDef = EquipmentCatalog.GetEquipmentDef(EquipmentCatalog.FindEquipmentIndex(equipmentGroup.name));
						if (!Object.op_Implicit((Object)(object)equipmentDef))
						{
							ItemDisplayPlacementHelperPlugin.InstanceLogger.LogError((object)("Couldn't get EquipmentDef name=\"" + equipmentGroup.name + "\""));
						}
						else
						{
							EditableDisplayRuleGroup editableDisplayRuleGroup2 = MapGroup(allBundles, childNames, equipmentGroup);
							editableDisplayRuleGroup2.KeyAsset = (Object)(object)equipmentDef;
							editableDisplayRuleGroup2.KeyAssetAddress = new IDRSKeyAssetReference("");
							AddKeyAsset(editableDisplayRuleGroup2);
						}
					}
					ApplyFilter(filter);
				}
				catch (Exception ex)
				{
					ItemDisplayPlacementHelperPlugin.InstanceLogger.LogError((object)ex);
					DialogController.ShowError("Import failed, check log.");
				}
			});
			void AddKeyAsset(EditableDisplayRuleGroup displayGroup)
			{
				for (int i = 0; i < itemDisplayRuleSet.DisplayRuleGroups.Count; i++)
				{
					if (itemDisplayRuleSet.DisplayRuleGroups[i].KeyAsset == displayGroup.KeyAsset)
					{
						itemDisplayRuleSet.DisplayRuleGroups[i] = displayGroup;
						previewRows[i].displayRuleGroup = displayGroup;
						return;
					}
				}
				itemDisplayRuleSet.DisplayRuleGroups.Add(displayGroup);
				notPickedAssets.Remove(displayGroup.KeyAsset);
				CreateRowInstance(displayGroup);
			}
			static EditableDisplayRuleGroup MapGroup(Dictionary<string, AssetBundle> allBundles, HashSet<string> childNames, ExportKeyAssetRuleGroup ruleGroup)
			{
				//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_00dd: 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_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fa: 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_0106: 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_0125: Expected O, but got Unknown
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c3: Expected O, but got Unknown
				EditableDisplayRuleGroup editableDisplayRuleGroup = new EditableDisplayRuleGroup();
				for (int i = 0; i < ruleGroup.rules.Count; i++)
				{
					ExportItemDisplayRule val = ruleGroup.rules[i];
					string text = val.childName;
					if (!string.IsNullOrEmpty(val.childPath))
					{
						Transform val2 = ((Component)ModelPicker.Instance.CharacterModel).transform.Find(val.childPath);
						if (Object.op_Implicit((Object)(object)val2))
						{
							text = StringHelpers.ChildNameFromPath(val.childPath);
							ChildLocator childLocator = ModelPicker.Instance.CharacterModel.childLocator;
							if (!Object.op_Implicit((Object)(object)childLocator.FindChild(text)))
							{
								ref NameTransformPair[] transformPairs = ref childLocator.transformPairs;
								NameTransformPair val3 = new NameTransformPair
								{
									name = text,
									transform = val2
								};
								ArrayUtils.ArrayAppend<NameTransformPair>(ref transformPairs, ref val3);
								ParentedPrefabDisplayController.Instance.childNameDropdown.options.Add(new OptionData(text));
							}
						}
					}
					EditableItemDisplayRule editableItemDisplayRule = new EditableItemDisplayRule
					{
						childName = text,
						ruleType = val.ruleType,
						limbMask = val.limbMask,
						localAngles = val.localAngles,
						localPos = val.localPos,
						localScale = val.localScale,
						followerPrefabAddress = new AssetReferenceGameObject(val.guid ?? "")
					};
					if (!string.IsNullOrEmpty(val.assetBundle))
					{
						AssetBundle val4 = allBundles[val.assetBundle];
						editableItemDisplayRule.followerPrefab = val4.LoadAsset<GameObject>(val.assetPath);
						if (Object.op_Implicit((Object)(object)editableItemDisplayRule.followerPrefab))
						{
							editableItemDisplayRule.assetBundle = val.assetBundle;
							editableItemDisplayRule.assetPath = val.assetPath;
							editableItemDisplayRule.referenceDiscovered = true;
						}
					}
					else
					{
						AssetReferenceGameObject followerPrefabAddress = editableItemDisplayRule.followerPrefabAddress;
						if (followerPrefabAddress != null && ((AssetReference)followerPrefabAddress).RuntimeKeyIsValid())
						{
							editableItemDisplayRule.referenceDiscovered = true;
						}
					}
					editableDisplayRuleGroup.Rules.Add(editableItemDisplayRule);
				}
				return editableDisplayRuleGroup;
			}
		}

		public bool FillPrefabReference(EditableItemDisplayRule rule, bool refreshBundles)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			if (rule.referenceDiscovered)
			{
				return false;
			}
			rule.referenceDiscovered = true;
			if (!Object.op_Implicit((Object)(object)rule.followerPrefab))
			{
				return false;
			}
			(string guid, string assetBundle, string path) prefabReference = GetPrefabReference(rule.followerPrefab, refreshBundles);
			string item = prefabReference.guid;
			string item2 = prefabReference.assetBundle;
			string item3 = prefabReference.path;
			rule.followerPrefabAddress = new AssetReferenceGameObject(item);
			rule.assetBundle = item2;
			rule.assetPath = item3;
			return true;
		}

		public (string guid, string assetBundle, string path) GetPrefabReference(GameObject go, bool refreshBundles)
		{
			if (pathToGuid == null)
			{
				Regex guidRegex = new Regex("^[0-9a-f]{32}$", RegexOptions.Compiled);
				IResourceLocator? obj = Addressables.ResourceLocators.FirstOrDefault((Func<IResourceLocator, bool>)((IResourceLocator l) => l.LocatorId == "AddressablesMainContentCatalog"));
				ResourceLocationMap val = (ResourceLocationMap)(object)((obj is ResourceLocationMap) ? obj : null);
				pathToGuid = (from l in val.Locations
					where l.Key is string { Length: 32 } text && guidRegex.IsMatch(text)
					where l.Value[0].ResourceType.IsAssignableFrom(typeof(GameObject))
					select l).ToDictionary<KeyValuePair<object, IList<IResourceLocation>>, string, string>((KeyValuePair<object, IList<IResourceLocation>> l) => l.Value[0].InternalId, (KeyValuePair<object, IList<IResourceLocation>> l) => l.Key as string, StringComparer.OrdinalIgnoreCase);
			}
			if (dirToBundle == null || refreshBundles)
			{
				if (dirToBundle == null)
				{
					dirToBundle = new Dictionary<string, AssetBundle>();
				}
				IEnumerable<AssetBundle> allLoadedAssetBundles = AssetBundle.GetAllLoadedAssetBundles();
				new Dictionary<AssetBundle, Dictionary<int, string>>();
				foreach (AssetBundle item in allLoadedAssetBundles)
				{
					foreach (string bundleDirectory in NativeHelpers.GetBundleDirectories(item))
					{
						dirToBundle["archive:/" + bundleDirectory + "/" + bundleDirectory] = item;
					}
				}
			}
			int instanceID = ((Object)go).GetInstanceID();
			string pathName = NativeHelpers.GetPathName(instanceID);
			if (dirToBundle.TryGetValue(pathName, out var value))
			{
				if (bundleToAssets == null)
				{
					bundleToAssets = new Dictionary<AssetBundle, Dictionary<int, string>>();
				}
				if (!bundleToAssets.TryGetValue(value, out var value2))
				{
					value2 = (bundleToAssets[value] = NativeHelpers.GetBundleContainerPaths(value));
				}
				if (value2.TryGetValue(instanceID, out var value3))
				{
					string name = ((Object)value).name;
					if (name.EndsWith(".bundle") && pathToGuid.TryGetValue(value3, out var value4))
					{
						return (guid: value4, assetBundle: null, path: null);
					}
					return (guid: null, assetBundle: name, path: value3);
				}
			}
			return default((string, string, string));
		}

		private void UpdateRowsVisibility()
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			bool flag = string.IsNullOrEmpty(filter);
			string identifier = showItemsMode.options[showItemsMode.value].text;
			ReadOnlyContentPack[] array = ((showItemsMode.value > 0) ? ((IEnumerable<ReadOnlyContentPack>)(object)ContentManager.allLoadedContentPacks).Where((ReadOnlyContentPack p) => ((ReadOnlyContentPack)(ref p)).identifier == identifier).ToArray() : null);
			foreach (DisplayRuleGroupPreviewController previewRow in previewRows)
			{
				bool flag2 = flag || previewRow.nameText.ContainsInSequence(filter);
				if (flag2 && array != null)
				{
					Object keyAsset = previewRow.displayRuleGroup.KeyAsset;
					ItemDef itemDef = (ItemDef)(object)((keyAsset is ItemDef) ? keyAsset : null);
					if (itemDef != null)
					{
						flag2 = array.Any((ReadOnlyContentPack p) => ((ReadOnlyContentPack)(ref p)).itemDefs.Contains(itemDef));
					}
					else
					{
						keyAsset = previewRow.displayRuleGroup.KeyAsset;
						EquipmentDef equipmentDef = (EquipmentDef)(object)((keyAsset is EquipmentDef) ? keyAsset : null);
						if (equipmentDef != null)
						{
							flag2 = array.Any((ReadOnlyContentPack p) => ((ReadOnlyContentPack)(ref p)).equipmentDefs.Contains(equipmentDef));
						}
					}
				}
				((Component)previewRow).gameObject.SetActive(flag2);
			}
		}
	}
	public class KeyAssetRowController : MonoBehaviour
	{
		public TMP_Text text;

		public TMP_Text subText;

		public Image icon;

		public Button button;

		[NonSerialized]
		public Object keyAsset;
	}
	public class LayoutElementHeightFromTarget : LayoutElement
	{
		public float maxHeight = -1f;

		public RectTransform target;

		public override float preferredHeight
		{
			get
			{
				//IL_0006: 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)
				Rect rect = target.rect;
				float height = ((Rect)(ref rect)).height;
				if (maxHeight != -1f && Object.op_Implicit((Object)(object)target))
				{
					if (!(height > maxHeight))
					{
						return height;
					}
					return maxHeight;
				}
				return height;
			}
			set
			{
				((LayoutElement)this).preferredHeight = value;
			}
		}
	}
	public class MatchLocalScale : MonoBehaviour
	{
		public Transform target;

		private void Update()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)target))
			{
				((Component)this).transform.localScale = target.localScale;
			}
		}
	}
	public class ModelPicker : MonoBehaviour
	{
		public delegate void OnModelChangedHandler(CharacterModel characterModel);

		public SearchableDropdown dropdown;

		public TMP_Dropdown skinsDropdown;

		public Transform modelSpawnPosition;

		[Space]
		public RawImage icon;

		public TextMeshProUGUI bodyNameText;

		public TextMeshProUGUI modelNameText;

		private ReverseSkin reverseSkin;

		private List<SearchableDropdown.OptionData> allBodyOptions;

		private List<SearchableDropdown.OptionData> logbookBodyOptions;

		public ModelPrefabInfo ModelInfo { get; private set; }

		public GameObject ModelInstance { get; private set; }

		public CharacterModel CharacterModel { get; private set; }

		public ModelSkinController ModelSkinController { get; private set; }

		public Dictionary<SkinnedMeshRenderer, MeshCollider> CachedSkinnedMeshRenderers { get; } = new Dictionary<SkinnedMeshRenderer, MeshCollider>();

		public static ModelPicker Instance { get; private set; }

		public static event OnModelChangedHandler OnModelChanged;

		public static event Action OnModelWillChange;

		private void Awake()
		{
			Instance = this;
			logbookBodyOptions = MapBodiesToOptions(SurvivorCatalog.orderedSurvivorDefs.Select((SurvivorDef survivorDef) => BodyCatalog.GetBodyPrefabBodyComponent(SurvivorCatalog.GetBodyIndexFromSurvivorIndex(survivorDef.survivorIndex))).Union(BodyCatalog.allBodyPrefabBodyBodyComponents.Where((CharacterBody characterBody) => Object.op_Implicit((Object)(object)characterBody) && Object.op_Implicit((Object)(object)((Component)characterBody).GetComponent<DeathRewards>()?.logUnlockableDef))));
			allBodyOptions = MapBodiesToOptions(BodyCatalog.allBodyPrefabBodyBodyComponents);
			dropdown.Options = logbookBodyOptions;
			((UnityEvent<object>)(dropdown.OnItemSelected ?? (dropdown.OnItemSelected = new SearchableDropdown.DropdownEvent()))).AddListener((UnityAction<object>)SelectModel);
			static List<SearchableDropdown.OptionData> MapBodiesToOptions(IEnumerable<CharacterBody> bodies)
			{
				return (from characterBody in bodies
					select (characterBody: characterBody, characterModel: ((Component)characterBody).GetComponentInChildren<CharacterModel>()) into el
					where Object.op_Implicit((Object)(object)el.characterModel)
					select el).Select(delegate((CharacterBody characterBody, CharacterModel characterModel) el)
				{
					ModelPrefabInfo modelPrefabInfo = new ModelPrefabInfo
					{
						modelPrefab = ((Component)el.characterModel).gameObject,
						bodyName = ((Object)el.characterBody).name,
						modelName = ((Object)el.characterModel).name,
						localizedBodyName = Language.GetString(el.characterBody.baseNameToken ?? ((Object)el.characterBody).name),
						characterBody = el.characterBody
					};
					return new SearchableDropdown.OptionData(modelPrefabInfo, modelPrefabInfo.localizedBodyName + " || " + modelPrefabInfo.bodyName + " || " + modelPrefabInfo.modelName);
				}).ToList();
			}
		}

		private void OnDestroy()
		{
			Instance = null;
		}

		public void SelectModel(object modelInfo)
		{
			((MonoBehaviour)this).StartCoroutine(SelectModelAsync(modelInfo));
		}

		public IEnumerator SelectModelAsync(object modelInfo)
		{
			if (modelInfo as ModelPrefabInfo != ModelInfo)
			{
				ModelPicker.OnModelWillChange?.Invoke();
				DestroyModelInstance();
				ModelInfo = modelInfo as ModelPrefabInfo;
				yield return BuildModelInstance();
				ConfigureSkinVariants();
				ModelPicker.OnModelChanged?.Invoke(CharacterModel);
			}
		}

		private void DestroyModelInstance()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			CachedSkinnedMeshRenderers.Clear();
			Object.Destroy((Object)(object)ModelInstance);
			ModelInstance = null;
			ModelSkinController = null;
			CharacterModel = null;
			((Graphic)icon).color = Color.clear;
			icon.texture = null;
			((TMP_Text)bodyNameText).text = null;
			((TMP_Text)modelNameText).text = null;
			reverseSkin = null;
		}

		private IEnumerator BuildModelInstance()
		{
			if (ModelInfo == null || Object.op_Implicit((Object)(object)ModelInstance))
			{
				yield break;
			}
			((Graphic)icon).color = Color.white;
			icon.texture = ModelInfo.characterBody.portraitIcon;
			((TMP_Text)bodyNameText).text = ModelInfo.localizedBodyName;
			((TMP_Text)modelNameText).text = ModelInfo.modelName;
			ModelInstance = Object.Instantiate<GameObject>(ModelInfo.modelPrefab, modelSpawnPosition.position, modelSpawnPosition.rotation);
			CharacterModel = ModelInstance.GetComponent<CharacterModel>();
			CharacterModel.constraintItemDisplaysScale = false;
			ModelSkinController = ModelInstance.GetComponent<ModelSkinController>();
			if (Object.op_Implicit((Object)(object)ModelSkinController) && ModelSkinController.skins.Length != 0)
			{
				yield return ModelSkinController.ApplySkinAsync(0, (AsyncReferenceHandleUnloadType)(-1));
				reverseSkin = new ReverseSkin(ModelInstance, ModelSkinController.skins[Mathf.Clamp(ModelSkinController.currentSkinIndex, 0, ModelSkinController.skins.Length - 1)]);
			}
			AimAnimator[] componentsInChildren = ModelInstance.GetComponentsInChildren<AimAnimator>();
			foreach (AimAnimator obj in componentsInChildren)
			{
				obj.inputBank = null;
				obj.directionComponent = null;
				((Behaviour)obj).enabled = false;
			}
			Animator[] componentsInChildren2 = ModelInstance.GetComponentsInChildren<Animator>();
			foreach (Animator obj2 in componentsInChildren2)
			{
				obj2.SetBool("isGrounded", true);
				obj2.SetFloat("aimPitchCycle", 0.5f);
				obj2.SetFloat("aimYawCycle", 0.5f);
				obj2.Play("Idle");
				obj2.Update(0f);
			}
			DitherModel[] componentsInChildren3 = ModelInstance.GetComponentsInChildren<DitherModel>();
			for (int i = 0; i < componentsInChildren3.Length; i++)
			{
				((Behaviour)componentsInChildren3[i]).enabled = false;
			}
			IKSimpleChain[] componentsInChildren4 = ModelInstance.GetComponentsInChildren<IKSimpleChain>();
			for (int i = 0; i < componentsInChildren4.Length; i++)
			{
				((Behaviour)componentsInChildren4[i]).enabled = false;
			}
			PrintController[] componentsInChildren5 = ModelInstance.GetComponentsInChildren<PrintController>();
			for (int i = 0; i < componentsInChildren5.Length; i++)
			{
				((Behaviour)componentsInChildren5[i]).enabled = false;
			}
			LightIntensityCurve[] componentsInChildren6 = ModelInstance.GetComponentsInChildren<LightIntensityCurve>();
			foreach (LightIntensityCurve val in componentsInChildren6)
			{
				if (!val.loop)
				{
					((Behaviour)val).enabled = false;
				}
			}
			AkEvent[] componentsInChildren7 = ModelInstance.GetComponentsInChildren<AkEvent>();
			for (int i = 0; i < componentsInChildren7.Length; i++)
			{
				((Behaviour)componentsInChildren7[i]).enabled = false;
			}
			ShakeEmitter[] componentsInChildren8 = ModelInstance.GetComponentsInChildren<ShakeEmitter>();
			for (int i = 0; i < componentsInChildren8.Length; i++)
			{
				((Behaviour)componentsInChildren8[i]).enabled = false;
			}
			Collider[] componentsInChildren9 = ModelInstance.GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren9.Length; i++)
			{
				componentsInChildren9[i].enabled = false;
			}
			InverseKinematics[] componentsInChildren10 = ModelInstance.GetComponentsInChildren<InverseKinematics>();
			for (int i = 0; i < componentsInChildren10.Length; i++)
			{
				((Behaviour)componentsInChildren10[i]).enabled = false;
			}
			MeshFilter[] componentsInChildren11 = ModelInstance.GetComponentsInChildren<MeshFilter>();
			foreach (MeshFilter val2 in componentsInChildren11)
			{
				MeshCollider obj3 = ((Component)val2).gameObject.AddComponent<MeshCollider>();
				obj3.convex = false;
				obj3.sharedMesh = val2.sharedMesh;
				((Component)val2).gameObject.layer = 11;
			}
			SkinnedMeshRenderer[] componentsInChildren12 = ModelInstance.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val3 in componentsInChildren12)
			{
				MeshCollider val4 = ((Component)val3).gameObject.AddComponent<MeshCollider>();
				val4.convex = false;
				val4.sharedMesh = new Mesh();
				((Component)val3).gameObject.layer = 11;
				CachedSkinnedMeshRenderers[val3] = val4;
			}
		}

		private void ConfigureSkinVariants()
		{
			skinsDropdown.ClearOptions();
			if (!Object.op_Implicit((Object)(object)ModelSkinController))
			{
				((Component)skinsDropdown).gameObject.SetActive(false);
				return;
			}
			skinsDropdown.AddOptions(((IEnumerable<SkinDef>)ModelSkinController.skins).Select((Func<SkinDef, OptionData>)delegate(SkinDef el)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Expected O, but got Unknown
				string text = ((el.nameToken == null) ? ((Object)el).name : Language.GetString(el.nameToken));
				if (string.IsNullOrWhiteSpace(text))
				{
					text = "<No name>";
				}
				return new OptionData(text, el.icon);
			}).ToList());
			((Component)skinsDropdown).gameObject.SetActive(true);
		}

		public void SelectSkin(int index)
		{
			((MonoBehaviour)this).StartCoroutine(SelectSkinAsync(index));
		}

		public IEnumerator SelectSkinAsync(int index)
		{
			if (Object.op_Implicit((Object)(object)ModelSkinController))
			{
				ItemDisplayRuleSet oldIDRS = CharacterModel.itemDisplayRuleSet;
				reverseSkin?.Apply();
				yield return ModelSkinController.ApplySkinAsync(index, (AsyncReferenceHandleUnloadType)(-1));
				reverseSkin = new ReverseSkin(ModelInstance, ModelSkinController.skins[ModelSkinController.currentSkinIndex]);
				if ((Object)(object)oldIDRS != (Object)(object)CharacterModel.itemDisplayRuleSet)
				{
					ItemDisplayRuleSetController.Instance.DisableAll();
					ModelPicker.OnModelWillChange?.Invoke();
					ModelPicker.OnModelChanged?.Invoke(CharacterModel);
				}
			}
		}

		public void ToggleBodyOptions(bool enabled)
		{
			if (enabled)
			{
				dropdown.Options = allBodyOptions;
			}
			else
			{
				dropdown.Options = logbookBodyOptions;
			}
		}
	}
	public class ModelPrefabInfo
	{
		public GameObject modelPrefab;

		public string bodyName;

		public string localizedBodyName;

		public string modelName;

		public CharacterBody characterBody;
	}
	public class MouseEventConsumer : MonoBehaviour
	{
		private void OnMouseDrag()
		{
		}
	}
	[RequireComponent(typeof(TMP_InputField))]
	public class NavigateInputFieldOnTab : MonoBehaviour
	{
		private TMP_InputField inputField;

		public MoveDirection moveDirection;

		public Selectable staticTarget;

		private void Awake()
		{
			inputField = ((Component)this).GetComponent<TMP_InputField>();
		}

		private void Update()
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Expected I4, but got Unknown
			if (!((Selectable)inputField).interactable || !inputField.isFocused)
			{
				return;
			}
			Navigation navigation = ((Selectable)inputField).navigation;
			if ((int)((Navigation)(ref navigation)).mode == 0 || !Input.GetKeyDown((KeyCode)9))
			{
				return;
			}
			if (Object.op_Implicit((Object)(object)staticTarget))
			{
				staticTarget.Select();
				return;
			}
			Selectable val = null;
			MoveDirection val2 = moveDirection;
			switch ((int)val2)
			{
			case 0:
				val = ((Selectable)inputField).FindSelectableOnLeft();
				break;
			case 1:
				val = ((Selectable)inputField).FindSelectableOnUp();
				break;
			case 2:
				val = ((Selectable)inputField).FindSelectableOnRight();
				break;
			case 3:
				val = ((Selectable)inputField).FindSelectableOnDown();
				break;
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				val.Select();
			}
		}
	}
	public class ParentedPrefabDisplayController : MonoBehaviour
	{
		private static readonly Regex placeholderRegex = new Regex("(?<!\\{)\\{((?<modificator>.??):)?(?<field>[^\\{\\}:]*?)(\\.(?<subfield>.*?))?(:(?<precision>.*?))?\\}(?!\\})", RegexOptions.Compiled);

		public TMP_Dropdown ruleTypeDropdown;

		public MultipleOptionsDropdown limbMaskDropdown;

		public Button selectPrefabButton;

		public TMP_Text prefabText;

		public TMP_Dropdown childNameDropdown;

		public SearchableDropdown childPathDropdown;

		[Space]
		public Vector3InputField localPosInput;

		public Vector3InputField localAnglesInput;

		public Vector3InputField localScaleInput;

		[Space]
		public Button copyToClipboardButton;

		public Button editCopyFormatButton;

		[Space]
		public GameObject editFormatContainer;

		public TMP_InputField customFormatInput;

		public TMP_Text formatPreviewText;

		public TMP_Dropdown formatDropdown;

		private CharacterModel characterModel;

		private CopyFormat _copyFormat;

		private const string blockFormat = "childName = {childName},\r\nlocalPos = {localPos:5},\r\nlocalAngles = {localAngles:5},\r\nlocalScale = {localScale:5}\r\n";

		private const string inlineFormat = "{childName}, {localPos:5}, {localAngles:5}, {localScale:5}";

		private const string forParsing = "{r:childName},{r:localPos.x:5},{r:localPos.y:5},{r:localPos.z:5},{r:localAngles.x:5},{r:localAngles.y:5},{r:localAngles.z:5},{r:localScale.x:5},{r:localScale.y:5},{r:localScale.z:5}";

		public EditableItemDisplayRule ItemDisplayRule { get; private set; }

		public static ParentedPrefabDisplayController Instance { get; private set; }

		public CopyFormat CopyFormat
		{
			get
			{
				return _copyFormat;
			}
			set
			{
				if (formatDropdown.value == (int)value)
				{
					SelectFormat((int)value);
				}
				else
				{
					formatDropdown.value = (int)value;
				}
			}
		}

		private void Awake()
		{
			Instance = this;
			Vector3InputField vector3InputField = localPosInput;
			vector3InputField.onValueChanged = (Vector3InputField.OnChangeEvent)Delegate.Combine(vector3InputField.onValueChanged, new Vector3InputField.OnChangeEvent(OnLocalPosChanged));
			Vector3InputField vector3InputField2 = localAnglesInput;
			vector3InputField2.onValueChanged = (Vector3InputField.OnChangeEvent)Delegate.Combine(vector3InputField2.onValueChanged, new Vector3InputField.OnChangeEvent(OnLocalAnglesChanged));
			Vector3InputField vector3InputField3 = localScaleInput;
			vector3InputField3.onValueChanged = (Vector3InputField.OnChangeEvent)Delegate.Combine(vector3InputField3.onValueChanged, new Vector3InputField.OnChangeEvent(OnLocalScaleChanged));
			ModelPicker.OnModelChanged += OnModelChanged;
			ModelPicker.OnModelWillChange += OnModelWillChange;
			DisplayRuleGroupEditingController.OnDisplayRuleGroupChanged = (DisplayRuleGroupEditingController.OnDisplayRuleGroupChangedHandler)Delegate.Combine(DisplayRuleGroupEditingController.OnDisplayRuleGroupChanged, new DisplayRuleGroupEditingController.OnDisplayRuleGroupChangedHandler(OnDisplayRuleGroupChanged));
			ruleTypeDropdown.AddOptions(((IEnumerable<string>)Enum.GetNames(typeof(ItemDisplayRuleType))).Select((Func<string, OptionData>)((string name) => new OptionData(name))).ToList());
			formatDropdown.AddOptions(((IEnumerable<string>)Enum.GetNames(typeof(CopyFormat))).Select((Func<string, OptionData>)((string name) => new OptionData(name))).ToList());
			string[] names = Enum.GetNames(typeof(LimbFlags));
			IList values = Enum.GetValues(typeof(LimbFlags));
			List<MultipleOptionsDropdown.OptionData> list = new List<MultipleOptionsDropdown.OptionData>();
			for (int num = 0; num < names.Length; num++)
			{
				int num2 = (int)values[num];
				if (Utils.IsPowerOfTwo(num2))
				{
					list.Add(new MultipleOptionsDropdown.OptionData(names[num], null, num2));
				}
			}
			limbMaskDropdown.AddOptions(list);
		}

		private void OnDestroy()
		{
			ModelPicker.OnModelChanged -= OnModelChanged;
			ModelPicker.OnModelWillChange -= OnModelWillChange;
			DisplayRuleGroupEditingController.OnDisplayRuleGroupChanged = (DisplayRuleGroupEditingController.OnDisplayRuleGroupChangedHandler)Delegate.Remove(DisplayRuleGroupEditingController.OnDisplayRuleGroupChanged, new DisplayRuleGroupEditingController.OnDisplayRuleGroupChangedHandler(OnDisplayRuleGroupChanged));
			Instance = null;
		}

		private void OnModelWillChange()
		{
			ClearValues();
			childNameDropdown.ClearOptions();
			childPathDropdown.ClearOptions();
		}

		private void OnModelChanged(CharacterModel characterModel)
		{
			this.characterModel = characterModel;
			if (Object.op_Implicit((Object)(object)characterModel) && Object.op_Implicit((Object)(object)characterModel.childLocator))
			{
				childNameDropdown.options.AddRange(((IEnumerable<NameTransformPair>)characterModel.childLocator.transformPairs).Select((Func<NameTransformPair, OptionData>)((NameTransformPair el) => new OptionData(el.name))).ToList());
				BuildChildPathDropdownOptions(ModelPicker.Instance.ModelInfo.modelPrefab.transform);
			}
		}

		private void BuildChildPathDropdownOptions(Transform parent, string parentPath = null)
		{
			int childCount = parent.childCount;
			for (int i = 0; i < childCount; i++)
			{
				Transform child = parent.GetChild(i);
				string text = ((parentPath == null) ? ((Object)child).name : (parentPath + "/" + ((Object)child).name));
				childPathDropdown.Options.Add(new SearchableDropdown.OptionData(text, text));
				BuildChildPathDropdownOptions(child, text);
			}
		}

		private void OnDisplayRuleGroupChanged(EditableDisplayRuleGroup keyAssetRuleGroup)
		{
			SetItemDisplayRule(null);
		}

		private void Update()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Invalid comparison between Unknown and I4
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ItemDisplayRule != null;
			bool flag2 = Object.op_Implicit((Object)(object)ItemDisplayRule?.instance);
			((Selectable)ruleTypeDropdown).interactable = flag;
			MultipleOptionsDropdown multipleOptionsDropdown = limbMaskDropdown;
			EditableItemDisplayRule itemDisplayRule = ItemDisplayRule;
			((Selectable)multipleOptionsDropdown).interactable = itemDisplayRule != null && (int)itemDisplayRule.ruleType == 1;
			EditableItemDisplayRule itemDisplayRule2 = ItemDisplayRule;
			bool interactable = itemDisplayRule2 != null && (int)itemDisplayRule2.ruleType == 0;
			((Selectable)selectPrefabButton).interactable = interactable;
			((Selectable)childNameDropdown).interactable = interactable;
			((Selectable)childPathDropdown).interactable = interactable;
			localPosInput.interactable = flag2;
			localAnglesInput.interactable = flag2;
			localScaleInput.interactable = flag2;
			((Selectable)copyToClipboardButton).interactable = flag;
			((Selectable)editCopyFormatButton).interactable = flag;
			if (!flag)
			{
				editFormatContainer.SetActive(false);
			}
			if (flag2)
			{
				localPosInput.SetValueWithoutNotify(ItemDisplayRule.instance.transform.localPosition);
				localAnglesInput.SetValueWithoutNotify(ItemDisplayRule.instance.transform.localEulerAngles);
				localScaleInput.SetValueWithoutNotify(ItemDisplayRule.instance.transform.localScale);
				ItemDisplayRule.localPos = localPosInput.CurrentValue;
				ItemDisplayRule.localAngles = localAnglesInput.CurrentValue;
				ItemDisplayRule.localScale = localScaleInput.CurrentValue;
			}
		}

		private void ClearValues()
		{
			prefabText.text = "No prefab";
			ruleTypeDropdown.SetValueWithoutNotify(-1);
			ruleTypeDropdown.RefreshShownValue();
			limbMaskDropdown.SetValueWithoutNotify(0);
			limbMaskDropdown.RefreshShownValue();
			childNameDropdown.SetValueWithoutNotify(-1);
			childNameDropdown.RefreshShownValue();
			localPosInput.ClearValues();
			localAnglesInput.ClearValues();
			localScaleInput.ClearValues();
		}

		public void SetItemDisplayRule(EditableItemDisplayRule itemDisplayRule)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected I4, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected I4, but got Unknown
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: 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_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: 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)
			if (ItemDisplayRule == itemDisplayRule)
			{
				return;
			}
			ClearValues();
			ItemDisplayRule = itemDisplayRule;
			EditorAxisController.Instance.SetSelectedObject(Object.op_Implicit((Object)(object)ItemDisplayRule?.instance) ? ItemDisplayRule.instance.transform : null);
			if (ItemDisplayRule == null)
			{
				return;
			}
			ruleTypeDropdown.SetValueWithoutNotify((int)itemDisplayRule.ruleType);
			ruleTypeDropdown.RefreshShownValue();
			limbMaskDropdown.SetValueWithoutNotify((int)itemDisplayRule.limbMask);
			limbMaskDropdown.RefreshShownValue();
			prefabText.text = (Object.op_Implicit((Object)(object)itemDisplayRule.followerPrefab) ? ((Object)itemDisplayRule.followerPrefab).name : "No prefab");
			GameObject instance = itemDisplayRule.instance;
			Transform displayTransform = ((instance != null) ? instance.transform : null);
			if (Object.op_Implicit((Object)(object)displayTransform))
			{
				string childName = ((IEnumerable<NameTransformPair>)characterModel.childLocator.transformPairs).FirstOrDefault((Func<NameTransformPair, bool>)((NameTransformPair el) => (Object)(object)el.transform == (Object)(object)displayTransform.parent)).name;
				childNameDropdown.SetValueWithoutNotify(childNameDropdown.options.FindIndex((OptionData el) => el.text == childName));
				childNameDropdown.RefreshShownValue();
				localPosInput.SetValueWithoutNotify(displayTransform.localPosition, forceUpdate: true);
				localAnglesInput.SetValueWithoutNotify(displayTransform.localEulerAngles, forceUpdate: true);
				localScaleInput.SetValueWithoutNotify(displayTransform.localScale, forceUpdate: true);
			}
			else
			{
				childNameDropdown.SetValueWithoutNotify(childNameDropdown.options.FindIndex((OptionData el) => el.text == ItemDisplayRule.childName));
				childNameDropdown.RefreshShownValue();
				localPosInput.SetV