Decompiled source of MountUpRestored v3.5.1

MountUpRestored.dll

Decompiled 12 hours ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Formatters.Binary;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using LetMeTameYou;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using MountUp.ModCompat;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using ValheimVRMod.Patches;
using ValheimVRMod.VRCore.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: Guid("9e1c6dc2-1a11-4768-96f1-0f71c70e1dbe")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyDescription("")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("MountUp")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyTitle("MountUp")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace MountUp
{
	internal class DBG
	{
		public static void blogInfo(object o)
		{
			Setup.logger.LogInfo(o);
		}

		public static void blogWarning(object o)
		{
			Setup.logger.LogWarning(o);
		}

		public static void blogDebug(object o)
		{
			if (Setup.debugout.Value)
			{
				Setup.logger.LogWarning(o);
			}
		}

		public static void tryblogDebug(object o, object o_backup)
		{
			try
			{
				if (Setup.debugout.Value)
				{
					Setup.logger.LogWarning(o);
				}
			}
			catch
			{
				Setup.logger.LogWarning(o_backup);
			}
		}
	}
	internal class AdjustmentPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetHoverText")]
		private static void Char_GetHoverText(Character __instance, ref string __result)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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)
			Mountable mountable = default(Mountable);
			if (!__instance.m_tamed || !((Component)__instance).gameObject.TryGetComponent<Mountable>(ref mountable) || !Setup.adjustCustom.Value || !ZNet.instance.IsServer() || (Object)(object)mountable.getSaddle() == (Object)null || !mountable.getSaddle().activeSelf)
			{
				return;
			}
			KeyboardShortcut val = new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
			if (((KeyboardShortcut)(ref val)).IsDown())
			{
				Player localPlayer = Player.m_localPlayer;
				Sadle component = mountable.getSaddle().GetComponent<Sadle>();
				if ((Object)(object)component != (Object)null && (Object)(object)localPlayer != (Object)null)
				{
					DBG.blogWarning("Attempt Force Mount");
					ZNetView nview = component.m_nview;
					object[] array = new object[1];
					ZDOID zDOID = ((Character)localPlayer).GetZDOID();
					array[0] = ((ZDOID)(ref zDOID)).UserID;
					nview.InvokeRPC("RequestControl", array);
				}
			}
			string text = Localization.instance.Localize("$hud_rename");
			string text2 = Localization.instance.Localize("$sitinsaddle");
			__result = __result.Replace(text, text + "\n[<color=orange><b>Alt+E</b></color>] " + text2);
		}
	}
	[Serializable]
	public class CfgPackage
	{
		public MountSerialized[] mounts;

		public static ZPackage zpack;

		public ZPackage PackMountlist()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			if (zpack == null)
			{
				Pack();
				DBG.blogInfo("Packed List");
			}
			else
			{
				DBG.blogInfo("Already Packed List");
			}
			ZPackage val = new ZPackage();
			return zpack;
		}

		public ZPackage Pack()
		{
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Expected O, but got Unknown
			mounts = new MountSerialized[Setup.customMounts.Count];
			int num = 0;
			foreach (KeyValuePair<string, Mount> customMount in Setup.customMounts)
			{
				mounts[num] = new MountSerialized(customMount.Value);
				num++;
			}
			MountSerialized[] array = mounts;
			foreach (MountSerialized mountSerialized in array)
			{
				DBG.blogWarning("mount in list=" + mountSerialized.PrefabName);
			}
			ZPackage val = new ZPackage();
			using MemoryStream memoryStream = new MemoryStream();
			using (GZipStream serializationStream = new GZipStream(memoryStream, CompressionLevel.Optimal))
			{
				new BinaryFormatter().Serialize(serializationStream, this);
			}
			byte[] buffer = memoryStream.GetBuffer();
			val.Write(buffer);
			zpack = val;
			return val;
		}

		public static void Unpack(ZPackage package, bool setValue = true)
		{
			byte[] buffer = package.ReadByteArray();
			using MemoryStream stream = new MemoryStream(buffer);
			using GZipStream serializationStream = new GZipStream(stream, CompressionMode.Decompress, leaveOpen: true);
			if (new BinaryFormatter().Deserialize(serializationStream) is CfgPackage cfgPackage)
			{
				DBG.blogDebug("Unpackaging MountUp Configs.");
				MountSerialized[] array = cfgPackage.mounts;
				Setup.removeMounts = new Dictionary<string, Mount>(Setup.customMounts);
				Setup.customMounts.Clear();
				MountSerialized[] array2 = array;
				foreach (MountSerialized mountSerialized in array2)
				{
					DBG.blogDebug("mount=" + mountSerialized.PrefabName);
					Setup.customMounts.Add(mountSerialized.PrefabName, new Mount(mountSerialized));
				}
				DBG.blogDebug("Successfully unpacked configs.");
			}
			else
			{
				DBG.blogWarning("Received bad config package. Unable to load.");
			}
		}
	}
	public class Mountable : MonoBehaviour
	{
		public GameObject mountPoint;

		private Transform mountPointBase;

		private GameObject saddle;

		private float flyStaminaDrain = 10f;

		public bool canfly = false;

		private Animator anim;

		public string Type;

		public Vector3 basePos;

		private static Vector3 rotationAdjust = Setup.rotationAdjust;

		private static Vector3 posDefault = Setup.posDefault;

		public int[] attackorder = new int[4];

		private bool initAttacks = false;

		private bool setCustomAttacks = false;

		private float updateTime = 0.7f;

		public ZNetView m_nview;

		public Vector3 RootScale = Vector3.one;

		public unsafe void Awake()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_0789: Unknown result type (might be due to invalid IL or missing references)
			//IL_0670: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06af: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08de: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Unknown result type (might be due to invalid IL or missing references)
			//IL_091a: Unknown result type (might be due to invalid IL or missing references)
			//IL_093b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_094b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_0932: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a20: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a25: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a58: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a60: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a67: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a83: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a93: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0acc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b02: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b07: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b0c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b23: Unknown result type (might be due to invalid IL or missing references)
			Tameable component = ((Component)this).GetComponent<Tameable>();
			Type = ((Object)component).name.Replace("(Clone)", "");
			Humanoid component2 = ((Component)this).gameObject.GetComponent<Humanoid>();
			Transform val = ((Component)component2).gameObject.transform.Find("Visual");
			mountPoint = new GameObject("MountPoint");
			mountPoint.transform.parent = val;
			mountPoint.transform.rotation = ((Component)this).transform.rotation;
			Vector3 val2 = posDefault;
			Vector3 val3 = posDefault;
			Vector3 one = Vector3.one;
			Vector3 val4 = one;
			DBG.blogDebug("Scale1=" + ((object)(*(Vector3*)(&val4))/*cast due to .constrained prefix*/).ToString());
			Vector3 val5 = rotationAdjust;
			m_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
			if (!m_nview.m_functions.ContainsKey(StringExtensionMethods.GetStableHashCode("RPC_SetMountPoint")))
			{
				m_nview.Register("RPC_SetMountPoint", (Action<long>)RPC_SetMountPoint);
			}
			if (!Setup.customMounts.TryGetValue(Type, out var value))
			{
				DBG.blogWarning(Type + " is not in custom mounts list, removing mountable");
				Object.Destroy((Object)(object)this);
				return;
			}
			string text = value.mountPath ?? "";
			if (text.Contains("\\"))
			{
				DBG.blogWarning(Type + " Mount Path should use '/' rather than '\\', trying to replace");
				text.Replace('\\', '/');
				value.mountPath = text;
			}
			if (text != "")
			{
				mountPointBase = val.Find(text);
			}
			val2 = (basePos = value.mountPoint);
			val3 = value.saddlePos;
			one = value.saddleScale;
			val5 = value.saddleRotation + rotationAdjust;
			if ((Object)(object)mountPointBase == (Object)null)
			{
				string[] array;
				if (!(text == ""))
				{
					mountPoint.transform.parent = val;
					string text2 = "";
					array = text.Split(new char[1] { '/' });
					string[] array2 = array;
					foreach (string text3 in array2)
					{
						if (!text2.Equals(""))
						{
							text2 += "/";
						}
						if ((Object)(object)val.Find(text2 + text3) == (Object)null)
						{
							string text4 = Type + " Mount Path '" + text + "' is not correct. ";
							if (text2 != "")
							{
								text4 = text4 + "'" + text2 + "' appears to work. ";
							}
							text4 = text4 + text3 + " cannot be found in " + Type + " body. " + Type + " will not be rideable.";
							((Component)component2).GetComponent<Tameable>().m_saddleItem = null;
							Setup.logger.LogError((object)text4);
							return;
						}
						text2 += text3;
					}
					Setup.logger.LogError((object)("Unknown error in setting up saddle and riding for " + Type + ", it will not be rideable"));
					((Component)component2).GetComponent<Tameable>().m_saddleItem = null;
					return;
				}
				Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>();
				string[] array3 = new string[7] { "spine2", "spine1", "tail2", "spine", "neck", "head", "armature" };
				List<string> list = new List<string>();
				array = array3;
				string[] array4 = array;
				foreach (string text5 in array4)
				{
					Transform[] array5 = componentsInChildren;
					Transform[] array6 = array5;
					foreach (Transform val6 in array6)
					{
						if (((Object)val6).name.ToLowerInvariant() == text5)
						{
							Transform val7 = val6;
							if (text5 == "neck")
							{
								val7 = val7.parent;
							}
							if ((Object)(object)mountPointBase == (Object)null)
							{
								mountPointBase = val7;
								text = GetPath(val7);
							}
							else if (text5 != "armature")
							{
								list.Add(GetPath(val7));
							}
							break;
						}
					}
				}
				if ((Object)(object)mountPointBase == (Object)null)
				{
					array = array3;
					string[] array7 = array;
					foreach (string value2 in array7)
					{
						Transform[] array8 = componentsInChildren;
						Transform[] array9 = array8;
						foreach (Transform val8 in array9)
						{
							string text6 = ((Object)val8).name.ToLowerInvariant();
							if (text6.StartsWith(value2) || text6.EndsWith(value2))
							{
								if ((Object)(object)mountPointBase == (Object)null)
								{
									mountPointBase = val8;
									text = GetPath(val8);
								}
								else
								{
									list.Add(GetPath(val8));
								}
								break;
							}
						}
					}
				}
				if (!((Object)(object)mountPointBase != (Object)null))
				{
					Setup.logger.LogError((object)("Could not find potential Mount Path for " + Type + ". " + Type + " will not be rideable"));
					((Component)component2).GetComponent<Tameable>().m_saddleItem = null;
					return;
				}
				string text7 = "";
				if (list.Count > 0)
				{
					text7 = "\nPossible Alternatives:";
					foreach (string item in list)
					{
						text7 = text7 + "\n" + item;
					}
				}
				value.mountPath = text;
				if (value.saddleRotation == Vector3.zero)
				{
					mountPoint.transform.rotation = mountPointBase.rotation;
					value.saddleRotation = mountPoint.transform.localEulerAngles - Setup.rotationAdjust;
					val5 = value.saddleRotation + Setup.rotationAdjust;
				}
				DBG.blogDebug("Found potential Mount Path for " + Type + ": " + text + text7);
				Setup.AddFullMountToYaml.Add(value.PrefabName);
				((MonoBehaviour)this).Invoke("UpdateConfig", 5f);
			}
			mountPoint.transform.parent = val;
			saddle = Object.Instantiate<GameObject>(((Component)Setup.tieredSaddlePrefabs[value.saddleTier].transform.GetChild(0)).gameObject, val);
			mountPoint.transform.localEulerAngles = val5;
			saddle.transform.localEulerAngles = val5;
			saddle.GetComponent<Sadle>().m_maxStamina = value.stamina;
			flyStaminaDrain = value.flyingStamina;
			BaseAI baseAI = ((Character)component2).GetBaseAI();
			MonsterAI val9 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null);
			if ((Object)(object)val9 != (Object)null && val9.m_avoidLand)
			{
				saddle.GetComponent<Sadle>().m_swimStaminaDrain = 0f;
			}
			if (((Character)component2).IsFlying())
			{
				if (flyStaminaDrain < 0f)
				{
					flyStaminaDrain = 1f;
				}
				canfly = true;
			}
			else if (flyStaminaDrain > 0f)
			{
				canfly = true;
			}
			Sadle component3 = saddle.GetComponent<Sadle>();
			component3.m_hoverText = ((Character)component2).m_name + " $mu_saddle";
			component3.m_attachPoint = mountPoint.transform;
			if ((value.customSaddle ?? "") != "" && value.customSaddle.StartsWith("attach_"))
			{
				component3.m_attachAnimation = value.customSaddle;
			}
			saddle.SetActive(false);
			component.m_saddle = component3;
			((Component)component3).transform.localPosition = val3;
			((Component)component3).transform.localScale = one;
			if (Setup.adjustCustom.Value)
			{
				anim = ((Component)component2).gameObject.GetComponentInChildren<Animator>();
			}
			if (val5 != rotationAdjust)
			{
				((Component)component3).GetComponentInChildren<Transform>().localEulerAngles = val5;
			}
			val2 += Setup.MountPointAdjustment.Value;
			mountPoint.transform.localPosition = val2;
			if ((Object)(object)component.m_saddle != (Object)null)
			{
				ZNetView nview = component.m_nview;
				if (!nview.m_functions.ContainsKey(StringExtensionMethods.GetStableHashCode("AddSaddle")))
				{
					nview.Register("AddSaddle", (Action<long>)component.RPC_AddSaddle);
				}
				if (!nview.m_functions.ContainsKey(StringExtensionMethods.GetStableHashCode("SetSaddle")))
				{
					nview.Register<bool>("SetSaddle", (Action<long, bool>)component.RPC_SetSaddle);
				}
				component.SetSaddle(component.HaveSaddle());
			}
			mountPoint.transform.parent = mountPointBase;
			Vector3 localScale = saddle.transform.localScale;
			saddle.transform.parent = mountPointBase;
			Vector3 localScale2 = saddle.transform.localScale;
			RootScale = new Vector3(localScale.x / localScale2.x, localScale.y / localScale2.y, localScale.z / localScale2.z);
			mountPoint.transform.localEulerAngles = val5;
			saddle.transform.localEulerAngles = val5;
			mountPoint.transform.localPosition = val2;
			Transform transform = mountPoint.transform;
			transform.position -= mountPoint.transform.rotation * (MountUp.lossyfactor * (saddle.transform.lossyScale.z - 1f) * Vector3.forward);
			((Component)component3).transform.localPosition = val3;
			SphereCollider component4 = saddle.GetComponent<SphereCollider>();
			if (!((value.customAttackOrder ?? "") != ""))
			{
				return;
			}
			string[] array10 = value.customAttackOrder.Split(new char[1] { ',' });
			int num = Math.Min(4, array10.Length);
			for (int n = 0; n < num; n++)
			{
				if (int.TryParse(array10[n], out var result))
				{
					attackorder[n] = result;
				}
				else
				{
					DBG.blogWarning("Failed to set custom attack order for " + array10[n]);
				}
			}
			setCustomAttacks = true;
		}

		public void setattacks(Humanoid humanoid)
		{
			if (humanoid.m_inventory != null)
			{
				List<ItemData> inventory = humanoid.m_inventory.m_inventory;
				bool[] array = new bool[4];
				bool flag = true;
				if (setCustomAttacks)
				{
					for (int i = 0; i < attackorder.Length; i++)
					{
						if (attackorder[i] >= inventory.Count)
						{
							DBG.blogWarning(attackorder[i] + " is higher than the total array of attacks (" + (inventory.Count - 1) + "), please reduce the number");
							flag = false;
						}
					}
					if (flag)
					{
						initAttacks = true;
						return;
					}
				}
				for (int j = 0; j < inventory.Count; j++)
				{
					float totalDamage = ((DamageTypes)(ref inventory[j].m_shared.m_damages)).GetTotalDamage();
					if (totalDamage <= 0f)
					{
						continue;
					}
					if (inventory[j].m_shared.m_aiWhenFlying)
					{
						if (!array[2])
						{
							attackorder[2] = j;
							array[2] = true;
							continue;
						}
						if (array[3])
						{
							if (((DamageTypes)(ref inventory[attackorder[3]].m_shared.m_damages)).GetTotalDamage() < totalDamage)
							{
								attackorder[3] = j;
							}
							continue;
						}
						if (((DamageTypes)(ref inventory[attackorder[2]].m_shared.m_damages)).GetTotalDamage() > totalDamage)
						{
							attackorder[3] = attackorder[2];
							attackorder[2] = j;
						}
						else
						{
							attackorder[3] = j;
						}
						array[3] = true;
					}
					else if (!array[0])
					{
						attackorder[0] = j;
						array[0] = true;
					}
					else if (array[1])
					{
						if (((DamageTypes)(ref inventory[attackorder[1]].m_shared.m_damages)).GetTotalDamage() < totalDamage)
						{
							attackorder[1] = j;
						}
					}
					else
					{
						if (((DamageTypes)(ref inventory[attackorder[0]].m_shared.m_damages)).GetTotalDamage() > totalDamage)
						{
							attackorder[1] = attackorder[0];
							attackorder[0] = j;
						}
						else
						{
							attackorder[1] = j;
						}
						array[1] = true;
					}
				}
				if (!array[3])
				{
					attackorder[3] = attackorder[2];
				}
				if (!array[0] & array[2])
				{
					attackorder[0] = attackorder[2];
					if (array[3])
					{
						attackorder[1] = attackorder[3];
						array[1] = true;
					}
				}
				if (!array[1])
				{
					attackorder[1] = attackorder[0];
				}
				initAttacks = true;
			}
			else
			{
				DBG.blogWarning("Creature does not have attacks");
			}
		}

		public void Delayed_ResetMountPoint()
		{
			ResetMountPoint();
			if (!Setup.adjustCustom.Value)
			{
				((MonoBehaviour)this).Invoke("Delayed_ResetMountPoint", updateTime);
				updateTime += 1f;
			}
		}

		public void ResetMountPoint()
		{
			//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)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = mountPoint.transform;
			transform.localPosition = basePos;
			transform.position -= ((Component)transform).transform.rotation * (MountUp.lossyfactor * (saddle.transform.lossyScale.z - 1f) * Vector3.forward);
		}

		public void RPC_SetMountPoint(long sender)
		{
			ResetMountPoint();
		}

		public bool hasInitAttacks()
		{
			return initAttacks;
		}

		public void setAnimation(bool isAnimating)
		{
			if ((Object)(object)anim != (Object)null)
			{
				((Behaviour)anim).enabled = isAnimating;
			}
		}

		public float getFlyStaminaDrain()
		{
			return flyStaminaDrain;
		}

		public GameObject getSaddle()
		{
			return saddle;
		}

		public void reduceflyingStamina(float dt)
		{
			Character component = ((Component)this).gameObject.GetComponent<Character>();
			if (Object.op_Implicit((Object)(object)component) && component.m_flying)
			{
				float stamina = saddle.GetComponent<Sadle>().GetStamina();
				saddle.GetComponent<Sadle>().SetStamina(stamina - dt * flyStaminaDrain);
			}
		}

		private string GetPath(Transform child)
		{
			string text = ((Object)child).name;
			Transform parent = child.parent;
			while (((Object)parent).name != "Visual")
			{
				text = ((Object)parent).name + "/" + text;
				parent = parent.parent;
			}
			return text;
		}

		private void UpdateConfig()
		{
			Setup.writeYML();
		}
	}
	public class MountUp
	{
		public enum AdjustMode
		{
			None,
			Saddle,
			Mount,
			Rotation,
			Scale
		}

		[HarmonyPatch(typeof(Tameable), "SetSaddle")]
		public static class InterceptSetSaddle
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				bool skipped = false;
				foreach (CodeInstruction instruction in instructions)
				{
					if (instruction.opcode == OpCodes.Ldarg_0)
					{
						skipped = true;
					}
					if (skipped)
					{
						yield return instruction;
					}
				}
			}
		}

		public static GameObject keyDisplayPanel;

		public static Text EditModeTitle;

		public static Text commandDisplay;

		public static Text keyDisplay;

		public static string CommandStringPos = "";

		public static string CommandStringRot = "";

		public static string CommandStringScale = "";

		public static string keyString = "";

		public static float dampingPercent = 0.9f;

		public static float AdjustSpeed = 0.9f;

		public static Vector3 sumOffset = Vector3.zero;

		public static int countOffset = 0;

		public static Vector3 avgOffset = Vector3.zero;

		public static Vector3 lastPos = Vector3.zero;

		public static Vector3 speedMulti = Vector3.one;

		public static float max_dist = 2f;

		public static float lossyfactor = 0.25f;

		public static bool useSmooth = true;

		public static AdjustMode adjustMode;

		[HarmonyPatch(typeof(LevelEffects), "Start")]
		[HarmonyPostfix]
		private static void LevelEffectsStart_Patch(LevelEffects __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.m_baseEnableObject))
			{
				Mountable component = __instance.m_baseEnableObject.GetComponent<Mountable>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ResetMountPoint();
				}
			}
		}

		[HarmonyPatch(typeof(Sadle), "Interact")]
		[HarmonyPrefix]
		private static void Sadle_Interact_Patch(Sadle __instance)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			Mountable mountable = default(Mountable);
			if (((Component)__instance.m_character).TryGetComponent<Mountable>(ref mountable) && !Setup.adjustCustom.Value)
			{
				mountable.m_nview.InvokeRPC("RPC_SetMountPoint", Array.Empty<object>());
			}
			__instance.m_character.m_maxAirAltitude = ((Component)__instance).transform.position.y;
			__instance.m_character.m_groundContact = false;
		}

		[HarmonyPatch(typeof(Sadle), "Awake")]
		[HarmonyPostfix]
		private static void Sadle_Awake_Patch(Sadle __instance)
		{
			Mountable mountable = default(Mountable);
			if (((Component)__instance.m_character).TryGetComponent<Mountable>(ref mountable))
			{
				((MonoBehaviour)mountable).Invoke("Delayed_ResetMountPoint", 1.3f);
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPostfix]
		private static void Player_Update_Patch(Player __instance)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			if (((Character)__instance).IsRiding())
			{
				((Component)__instance).transform.position = __instance.m_attachPoint.position;
				((Component)__instance).transform.rotation = __instance.m_attachPoint.rotation;
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		[HarmonyPriority(5)]
		private static void Postfix_ODB_Awake(ObjectDB __instance)
		{
			DBG.blogWarning("ODB Awake");
			if (!Setup.localizeLoaded)
			{
				DBG.blogWarning("Loading Localizer");
				Localizer.Load();
				Setup.localizeLoaded = true;
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Shutdown")]
		[HarmonyPostfix]
		private static void Postfix()
		{
			DBG.blogDebug("Reseting Mounts");
			Setup.ResetAllMounts();
		}

		[HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")]
		[HarmonyPostfix]
		private static void LevelEffectsSetupLevelVisualization_Patch(LevelEffects __instance)
		{
			Mountable mountable = default(Mountable);
			if (Object.op_Implicit((Object)(object)__instance.m_character) && ((Component)__instance.m_character).gameObject.TryGetComponent<Mountable>(ref mountable))
			{
				mountable.ResetMountPoint();
			}
		}

		private static void displayKeybinds(bool active)
		{
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)keyDisplayPanel))
			{
				if (GUIManager.Instance == null)
				{
					Debug.LogError((object)"GUIManager instance is null");
					return;
				}
				if (!Object.op_Implicit((Object)(object)GUIManager.CustomGUIFront))
				{
					Debug.LogError((object)"GUIManager CustomGUI is null");
					return;
				}
				SetCommandsStrings();
				keyDisplayPanel = GUIManager.Instance.CreateWoodpanel(GUIManager.CustomGUIFront.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(0f, -300f), 400f, 500f, false);
				((Behaviour)keyDisplayPanel.GetComponent<Image>()).enabled = false;
				GameObject val = GUIManager.Instance.CreateText(keyString.Substring(0, keyString.IndexOf('\n')), keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(187f, -265f), GUIManager.Instance.AveriaSerifBold, 20, GUIManager.Instance.ValheimOrange, true, Color.black, 300f, 500f, false);
				keyDisplay = val.GetComponent<Text>();
				GameObject val2 = GUIManager.Instance.CreateText(CommandStringPos.Substring(0, CommandStringPos.IndexOf('\n')), keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(-45f, -265f), GUIManager.Instance.AveriaSerifBold, 20, Color.white, true, Color.black, 300f, 500f, false);
				commandDisplay = val2.GetComponent<Text>();
				commandDisplay.alignment = (TextAnchor)2;
				GameObject val3 = GUIManager.Instance.CreateText("Not Editing", keyDisplayPanel.transform, new Vector2(0.5f, 1f), new Vector2(0.5f, 1f), new Vector2(50f, 5f), GUIManager.Instance.AveriaSerifBold, 27, Color.red, true, Color.black, 400f, 40f, false);
				EditModeTitle = val3.GetComponent<Text>();
				EditModeTitle.alignment = (TextAnchor)7;
			}
			keyDisplayPanel.SetActive(active);
		}

		public static string getKeybingsString()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003d: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_0104: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string text2 = text;
			KeyboardShortcut value = Setup.adjustCustomModeSwitch.Value;
			text = text2 + string.Join("+", ((KeyboardShortcut)(ref value)).Modifiers);
			string text3 = text;
			value = Setup.adjustCustomModeSwitch.Value;
			text = text3 + "+" + ((object)((KeyboardShortcut)(ref value)).MainKey/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)276/*cast due to .constrained prefix*/).ToString() + "/" + ((object)(KeyCode)275/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)273/*cast due to .constrained prefix*/).ToString() + "/" + ((object)(KeyCode)274/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)280/*cast due to .constrained prefix*/).ToString() + "/" + ((object)(KeyCode)281/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)306/*cast due to .constrained prefix*/).ToString() + "+" + ((object)(KeyCode)115/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + "\n" + ((object)(KeyCode)305/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)303/*cast due to .constrained prefix*/).ToString() + "\n";
			text = text + ((object)(KeyCode)307/*cast due to .constrained prefix*/).ToString() + "\n";
			return SimplifyKeys(text);
		}

		public static string SimplifyKeys(string keyString)
		{
			return keyString.Replace("Left", "L-").Replace("Right", "R-").Replace("Control", "Ctrl")
				.Replace("BackQuote", "` (BackQuote)");
		}

		public static void SetCommandsStrings()
		{
			CommandStringPos = "Cycle Edit Mode                 \n";
			CommandStringRot = CommandStringPos;
			CommandStringScale = CommandStringPos;
			CommandStringRot += "Tilt Left/Right                 \nRotate Forward/Back                 \nSpin Left/Right                 \n";
			CommandStringPos += "Move Left/Right                 \nMove Forward/Back                 \nMove Up/Down                 \n";
			CommandStringScale += "Width Decrease/Increase                 \nLength Decrease/Increase                 \nHeight Decrease/Increase                 \n";
			string text = "Save to YML                 \n Finer Adjustment:\n0.5x (hold)                 \n0.1x (hold)                 \n0.05x (hold)                 \n";
			CommandStringPos += text;
			CommandStringRot += text;
			CommandStringScale += text;
			keyString = getKeybingsString();
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPrefix]
		private static void PlayerUpdate_Patch(Player __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0605: Unknown result type (might be due to invalid IL or missing references)
			//IL_060c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0611: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0762: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0642: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0658: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_079c: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0791: Unknown result type (might be due to invalid IL or missing references)
			//IL_0678: Unknown result type (might be due to invalid IL or missing references)
			//IL_067f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0686: Unknown result type (might be due to invalid IL or missing references)
			//IL_068b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0690: Unknown result type (might be due to invalid IL or missing references)
			//IL_0695: Unknown result type (might be due to invalid IL or missing references)
			//IL_0504: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0520: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0541: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0924: Unknown result type (might be due to invalid IL or missing references)
			//IL_0926: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0700: Unknown result type (might be due to invalid IL or missing references)
			//IL_0705: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			//IL_070f: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0595: Unknown result type (might be due to invalid IL or missing references)
			//IL_059a: Unknown result type (might be due to invalid IL or missing references)
			//IL_090c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0911: Unknown result type (might be due to invalid IL or missing references)
			//IL_0916: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0866: Unknown result type (might be due to invalid IL or missing references)
			//IL_086b: Unknown result type (might be due to invalid IL or missing references)
			//IL_086d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0838: Unknown result type (might be due to invalid IL or missing references)
			//IL_072f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0736: Unknown result type (might be due to invalid IL or missing references)
			//IL_073d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0742: Unknown result type (might be due to invalid IL or missing references)
			//IL_0747: Unknown result type (might be due to invalid IL or missing references)
			//IL_074c: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0974: Unknown result type (might be due to invalid IL or missing references)
			//IL_0959: Unknown result type (might be due to invalid IL or missing references)
			//IL_088d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0892: Unknown result type (might be due to invalid IL or missing references)
			//IL_0894: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
			{
				displayKeybinds(active: false);
				return;
			}
			if (!Setup.adjustCustom.Value)
			{
				displayKeybinds(active: false);
				return;
			}
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool num = ZInput.instance != null;
			KeyboardShortcut value = Setup.adjustCustomModeSwitch.Value;
			if (num & ((KeyboardShortcut)(ref value)).IsDown())
			{
				adjustMode = (AdjustMode)((int)(adjustMode + 1) % Enum.GetValues(typeof(AdjustMode)).Length);
				string text = "";
				if (CommandStringPos == "")
				{
					SetCommandsStrings();
				}
				switch (adjustMode)
				{
				case AdjustMode.None:
					text = "Adjust Mode: None";
					EditModeTitle.text = "Not Editing";
					commandDisplay.text = CommandStringPos.Substring(0, CommandStringPos.IndexOf('\n'));
					keyDisplay.text = keyString.Substring(0, keyString.IndexOf('\n'));
					break;
				case AdjustMode.Saddle:
					text = "Adjust Mode: Saddle Position";
					EditModeTitle.text = "Adjust Mode: Saddle Position";
					commandDisplay.text = CommandStringPos;
					keyDisplay.text = keyString;
					flag = true;
					break;
				case AdjustMode.Mount:
					text = "Adjust Mode: Player Mount Position";
					EditModeTitle.text = "Adjust Mode: Player Mount Position";
					commandDisplay.text = CommandStringPos;
					keyDisplay.text = keyString;
					flag = true;
					break;
				case AdjustMode.Rotation:
					text = "Adjust Mode: Saddle Rotation";
					EditModeTitle.text = "Adjust Mode: Rotation";
					commandDisplay.text = CommandStringRot;
					keyDisplay.text = keyString;
					flag2 = true;
					break;
				case AdjustMode.Scale:
					text = "Adjust Mode: Saddle Scale";
					EditModeTitle.text = "Adjust Mode: Scale";
					commandDisplay.text = CommandStringScale;
					keyDisplay.text = keyString;
					flag3 = true;
					break;
				default:
					text = "Adjust Mode: Unknown (error)";
					EditModeTitle.text = "Error: Not Editing";
					break;
				}
				MessageHud.instance.ShowMessage((MessageType)1, text, 0, (Sprite)null, false, true);
			}
			IDoodadController doodadController = __instance.GetDoodadController();
			Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
			if ((Object)(object)val == (Object)null)
			{
				displayKeybinds(active: false);
				return;
			}
			Mountable component = ((Component)val.GetCharacter()).gameObject.GetComponent<Mountable>();
			if (!Object.op_Implicit((Object)(object)component))
			{
				displayKeybinds(active: false);
				return;
			}
			displayKeybinds(active: true);
			Transform val2 = null;
			Transform val3 = null;
			switch (adjustMode)
			{
			case AdjustMode.None:
				val2 = null;
				component.setAnimation(isAnimating: true);
				break;
			case AdjustMode.Saddle:
				val2 = ((Component)val).transform;
				val3 = val.m_attachPoint;
				component.setAnimation(isAnimating: false);
				break;
			case AdjustMode.Rotation:
				val2 = ((Component)val).transform;
				val3 = val.m_attachPoint;
				component.setAnimation(isAnimating: false);
				break;
			case AdjustMode.Mount:
				val2 = val.m_attachPoint;
				val3 = ((Component)val).transform;
				component.setAnimation(isAnimating: false);
				break;
			case AdjustMode.Scale:
				val2 = ((Component)val).transform;
				val3 = val.m_attachPoint;
				component.setAnimation(isAnimating: false);
				break;
			default:
				component.setAnimation(isAnimating: false);
				break;
			}
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			float num2 = 1f;
			if (Input.GetKey((KeyCode)305))
			{
				num2 *= 0.5f;
			}
			if (Input.GetKey((KeyCode)303))
			{
				num2 *= 0.1f;
			}
			if (Input.GetKey((KeyCode)307))
			{
				num2 *= 0.05f;
			}
			Vector3 localPosition = val2.localPosition;
			Vector3 val4 = Vector3.Scale(val2.localScale, component.RootScale);
			Vector3 localEulerAngles = val2.localEulerAngles;
			if (adjustMode == AdjustMode.Rotation)
			{
				num2 *= 20f;
				if (rotateTransform(val2, num2) && (Object)(object)val3 != (Object)null)
				{
					rotateTransform(val3, num2);
				}
			}
			else if (adjustMode == AdjustMode.Scale)
			{
				num2 *= 0.1f;
				if (Input.GetKeyDown((KeyCode)275))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f + num2, 1f, 1f));
				}
				if (Input.GetKeyDown((KeyCode)276))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f - num2, 1f, 1f));
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f, 1f, 1f + num2));
				}
				if (Input.GetKeyDown((KeyCode)274))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f, 1f, 1f - num2));
				}
				if (Input.GetKeyDown((KeyCode)280))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f, 1f + num2, 1f));
				}
				if (Input.GetKeyDown((KeyCode)281))
				{
					val2.localScale = Vector3.Scale(val2.localScale, new Vector3(1f, 1f - num2, 1f));
				}
			}
			else
			{
				if (Input.GetKeyDown((KeyCode)275))
				{
					Transform obj = val2;
					obj.position += val2.rotation * (num2 * Vector3.right);
				}
				if (Input.GetKeyDown((KeyCode)276))
				{
					Transform obj2 = val2;
					obj2.position -= val2.rotation * (num2 * Vector3.right);
				}
				if (Input.GetKeyDown((KeyCode)273))
				{
					Transform obj3 = val2;
					obj3.position += val2.rotation * (num2 * Vector3.forward);
				}
				if (Input.GetKeyDown((KeyCode)274))
				{
					Transform obj4 = val2;
					obj4.position -= val2.rotation * (num2 * Vector3.forward);
				}
				if (Input.GetKeyDown((KeyCode)280))
				{
					Transform obj5 = val2;
					obj5.position += val2.rotation * (num2 * Vector3.up);
				}
				if (Input.GetKeyDown((KeyCode)281))
				{
					Transform obj6 = val2;
					obj6.position -= val2.rotation * (num2 * Vector3.up);
				}
			}
			if (Vector3.Distance(val2.position, val3.position) > 2.5f)
			{
				MessageHud.instance.ShowMessage((MessageType)2, "Saddle and Mount Point Must Stay closer,\n or player will dismount", 0, (Sprite)null, false, true);
				val2.localPosition = localPosition;
			}
			Vector3 val5 = Vector3.Scale(val2.localScale, component.RootScale);
			string text2 = ((Object)val.GetCharacter()).name.Replace("(Clone)", "");
			if (val2.localPosition != localPosition || flag)
			{
				Vector3 val6 = val2.localPosition - localPosition;
				if (Setup.customMounts.TryGetValue(text2, out var value2))
				{
					string text3 = text2 + " saddlePos: ";
					if (adjustMode == AdjustMode.Mount)
					{
						text3 = text2 + " mountPoint: ";
					}
					string text4 = Setup.StringVec(val2.localPosition);
					DBG.blogInfo(text3 + text4);
				}
				if (adjustMode == AdjustMode.Mount)
				{
					Mount mount = value2;
					mount.mountPoint += val6;
				}
				else if (adjustMode == AdjustMode.Saddle)
				{
					Mount mount2 = value2;
					mount2.saddlePos += val6;
				}
			}
			else if (val2.localEulerAngles != localEulerAngles || flag2)
			{
				if (Setup.customMounts.TryGetValue(text2, out var value3))
				{
					string text5 = text2 + " saddleRotation: ";
					string text6 = Setup.StringVec(val2.localEulerAngles - Setup.rotationAdjust);
					DBG.blogInfo(text5 + text6);
				}
				value3.saddleRotation = val2.localEulerAngles - Setup.rotationAdjust;
			}
			else if (val5 != val4 || flag3)
			{
				if (Setup.customMounts.TryGetValue(text2, out var value4))
				{
					string text7 = text2 + " saddleScale: ";
					string text8 = Setup.StringVec(val5);
					DBG.blogInfo(text7 + text8);
				}
				value4.saddleScale = val5;
			}
			if (((KeyboardShortcut)(ref Setup.saveMountKeys)).IsDown())
			{
				MessageHud.instance.ShowMessage((MessageType)2, "Saving " + text2 + " to MountUp YML", 0, (Sprite)null, false, true);
				if (!Setup.AddFullMountToYaml.Contains(text2))
				{
					Setup.AddFullMountToYaml.Add(text2);
				}
				Setup.writeYML();
			}
		}

		private static bool rotateTransform(Transform transform, float num)
		{
			//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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			bool result = false;
			if (Input.GetKeyDown((KeyCode)275))
			{
				transform.Rotate((0f - num) * Vector3.forward);
				result = true;
			}
			if (Input.GetKeyDown((KeyCode)276))
			{
				transform.Rotate(num * Vector3.forward);
				result = true;
			}
			if (Input.GetKeyDown((KeyCode)273))
			{
				transform.Rotate(num * Vector3.right);
				result = true;
			}
			if (Input.GetKeyDown((KeyCode)274))
			{
				transform.Rotate((0f - num) * Vector3.right);
				result = true;
			}
			if (Input.GetKeyDown((KeyCode)280))
			{
				transform.Rotate(num * Vector3.up);
				result = true;
			}
			if (Input.GetKeyDown((KeyCode)281))
			{
				transform.Rotate((0f - num) * Vector3.up);
				result = true;
			}
			return result;
		}

		[HarmonyPatch(typeof(TeleportWorldTrigger), "OnTriggerEnter")]
		[HarmonyPostfix]
		private static void TeleportWorldTriggerOnTriggerEnter_Patch(TeleportWorldTrigger __instance, Collider colliderIn)
		{
			if (!Setup.teleportMounts.Value)
			{
				return;
			}
			Tameable component = ((Component)colliderIn).GetComponent<Tameable>();
			if (!((Object)(object)component != (Object)null) || !component.m_character.IsTamed() || !component.HaveRider())
			{
				return;
			}
			long user = component.m_saddle.GetUser();
			if (!component.m_saddle.HaveValidUser())
			{
				return;
			}
			ZDO val = null;
			foreach (ZDO allCharacterZDO in ZNet.instance.GetAllCharacterZDOS())
			{
				if (((ZDOID)(ref allCharacterZDO.m_uid)).UserID == user)
				{
					val = allCharacterZDO;
				}
			}
			if (val == null)
			{
				return;
			}
			GameObject gameObject = ((Component)ZNetScene.instance.FindInstance(val)).gameObject;
			if (!((Object)(object)gameObject == (Object)null))
			{
				Player component2 = gameObject.GetComponent<Player>();
				if (!((Object)(object)component2 == (Object)null) && !((Object)(object)Player.m_localPlayer != (Object)(object)component2))
				{
					__instance.m_teleportWorld.Teleport(component2);
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(TeleportWorld), "Teleport")]
		private static void TeleportWorldTeleport_Patch(Player player)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (Setup.teleportMounts.Value)
			{
				IDoodadController doodadController = player.GetDoodadController();
				Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
				if ((Object)(object)val != (Object)null)
				{
					val.m_speed = (Speed)0;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "UpdateTeleport")]
		private static void PlayerUpdateTeleport_Patch(ref bool ___m_teleporting, ref float ___m_teleportTimer, ref Vector3 ___m_teleportTargetPos, ref Quaternion ___m_teleportTargetRot, Player __instance)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			if ((Setup.teleportMounts.Value & ___m_teleporting) && (double)___m_teleportTimer > 2.0)
			{
				IDoodadController doodadController = __instance.m_doodadController;
				Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
				if ((Object)(object)val != (Object)null)
				{
					_ = __instance.m_teleportTargetRot * Vector3.forward;
					((Component)val.GetCharacter()).transform.position = __instance.m_teleportTargetPos;
					((Component)val.GetCharacter()).transform.rotation = __instance.m_teleportTargetRot;
					val.GetCharacter().m_body.linearVelocity = Vector3.zero;
					val.m_speed = (Speed)0;
				}
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(Player), "Interact", new Type[]
		{
			typeof(GameObject),
			typeof(bool),
			typeof(bool)
		})]
		private static void PlayerInteract_Patch(GameObject go, bool hold, bool alt, ref float ___m_lastHoverInteractTime, Player __instance)
		{
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			Player componentInParent = go.GetComponentInParent<Player>();
			if ((Object)(object)componentInParent != (Object)null && Setup.canMountPlayer.Value && alt)
			{
				___m_lastHoverInteractTime = Time.time;
				GameObject visual = ((Character)componentInParent).GetVisual();
				if (((Object)((Component)visual.transform.GetChild(visual.transform.childCount - 1)).gameObject).name.Equals("MountPoint"))
				{
					Transform child = visual.transform.GetChild(visual.transform.childCount - 1);
					child.parent = null;
					Object.Destroy((Object)(object)((Component)child).gameObject);
				}
				GameObject val = new GameObject("MountPoint");
				val.transform.parent = visual.transform;
				Vector3 localPosition = default(Vector3);
				((Vector3)(ref localPosition))..ctor(0f, 0.6997871f, -0.2250879f);
				Quaternion rotation = visual.transform.rotation;
				val.transform.rotation = rotation;
				val.transform.localPosition = localPosition;
				Transform transform = val.transform;
				Vector3 val2 = default(Vector3);
				((Vector3)(ref val2))..ctor(0f, 0f, 0f);
				string text = "attach_chair";
				((Character)__instance).AttachStart(transform, visual, false, false, false, text, val2, (Transform)null);
			}
		}

		public static bool HasSwimDrain(float swimDrain)
		{
			return swimDrain > 0f;
		}

		[HarmonyPatch(typeof(Sadle), "UpdateDrown")]
		[HarmonyPrefix]
		private static bool SadleUpdateDrown_Patch(Sadle __instance)
		{
			if (__instance.m_swimStaminaDrain > 0f && Setup.mountsCanDrown.Value)
			{
				return true;
			}
			return false;
		}

		[HarmonyPatch(typeof(Sadle), "UpdateStamina")]
		[HarmonyPrefix]
		private static void SadleUpdateStamina_Patch(Sadle __instance, float dt)
		{
			Character character = __instance.m_character;
			if (!Object.op_Implicit((Object)(object)character))
			{
				return;
			}
			Mountable component = ((Component)character).GetComponent<Mountable>();
			float stamina = __instance.GetStamina();
			if (Object.op_Implicit((Object)(object)component) && __instance.HaveValidUser() && character.m_flying)
			{
				float num = stamina - dt * component.getFlyStaminaDrain();
				if (num < 0f)
				{
					character.Land();
					num = 0f;
				}
				__instance.SetStamina(num);
			}
			if (__instance.m_staminaRegenTimer > 0f || character.InAttack() || (character.IsSwimming() && __instance.m_swimStaminaDrain > 0f))
			{
				return;
			}
			float maxStamina = __instance.GetMaxStamina();
			if (stamina < maxStamina || stamina > maxStamina)
			{
				float num2 = (__instance.m_tambable.IsHungry() ? __instance.m_staminaRegenHungry : (__instance.m_staminaRegen * Setup.FedStaminaMultiplier.Value));
				float num3 = num2 + (1f - stamina / maxStamina) * num2;
				stamina += num3 * dt;
				if (stamina > maxStamina)
				{
					stamina = maxStamina;
				}
				__instance.SetStamina(stamina);
			}
		}

		[HarmonyPatch(typeof(Player), "SetControls")]
		[HarmonyPrefix]
		[HarmonyPriority(410)]
		private static void PrefixSetControls(Player __instance, ref bool jump, ref bool crouch, ref bool attack, ref bool secondaryAttack, ref bool block)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			if (!((Character)__instance).IsRiding())
			{
				return;
			}
			Sadle val = (Sadle)__instance.m_doodadController;
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Mountable component = ((Component)val.m_character).GetComponent<Mountable>();
			bool flying = ((BaseAI)val.m_monsterAI).m_character.m_flying;
			if (jump)
			{
				if (Object.op_Implicit((Object)(object)component))
				{
					if (component.canfly && !flying)
					{
						try
						{
							((BaseAI)val.m_monsterAI).m_character.TakeOff();
						}
						catch
						{
							((BaseAI)val.m_monsterAI).m_character.m_flying = true;
						}
					}
					else
					{
						try
						{
							((BaseAI)val.m_monsterAI).m_character.Jump(false);
						}
						catch
						{
							DBG.blogDebug("Jump Effects failed, most likley an effect is null");
						}
					}
				}
				else
				{
					try
					{
						((BaseAI)val.m_monsterAI).m_character.Jump(false);
					}
					catch
					{
						DBG.blogDebug("Jump Effects failed, most likley an effect is null");
					}
				}
				jump = false;
			}
			else if (Object.op_Implicit((Object)(object)component) && (ZInput.GetButton("Jump") || ZInput.GetButtonDown("JoyJump")) && component.canfly && !flying)
			{
				try
				{
					((BaseAI)val.m_monsterAI).m_character.TakeOff();
				}
				catch
				{
					((BaseAI)val.m_monsterAI).m_character.m_flying = true;
				}
			}
			if (Setup.canAttackMounted.Value && ((attack | secondaryAttack) || (block && Setup.useBlockforSecondary.Value)))
			{
				Character character = val.m_character;
				Humanoid val2 = (Humanoid)(object)((character is Humanoid) ? character : null);
				if (Object.op_Implicit((Object)(object)val2) && val2.m_inventory != null)
				{
					int count = val2.m_inventory.m_inventory.Count;
					if (count > 0)
					{
						int num = 0;
						if (Object.op_Implicit((Object)(object)component))
						{
							if (!component.hasInitAttacks())
							{
								component.setattacks(val2);
							}
							num = component.attackorder[((secondaryAttack | block) ? 1 : 0) + (flying ? 2 : 0)];
						}
						else
						{
							num = ((secondaryAttack | block) ? 1 : 0);
						}
						num = Math.Min(num, count - 1);
						val2.EquipItem(val2.m_inventory.m_inventory[num], false);
					}
					((Character)val2).StartAttack((Character)null, false);
				}
				attack = false;
				secondaryAttack = false;
			}
			if (!flying)
			{
				return;
			}
			if (ZInput.GetButton("Jump") || ZInput.GetButtonDown("JoyJump"))
			{
				((BaseAI)val.m_monsterAI).m_character.m_body.AddForce(new Vector3(0f, 200f, 0f) * ((BaseAI)val.m_monsterAI).m_character.m_body.mass);
			}
			else if (ZInput.GetButton("Crouch") || ZInput.GetButton("JoyCrouch"))
			{
				Character character2 = ((BaseAI)val.m_monsterAI).m_character;
				character2.m_body.AddForce(new Vector3(0f, -300f, 0f) * character2.m_body.mass);
				float num2 = default(float);
				if (character2.m_baseAI.GetSolidHeight(((Component)character2).transform.position, 0f, 1f, ref num2))
				{
					character2.Land();
				}
			}
		}

		[HarmonyPatch(typeof(Sadle), "UpdateRiding")]
		[HarmonyTranspiler]
		private static IEnumerable<CodeInstruction> SadleUpdateRiding_Transpile(IEnumerable<CodeInstruction> instructions)
		{
			bool Ldfld = false;
			bool foundCall = false;
			bool executed = false;
			foreach (CodeInstruction instruction in instructions)
			{
				if (!executed && !Ldfld && instruction.opcode == OpCodes.Ldfld)
				{
					Ldfld = true;
					yield return instruction;
				}
				else if (!executed && Ldfld && !foundCall && instruction.opcode == OpCodes.Callvirt)
				{
					foundCall = true;
					yield return instruction;
				}
				else if (!executed && Ldfld && foundCall && instruction.opcode == OpCodes.Brfalse)
				{
					executed = true;
					CodeInstruction jumpcall = instruction;
					yield return instruction;
					yield return new CodeInstruction(OpCodes.Ldarg_0, (object)null);
					yield return CodeInstruction.LoadField(typeof(Sadle), "m_swimStaminaDrain", false);
					yield return CodeInstruction.Call(typeof(MountUp), "HasSwimDrain", (Type[])null, (Type[])null);
					yield return jumpcall;
				}
				else
				{
					Ldfld = false;
					foundCall = false;
					yield return instruction;
				}
			}
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Character), "GetSlideAngle")]
		private static bool CharacterGetSlideAngle_PostPatch(Character __instance, ref float __result)
		{
			if (__instance.IsPlayer())
			{
				__result = 38f;
				return false;
			}
			if (__instance.HaveRider())
			{
				__result = 55f;
				return false;
			}
			__result = 90f;
			return false;
		}
	}
	public class MountSet
	{
		public List<Mount> mounts { get; set; }
	}
	public class Mount
	{
		public string PrefabName { get; set; }

		public string mountPath { get; set; } = string.Empty;

		public float stamina { get; set; } = 120f;

		public int saddleTier { get; set; } = 5;

		public Vector3 mountPoint { get; set; } = Setup.posDefault;

		public Vector3 saddlePos { get; set; } = Setup.posDefault;

		public Vector3 saddleScale { get; set; } = Vector3.one;

		public Vector3 saddleRotation { get; set; } = Vector3.zero;

		public float flyingStamina { get; set; } = -1f;

		public string customSaddle { get; set; } = string.Empty;

		public string customAttackOrder { get; set; } = string.Empty;

		public Mount(MountSerialized mount)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			PrefabName = mount.PrefabName;
			mountPath = mount.mountPath;
			stamina = mount.stamina;
			saddleTier = mount.saddleTier;
			flyingStamina = mount.flyingStamina;
			mountPoint = new Vector3(mount.mountPoint[0], mount.mountPoint[1], mount.mountPoint[2]);
			saddlePos = new Vector3(mount.saddlePos[0], mount.saddlePos[1], mount.saddlePos[2]);
			saddleScale = new Vector3(mount.saddleScale[0], mount.saddleScale[1], mount.saddleScale[2]);
			saddleRotation = new Vector3(mount.saddleRotation[0], mount.saddleRotation[1], mount.saddleRotation[2]);
			customSaddle = mount.customSaddle;
			customAttackOrder = mount.customAttackOrder;
		}

		public Mount()
		{
		}//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)

	}
	[Serializable]
	public class MountSerialized
	{
		public string PrefabName { get; set; }

		public string mountPath { get; set; } = string.Empty;

		public float stamina { get; set; } = 120f;

		public int saddleTier { get; set; } = 5;

		public float[] mountPoint { get; set; } = new float[3];

		public float[] saddlePos { get; set; } = new float[3];

		public float[] saddleScale { get; set; } = new float[3] { 1f, 1f, 1f };

		public float[] saddleRotation { get; set; } = new float[3];

		public float flyingStamina { get; set; } = -1f;

		public string customSaddle { get; set; } = string.Empty;

		public string customAttackOrder { get; set; } = string.Empty;

		public MountSerialized(Mount mount)
		{
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: 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_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			PrefabName = mount.PrefabName;
			mountPath = mount.mountPath;
			stamina = mount.stamina;
			saddleTier = mount.saddleTier;
			flyingStamina = mount.flyingStamina;
			mountPoint = new float[3]
			{
				mount.mountPoint.x,
				mount.mountPoint.y,
				mount.mountPoint.z
			};
			saddlePos = new float[3]
			{
				mount.saddlePos.x,
				mount.saddlePos.y,
				mount.saddlePos.z
			};
			saddleScale = new float[3]
			{
				mount.saddleScale.x,
				mount.saddleScale.y,
				mount.saddleScale.z
			};
			saddleRotation = new float[3]
			{
				mount.saddleRotation.x,
				mount.saddleRotation.y,
				mount.saddleRotation.z
			};
			customSaddle = mount.customSaddle;
			customAttackOrder = mount.customAttackOrder;
		}

		public MountSerialized()
		{
		}
	}
	public class MountToYaml
	{
		public string PrefabName { get; set; }

		public string mountPath { get; set; }

		public float stamina { get; set; }

		public int saddleTier { get; set; }

		public string mountPoint { get; set; }

		public string saddlePos { get; set; }

		public string saddleScale { get; set; }

		public string saddleRotation { get; set; }

		public float flyingStamina { get; set; }

		public string customSaddle { get; set; }

		public string customAttackOrder { get; set; }

		public MountToYaml(Mount mount)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			PrefabName = mount.PrefabName;
			mountPath = mount.mountPath;
			stamina = mount.stamina;
			saddleTier = mount.saddleTier;
			flyingStamina = mount.flyingStamina;
			mountPoint = "[" + mount.mountPoint.x + "," + mount.mountPoint.y + "," + mount.mountPoint.z + "]";
			saddlePos = "[" + mount.saddlePos.x + "," + mount.saddlePos.y + "," + mount.saddlePos.z + "]";
			saddleScale = "[" + mount.saddleScale.x + "," + mount.saddleScale.y + "," + mount.saddleScale.z + "]";
			saddleRotation = "[" + mount.saddleRotation.x + "," + mount.saddleRotation.y + "," + mount.saddleRotation.z + "]";
			customSaddle = mount.customSaddle;
			customAttackOrder = mount.customAttackOrder;
		}
	}
	internal class Patches
	{
		public const string LMTY_GUID = "meldurson.LetMeTameYou";

		public static Setup setup;

		public static PatchBetterRiding patchBetterRding;

		internal static void Apply()
		{
			Harmony harmony = Setup.harmony;
			harmony.PatchAll(typeof(MountUp));
			harmony.PatchAll(typeof(MountUp.InterceptSetSaddle));
			if (Setup.adjustCustom.Value)
			{
				harmony.PatchAll(typeof(AdjustmentPatches));
			}
			if (Chainloader.PluginInfos.ContainsKey("meldurson.LetMeTameYou"))
			{
				DBG.blogDebug("Applying LMTY patches");
				harmony.PatchAll(typeof(PatcherLMTY));
			}
			else
			{
				DBG.blogDebug("Applying Shared Content");
				harmony.PatchAll(typeof(SharedContent));
			}
			if (Chainloader.PluginInfos.ContainsKey("Yggdrah.BetterRiding"))
			{
				DBG.blogInfo("Applying BetterRiding patches");
				IEnumerable<Component> source = from c in setup.Root.GetComponents(typeof(BaseUnityPlugin))
					where ((object)c).GetType().Name == "BetterRidingPlugin"
					select c;
				if (source.Any())
				{
					Component obj = source.First();
					BaseUnityPlugin val = (BaseUnityPlugin)(object)((obj is BaseUnityPlugin) ? obj : null);
					((Behaviour)val).enabled = false;
					DBG.blogDebug("is BetterRiding Disabled:" + !((Behaviour)val).enabled);
					harmony.PatchAll(typeof(PatchBetterRiding));
					DBG.blogDebug("Applied BetterRiding patches");
					patchBetterRding = ((Component)Setup.instance).gameObject.AddComponent<PatchBetterRiding>();
				}
				MethodInfo method = typeof(Player).GetMethod("SetControls");
				RemovePatch(method, isPrefix: true, new string[1] { "Yggdrah.BetterRiding/Start_Prefix" });
			}
		}

		public static void RemovePatch(MethodBase method, bool isPrefix, string[] patchNames)
		{
			Patches patchInfo = Harmony.GetPatchInfo(method);
			if (patchInfo == null)
			{
				DBG.blogDebug("no patches on " + method.Name);
				return;
			}
			DBG.blogDebug("Attempting to remove Patches from " + method.Name);
			ReadOnlyCollection<Patch> readOnlyCollection = ((!isPrefix) ? patchInfo.Postfixes : patchInfo.Prefixes);
			DBG.blogDebug("Patch owners: " + string.Join(",", patchInfo.Owners));
			foreach (Patch item in readOnlyCollection)
			{
				DBG.blogDebug("owner: " + item.owner);
				DBG.blogDebug("patch method Name: " + item.PatchMethod.Name);
				int priority = item.priority;
				DBG.blogDebug("priority: " + priority);
				for (int i = 0; i < patchNames.Length; i++)
				{
					string[] array = patchNames[i].Split(new char[1] { '/' });
					if (item.owner == array[0] && (array.Length < 2 || item.PatchMethod.Name == array[1]))
					{
						Setup.harmony.Unpatch(method, item.PatchMethod);
						DBG.blogDebug("Unpatched method Name: " + item.PatchMethod.Name);
					}
				}
			}
		}
	}
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("meldurson.MountUpRestored", "Mount Up Restored", "3.5.1")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Setup : BaseUnityPlugin
	{
		private const string ModGUID = "meldurson.MountUpRestored";

		public static ManualLogSource logger;

		public static GameObject boarSaddlePrefab;

		public static ItemDrop boarSaddleItem;

		public static ItemDrop wolfSaddleItem;

		public static ItemDrop loxSaddleItem;

		public static GameObject wolfSaddlePrefab;

		public static GameObject genericSaddlePrefab;

		public static GameObject[] tieredSaddlePrefabs = (GameObject[])(object)new GameObject[9];

		public static ItemDrop[] tieredSaddleItems = (ItemDrop[])(object)new ItemDrop[9];

		public static bool lateLoad = false;

		public static Vector3 boarMountPos = new Vector3(-0.509f, -0.2195f, 0.0495f);

		public static Vector3 wolfMountPos = new Vector3(-0.327f, -0.127f, 0.023f);

		public static Vector3 boarSaddlePos = new Vector3(0.0189f, -0.283f, 0f);

		public static Vector3 wolfSaddlePos = new Vector3(0.00398f, -0.177f, 0f);

		public static Vector3 boarLocalScale = new Vector3(0.9f, 1f, 1f);

		public static Vector3 wolfLocalScale = new Vector3(0.9f, 1.27f, 1.05f);

		public static Vector3 rotationAdjust = new Vector3(0f, -90f, 180f);

		public static Vector3 posDefault = new Vector3(0f, 0.01f, 0f);

		public static ConfigEntry<bool> canMountPlayer;

		public static ConfigEntry<float> BoarStamina;

		public static ConfigEntry<float> WolfStamina;

		public static ConfigEntry<float> LoxStamina;

		public static ConfigEntry<float> AsksvinStamina;

		public static ConfigEntry<float> FedStaminaMultiplier;

		public static ConfigEntry<bool> adjustCustom;

		public static ConfigEntry<KeyboardShortcut> adjustCustomModeSwitch;

		public static KeyboardShortcut saveMountKeys = new KeyboardShortcut((KeyCode)115, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 });

		public static ButtonConfig adjustCustomModeSwitchButton;

		public static ConfigEntry<bool> debugout;

		public static ConfigEntry<bool> teleportMounts;

		public static ConfigEntry<int> customMountCount;

		public static Dictionary<string, int> mountNameDict;

		public static List<ConfigEntry<string>> customMountNames;

		public static List<ConfigEntry<int>> customMountSaddleTiers;

		public static List<ConfigEntry<Vector3>> customMountPoints;

		public static List<ConfigEntry<Vector3>> customSaddlePos;

		public static List<ConfigEntry<Vector3>> customSaddleScale;

		public static List<ConfigEntry<Vector3>> customSaddleRot;

		public static List<ConfigEntry<float>> customMountFlyStamina;

		public static List<ConfigEntry<float>> customStamina;

		public static List<ConfigEntry<string>> customTightMountPaths;

		public static ConfigEntry<Vector3> MountPointAdjustment;

		private static ConfigEntry<KeyboardShortcut> mountModifierKey;

		public static ConfigEntry<bool> useBlockforSecondary;

		public static ConfigEntry<string> saddleNames;

		public static ConfigEntry<string> saddleT1_recipe;

		public static ConfigEntry<string> saddleT1_station;

		public static ConfigEntry<string> saddleT2_recipe;

		public static ConfigEntry<string> saddleT2_station;

		public static ConfigEntry<string> saddleT3_recipe;

		public static ConfigEntry<string> saddleT3_station;

		public static ConfigEntry<string> saddleT4_recipe;

		public static ConfigEntry<string> saddleT4_station;

		public static ConfigEntry<string> saddleT5_recipe;

		public static ConfigEntry<string> saddleT5_station;

		public static ConfigEntry<string> saddleT6_recipe;

		public static ConfigEntry<string> saddleT6_station;

		public static ConfigEntry<string> saddleT7_recipe;

		public static ConfigEntry<string> saddleT7_station;

		public static ConfigEntry<string> saddleT8_recipe;

		public static ConfigEntry<string> saddleT8_station;

		public static ConfigEntry<bool> canAttackMounted;

		public static ConfigEntry<bool> mountsCanDrown;

		public static GameObject SalObj;

		public static Dictionary<string, Mount> customMounts = new Dictionary<string, Mount>();

		public static Dictionary<string, Mount> removeMounts = new Dictionary<string, Mount>();

		public static List<string> LateLoadMounts = new List<string>();

		public static List<string> AddFullMountToYaml = new List<string>();

		public static List<string> AddJustPathToYaml = new List<string>();

		public static string[] TieredSaddleNames = new string[9];

		public static Dictionary<string, Mount> legacyMounts = new Dictionary<string, Mount>();

		public static Vector3 legacyOffset = new Vector3(0.048f, 0.035f, -0.205f);

		public static Vector3 legacyScale = new Vector3(1.7f, 0.77f, 1f);

		public static bool isWritingYML = false;

		public static bool RecipesMade = false;

		private static string AssetPath = "Assets/Saddles/";

		public static CustomRPC jot_MountlistRPC;

		public static bool MountUpdate = false;

		public GameObject Root;

		public static Harmony harmony = new Harmony("meldurson.MountUpRestored");

		public static Setup instance = null;

		public static bool localizeLoaded = false;

		private void Awake()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//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_00b7: Expected O, but got Unknown
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Expected O, but got Unknown
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Expected O, but got Unknown
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Expected O, but got Unknown
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Expected O, but got Unknown
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Expected O, but got Unknown
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Expected O, but got Unknown
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Expected O, but got Unknown
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Expected O, but got Unknown
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Expected O, but got Unknown
			//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Expected O, but got Unknown
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Expected O, but got Unknown
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Expected O, but got Unknown
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Expected O, but got Unknown
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_039b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Expected O, but got Unknown
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Expected O, but got Unknown
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Expected O, but got Unknown
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Expected O, but got Unknown
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Expected O, but got Unknown
			//IL_0456: Unknown result type (might be due to invalid IL or missing references)
			//IL_045b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0464: Expected O, but got Unknown
			//IL_0464: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Expected O, but got Unknown
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Expected O, but got Unknown
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Expected O, but got Unknown
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04db: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e4: Expected O, but got Unknown
			//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ee: Expected O, but got Unknown
			//IL_0516: Unknown result type (might be due to invalid IL or missing references)
			//IL_051b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Expected O, but got Unknown
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_052e: Expected O, but got Unknown
			//IL_0556: Unknown result type (might be due to invalid IL or missing references)
			//IL_055b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0564: Expected O, but got Unknown
			//IL_0564: Unknown result type (might be due to invalid IL or missing references)
			//IL_056e: Expected O, but got Unknown
			//IL_0596: Unknown result type (might be due to invalid IL or missing references)
			//IL_059b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Expected O, but got Unknown
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Expected O, but got Unknown
			//IL_05d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05db: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e4: Expected O, but got Unknown
			//IL_05e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ee: Expected O, but got Unknown
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			//IL_061b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Expected O, but got Unknown
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_062e: Expected O, but got Unknown
			//IL_0656: Unknown result type (might be due to invalid IL or missing references)
			//IL_065b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Expected O, but got Unknown
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Expected O, but got Unknown
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Expected O, but got Unknown
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Expected O, but got Unknown
			//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06db: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e4: Expected O, but got Unknown
			//IL_06e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Expected O, but got Unknown
			//IL_0716: Unknown result type (might be due to invalid IL or missing references)
			//IL_071b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Expected O, but got Unknown
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_072e: Expected O, but got Unknown
			//IL_0756: Unknown result type (might be due to invalid IL or missing references)
			//IL_075b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0764: Expected O, but got Unknown
			//IL_0764: Unknown result type (might be due to invalid IL or missing references)
			//IL_076e: Expected O, but got Unknown
			//IL_0793: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d8: Expected O, but got Unknown
			logger = ((BaseUnityPlugin)this).Logger;
			UseFileOpenReadTextWithSystemTextYaml();
			debugout = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Debug Output", false, new ConfigDescription("Determines if debug is output to bepinex log", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = false
			} }));
			canMountPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Mount Player", false, new ConfigDescription("Experimental: Can Players be mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			teleportMounts = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Teleport Mounts", true, new ConfigDescription("Allow Mounts to Teleport with their rider", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			BoarStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Boar Stamina", 60f, new ConfigDescription("Mounted Boar Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			WolfStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Wolf Stamina", 120f, new ConfigDescription("Mounted Wolf Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			LoxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Lox Stamina Override", -1f, new ConfigDescription("Override Lox Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			AsksvinStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Asksvin Stamina Override", -1f, new ConfigDescription("Override Asksvin Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			FedStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Stamina Regen Multiplier", 1f, new ConfigDescription("Multiply stamina regen rate when mount is fed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			MountPointAdjustment = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Micromanagement", "Mount Point Adjustment", Vector3.zero, (ConfigDescription)null);
			mountModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Player Mount Modifier Key", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "This key plus your interact key will attempt to mount another player");
			adjustCustom = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Mounts", "Enable Adjust Custom Mounts", false, new ConfigDescription("Enable Controls to adjust custom mount's mount points and saddle position", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			canAttackMounted = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Attack Mounted", true, new ConfigDescription("Allow mount to attack using attack keys while mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			mountsCanDrown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Land Mounts can Drown", true, new ConfigDescription("Do land mounts start to take damage if you run out of stamina when swimming", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			useBlockforSecondary = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Block Key to Perform Secondary", true, new ConfigDescription("Determines if while mounted the block key also performs secondary attack", (AcceptableValueBase)null, Array.Empty<object>()));
			saddleNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Saddle Names", "Meadows Saddle,Forest Saddle,Swamp Saddle,Mountain Saddle,Plains Saddle,Mistlands Saddle,Ashlands Saddle,Deep North Saddle,", new ConfigDescription("Set the names of the different tiers of Saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			saddleT1_recipe = ((BaseUnityPlugin)this).Config.Bind<string>("Recipes", "Tier 1 Saddle Recipe", "LeatherScraps:6,DeerHide:4,HardAntler:2,Dandelion:10", new ConfigDescription("What is the recipe for crafting the Tier 1 Saddle, separate amount with : and different items with ,", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			saddleT1_station = ((BaseUnityPlugin)this).Config.Bind<string>("Recipes", "Tier 1 Saddle Station", "piece_workbench:1", new ConfigDescription("What is the required Crafting Station and Level, separated by a: such as piece_workbench:3 would be lvl 3 Workbench(vanilla stations are: piece_workbench, forge, piece_cauldron, piece_stonecutter, piece_artisanstation, blackforge, piece_magetable, piece_MeadCauldron, piece_preptable", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				IsAdminOnly = true
			} }));
			saddleT2_recipe = ((BaseUnityPlugin)this).Config.Bind<string>("Recipes", "Tier 2 Saddle Recipe", "Tr