Decompiled source of balrond character customization v0.1.3

plugins/BalrondCharacterCustomization.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
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.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using HarmonyLib;
using LitJson2;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PlayerColors")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PlayerColors")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("557f8e2f-a3ae-46a6-88b4-1e0416ad09c5")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace BalPlayerColorsrondVnV
{
	[Serializable]
	public class MappedEffectList
	{
		public List<EffectInfo> pieceEffect;

		public List<EffectInfo> destroyedEffects;

		public List<EffectInfo> hitEffects;

		public List<EffectInfo> switchEffect;

		public List<EffectInfo> blockEffect;

		public List<EffectInfo> equipEffect;

		public List<EffectInfo> hitEffect;

		public List<EffectInfo> hitTerrainEffect;

		public List<EffectInfo> holdStartEffect;

		public List<EffectInfo> startEffect;

		public List<EffectInfo> trailStartEffect;

		public List<EffectInfo> triggerEffect;

		public List<EffectInfo> unequipEffect;

		public EffectList createEffectListFromInfo(List<EffectInfo> list)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			EffectList val = new EffectList();
			List<EffectData> list2 = new List<EffectData>();
			val.m_effectPrefabs = list2.ToArray();
			return val;
		}

		private EffectData createEffectData(EffectInfo info)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			EffectData val = new EffectData();
			val.m_inheritParentRotation = info.inheritRotation;
			val.m_multiplyParentVisualScale = info.multiplyScale;
			val.m_childTransform = info.childName;
			val.m_inheritParentScale = info.inheritScale;
			val.m_variant = info.variant;
			val.m_scale = info.scale;
			val.m_attach = info.attach;
			val.m_follow = info.follow;
			val.m_prefab = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == info.name);
			return val;
		}
	}
	[Serializable]
	public struct EffectInfo
	{
		public string name;

		public bool enabled;

		public int variant;

		public bool attach;

		public bool follow;

		public bool inheritRotation;

		public bool inheritScale;

		public bool multiplyScale;

		public bool radnomRotation;

		public bool scale;

		public string childName;

		public EffectInfo(string name, bool enabled = true, int variant = -1, bool attach = false, bool follow = false, bool inheritRotation = false, bool inheritScale = false, bool multiplyScale = false, bool radnomRotation = false, bool scale = false, string childName = null)
		{
			this.name = name;
			this.enabled = enabled;
			this.variant = variant;
			this.attach = attach;
			this.follow = follow;
			this.inheritRotation = inheritRotation;
			this.inheritScale = inheritScale;
			this.multiplyScale = multiplyScale;
			this.radnomRotation = radnomRotation;
			this.scale = scale;
			this.childName = childName;
		}
	}
}
namespace PlayerColors
{
	public class BalrondPlayerCustomization : MonoBehaviour
	{
		private ZNetView netView;

		private Player _player;

		private VisEquipment _visEquipment;

		private SkinnedMeshRenderer _meshRenderer;

		private Transform _visual;

		public Color eyeColor;

		public Vector3 eyeColorVector;

		public float height = 0f;

		public GameObject eyesObject;

		public GameObject _eyesInstanced;

		public int eyesItemHash;

		private void Start()
		{
			netView = ((Component)this).GetComponent<ZNetView>();
			_player = ((Component)this).GetComponent<Player>();
			_visEquipment = ((Component)this).GetComponent<VisEquipment>();
			if ((Object)(object)_player == (Object)null || (Object)(object)_visEquipment == (Object)null)
			{
				return;
			}
			_meshRenderer = _visEquipment.m_bodyModel;
			if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
			{
				eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
				eyesItemHash = (((Object)(object)eyesObject != (Object)null) ? ((object)eyesObject).GetHashCode() : 0);
			}
			if ((Object)(object)Launch.eyesObject != (Object)null)
			{
				eyesObject = Launch.eyesObject;
				if ((Object)(object)_eyesInstanced == (Object)null)
				{
					_eyesInstanced = Launch.AttachItem(eyesObject, -1, _visEquipment.m_helmet, _visEquipment);
				}
			}
			_visual = ((Component)_player).transform.Find("Visual");
			if ((Object)(object)netView != (Object)null)
			{
				GetPlayerColor();
				GetPlayerHeight();
			}
		}

		public void SetEyeColor(Color eyeColor)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			this.eyeColor = eyeColor;
			eyeColorVector = Utils.ColorToVec3(eyeColor);
			SaveToCustomData();
			ApplyColorToInstancedEyes(eyeColor);
		}

		public void SetHeight(float height)
		{
			this.height = height;
			SaveHeightToCustomData();
			ApplyHeight(height);
		}

		public void SaveHeightToCustomData()
		{
			if ((Object)(object)_player != (Object)null)
			{
				_player.m_customData.Remove("BalrondHeight");
				_player.m_customData.Add("BalrondHeight", height.ToString());
			}
		}

		public void SaveToCustomData()
		{
			if ((Object)(object)_player != (Object)null)
			{
				_player.m_customData.Remove("BalrondEyesX");
				_player.m_customData.Remove("BalrondEyesY");
				_player.m_customData.Remove("BalrondEyesZ");
				_player.m_customData.Add("BalrondEyesX", eyeColorVector.x.ToString());
				_player.m_customData.Add("BalrondEyesY", eyeColorVector.y.ToString());
				_player.m_customData.Add("BalrondEyesZ", eyeColorVector.z.ToString());
			}
		}

		public float GetHeightFromPlayerCustomData(Player player = null)
		{
			string value = "0";
			Player val = _player;
			if ((Object)(object)player != (Object)null)
			{
				val = player;
			}
			string s = (val.m_customData.TryGetValue("BalrondHeight", out value) ? value : "0");
			return float.Parse(s);
		}

		public Vector3 GetFromPlayerCustomData(Player player = null)
		{
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			string value = "1";
			string value2 = "1";
			string value3 = "1";
			Player val = _player;
			if ((Object)(object)player != (Object)null)
			{
				val = player;
			}
			string s = (val.m_customData.TryGetValue("BalrondEyesX", out value) ? value : "1");
			string s2 = (val.m_customData.TryGetValue("BalrondEyesY", out value2) ? value2 : "1");
			string s3 = (val.m_customData.TryGetValue("BalrondEyesZ", out value3) ? value3 : "1");
			return new Vector3(float.Parse(s), float.Parse(s2), float.Parse(s3));
		}

		private void GetPlayerColor()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			eyeColorVector = GetFromPlayerCustomData();
			eyeColor = new Color(eyeColorVector.x, eyeColorVector.y, eyeColorVector.z, 1f);
			SetEyeColor(eyeColor);
		}

		private void GetPlayerHeight()
		{
			height = GetHeightFromPlayerCustomData();
			SetHeight(height);
		}

		private void ApplyHeight(float height)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			if (height != 0f && (Object)(object)_visual != (Object)null)
			{
				_visual.localScale = new Vector3(0.95f, 0.95f + height, 0.95f);
			}
		}

		private void ApplyColorToInstancedEyes(Color color)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_eyesInstanced == (Object)null))
			{
				Renderer[] componentsInChildren = _eyesInstanced.GetComponentsInChildren<Renderer>();
				for (int i = 0; i < componentsInChildren.Length; i++)
				{
					Material material = componentsInChildren[i].material;
					material.SetColor("_Color", color);
					material.SetColor("_EmissionColor", color);
				}
			}
		}
	}
	public class BalrondTranslator
	{
		public static Dictionary<string, Dictionary<string, string>> translations = new Dictionary<string, Dictionary<string, string>>();

		public static Dictionary<string, string> getLanguage(string language)
		{
			if (string.IsNullOrEmpty(language))
			{
				return null;
			}
			if (translations.TryGetValue(language, out var value))
			{
				return value;
			}
			return null;
		}
	}
	public class ReassignBoneWeigthsToNewMesh : MonoBehaviour
	{
		public string rootBoneName = "Hips";

		private void Start()
		{
			Transform transform = ((Component)this).transform;
			object obj;
			if (transform == null)
			{
				obj = null;
			}
			else
			{
				Transform parent = transform.parent;
				if (parent == null)
				{
					obj = null;
				}
				else
				{
					Transform parent2 = parent.parent;
					if (parent2 == null)
					{
						obj = null;
					}
					else
					{
						Transform obj2 = parent2.Find("Armature");
						obj = ((obj2 != null) ? ((Component)obj2).transform : null);
					}
				}
			}
			Transform val = (Transform)obj;
			if (!((Object)(object)val == (Object)null))
			{
				SkinnedMeshRenderer component = ((Component)this).gameObject.GetComponent<SkinnedMeshRenderer>();
				Transform[] bones = component.bones;
				component.rootBone = val.Find(rootBoneName);
				Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>();
				bones[31] = componentsInChildren[41];
				bones[8] = componentsInChildren[12];
				bones[9] = componentsInChildren[13];
				bones[10] = componentsInChildren[14];
				component.bones = bones;
			}
		}
	}
	public class DatabaseAddMethods
	{
		public void AddItems(List<GameObject> items)
		{
			foreach (GameObject item in items)
			{
				AddItem(item);
			}
		}

		public void AddRecipes(List<Recipe> recipes)
		{
			foreach (Recipe recipe in recipes)
			{
				AddRecipe(recipe);
			}
		}

		public void AddStatuseffects(List<StatusEffect> statusEffects)
		{
			foreach (StatusEffect statusEffect in statusEffects)
			{
				AddStatus(statusEffect);
			}
		}

		private bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		private void AddStatus(StatusEffect status)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)status != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetStatusEffect(status.m_nameHash) == (Object)null)
				{
					ObjectDB.instance.m_StatusEffects.Add(status);
				}
				else
				{
					Debug.Log((object)(Launch.projectName + ":  " + ((Object)status).name + " - Status already in the game"));
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ":  " + ((Object)status).name + " - Status not found"));
			}
		}

		private void AddRecipe(Recipe recipe)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			if ((Object)(object)recipe != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.m_recipes.Find((Recipe x) => ((Object)x).name == ((Object)recipe).name) == (Object)null)
				{
					if ((Object)(object)recipe.m_item != (Object)null)
					{
						ObjectDB.instance.m_recipes.Add(recipe);
					}
				}
				else
				{
					Debug.Log((object)(Launch.projectName + ":  " + ((Object)recipe).name + " - Recipe with this name already in the Game"));
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ":  " + ((Object)recipe).name + " - Recipe not found"));
			}
		}

		private void AddItem(GameObject newPrefab)
		{
			if (!IsObjectDBValid())
			{
				return;
			}
			ItemDrop component = newPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
				{
					ObjectDB.instance.m_items.Add(newPrefab);
					Dictionary<int, GameObject> dictionary = (Dictionary<int, GameObject>)typeof(ObjectDB).GetField("m_itemByHash", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(ObjectDB.instance);
					dictionary[((Object)newPrefab).name.GetHashCode()] = newPrefab;
					if ((Object)(object)ObjectDB.instance.GetItemPrefab(((Object)newPrefab).name) == (Object)null)
					{
						ObjectDB.instance.m_itemByHash.Add(StringExtensionMethods.GetStableHashCode(((Object)newPrefab).name), newPrefab);
					}
				}
				else
				{
					Debug.Log((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop already exist"));
				}
			}
			else
			{
				Debug.LogError((object)(Launch.projectName + ": " + ((Object)newPrefab).name + " - ItemDrop not found on prefab"));
			}
		}
	}
	public class FxReplacment
	{
		public void ReplaceOnObject(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			SpawnArea component = gameObject.GetComponent<SpawnArea>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList spawnEffects = component.m_spawnEffects;
				if (spawnEffects != null)
				{
					findEffectsAndChange(spawnEffects.m_effectPrefabs, zNetScene);
				}
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
				}
				EffectList destroyedEffect = component2.m_destroyedEffect;
				if (destroyedEffect != null)
				{
					findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
				}
			}
			Projectile component3 = gameObject.GetComponent<Projectile>();
			if ((Object)(object)component3 != (Object)null)
			{
				EffectList hitEffects = component3.m_hitEffects;
				if (hitEffects != null)
				{
					findEffectsAndChange(hitEffects.m_effectPrefabs, zNetScene);
				}
				EffectList hitWaterEffects = component3.m_hitWaterEffects;
				if (hitWaterEffects != null)
				{
					findEffectsAndChange(hitWaterEffects.m_effectPrefabs, zNetScene);
				}
				EffectList spawnOnHitEffects = component3.m_spawnOnHitEffects;
				if (spawnOnHitEffects != null)
				{
					findEffectsAndChange(spawnOnHitEffects.m_effectPrefabs, zNetScene);
				}
			}
		}

		public void ReplaceOnVegetation(GameObject gameObject, ZNetScene zNetScene)
		{
			Pickable component = gameObject.GetComponent<Pickable>();
			if ((Object)(object)component != (Object)null)
			{
				fixPlant(component, zNetScene);
			}
			Destructible component2 = gameObject.GetComponent<Destructible>();
			if ((Object)(object)component2 != (Object)null)
			{
				fixPDestructable(component2, zNetScene);
			}
			MineRock5 component3 = gameObject.GetComponent<MineRock5>();
			if ((Object)(object)component3 != (Object)null)
			{
				fixMineRock5(component3, zNetScene);
			}
			MineRock component4 = gameObject.GetComponent<MineRock>();
			if ((Object)(object)component4 != (Object)null)
			{
				fixMineRock(component4, zNetScene);
			}
		}

		private void fixPlant(Pickable pickable, ZNetScene zNetScene)
		{
			EffectList pickEffector = pickable.m_pickEffector;
			if (pickEffector != null)
			{
				findEffectsAndChange(pickEffector.m_effectPrefabs, zNetScene);
			}
		}

		private void fixPDestructable(Destructible minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		private void fixMineRock5(MineRock5 minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		private void fixMineRock(MineRock minerock5, ZNetScene zNetScene)
		{
			EffectList hitEffect = minerock5.m_hitEffect;
			if (hitEffect != null)
			{
				findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
			}
			EffectList destroyedEffect = minerock5.m_destroyedEffect;
			if (destroyedEffect != null)
			{
				findEffectsAndChange(destroyedEffect.m_effectPrefabs, zNetScene);
			}
		}

		public void ReplaceOnMonster(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				Debug.LogWarning((object)(Launch.projectName + ":: GameObject not found"));
				return;
			}
			Humanoid component = gameObject.GetComponent<Humanoid>();
			if ((Object)(object)component == (Object)null)
			{
				Debug.LogWarning((object)(Launch.projectName + ":: GameObject not found"));
				return;
			}
			EffectList dropEffects = component.m_dropEffects;
			if (dropEffects != null)
			{
				findEffectsAndChange(dropEffects.m_effectPrefabs, zNetScene);
			}
			EffectList backstabHitEffects = ((Character)component).m_backstabHitEffects;
			if (backstabHitEffects != null)
			{
				findEffectsAndChange(backstabHitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList consumeItemEffects = component.m_consumeItemEffects;
			if (consumeItemEffects != null)
			{
				findEffectsAndChange(consumeItemEffects.m_effectPrefabs, zNetScene);
			}
			EffectList critHitEffects = ((Character)component).m_critHitEffects;
			if (critHitEffects != null)
			{
				findEffectsAndChange(critHitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList deathEffects = ((Character)component).m_deathEffects;
			if (deathEffects != null)
			{
				findEffectsAndChange(deathEffects.m_effectPrefabs, zNetScene);
			}
			EffectList hitEffects = ((Character)component).m_hitEffects;
			if (hitEffects != null)
			{
				findEffectsAndChange(hitEffects.m_effectPrefabs, zNetScene);
			}
			EffectList jumpEffects = ((Character)component).m_jumpEffects;
			if (jumpEffects != null)
			{
				findEffectsAndChange(jumpEffects.m_effectPrefabs, zNetScene);
			}
			EffectList perfectBlockEffect = component.m_perfectBlockEffect;
			if (perfectBlockEffect != null)
			{
				findEffectsAndChange(perfectBlockEffect.m_effectPrefabs, zNetScene);
			}
			EffectList pickupEffects = component.m_pickupEffects;
			if (pickupEffects != null)
			{
				findEffectsAndChange(pickupEffects.m_effectPrefabs, zNetScene);
			}
			EffectList slideEffects = ((Character)component).m_slideEffects;
			if (slideEffects != null)
			{
				findEffectsAndChange(slideEffects.m_effectPrefabs, zNetScene);
			}
			EffectList tarEffects = ((Character)component).m_tarEffects;
			if (tarEffects != null)
			{
				findEffectsAndChange(tarEffects.m_effectPrefabs, zNetScene);
			}
			EffectList waterEffects = ((Character)component).m_waterEffects;
			if (waterEffects != null)
			{
				findEffectsAndChange(waterEffects.m_effectPrefabs, zNetScene);
			}
			FootStep component2 = gameObject.GetComponent<FootStep>();
			if (!((Object)(object)component2 != (Object)null))
			{
				return;
			}
			List<StepEffect> effects = component2.m_effects;
			foreach (StepEffect item in effects)
			{
				GameObject[] effectPrefabs = item.m_effectPrefabs;
				List<GameObject> list = new List<GameObject>();
				list.AddRange(effectPrefabs);
				for (int i = 0; i < list.Count; i++)
				{
					if ((Object)(object)list[i] != (Object)null)
					{
						string name = ((Object)list[i]).name;
						GameObject val = ZNetScene.instance.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
						if (!((Object)(object)val == (Object)null))
						{
							list[i] = val;
						}
					}
				}
			}
		}

		public void ReplaceOnItem(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			ItemDrop component = gameObject.GetComponent<ItemDrop>();
			if (!((Object)(object)component == (Object)null))
			{
				EffectList hitEffect = component.m_itemData.m_shared.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
				}
				EffectList hitTerrainEffect = component.m_itemData.m_shared.m_hitTerrainEffect;
				if (hitTerrainEffect != null)
				{
					findEffectsAndChange(hitTerrainEffect.m_effectPrefabs, zNetScene);
				}
				EffectList holdStartEffect = component.m_itemData.m_shared.m_holdStartEffect;
				if (holdStartEffect != null)
				{
					findEffectsAndChange(holdStartEffect.m_effectPrefabs, zNetScene);
				}
				EffectList trailStartEffect = component.m_itemData.m_shared.m_trailStartEffect;
				if (trailStartEffect != null)
				{
					findEffectsAndChange(trailStartEffect.m_effectPrefabs, zNetScene);
				}
				EffectList blockEffect = component.m_itemData.m_shared.m_blockEffect;
				if (blockEffect != null)
				{
					findEffectsAndChange(blockEffect.m_effectPrefabs, zNetScene);
				}
			}
		}

		public void ReplaceFxOnPiece(GameObject gameObject, ZNetScene zNetScene)
		{
			if ((Object)(object)gameObject == (Object)null)
			{
				return;
			}
			Piece component = gameObject.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null)
			{
				EffectList placeEffect = component.m_placeEffect;
				if (placeEffect != null)
				{
					findEffectsAndChange(placeEffect.m_effectPrefabs, zNetScene);
				}
			}
			WearNTear component2 = gameObject.GetComponent<WearNTear>();
			if ((Object)(object)component2 != (Object)null)
			{
				EffectList hitEffect = component2.m_hitEffect;
				if (hitEffect != null)
				{
					findEffectsAndChange(hitEffect.m_effectPrefabs, zNetScene);
				}
			}
		}

		private void findEffectsAndChange(EffectData[] effects, ZNetScene zNetScene)
		{
			if (effects == null || effects.Length == 0)
			{
				return;
			}
			foreach (EffectData val in effects)
			{
				if ((Object)(object)val.m_prefab != (Object)null)
				{
					string name = ((Object)val.m_prefab).name;
					GameObject val2 = zNetScene.m_prefabs.Find((GameObject x) => (Object)(object)x != (Object)null && ((Object)x).name == name);
					if ((Object)(object)val2 != (Object)null)
					{
						val.m_prefab = val2;
					}
					else
					{
						Debug.LogWarning((object)("Coulnt not find in Znet fx name:" + name));
					}
				}
			}
		}
	}
	public class ModResourceLoader
	{
		public AssetBundle assetBundle;

		public List<GameObject> itemPrefabs = new List<GameObject>();

		public List<GameObject> roomPrefabs = new List<GameObject>();

		public List<GameObject> vfxPrefabs = new List<GameObject>();

		public List<Sprite> backgrounds = new List<Sprite>();

		public FxReplacment fxReplacment = new FxReplacment();

		public List<Recipe> recipes = new List<Recipe>();

		public List<StatusEffect> statusEffects = new List<StatusEffect>();

		public StatusEffect newBarleyStatus = null;

		public ShaderReplacment shaderReplacment = new ShaderReplacment();

		public Sprite skillIconLockpicking;

		public Sprite skillIconEndurance;

		public Sprite skillIconForaging;

		public void loadAssets()
		{
			assetBundle = GetAssetBundleFromResources("balrondcharacteredit");
			string basePath = "Assets/Custom/BalrondCharacterEdit/";
			loadItems(basePath);
			loadOther(basePath);
		}

		public void AddPrefabsToZnetScene(ZNetScene zNetScene)
		{
			validateAddedPrefabs(itemPrefabs, zNetScene);
			validateAddedPrefabs(vfxPrefabs, zNetScene);
			zNetScene.m_prefabs.RemoveAll((GameObject x) => (Object)(object)x == (Object)null);
		}

		private void prepareOtherEffects(string mainPath)
		{
			string[] array = new string[0];
			string[] array2 = array;
			foreach (string text in array2)
			{
				StatusEffect val = (StatusEffect)(object)assetBundle.LoadAsset<SE_Stats>(mainPath + "Status/" + text + ".asset");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Satus not found: " + text));
				}
				else
				{
					statusEffects.Add(val);
				}
			}
		}

		private void validateAddedPrefabs(List<GameObject> list, ZNetScene zNetScene)
		{
			foreach (GameObject item in list)
			{
				if (zNetScene.m_namedPrefabs.ContainsKey(StringExtensionMethods.GetStableHashCode(((Object)item).name)))
				{
					Debug.LogWarning((object)("DUPLICATE: " + ((Object)item).name));
				}
				else
				{
					zNetScene.m_prefabs.Add(item);
				}
			}
		}

		private void loadBackground(string mainPath)
		{
			string[] array = new string[5] { "ashlands1.jpg", "ashlands2.png", "blackforest.png", "mistlands.jpg", "meadows.png" };
			string[] array2 = array;
			foreach (string text in array2)
			{
				Sprite val = assetBundle.LoadAsset<Sprite>(mainPath + "screens/" + text);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find background with name: " + text));
				}
				else
				{
					backgrounds.Add(val);
				}
			}
		}

		private GameObject FindPrefabInZnet(string name, ZNetScene zNetScene)
		{
			GameObject value = null;
			zNetScene.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode(name), out value);
			if ((Object)(object)value == (Object)null)
			{
				value = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
			}
			return value;
		}

		private GameObject getRavenGuidePrefab(ZNetScene zNetScene)
		{
			string name = "Ravens";
			GameObject val = FindPrefabInZnet(name, zNetScene);
			if ((Object)(object)val != (Object)null)
			{
				return val;
			}
			string text = "piece_workbench";
			GameObject val2 = FindPrefabInZnet(text, zNetScene);
			if (text != null)
			{
				GameObject gameObject = ((Component)val2.transform.Find("GuidePoint")).gameObject;
				if ((Object)(object)gameObject != (Object)null)
				{
					GuidePoint component = gameObject.GetComponent<GuidePoint>();
					if ((Object)(object)component != (Object)null)
					{
						return component.m_ravenPrefab;
					}
				}
			}
			return null;
		}

		public void setupRavenGuide(GameObject gameObject, ZNetScene zNetScene)
		{
			GameObject val = null;
			Transform val2 = gameObject.transform.Find("GuidePoint");
			if (!((Object)(object)val2 == (Object)null))
			{
				val = getRavenGuidePrefab(zNetScene);
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)"Ravens not found");
				}
				else
				{
					((Component)val2).GetComponent<GuidePoint>().m_ravenPrefab = val;
				}
			}
		}

		private AssetBundle GetAssetBundleFromResources(string filename)
		{
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = executingAssembly.GetManifestResourceNames().Single((string str) => str.EndsWith(filename));
			using Stream stream = executingAssembly.GetManifestResourceStream(name);
			return AssetBundle.LoadFromStream(stream);
		}

		private void addNewPrefabToCollection(string[] nameList, string mainPath, List<GameObject> prefabList, string typeName = "Prefab")
		{
			foreach (string text in nameList)
			{
				GameObject val = assetBundle.LoadAsset<GameObject>(mainPath + text + ".prefab");
				if ((Object)(object)val == (Object)null)
				{
					Debug.LogWarning((object)("Could not find " + typeName + " with name: " + text));
					continue;
				}
				ShaderReplacment.Replace(val);
				prefabList.Add(val);
			}
		}

		private void loadItems(string basePath)
		{
			string mainPath = basePath + "items/";
			string[] items = ItemList.items;
			addNewPrefabToCollection(items, mainPath, itemPrefabs, "item");
		}

		private void loadOther(string basePath)
		{
			string mainPath = basePath + "Other/";
			string[] nameList = new string[0];
			addNewPrefabToCollection(nameList, mainPath, vfxPrefabs, "vfx");
		}
	}
	public class ShaderReplacment
	{
		public static List<GameObject> prefabsToReplaceShader = new List<GameObject>();

		public static List<Material> materialsInPrefabs = new List<Material>();

		public static List<Shader> shaders = new List<Shader>();

		private static readonly HashSet<Shader> CachedShaders = new HashSet<Shader>();

		public static bool debug = true;

		public static Shader GetShaderByName(string name)
		{
			return shaders.Find((Shader x) => ((Object)x).name == name.Trim());
		}

		public static void Replace(GameObject gameObject)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			if (!new ZNet().IsDedicated())
			{
				prefabsToReplaceShader.Add(gameObject);
				GetMaterialsInPrefab(gameObject);
			}
		}

		public static void GetMaterialsInPrefab(GameObject gameObject)
		{
			Renderer[] componentsInChildren = gameObject.GetComponentsInChildren<Renderer>(true);
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Material[] sharedMaterials = val.sharedMaterials;
				if (sharedMaterials == null || sharedMaterials.Length == 0)
				{
					continue;
				}
				Material[] array2 = sharedMaterials;
				foreach (Material val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && !materialsInPrefabs.Contains(val2))
					{
						materialsInPrefabs.Add(val2);
					}
				}
			}
		}

		public static void getMeShaders()
		{
			AssetBundle[] array = Resources.FindObjectsOfTypeAll<AssetBundle>();
			AssetBundle[] array2 = array;
			foreach (AssetBundle val in array2)
			{
				IEnumerable<Shader> enumerable3;
				try
				{
					IEnumerable<Shader> enumerable2;
					if (!val.isStreamedSceneAssetBundle || !Object.op_Implicit((Object)(object)val))
					{
						IEnumerable<Shader> enumerable = val.LoadAllAssets<Shader>();
						enumerable2 = enumerable;
					}
					else
					{
						enumerable2 = from shader in ((IEnumerable<string>)val.GetAllAssetNames()).Select((Func<string, Shader>)val.LoadAsset<Shader>)
							where (Object)(object)shader != (Object)null
							select shader;
					}
					enumerable3 = enumerable2;
				}
				catch (Exception)
				{
					continue;
				}
				if (enumerable3 == null)
				{
					continue;
				}
				foreach (Shader item in enumerable3)
				{
					CachedShaders.Add(item);
				}
			}
		}

		public static void runMaterialFix()
		{
			getMeShaders();
			shaders.AddRange(CachedShaders);
			foreach (Material materialsInPrefab in materialsInPrefabs)
			{
				Shader shader = materialsInPrefab.shader;
				if (!((Object)(object)shader == (Object)null))
				{
					string name = ((Object)shader).name;
					if (!(name == "Standard") && !name.Contains("ScrollingTex") && name.Contains("Balrond"))
					{
						setProperValue(materialsInPrefab, name);
					}
				}
			}
		}

		private static void setProperValue(Material material, string shaderName)
		{
			string name = shaderName.Replace("Balrond", "Custom");
			name = checkNaming(name);
			Shader shaderByName = GetShaderByName(name);
			if ((Object)(object)shaderByName == (Object)null)
			{
				Debug.LogWarning((object)("Shader not found " + name));
			}
			else
			{
				material.shader = shaderByName;
			}
		}

		private static string checkNaming(string name)
		{
			string result = name;
			if (name.Contains("Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Tess Bumped"))
			{
				result = name.Replace("Custom", "Lux Lit Particles");
			}
			if (name.Contains("Standard Surface"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Surface2", "Standard Surface");
			}
			if (name.Contains("Standard Unlit"))
			{
				result = name.Replace("Custom", "Particles");
				result = result.Replace("Standard Unlit", "Standard Unlit2");
				result = result.Replace("Standard Unlit22", "Standard Unlit2");
			}
			return result;
		}
	}
	public class TableMapper
	{
		public static CraftingStation cauldron;

		public static CraftingStation workbench;

		public static CraftingStation heavyWorkbench;

		public static CraftingStation forge;

		public static CraftingStation ironworks;

		public static CraftingStation blackforge;

		public static CraftingStation stoneCutter;

		public static CraftingStation artisian;

		public static CraftingStation magetable;

		public static CraftingStation runeforge;

		public static CraftingStation tannery;

		public static CraftingStation fletcher;

		public static CraftingStation grill;

		public static CraftingStation alchemylab;

		public static CraftingStation shamantable;

		public static CraftingStation foodtable;

		public static ZNetScene zNetScene;

		public static List<GameObject> list = new List<GameObject>();

		public static void setupTables(ZNetScene zNetScene = null, List<GameObject> list = null)
		{
			TableMapper.zNetScene = zNetScene;
			TableMapper.list = list;
			prepareTables();
		}

		private static GameObject FindPrefabInZnet(string name, ZNetScene zNetScene)
		{
			GameObject value = null;
			zNetScene.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode(name), out value);
			if ((Object)(object)value == (Object)null)
			{
				value = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
			}
			return value;
		}

		private static CraftingStation FindStation(string name)
		{
			GameObject val = null;
			val = (GameObject)((!((Object)(object)zNetScene != (Object)null)) ? ((object)list.Find((GameObject x) => ((Object)x).name == name)) : ((object)FindPrefabInZnet(name, zNetScene)));
			if ((Object)(object)val != (Object)null)
			{
				return val.GetComponent<CraftingStation>();
			}
			Debug.LogWarning((object)("TableMapper - Station not found: " + name));
			return null;
		}

		private static void prepareTables()
		{
			cauldron = FindStation("piece_cauldron");
			workbench = FindStation("piece_workbench");
			heavyWorkbench = FindStation("piece_heavy_workbench_bal");
			forge = FindStation("forge");
			ironworks = FindStation("piece_metalworks_bal");
			blackforge = FindStation("blackforge");
			stoneCutter = FindStation("piece_stonecutter");
			artisian = FindStation("piece_artisanstation");
			runeforge = FindStation("piece_runeforge_bal");
			magetable = FindStation("piece_magetable");
			fletcher = FindStation("piece_fletcher_bal");
			shamantable = FindStation("piece_shamantable_bal");
			foodtable = FindStation("piece_preptable");
			grill = FindStation("piece_grill_bal");
			alchemylab = FindStation("piece_MeadCauldron");
		}
	}
	internal class ItemList
	{
		public static string[] items = new string[11]
		{
			"eyes_bal", "HairClaireKiara", "HairErisSassy", "HairGrandeLittledica", "HairKendallNightcrawler", "HairLilaFeralpoodles", "HairMohawkKaisims", "HairMohawkponyRedearcat", "HairNovaNightcrawler", "HairQicc",
			"HairZaharaNords"
		};
	}
	public class JsonLoader
	{
		public string defaultPath = string.Empty;

		public void loadJson()
		{
			LoadTranslations();
			justDefaultPath();
		}

		public void justDefaultPath()
		{
			string configPath = Paths.ConfigPath;
			string text = Path.Combine(configPath, "BalrondCharacterCustomization-translation/");
			defaultPath = text;
		}

		public void createDefaultPath()
		{
			string configPath = Paths.ConfigPath;
			string text = Path.Combine(configPath, "BalrondCharacterCustomization-translation/");
			if (!Directory.Exists(text))
			{
				CreateFolder(text);
			}
			else
			{
				Debug.Log((object)("BalrondCharacterCustomization: Folder already exists: " + text));
			}
			defaultPath = text;
		}

		private string[] jsonFilePath(string folderName, string extension)
		{
			string configPath = Paths.ConfigPath;
			string text = Path.Combine(configPath, "BalrondCharacterCustomization-translation/");
			if (!Directory.Exists(text))
			{
				CreateFolder(text);
			}
			else
			{
				Debug.Log((object)("BalrondCharacterCustomization: Folder already exists: " + text));
			}
			string[] files = Directory.GetFiles(text, extension);
			Debug.Log((object)("BalrondCharacterCustomization:" + folderName + " Json Files Found: " + files.Length));
			return files;
		}

		private static void CreateFolder(string path)
		{
			try
			{
				Directory.CreateDirectory(path);
				Debug.Log((object)"BalrondCharacterCustomization: Folder created successfully.");
			}
			catch (Exception ex)
			{
				Debug.Log((object)("BalrondCharacterCustomization: Error creating folder: " + ex.Message));
			}
		}

		private void LoadTranslations()
		{
			int num = 0;
			string[] array = jsonFilePath("Translation", "*.json");
			foreach (string text in array)
			{
				string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(text);
				string json = File.ReadAllText(text);
				JsonData jsonData = JsonMapper.ToObject(json);
				Dictionary<string, string> dictionary = new Dictionary<string, string>();
				foreach (string key in jsonData.Keys)
				{
					dictionary[key] = jsonData[key].ToString();
				}
				if (dictionary != null)
				{
					BalrondTranslator.translations.Add(fileNameWithoutExtension, dictionary);
					Debug.Log((object)("BalrondCharacterCustomization: Json Files Language: " + fileNameWithoutExtension));
					num++;
				}
				else
				{
					Debug.LogError((object)("BalrondCharacterCustomization: Loading FAILED file: " + text));
				}
			}
			Debug.Log((object)("BalrondCharacterCustomization: Translation JsonFiles Loaded: " + num));
		}
	}
	[BepInPlugin("balrond.astafaraios.BalrondCharacterCustomization", "BalrondCharacterCustomization", "0.1.3")]
	public class Launch : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(ObjectDB), "CopyOtherDB")]
		public static class Object_CopyOtherDB_Path
		{
			public static void Postfix()
			{
				if (!IsObjectDBValid())
				{
					return;
				}
				databaseAddMethods.AddItems(modResourceLoader.itemPrefabs);
				ShaderReplacment.runMaterialFix();
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("Hair3");
				if (!((Object)(object)itemPrefab != (Object)null))
				{
					return;
				}
				Material val = null;
				Renderer[] componentsInChildren = itemPrefab.GetComponentsInChildren<Renderer>();
				foreach (Renderer val2 in componentsInChildren)
				{
					val = val2.material;
				}
				foreach (GameObject itemPrefab2 in modResourceLoader.itemPrefabs)
				{
					if (((Object)itemPrefab2).name.Contains("Hair") && (Object)(object)val != (Object)null)
					{
						Renderer[] componentsInChildren2 = itemPrefab.GetComponentsInChildren<Renderer>();
						foreach (Renderer val3 in componentsInChildren2)
						{
							val3.material = val;
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Path
		{
			public static void Postfix()
			{
				if (IsObjectDBValid())
				{
					databaseAddMethods.AddItems(modResourceLoader.itemPrefabs);
					databaseAddMethods.AddStatuseffects(modResourceLoader.statusEffects);
					databaseAddMethods.AddRecipes(modResourceLoader.recipes);
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		public static class ZNetScene_Awake_Path
		{
			public static bool hasSpawned;

			public static void Prefix(ZNetScene __instance)
			{
				//IL_0087: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance == (Object)null)
				{
					Debug.LogWarning((object)(projectName + ": No ZnetScene found"));
					return;
				}
				modResourceLoader.AddPrefabsToZnetScene(__instance);
				GameObject val = __instance.m_prefabs.Find((GameObject x) => ((Object)x).name == "Player");
				BalrondPlayerCustomization component = val.GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)component == (Object)null)
				{
					val.AddComponent<BalrondPlayerCustomization>();
				}
				if (!Launch.hasSpawned)
				{
					if (new ZNet().IsDedicated())
					{
						Launch.hasSpawned = true;
						return;
					}
					ShaderReplacment.runMaterialFix();
					Launch.hasSpawned = true;
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "SetupGui")]
		private class FejdStartup_SetupGUI
		{
			private static void Postfix()
			{
				string selectedLanguage = Localization.instance.GetSelectedLanguage();
				Dictionary<string, string> translations = GetTranslations(selectedLanguage);
				AddTranslations(translations);
				RefreshLabels();
			}
		}

		[HarmonyPriority(800)]
		[HarmonyPatch(typeof(Localization), "SetupLanguage")]
		private class Translation_SetupLanguage
		{
			private static void Prefix(Localization __instance, string language)
			{
				Dictionary<string, string> translations = GetTranslations(language);
				AddTranslations(translations, __instance);
				RefreshLabels();
			}
		}

		[HarmonyPriority(800)]
		[HarmonyPatch(typeof(Localization), "LoadCSV")]
		private class Translation_LoadCSV
		{
			private static void Prefix(Localization __instance, string language)
			{
				Dictionary<string, string> translations = GetTranslations(language);
				AddTranslations(translations, __instance);
				RefreshLabels();
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardLeft")]
		public static class PlayerCustomizatonOnBeardLeft
		{
			public static void Prefix(PlayerCustomizaton __instance)
			{
				if (__instance.GetPlayer().GetPlayerModel() == 0)
				{
					return;
				}
				int num = __instance.GetBeardIndex();
				for (int num2 = num - 1; num2 >= 0; num2--)
				{
					if (__instance.m_beards[num2].m_itemData.m_shared.m_toolTier <= __instance.m_hairToolTier)
					{
						num = num2;
						break;
					}
				}
				__instance.SetBeard(num);
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizaton), "OnBeardRight")]
		public static class PlayerCustomizatonOnBeardRight
		{
			public static void Prefix(PlayerCustomizaton __instance)
			{
				if (__instance.GetPlayer().GetPlayerModel() == 0)
				{
					return;
				}
				int num = __instance.GetBeardIndex();
				for (int i = num + 1; i < __instance.m_beards.Count; i++)
				{
					if (__instance.m_beards[i].m_itemData.m_shared.m_toolTier <= __instance.m_hairToolTier)
					{
						num = i;
						break;
					}
				}
				__instance.SetBeard(num);
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		public static class FejdStartup_Awake_Patch
		{
			public static void Postfix(FejdStartup __instance)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Expected O, but got Unknown
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Expected O, but got Unknown
				//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
				Transform val = FejdStartup.instance.m_selectCharacterPanel.transform.Find("BottomWindow");
				Transform val2 = Object.Instantiate<Transform>(val.Find("New"));
				((Object)val2).name = "Edit";
				((Component)val2).transform.SetParent(val);
				((Component)val2).GetComponent<RectTransform>().anchoredPosition = Vector2.op_Implicit(new Vector3(-100f, 50f, 0f));
				editButton = ((Component)((Component)val2).transform.Find("Text")).GetComponent<TMP_Text>();
				editButton.text = Localization.instance.Localize("$tag_edit_character_button");
				((UnityEventBase)((Component)val2).GetComponent<Button>().onClick).RemoveAllListeners();
				((Component)val2).GetComponent<Button>().onClick = new ButtonClickedEvent();
				((UnityEvent)((Component)val2).GetComponent<Button>().onClick).AddListener(new UnityAction(StartCharacterEdit));
				((Component)val2).GetComponent<UIGamePad>().m_zinputKey = "JoyLTrigger";
				((TMP_Text)((Component)((Component)val2).transform.Find("gamepad_hint").Find("Text")).GetComponent<TextMeshProUGUI>()).text = "LT";
				title = Object.Instantiate<Transform>(FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic"));
				editTitle = ((Component)title).GetComponent<TMP_Text>();
				((Object)title).name = "EditTitle";
				title.SetParent(FejdStartup.instance.m_newCharacterPanel.transform);
				editTitle.text = Localization.instance.Localize("$tag_edit_character_panel");
				((Component)title).GetComponent<RectTransform>().anchoredPosition = ((Component)FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic")).GetComponent<RectTransform>().anchoredPosition;
				((Component)title).gameObject.SetActive(false);
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
				BalrondPlayerCustomization component = FejdStartup.instance.m_playerPrefab.GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)component == (Object)null)
				{
					component = FejdStartup.instance.m_playerPrefab.AddComponent<BalrondPlayerCustomization>();
				}
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizaton), "Update")]
		public static class PlayerCustomizatonUpdatePatch
		{
			public static void Postfix(PlayerCustomizaton __instance)
			{
				//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0403: Unknown result type (might be due to invalid IL or missing references)
				//IL_0409: Unknown result type (might be due to invalid IL or missing references)
				//IL_0418: 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_0420: Unknown result type (might be due to invalid IL or missing references)
				//IL_0422: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0591: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)CustomizationPanel == (Object)null && (Object)(object)__instance.m_hairTone != (Object)null)
				{
					CustomizationPanel = ((Component)__instance.m_hairTone).transform.parent.parent.parent;
				}
				if ((Object)(object)CustomizationPanel == (Object)null)
				{
					return;
				}
				if ((Object)(object)hairPanel == (Object)null || (Object)(object)barberhairPanel == (Object)null)
				{
					Transform[] componentsInChildren = ((Component)CustomizationPanel).GetComponentsInChildren<Transform>();
					for (int i = 0; i < componentsInChildren.Length; i++)
					{
						if ((Object)(object)hairPanel == (Object)null && ((Object)componentsInChildren[i]).name == "BalrondCustomizationPanel")
						{
							hairPanel = componentsInChildren[i];
						}
						else if ((Object)(object)barberhairPanel == (Object)null && ((Object)componentsInChildren[i]).name == "BarberHairPanel")
						{
							barberhairPanel = componentsInChildren[i];
						}
						if ((Object)(object)hairPanel != (Object)null && (Object)(object)barberhairPanel != (Object)null)
						{
							break;
						}
					}
				}
				if ((Object)(object)sliderR == (Object)null || (Object)(object)sliderG == (Object)null || (Object)(object)sliderB == (Object)null || (Object)(object)sliderS == (Object)null || (Object)(object)sliderER == (Object)null || (Object)(object)sliderEG == (Object)null || (Object)(object)sliderEB == (Object)null || (Object)(object)sliderH == (Object)null)
				{
					Transform[] componentsInChildren2 = ((Component)CustomizationPanel).GetComponentsInChildren<Transform>();
					for (int j = 0; j < componentsInChildren2.Length; j++)
					{
						string name = ((Object)componentsInChildren2[j]).name;
						Slider component = ((Component)componentsInChildren2[j]).GetComponent<Slider>();
						if (!((Object)(object)component == (Object)null))
						{
							switch (name)
							{
							case "Red_Slider":
								sliderR = component;
								break;
							case "Green_Slider":
								sliderG = component;
								break;
							case "Blue_Slider":
								sliderB = component;
								break;
							case "Skin slider":
								sliderS = component;
								break;
							case "RedEye_Slider":
								sliderER = component;
								break;
							case "GreenEye_Slider":
								sliderEG = component;
								break;
							case "BlueEye_Slider":
								sliderEB = component;
								break;
							case "Height_Slider":
								sliderH = component;
								break;
							}
						}
					}
				}
				if ((Object)(object)sliderR != (Object)null)
				{
					myR = sliderR.value;
				}
				if ((Object)(object)sliderG != (Object)null)
				{
					myG = sliderG.value;
				}
				if ((Object)(object)sliderB != (Object)null)
				{
					myB = sliderB.value;
				}
				if (myR == 99f || myG == 99f || myB == 99f)
				{
					return;
				}
				Color val = default(Color);
				((Color)(ref val))..ctor(myR, myG, myB, 1f);
				Player val2 = null;
				FejdStartup componentInParent = ((Component)__instance).GetComponentInParent<FejdStartup>();
				if ((Object)(object)componentInParent != (Object)null)
				{
					val2 = componentInParent.GetPreviewPlayer();
				}
				else if ((Object)(object)PlayerCustomizaton.m_barberInstance != (Object)null)
				{
					val2 = PlayerCustomizaton.m_barberInstance.GetPlayer();
				}
				if ((Object)(object)val2 == (Object)null)
				{
					return;
				}
				val2.SetHairColor(Utils.ColorToVec3(val));
				if ((Object)(object)sliderS != (Object)null)
				{
					Color val3 = Color.Lerp(__instance.m_skinColor0, __instance.m_skinColor1, sliderS.value);
					val2.SetSkinColor(Utils.ColorToVec3(val3));
				}
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)itemPrefab != (Object)null)
					{
						eyesItemHash = ((object)itemPrefab).GetHashCode();
					}
				}
				BalrondPlayerCustomization component2 = ((Component)val2).GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)component2 != (Object)null && (Object)(object)sliderER != (Object)null && (Object)(object)sliderEG != (Object)null && (Object)(object)sliderEB != (Object)null && (Object)(object)sliderH != (Object)null)
				{
					Color val4 = default(Color);
					((Color)(ref val4))..ctor(sliderER.value, sliderEG.value, sliderEB.value, 1f);
					if (val4 != component2.eyeColor)
					{
						val2.m_customData.Remove("BalrondEyesX");
						val2.m_customData.Remove("BalrondEyesY");
						val2.m_customData.Remove("BalrondEyesZ");
						val2.m_customData.Add("BalrondEyesX", val4.r.ToString());
						val2.m_customData.Add("BalrondEyesY", val4.g.ToString());
						val2.m_customData.Add("BalrondEyesZ", val4.b.ToString());
						component2.SetEyeColor(val4);
					}
					if ((Object)(object)sliderH != (Object)null && sliderH.value != component2.height)
					{
						val2.m_customData.Remove("BalrondHeight");
						val2.m_customData.Add("BalrondHeight", sliderH.value.ToString());
						component2.SetHeight(sliderH.value);
					}
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "SetupCharacterPreview")]
		public static class FejdStartup_SetupCharacterPreview_Patch
		{
			public static void Postfix(FejdStartup __instance)
			{
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
				BalrondPlayerCustomization component = __instance.m_playerInstance.GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)component != (Object)null)
				{
					Player previewPlayer = __instance.GetPreviewPlayer();
					Vector3 fromPlayerCustomData = component.GetFromPlayerCustomData(previewPlayer);
					float heightFromPlayerCustomData = component.GetHeightFromPlayerCustomData(previewPlayer);
					if ((Object)(object)component._eyesInstanced == (Object)null)
					{
						component._eyesInstanced = AttachItem(eyesObject, -1, ((Humanoid)previewPlayer).m_visEquipment.m_helmet, ((Humanoid)previewPlayer).m_visEquipment);
					}
					component.SetEyeColor(new Color(fromPlayerCustomData.x, fromPlayerCustomData.y, fromPlayerCustomData.z, 1f));
					component.SetHeight(heightFromPlayerCustomData);
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "OnNewCharacterDone")]
		public static class FejdStartup_OnNewCharacterDone_Patch
		{
			public static bool Prefix(FejdStartup __instance, ref List<PlayerProfile> ___m_profiles)
			{
				if (!editingCharacter)
				{
					return true;
				}
				((Component)title).gameObject.SetActive(false);
				((Component)FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic")).gameObject.SetActive(true);
				editingCharacter = false;
				string text = ((TMP_InputField)__instance.m_csNewCharacterName).text;
				string text2 = text.ToLower();
				Traverse val = Traverse.Create((object)FejdStartup.instance);
				int value = val.Field("m_profileIndex").GetValue<int>();
				List<PlayerProfile> value2 = val.Field("m_profiles").GetValue<List<PlayerProfile>>();
				PlayerProfile val2 = value2[value];
				GameObject value3 = val.Field("m_playerInstance").GetValue<GameObject>();
				Player component = value3.GetComponent<Player>();
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
				BalrondPlayerCustomization component2 = value3.GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)component2 != (Object)null)
				{
					component.m_customData.Remove("BalrondEyesX");
					component.m_customData.Remove("BalrondEyesY");
					component.m_customData.Remove("BalrondEyesZ");
					component.m_customData.Remove("BalrondHeight");
					component.m_customData.Add("BalrondEyesX", sliderER.value.ToString());
					component.m_customData.Add("BalrondEyesY", sliderEG.value.ToString());
					component.m_customData.Add("BalrondEyesZ", sliderEB.value.ToString());
					component.m_customData.Add("BalrondHeight", sliderH.value.ToString());
				}
				else
				{
					Debug.LogWarning((object)"Couldnt save character custom information");
				}
				val2.SavePlayerData(component);
				val2.SetName(text);
				val2.Save();
				__instance.m_selectCharacterPanel.SetActive(true);
				__instance.m_newCharacterPanel.SetActive(false);
				___m_profiles = null;
				Traverse.Create((object)__instance).Method("SetSelectedProfile", new object[1] { text2 }).GetValue();
				return false;
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "OnNewCharacterCancel")]
		public static class FejdStartup_OnNewCharacterCancel_Patch
		{
			public static void Postfix(FejdStartup __instance)
			{
				((Component)title).gameObject.SetActive(false);
				((Component)FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic")).gameObject.SetActive(true);
				editingCharacter = false;
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizaton), "OnEnable")]
		public static class PlayerCustomizaton_OnEnable_Patch
		{
			public static void Postfix(PlayerCustomizaton __instance)
			{
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0139: Unknown result type (might be due to invalid IL or missing references)
				//IL_013e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
				if (!editingCharacter)
				{
					return;
				}
				FejdStartup componentInParent = ((Component)__instance).GetComponentInParent<FejdStartup>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return;
				}
				Player previewPlayer = componentInParent.GetPreviewPlayer();
				if ((Object)(object)previewPlayer == (Object)null)
				{
					return;
				}
				if (previewPlayer.GetPlayerModel() == 1)
				{
					__instance.m_maleToggle.isOn = false;
					__instance.m_femaleToggle.isOn = true;
				}
				VisEquipment value = Traverse.Create((object)previewPlayer).Field("m_visEquipment").GetValue<VisEquipment>();
				if ((Object)(object)value == (Object)null)
				{
					return;
				}
				Vector3 value2 = Traverse.Create((object)value).Field("m_skinColor").GetValue<Vector3>();
				Vector3 val = Utils.ColorToVec3(__instance.m_skinColor0);
				Vector3 val2 = Utils.ColorToVec3(__instance.m_skinColor1);
				float num = Vector3.Distance(val2, val);
				float value3 = ((num > 0f) ? (Vector3.Distance(value2, val) / num * (__instance.m_skinHue.maxValue - __instance.m_skinHue.minValue) + __instance.m_skinHue.minValue) : __instance.m_skinHue.minValue);
				__instance.m_skinHue.value = value3;
				Vector3 value4 = Traverse.Create((object)value).Field("m_hairColor").GetValue<Vector3>();
				BalrondPlayerCustomization component = ((Component)previewPlayer).GetComponent<BalrondPlayerCustomization>();
				if ((Object)(object)uiPanel == (Object)null)
				{
					EditExistingPanel();
					CreateHairPanel();
				}
				Slider[] componentsInChildren = uiPanel.GetComponentsInChildren<Slider>();
				foreach (Slider val3 in componentsInChildren)
				{
					string name = ((Object)val3).name;
					switch (name)
					{
					case "Red_Slider":
						val3.value = value4.x;
						break;
					case "Green_Slider":
						val3.value = value4.y;
						break;
					case "Blue_Slider":
						val3.value = value4.z;
						break;
					}
					if ((Object)(object)component != (Object)null)
					{
						switch (name)
						{
						case "RedEye_Slider":
							val3.value = component.eyeColorVector.x;
							break;
						case "GreenEye_Slider":
							val3.value = component.eyeColorVector.y;
							break;
						case "BlueEye_Slider":
							val3.value = component.eyeColorVector.z;
							break;
						case "Height_Slider":
							val3.value = component.height;
							break;
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "OnCharacterNew")]
		public static class OnCharacterNewPatch
		{
			public static void Postfix(FejdStartup __instance)
			{
				string selectedLanguage = Localization.instance.GetSelectedLanguage();
				Dictionary<string, string> translations = GetTranslations(selectedLanguage);
				AddTranslations(translations);
				if ((Object)(object)uiPanel == (Object)null)
				{
					EditExistingPanel();
					CreateHairPanel();
				}
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
				RefreshLabels();
			}
		}

		[HarmonyPatch(typeof(PlayerCustomizaton), "ShowBarberGui")]
		public static class PlayerCustomizaton_ShowBarberGui_Patch
		{
			public static Vector3 playerHairColor = Vector3.zero;

			public static void Prefix(PlayerCustomizaton __instance)
			{
				//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)
				playerHairColor = Player.m_localPlayer.GetHairColor();
			}

			public static void Postfix(PlayerCustomizaton __instance)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001a: Unknown result type (might be due to invalid IL or missing references)
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_019a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				PlayerCustomizaton.m_lastHairColor = playerHairColor;
				Vector3 eyeColorVector = ((Component)Player.m_localPlayer).GetComponent<BalrondPlayerCustomization>().eyeColorVector;
				float height = ((Component)Player.m_localPlayer).GetComponent<BalrondPlayerCustomization>().height;
				if ((Object)(object)uiHairPanel == (Object)null)
				{
					EditBarberGuiLayout();
					CreateHairColorBarberGui();
				}
				if (eyesItemHash == 0 && (Object)(object)ObjectDB.instance != (Object)null)
				{
					eyesObject = ObjectDB.instance.GetItemPrefab("eyes_bal");
					if ((Object)(object)eyesObject != (Object)null)
					{
						eyesItemHash = ((object)eyesObject).GetHashCode();
					}
				}
				Slider[] componentsInChildren = uiHairPanel.GetComponentsInChildren<Slider>();
				foreach (Slider val in componentsInChildren)
				{
					if (((Object)val).name == "Red_Slider")
					{
						val.value = playerHairColor.x;
					}
					else if (((Object)val).name == "Green_Slider")
					{
						val.value = playerHairColor.y;
					}
					else if (((Object)val).name == "Blue_Slider")
					{
						val.value = playerHairColor.z;
					}
					if (((Object)val).name == "RedEye_Slider")
					{
						val.value = eyeColorVector.x;
					}
					else if (((Object)val).name == "GreenEye_Slider")
					{
						val.value = eyeColorVector.y;
					}
					else if (((Object)val).name == "BlueEye_Slider")
					{
						val.value = eyeColorVector.z;
					}
					if (((Object)val).name == "Height_Slider")
					{
						val.value = eyeColorVector.x;
					}
				}
				RefreshLabels();
			}
		}

		private readonly Harmony _harmony = new Harmony("balrond.astafaraios.BalrondCharacterCustomization");

		public static JsonLoader jsonLoader = new JsonLoader();

		public static GameObject RootObject;

		public static GameObject PrefabContainer;

		public static ModResourceLoader modResourceLoader = new ModResourceLoader();

		public static DatabaseAddMethods databaseAddMethods = new DatabaseAddMethods();

		public static string projectName = "BalrondCharacterCustomization";

		public static bool hasSpawned = false;

		public const string PluginName = "BalrondCharacterCustomization";

		public static bool disableTutorials;

		public static bool newHardcorePlayer;

		public static bool skipIntro;

		public static bool editedBarber = false;

		public static GameObject uiPanel;

		public static GameObject uiHairPanel;

		public static Slider sliderR;

		public static Slider sliderG;

		public static Slider sliderB;

		public static Slider sliderS;

		public static Slider sliderER;

		public static Slider sliderEG;

		public static Slider sliderEB;

		public static Slider sliderH;

		public static float myR = 99f;

		public static float myG = 99f;

		public static float myB = 99f;

		public static Transform CustomizationPanel;

		public static Transform BarberCustomizationPanel;

		public static Transform hairPanel;

		public static Transform barberhairPanel;

		public static bool tryToFind = true;

		public static readonly bool isDebug = true;

		public static bool editingCharacter = false;

		public static Transform title;

		public static int eyesItemHash = 0;

		public static GameObject eyesObject;

		public static Dictionary<string, Vector3> eyeColors = new Dictionary<string, Vector3>();

		public static Dictionary<string, TextMeshProUGUI> textMeshProUGUIs = new Dictionary<string, TextMeshProUGUI>();

		public static TMP_Text editButton;

		public static TMP_Text editTitle;

		private void Awake()
		{
			jsonLoader.loadJson();
			createPrefabContainer();
			modResourceLoader.loadAssets();
			_harmony.PatchAll();
		}

		public void createPrefabContainer()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			RootObject = new GameObject("_ValheimReforgedRoot");
			Object.DontDestroyOnLoad((Object)(object)RootObject);
			PrefabContainer = new GameObject("Prefabs");
			PrefabContainer.transform.parent = RootObject.transform;
			PrefabContainer.SetActive(false);
		}

		public static GameObject cloneMe(GameObject source, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(source, PrefabContainer.transform);
			((Object)val).name = name;
			fixMaterials(val, source);
			val.SetActive(true);
			return val;
		}

		public static GameObject fixMaterials(GameObject clone, GameObject source)
		{
			MeshRenderer[] componentsInChildren = source.GetComponentsInChildren<MeshRenderer>();
			foreach (MeshRenderer val in componentsInChildren)
			{
				MeshRenderer[] componentsInChildren2 = clone.GetComponentsInChildren<MeshRenderer>();
				foreach (MeshRenderer val2 in componentsInChildren2)
				{
					if (((Object)val).name == ((Object)val2).name)
					{
						((Renderer)val2).materials = ((Renderer)val).sharedMaterials;
						((Renderer)val2).sharedMaterials = ((Renderer)val).sharedMaterials;
						break;
					}
				}
			}
			return clone;
		}

		private void OnDestroy()
		{
			_harmony.UnpatchSelf();
			if ((Object)(object)uiPanel != (Object)null)
			{
				Object.Destroy((Object)(object)uiPanel);
			}
		}

		private static bool IsObjectDBValid()
		{
			return (Object)(object)ObjectDB.instance != (Object)null && ObjectDB.instance.m_items.Count != 0 && ObjectDB.instance.m_recipes.Count != 0 && (Object)(object)ObjectDB.instance.GetItemPrefab("Amber") != (Object)null;
		}

		public static GameObject FindPrefabInZnet(string name, ZNetScene zNetScene)
		{
			GameObject value = null;
			zNetScene.m_namedPrefabs.TryGetValue(StringExtensionMethods.GetStableHashCode(name), out value);
			if ((Object)(object)value == (Object)null)
			{
				value = zNetScene.m_prefabs.Find((GameObject x) => ((Object)x).name == name);
			}
			return value;
		}

		private static Dictionary<string, string> GetTranslations(string language)
		{
			Dictionary<string, string> result = BalrondTranslator.getLanguage("English");
			if (!string.Equals(language, "English", StringComparison.OrdinalIgnoreCase))
			{
				Dictionary<string, string> language2 = BalrondTranslator.getLanguage(language);
				if (language2 != null)
				{
					result = language2;
				}
				else
				{
					Debug.Log((object)("BalrondCharacterCustomization: Did not find translation file for '" + language + "', loading English"));
				}
			}
			return result;
		}

		private static void AddTranslations(Dictionary<string, string> translations, Localization localizationInstance = null)
		{
			if (translations == null)
			{
				Debug.LogWarning((object)"BalrondCharacterCustomization: No translation file found!");
				return;
			}
			if (localizationInstance != null)
			{
				foreach (KeyValuePair<string, string> translation in translations)
				{
					localizationInstance.AddWord(translation.Key, translation.Value);
				}
				return;
			}
			foreach (KeyValuePair<string, string> translation2 in translations)
			{
				Localization.instance.AddWord(translation2.Key, translation2.Value);
			}
		}

		public static string ColorToString(Color color)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			return $"{color.r} {color.g} {color.b} {color.a}";
		}

		public static GameObject AttachItem(GameObject itemPrefab, int variant, Transform joint, VisEquipment visEquipment, bool enableEquipEffects = true, bool backAttach = false)
		{
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_0229: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)itemPrefab == (Object)null)
			{
				Debug.LogWarning((object)"attach item not found(probably the Eyes object)");
				return null;
			}
			GameObject val = null;
			Transform val2 = itemPrefab.transform.Find("equipoffset");
			int childCount = itemPrefab.transform.childCount;
			for (int i = 0; i < childCount; i++)
			{
				Transform child = itemPrefab.transform.GetChild(i);
				if (backAttach && ((Object)((Component)child).gameObject).name == "attach_back")
				{
					val = ((Component)child).gameObject;
					break;
				}
				if (((Object)((Component)child).gameObject).name == "attach" || (!backAttach && ((Object)((Component)child).gameObject).name == "attach_skin"))
				{
					val = ((Component)child).gameObject;
					break;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			GameObject val3 = Object.Instantiate<GameObject>(val);
			val3.SetActive(true);
			CleanupInstance(val3);
			if (((Object)val).name == "attach_skin")
			{
				val3.transform.SetParent(((Component)visEquipment.m_bodyModel).transform.parent);
				val3.transform.localPosition = Vector3.zero;
				val3.transform.localRotation = Quaternion.identity;
				SkinnedMeshRenderer[] componentsInChildren = val3.GetComponentsInChildren<SkinnedMeshRenderer>();
				SkinnedMeshRenderer[] array = componentsInChildren;
				foreach (SkinnedMeshRenderer val4 in array)
				{
					val4.rootBone = visEquipment.m_bodyModel.rootBone;
					val4.bones = visEquipment.m_bodyModel.bones;
				}
			}
			else
			{
				val3.transform.SetParent(joint);
				val3.transform.localPosition = Vector3.zero;
				val3.transform.localRotation = Quaternion.identity;
			}
			if ((Object)(object)val2 != (Object)null)
			{
				Transform transform = val3.transform;
				transform.localPosition += val2.position;
				Transform transform2 = val3.transform;
				transform2.localRotation *= val2.rotation;
			}
			IEquipmentVisual componentInChildren = val3.GetComponentInChildren<IEquipmentVisual>();
			if (componentInChildren != null)
			{
				componentInChildren.Setup(variant);
			}
			return val3;
		}

		private static void CleanupInstance(GameObject instance)
		{
			Collider[] componentsInChildren = instance.GetComponentsInChildren<Collider>();
			foreach (Collider val in componentsInChildren)
			{
				val.enabled = false;
			}
		}

		public static void StartCharacterEdit()
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			string selectedLanguage = Localization.instance.GetSelectedLanguage();
			Dictionary<string, string> translations = GetTranslations(selectedLanguage);
			AddTranslations(translations);
			editingCharacter = true;
			((Component)title).gameObject.SetActive(true);
			((Component)FejdStartup.instance.m_newCharacterPanel.transform.Find("Topic")).gameObject.SetActive(false);
			PlayerProfile val = Traverse.Create((object)FejdStartup.instance).Field("m_profiles").GetValue<List<PlayerProfile>>()[Traverse.Create((object)FejdStartup.instance).Field("m_profileIndex").GetValue<int>()];
			FejdStartup.instance.m_newCharacterPanel.SetActive(true);
			FejdStartup.instance.m_selectCharacterPanel.SetActive(false);
			((TMP_InputField)FejdStartup.instance.m_csNewCharacterName).text = val.GetName();
			FejdStartup.instance.m_newCharacterError.SetActive(false);
			Player previewPlayer = FejdStartup.instance.GetPreviewPlayer();
			BalrondPlayerCustomization balrondPlayerCustomization = ((previewPlayer != null) ? ((Component)previewPlayer).GetComponent<BalrondPlayerCustomization>() : null);
			if ((Object)(object)balrondPlayerCustomization != (Object)null)
			{
				Vector3 fromPlayerCustomData = balrondPlayerCustomization.GetFromPlayerCustomData(FejdStartup.instance.GetPreviewPlayer());
				float heightFromPlayerCustomData = balrondPlayerCustomization.GetHeightFromPlayerCustomData(FejdStartup.instance.GetPreviewPlayer());
				balrondPlayerCustomization.SetEyeColor(new Color(fromPlayerCustomData.x, fromPlayerCustomData.y, fromPlayerCustomData.z, 1f));
				balrondPlayerCustomization.SetHeight(heightFromPlayerCustomData);
			}
			Traverse.Create((object)FejdStartup.instance).Method("SetupCharacterPreview", new object[1] { val }).GetValue();
			Gogan.LogEvent("Screen", "Enter", "CreateCharacter", 0L);
		}

		public static GameObject CreateObjectFrom(GameObject source, Transform parent, string name)
		{
			GameObject val = Object.Instantiate<GameObject>(source, parent);
			((Object)val).name = name;
			return val;
		}

		public static void AddLabel(ref TextMeshProUGUI text, string label)
		{
			textMeshProUGUIs.Remove(label);
			textMeshProUGUIs.Add(label, text);
		}

		public static void RefreshLabels()
		{
			foreach (KeyValuePair<string, TextMeshProUGUI> textMeshProUGUI in textMeshProUGUIs)
			{
				((TMP_Text)textMeshProUGUI.Value).text = Localization.instance.Localize(textMeshProUGUI.Key);
			}
			if ((Object)(object)editButton != (Object)null)
			{
				editButton.text = Localization.instance.Localize("$tag_edit_character_button");
			}
			if ((Object)(object)editTitle != (Object)null)
			{
				editTitle.text = Localization.instance.Localize("$tag_edit_character_panel");
			}
		}

		public static void CreateLabel(GameObject parent, GameObject source, string name, float height, string translation = "", float offset = 0f)
		{
			//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)
			GameObject val = CreateObjectFrom(source, parent.transform, name + "_Label");
			RectTransform component = val.GetComponent<RectTransform>();
			TextMeshProUGUI text = val.GetComponent<TextMeshProUGUI>();
			if (translation == "")
			{
				AddLabel(ref text, name);
				((TMP_Text)text).SetText(name);
			}
			else
			{
				AddLabel(ref text, translation);
				((TMP_Text)text).SetText(Localization.instance.Localize(translation));
			}
			TextMeshProUGUI obj = text;
			((TMP_Text)obj).fontSize = ((TMP_Text)obj).fontSize * 0.25f;
			val.SetActive(true);
			component.anchoredPosition = new Vector2(source.GetComponent<RectTransform>().anchoredPosition.x + offset, height);
		}

		public static GameObject CreateSlider(GameObject parent, GameObject source, string name, float height)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateObjectFrom(source, parent.transform, name + "_Slider");
			RectTransform component = val.GetComponent<RectTransform>();
			val.SetActive(true);
			component.anchoredPosition = new Vector2(0f, height);
			return val;
		}

		public static void EditExistingPanel()
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			GameObject newCharacterPanel = FejdStartup.instance.m_newCharacterPanel;
			RectTransform component = ((Component)newCharacterPanel.transform.Find("CusomizationPanel")).GetComponent<RectTransform>();
			component.anchoredPosition += new Vector2(0f, 65f);
			RectTransform component2 = ((Component)((Transform)component).Find("bkg")).GetComponent<RectTransform>();
			component2.anchoredPosition += new Vector2(0f, 90f);
			((Transform)component2).localScale = new Vector3(((Transform)component2).localScale.x, ((Transform)component2).localScale.y * 0.6f, ((Transform)component2).localScale.z);
			RectTransform component3 = ((Component)((Transform)component).Find("HairPanel")).GetComponent<RectTransform>();
			RectTransform component4 = ((Component)((Transform)component).Find("BeardPanel")).GetComponent<RectTransform>();
			component3.anchoredPosition += new Vector2(0f, 50f);
			component4.anchoredPosition += new Vector2(0f, 50f);
			RectTransform component5 = newCharacterPanel.GetComponent<RectTransform>();
			component5.anchoredPosition += new Vector2(0f, 60f);
			string[] array = new string[4] { "Hair tone", "tone", "level", "Hair level" };
			for (int i = 0; i < array.Length; i++)
			{
				Transform val = ((Transform)component).Find("SkinPanel").Find(array[i]);
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).gameObject.SetActive(false);
				}
			}
		}

		public static GameObject CreateMainBalrondPanel()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			GameObject newCharacterPanel = FejdStartup.instance.m_newCharacterPanel;
			RectTransform component = ((Component)newCharacterPanel.transform.Find("CusomizationPanel")).GetComponent<RectTransform>();
			GameObject val = CreateObjectFrom(((Component)component).gameObject, newCharacterPanel.transform, "BalrondCustomizationPanel");
			RectTransform component2 = val.GetComponent<RectTransform>();
			((Transform)component2).localScale = Vector3.one;
			((Transform)component2).position = ((Transform)component).position + Vector3.down * 330f;
			return val;
		}

		public static void CreateHairPanel()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			GameObject newCharacterPanel = FejdStartup.instance.m_newCharacterPanel;
			GameObject val = CreateMainBalrondPanel();
			PlayerCustomizaton component = newCharacterPanel.GetComponent<PlayerCustomizaton>();
			AdjustRectTransformWithMoveAndScale(val.transform, "bkg", new Vector2(0f, -150f), new Vector3(1f, 1f, 1f));
			Transform val2 = val.transform.Find("SexPanel");
			Transform val3 = val.transform.Find("SkinPanel/tone");
			GameObject val4 = (((Object)(object)val2 != (Object)null) ? ((Component)val2).gameObject : null);
			GameObject val5 = (((Object)(object)val3 != (Object)null) ? ((Component)val3).gameObject : null);
			GameObject val6 = CreateObjectFrom(((Component)component.m_hairTone).gameObject, val.transform, "slider");
			GameObject val7 = CreateObjectFrom(val4, val.transform, "HairColorPanel");
			val7.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -110f);
			if ((Object)(object)val4 != (Object)null)
			{
				val4.SetActive(false);
			}
			float startHeight = 245f;
			startHeight = CreateColorSection(val7, val5, "Hair Color", new string[3] { "Red", "Green", "Blue" }, val6, startHeight, new string[3] { "$tag_red_slider", "$tag_green_slider", "$tag_blue_slider" }, "$tag_haircolor");
			startHeight = CreateColorSection(val7, val5, "Eye Color", new string[3] { "RedEye", "GreenEye", "BlueEye" }, val6, startHeight - 40f, new string[3] { "$tag_redeye_slider", "$tag_greeneye_slider", "$tag_blueeye_slider" }, "$tag_eyecolor");
			startHeight -= 10f;
			CreateLabel(val7, val5, "Height", startHeight, "$tag_heightslider");
			startHeight -= 30f;
			GameObject val8 = CreateSlider(val7, val6, "Height", startHeight);
			Slider component2 = val8.GetComponent<Slider>();
			component2.minValue = -0.05f;
			component2.maxValue = 0.05f;
			startHeight -= 25f;
			string[] array = new string[4] { "SexPanel", "HairPanel", "BeardPanel", "SkinPanel" };
			for (int i = 0; i < array.Length; i++)
			{
				DestroyIfFound(val.transform, array[i]);
			}
			string[] array2 = new string[3] { "Sex", "MaleToggle", "FemaleToggle" };
			for (int j = 0; j < array2.Length; j++)
			{
				DestroyIfFound(val7.transform, array2[j]);
			}
			uiPanel = val;
		}

		public static void AdjustVisibilityAndOffset(Transform parent, string name, Vector2 offset, bool assignSlider = false)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition += offset;
				((Component)val).gameObject.SetActive(true);
				if (assignSlider && name == "Skin slider")
				{
					sliderS = PlayerCustomizaton.m_barberInstance.m_skinHue;
				}
			}
		}

		private static void DestroyIfFound(Transform parent, string name)
		{
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
		}

		public static void EditBarberGuiLayout()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			GameObject rootPanel = PlayerCustomizaton.m_barberInstance.m_rootPanel;
			RectTransform component = rootPanel.GetComponent<RectTransform>();
			component.anchoredPosition += new Vector2(0f, 100f);
			AdjustRectTransformWithScale(rootPanel.transform, "bkg", new Vector3(1f, 1.75f, 1f));
			AdjustRectTransformWithMove(rootPanel.transform, "bkg", new Vector2(0f, -100f));
			AdjustRectTransformWithMove(rootPanel.transform, "title", new Vector2(0f, 100f));
			AdjustRectTransform(((Component)PlayerCustomizaton.m_barberInstance.m_apply).transform, new Vector2(0f, -280f));
			AdjustRectTransform(((Component)PlayerCustomizaton.m_barberInstance.m_cancel).transform, new Vector2(0f, -280f));
			string[] array = new string[4] { "Topic", "Left", "Right", "Selected" };
			RectTransform[] componentsInChildren = rootPanel.GetComponentsInChildren<RectTransform>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				for (int j = 0; j < array.Length; j++)
				{
					if (((Object)componentsInChildren[i]).name == array[j])
					{
						RectTransform obj = componentsInChildren[i];
						obj.anchoredPosition += new Vector2(0f, 70f);
						break;
					}
				}
			}
			AdjustVisibilityAndOffset(rootPanel.transform, "SkinTone", new Vector2(0f, 10f));
			AdjustVisibilityAndOffsetAndAssignSlider(rootPanel.transform, "Skin slider", new Vector2(0f, 10f));
			SetActiveIfFound(rootPanel.transform, "level", state: false);
			SetActiveIfFound(rootPanel.transform, "tone", state: false);
			((Component)PlayerCustomizaton.m_barberInstance.m_hairTone).gameObject.SetActive(false);
			((Component)PlayerCustomizaton.m_barberInstance.m_hairLevel).gameObject.SetActive(false);
		}

		private static void AdjustRectTransformWithMove(Transform parent, string childName, Vector2 move)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(childName);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition += move;
			}
		}

		private static void AdjustRectTransformWithScale(Transform parent, string childName, Vector3 scale)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(childName);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				((Transform)component).localScale = scale;
			}
		}

		private static void AdjustRectTransformWithMoveAndScale(Transform parent, string childName, Vector2 move, Vector3 scale)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(childName);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition += move;
				((Transform)component).localScale = scale;
			}
		}

		private static void AdjustRectTransform(Transform t, Vector2 move)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = ((Component)t).GetComponent<RectTransform>();
			component.anchoredPosition += move;
		}

		private static void AdjustVisibilityAndOffset(Transform parent, string name, Vector2 offset)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition += offset;
				((Component)val).gameObject.SetActive(true);
			}
		}

		private static void AdjustVisibilityAndOffsetAndAssignSlider(Transform parent, string name, Vector2 offset)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Transform val = parent.Find(name);
			if (!((Object)(object)val == (Object)null))
			{
				RectTransform component = ((Component)val).GetComponent<RectTransform>();
				component.anchoredPosition += offset;
				((Component)val).gameObject.SetActive(true);
				if (name == "Skin slider")
				{
					sliderS = PlayerCustomizaton.m_barberInstance.m_skinHue;
				}
			}
		}

		private static void SetActiveIfFound(Transform parent, string name, bool state)
		{
			Transform val = parent.Find(name);
			if ((Object)(object)val != (Object)null)
			{
				((Component)val).gameObject.SetActive(state);
			}
		}

		public static void CreateHairColorBarberGui()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			GameObject rootPanel = PlayerCustomizaton.m_barberInstance.m_rootPanel;
			barberhairPanel = (Transform)(object)((Component)rootPanel.transform.Find("HairPanel")).GetComponent<RectTransform>();
			GameObject val = CreateObjectFrom(((Component)barberhairPanel).gameObject, rootPanel.transform, "BarberHairPanel");
			val.GetComponent<RectTransform>().anchoredPosition = new Vector2(0f, -30f);
			val.SetActive(true);
			GameObject val2 = CreateObjectFrom(((Component)PlayerCustomizaton.m_barberInstance.m_hairTone).gameObject, rootPanel.transform, "slider");
			GameObject gameObject = ((Component)rootPanel.transform.Find("tone")).gameObject;
			float startHeight = 85f;
			startHeight = CreateColorSection(val, gameObject, "Hair Color", new string[3] { "Red", "Green", "Blue" }, val2, startHeight, new string[3] { "$tag_red_slider", "$tag_green_slider", "$tag_blue_slider" }, "$tag_haircolor");
			startHeight = CreateColorSection(val, gameObject, "Eye Color", new string[3] { "RedEye", "GreenEye", "BlueEye" }, val2, startHeight - 55f, new string[3] { "$tag_redeye_slider", "$tag_greeneye_slider", "$tag_blueeye_slider" }, "$tag_eyecolor");
			startHeight -= 10f;
			CreateLabel(val, gameObject, "Height", startHeight, "$tag_heightslider");
			startHeight -= 30f;
			GameObject val3 = CreateSlider(val, val2, "Height", startHeight);
			Slider component = val3.GetComponent<Slider>();
			component.minValue = -0.05f;
			component.maxValue = 0.05f;
			startHeight -= 25f;
			uiHairPanel = val;
		}

		private static float CreateColorSection(GameObject parent, GameObject toneRef, string sectionTitle, string[] colorNames, GameObject sliderTemplate, float startHeight, string[] translationNames, string panelLabel)
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = CreateObjectFrom(toneRef, parent.transform, sectionTitle + "_Title");
			RectTransform component = val.GetComponent<RectTransform>();
			TextMeshProUGUI text = val.GetComponent<TextMeshProUGUI>();
			AddLabel(ref text, panelLabel);
			((TMP_Text)text).SetText(Localization.instance.Localize(panelLabel));
			TextMeshProUGUI obj = text;
			((TMP_Text)obj).fontSize = ((TMP_Text)obj).fontSize * 1.8f;
			component.anchoredPosition = new Vector2(0f, startHeight + 35f);
			val.SetActive(true);
			float num = startHeight;
			for (int i = 0; i < colorNames.Length; i++)
			{
				CreateLabel(parent, toneRef, colorNames[i], num, translationNames[i]);
				num -= 30f;
				CreateSlider(parent, sliderTemplate, colorNames[i], num);
				num -= 25f;
			}
			toneRef.SetActive(false);
			return num;
		}
	}
}
namespace LitJson2
{
	internal enum JsonType
	{
		None,
		Object,
		Array,
		String,
		Int,
		Long,
		Double,
		Boolean
	}
	internal interface IJsonWrapper : IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable
	{
		bool IsArray { get; }

		bool IsBoolean { get; }

		bool IsDouble { get; }

		bool IsInt { get; }

		bool IsLong { get; }

		bool IsObject { get; }

		bool IsString { get; }

		bool GetBoolean();

		double GetDouble();

		int GetInt();

		JsonType GetJsonType();

		long GetLong();

		string GetString();

		void SetBoolean(bool val);

		void SetDouble(double val);

		void SetInt(int val);

		void SetJsonType(JsonType type);

		void SetLong(long val);

		void SetString(string val);

		string ToJson();

		void ToJson(JsonWriter writer);
	}
	internal class JsonData : IJsonWrapper, IList, IOrderedDictionary, IDictionary, ICollection, IEnumerable, IEquatable<JsonData>
	{
		private IList<JsonData> inst_array;

		private bool inst_boolean;

		private double inst_double;

		private int inst_int;

		private long inst_long;

		private IDictionary<string, JsonData> inst_object;

		private string inst_string;

		private string json;

		private JsonType type;

		private IList<KeyValuePair<string, JsonData>> object_list;

		public int Count => EnsureCollection().Count;

		public bool IsArray => type == JsonType.Array;

		public bool IsBoolean => type == JsonType.Boolean;

		public bool IsDouble => type == JsonType.Double;

		public bool IsInt => type == JsonType.Int;

		public bool IsLong => type == JsonType.Long;

		public bool IsObject => type == JsonType.Object;

		public bool IsString => type == JsonType.String;

		public ICollection<string> Keys
		{
			get
			{
				EnsureDictionary();
				return inst_object.Keys;
			}
		}

		int ICollection.Count => Count;

		bool ICollection.IsSynchronized => EnsureCollection().IsSynchronized;

		object ICollection.SyncRoot => EnsureCollection().SyncRoot;

		bool IDictionary.IsFixedSize => EnsureDictionary().IsFixedSize;

		bool IDictionary.IsReadOnly => EnsureDictionary().IsReadOnly;

		ICollection IDictionary.Keys
		{
			get
			{
				EnsureDictionary();
				IList<string> list = new List<string>();
				foreach (KeyValuePair<string, JsonData> item in object_list)
				{
					list.Add(item.Key);
				}
				return (ICollection)list;
			}
		}

		ICollection IDictionary.Values
		{
			get
			{
				EnsureDictionary();
				IList<JsonData> list = new List<JsonData>();
				foreach (KeyValuePair<string, JsonData> item in object_list)
				{
					list.Add(item.Value);
				}
				return (ICollection)list;
			}
		}

		bool IJsonWrapper.IsArray => IsArray;

		bool IJsonWrapper.IsBoolean => IsBoolean;

		bool IJsonWrapper.IsDouble => IsDouble;

		bool IJsonWrapper.IsInt => IsInt;

		bool IJsonWrapper.IsLong => IsLong;

		bool IJsonWrapper.IsObject => IsObject;

		bool IJsonWrapper.IsString => IsString;

		bool IList.IsFixedSize => EnsureList().IsFixedSize;

		bool IList.IsReadOnly => EnsureList().IsReadOnly;

		object IDictionary.this[object key]
		{
			get
			{
				return EnsureDictionary()[key];
			}
			set
			{
				if (!(key is string))
				{
					throw new ArgumentException("The key has to be a string");
				}
				JsonData value2 = ToJsonData(value);
				this[(string)key] = value2;
			}
		}

		object IOrderedDictionary.this[int idx]
		{
			get
			{
				EnsureDictionary();
				return object_list[idx].Value;
			}
			set
			{
				EnsureDictionary();
				JsonData value2 = ToJsonData(value);
				KeyValuePair<string, JsonData> keyValuePair = object_list[idx];
				inst_object[keyValuePair.Key] = value2;
				KeyValuePair<string, JsonData> value3 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value2);
				object_list[idx] = value3;
			}
		}

		object IList.this[int index]
		{
			get
			{
				return EnsureList()[index];
			}
			set
			{
				EnsureList();
				JsonData value2 = ToJsonData(value);
				this[index] = value2;
			}
		}

		public JsonData this[string prop_name]
		{
			get
			{
				EnsureDictionary();
				return inst_object[prop_name];
			}
			set
			{
				EnsureDictionary();
				KeyValuePair<string, JsonData> keyValuePair = new KeyValuePair<string, JsonData>(prop_name, value);
				if (inst_object.ContainsKey(prop_name))
				{
					for (int i = 0; i < object_list.Count; i++)
					{
						if (object_list[i].Key == prop_name)
						{
							object_list[i] = keyValuePair;
							break;
						}
					}
				}
				else
				{
					object_list.Add(keyValuePair);
				}
				inst_object[prop_name] = value;
				json = null;
			}
		}

		public JsonData this[int index]
		{
			get
			{
				EnsureCollection();
				if (type == JsonType.Array)
				{
					return inst_array[index];
				}
				return object_list[index].Value;
			}
			set
			{
				EnsureCollection();
				if (type == JsonType.Array)
				{
					inst_array[index] = value;
				}
				else
				{
					KeyValuePair<string, JsonData> keyValuePair = object_list[index];
					KeyValuePair<string, JsonData> value2 = new KeyValuePair<string, JsonData>(keyValuePair.Key, value);
					object_list[index] = value2;
					inst_object[keyValuePair.Key] = value;
				}
				json = null;
			}
		}

		public JsonData()
		{
		}

		public JsonData(bool boolean)
		{
			type = JsonType.Boolean;
			inst_boolean = boolean;
		}

		public JsonData(double number)
		{
			type = JsonType.Double;
			inst_double = number;
		}

		public JsonData(int number)
		{
			type = JsonType.Int;
			inst_int = number;
		}

		public JsonData(long number)
		{
			type = JsonType.Long;
			inst_long = number;
		}

		public JsonData(object obj)
		{
			if (obj is bool)
			{
				type = JsonType.Boolean;
				inst_boolean = (bool)obj;
				return;
			}
			if (obj is double)
			{
				type = JsonType.Double;
				inst_double = (double)obj;
				return;
			}
			if (obj is int)
			{
				type = JsonType.Int;
				inst_int = (int)obj;
				return;