Decompiled source of MountUpRestored v3.3.2

MountUpRestored.dll

Decompiled 2 weeks 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 AllTameable;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using MountUp;
using MountUp.ModCompat;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
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: AssemblyCompany("Microsoft")]
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("MountUp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyProduct("MountUp")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("9e1c6dc2-1a11-4768-96f1-0f71c70e1dbe")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyCopyright("Copyright © Microsoft 2021")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInPlugin("meldurson.MountUpRestored", "Mount Up Restored", "3.3.2")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Setup : BaseUnityPlugin
{
	public const string PluginGUID = "meldurson.MountUpRestored";

	public const string PluginName = "Mount Up Restored";

	public const string PluginVersion = "3.3.2";

	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 Vector3 boarMountPos = new Vector3(-0.509f, -0.2195f, 0.0495f);

	public static Vector3 wolfMountPos = new Vector3(-0.393f, -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<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> 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<KeyCode> mountModifierKey;

	public static ConfigEntry<bool> canAttackMounted;

	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> AddFullMountToYaml = new List<string>();

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

	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;

	private void Awake()
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Expected O, but got Unknown
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Expected O, but got Unknown
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Expected O, but got Unknown
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Expected O, but got Unknown
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Expected O, but got Unknown
		//IL_0109: 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_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Expected O, but got Unknown
		//IL_01b9: 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_0204: Expected O, but got Unknown
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Expected O, but got Unknown
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Expected O, but got Unknown
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f0: Expected O, but got Unknown
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Expected O, but got Unknown
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_037e: Expected O, but got Unknown
		//IL_03e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f8: Expected O, but got Unknown
		//IL_03f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: 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_0468: Expected O, but got Unknown
		//IL_0468: Unknown result type (might be due to invalid IL or missing references)
		//IL_0472: Expected O, but got Unknown
		//IL_04b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Expected O, but got Unknown
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dc: Expected O, but got Unknown
		//IL_04f0: 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_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		//IL_053c: Expected O, but got Unknown
		//IL_053c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Expected O, but got Unknown
		//IL_055a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0585: Unknown result type (might be due to invalid IL or missing references)
		//IL_0598: Unknown result type (might be due to invalid IL or missing references)
		//IL_059d: Unknown result type (might be due to invalid IL or missing references)
		//IL_05aa: Expected O, but got Unknown
		//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Expected O, but got Unknown
		//IL_05c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_05f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0606: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0618: Expected O, but got Unknown
		//IL_0618: Unknown result type (might be due to invalid IL or missing references)
		//IL_0622: Expected O, but got Unknown
		//IL_0636: Unknown result type (might be due to invalid IL or missing references)
		//IL_0674: Unknown result type (might be due to invalid IL or missing references)
		//IL_0679: Unknown result type (might be due to invalid IL or missing references)
		//IL_0686: Expected O, but got Unknown
		//IL_0686: Unknown result type (might be due to invalid IL or missing references)
		//IL_0690: Expected O, but got Unknown
		//IL_0715: Unknown result type (might be due to invalid IL or missing references)
		//IL_071a: Unknown result type (might be due to invalid IL or missing references)
		//IL_087a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0884: Expected O, but got Unknown
		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
		} }));
		MountPointAdjustment = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Micromanagement", "Mount Point Adjustment", Vector3.zero, (ConfigDescription)null);
		mountModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "Player Mount Modifier Key", (KeyCode)304, "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, "Enable Controls to adjust custom mount's mount points and saddle position");
		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
		} }));
		adjustCustomModeSwitch = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Custom Mounts", "Adjust Custom Mount Mode Switch", new KeyboardShortcut((KeyCode)96, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		customMountCount = ((BaseUnityPlugin)this).Config.Bind<int>("Custom Mounts", "CustomMountCount", 1, new ConfigDescription("Obsolete: Number of Custom Mounts to read from config, add names of creatures to YML", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, int.MaxValue), new object[1] { (object)new ConfigurationManagerAttributes
		{
			Browsable = false
		} }));
		mountNameDict = new Dictionary<string, int>();
		customMountNames = new List<ConfigEntry<string>>();
		customMountSaddleTiers = new List<ConfigEntry<int>>();
		customMountPoints = new List<ConfigEntry<Vector3>>();
		customSaddlePos = new List<ConfigEntry<Vector3>>();
		customSaddleScale = new List<ConfigEntry<Vector3>>();
		customSaddleRot = new List<ConfigEntry<Vector3>>();
		customMountFlyStamina = new List<ConfigEntry<float>>();
		customStamina = new List<ConfigEntry<float>>();
		customTightMountPaths = new List<ConfigEntry<string>>();
		logger = ((BaseUnityPlugin)this).Logger;
		UseFileOpenReadTextWithSystemTextYaml();
		Vector3 val = default(Vector3);
		for (int i = 1; i <= customMountCount.Value; i++)
		{
			Mount mount = new Mount();
			customMountNames.Add(((BaseUnityPlugin)this).Config.Bind<string>($"Custom Mount {i}", "Name", $"CustomMount {i}", new ConfigDescription("Custom Mount Prefab Name", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mountNameDict.Add(customMountNames[i - 1].Value, i - 1);
			mount.PrefabName = customMountNames[i - 1].Value;
			customTightMountPaths.Add(((BaseUnityPlugin)this).Config.Bind<string>($"Custom Mount {i}", "Mount Path", "", new ConfigDescription("Path in Mount Prefab where Saddle and player Mount Point should be placed (example: For the Boar it would be 'CG/Pelvis/Spine/Spine1'", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.mountPath = customTightMountPaths[i - 1].Value;
			((Vector3)(ref val))..ctor(0f, 1f, 0f);
			customStamina.Add(((BaseUnityPlugin)this).Config.Bind<float>($"Custom Mount {i}", "Stamina", 120f, new ConfigDescription("Custom Mount Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.stamina = customStamina[i - 1].Value;
			customMountSaddleTiers.Add(((BaseUnityPlugin)this).Config.Bind<int>($"Custom Mount {i}", "Saddle Tier", 3, new ConfigDescription("Custom Mount Saddle Tier (1=Simple/Boar Saddle, 2=Standard/Wolf Saddle, 3=Advanced/Lox Saddle", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 3), new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.saddleTier = customMountSaddleTiers[i - 1].Value;
			customMountPoints.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Mount Point", val, new ConfigDescription("Point relative to the Mount Path that player should be mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.mountPoint = customMountPoints[i - 1].Value;
			customSaddlePos.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Position", val, new ConfigDescription("Point relative to the Mount Path where the saddle should be placed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.saddlePos = customSaddlePos[i - 1].Value;
			customSaddleScale.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Scale", Vector3.one, new ConfigDescription("Scaling of the saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.saddleScale = customSaddleScale[i - 1].Value;
			customSaddleRot.Add(((BaseUnityPlugin)this).Config.Bind<Vector3>($"Custom Mount {i}", "Saddle Rotation", Vector3.zero, new ConfigDescription("Rotation of the saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.saddleRotation = customSaddleRot[i - 1].Value;
			customMountFlyStamina.Add(((BaseUnityPlugin)this).Config.Bind<float>($"Custom Mount {i}", "Flying Stamina", 0f, new ConfigDescription("Stamina Drain for Flying", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
			{
				Browsable = false
			} })));
			mount.flyingStamina = customMountFlyStamina[i - 1].Value;
			if (!customMounts.ContainsKey(customMountNames[i - 1].Value))
			{
				legacyMounts.Add(customMountNames[i - 1].Value, mount);
				ManualLogSource obj2 = logger;
				string value = customMountNames[i - 1].Value;
				Vector3 mountPoint = mount.mountPoint;
				obj2.LogMessage((object)("added from config=" + value + ", " + ((object)(Vector3)(ref mountPoint)).ToString()));
			}
		}
		if (Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml").Count() == 0)
		{
			create_YML();
		}
		WriteMounts();
		logger.LogMessage((object)"Finished loading in custom mounts");
		LoadBuiltInMounts();
		string text = "List of Mounts: ";
		foreach (KeyValuePair<string, Mount> customMount in customMounts)
		{
			text = text + customMount.Key + ", ";
		}
		logger.LogMessage((object)text.TrimEnd(',', ' '));
		Patches.Apply();
		PrefabManager.OnVanillaPrefabsAvailable += LoadAssets;
		PrefabManager.OnVanillaPrefabsAvailable += CreateSaddles;
		PrefabManager.OnVanillaPrefabsAvailable += SetupMountable;
		SynchronizationManager.OnConfigurationSynchronized += delegate
		{
			MountUpdate = true;
		};
		jot_MountlistRPC = NetworkManager.Instance.AddRPC("jot_MountlistRPC", (CoroutineHandler)null, new CoroutineHandler(jot_RPCClientReceive));
		SynchronizationManager.Instance.AddInitialSynchronization(jot_MountlistRPC, (Func<ZPackage>)SendInitialConfig);
	}

	private void LoadAssets()
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		AssetBundle val = AssetUtils.LoadAssetBundleFromResources("mountupassets", typeof(Setup).Assembly);
		genericSaddlePrefab = (GameObject)val.LoadAsset("Assets/MeldursonAssets/SaddleBase.prefab", typeof(GameObject));
		for (int i = 0; i < 9; i++)
		{
			tieredSaddlePrefabs[i] = (GameObject)val.LoadAsset(AssetPath + "SaddleT" + i + ".prefab", typeof(GameObject));
			PrefabExtension.FixReferences(tieredSaddlePrefabs[i], true);
		}
		PrefabManager.OnVanillaPrefabsAvailable -= LoadAssets;
	}

	private ZPackage SendInitialConfig()
	{
		logger.LogWarning((object)"Sent Client MountList RPC");
		CfgPackage cfgPackage = new CfgPackage();
		return cfgPackage.PackMountlist();
	}

	private static void LoadBuiltInMounts()
	{
		//IL_003a: 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_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		if (!customMounts.ContainsKey("Wolf"))
		{
			Mount mount = new Mount();
			mount.PrefabName = "Wolf";
			mount.mountPath = "WolfSmooth/CG/Pelvis/Spine/Spine1";
			mount.mountPoint = wolfMountPos;
			mount.saddlePos = wolfSaddlePos;
			mount.saddleTier = 4;
			mount.stamina = WolfStamina.Value;
			mount.saddleScale = wolfLocalScale;
			mount.saddleRotation = Vector3.zero;
			customMounts.Add("Wolf", mount);
			logger.LogMessage((object)("added from default=" + mount.PrefabName));
		}
		if (!customMounts.ContainsKey("Boar"))
		{
			Mount mount2 = new Mount();
			mount2.PrefabName = "Boar";
			mount2.mountPath = "CG/Pelvis/Spine/Spine1";
			mount2.mountPoint = boarMountPos;
			mount2.saddlePos = boarSaddlePos;
			mount2.saddleTier = 1;
			mount2.stamina = BoarStamina.Value;
			mount2.saddleScale = boarLocalScale;
			mount2.saddleRotation = Vector3.zero;
			customMounts.Add("Boar", mount2);
			logger.LogMessage((object)("added from default=" + mount2.PrefabName));
		}
	}

	private IEnumerator jot_RPCClientReceive(long sender, ZPackage package)
	{
		logger.LogWarning((object)"Client received MountList RPC");
		yield return null;
		removeMounts = customMounts;
		CfgPackage.Unpack(package);
		SetupMountable();
		CreateSaddles();
	}

	public static void writeYML()
	{
		logger.LogWarning((object)"Writing to YML");
		if (!ZNet.instance.IsServer())
		{
			logger.LogWarning((object)"not Server, cancelling WriteYML");
		}
		else
		{
			if (isWritingYML)
			{
				return;
			}
			try
			{
				isWritingYML = true;
				if (AddFullMountToYaml.Count <= 0)
				{
					isWritingYML = false;
					return;
				}
				WriteMounts();
				isWritingYML = false;
			}
			catch
			{
				logger.LogWarning((object)"Error in Writing YML");
				isWritingYML = false;
			}
			isWritingYML = false;
		}
	}

	public static List<Mount> ParseMounts(string ymlContents)
	{
		Parser parser = new Parser(new StringReader(ymlContents));
		IDeserializer deserializer = new DeserializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
		parser.Consume<YamlDotNet.Core.Events.StreamStart>();
		if (!parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out var _))
		{
			return new List<Mount>();
		}
		parser.Consume<MappingStart>();
		List<Mount> list = new List<Mount>();
		YamlDotNet.Core.Events.Scalar event2;
		while (parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out event2))
		{
			try
			{
				Mount mount;
				if (parser.Current.GetType() != typeof(MappingStart))
				{
					if ((event2.Value ?? "") == "")
					{
						continue;
					}
					mount = new Mount();
					goto IL_00c5;
				}
				mount = new Mount(deserializer.Deserialize<MountSerialized>(parser));
				goto IL_00c5;
				IL_00c5:
				if ((mount.PrefabName ?? "") == "")
				{
					mount.PrefabName = event2.Value;
				}
				list.Add(mount);
			}
			catch
			{
				logger.LogWarning((object)("Failed to parse " + event2.Value + " from yaml, check to make sure this prefab is formated correctly"));
			}
		}
		return list;
	}

	public static string formatMountYML(string mountYML, string prefabName)
	{
		mountYML = mountYML.Replace("\n", "\n  ").Replace("'", "");
		if (mountYML.StartsWith("prefabName:"))
		{
			mountYML = mountYML.Remove(0, mountYML.IndexOf("\n") + 1);
		}
		return prefabName + ":\n" + mountYML + "\n";
	}

	public static bool create_YML()
	{
		string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml");
		if (files.Count() > 0)
		{
			logger.LogError((object)"There are already MountUpRestored_CustomMounts in your config folder, check to make sure they are formatted correctly");
			logger.LogError((object)"The files are:");
			string[] array = files;
			foreach (string text in array)
			{
				logger.LogError((object)text);
			}
			return false;
		}
		string path = Path.Combine(Path.GetDirectoryName(Paths.BepInExConfigPath), Path.GetFileName("MountUpRestored_CustomMounts.yml"));
		File.Create(path).Dispose();
		string contents = "#   To start setup for mounting a creature, add the creature prefab name on its own line followed by a colon : such as\nPrefabName:\n#   Once loading into the game and coming across this creature it will attempt to snap the saddle to the correct bone and complete the rest of the config in this file\n#   By default the required saddle is a Tier 3 saddle (Advanced Saddle) that you will need to use on the creature to mount it.\n#   To adjust the mounting location you will need to set Enable Adjust Custom Mounts = true in meldurson.MountUpRestored.cfg\n#   You can also find a bunch of premade configurations *****HERE***** that you can copy/paste parts into this file, or paste the entire config into your config folder\n\n";
		File.AppendAllText(path, contents);
		return true;
	}

	public static void WriteMounts()
	{
		if (AddFullMountToYaml.Count <= 0)
		{
			return;
		}
		string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml");
		if (files.Count() > 0)
		{
			ISerializer serializer = new SerializerBuilder().WithNamingConvention(CamelCaseNamingConvention.Instance).Build();
			string[] array = files;
			foreach (string path in array)
			{
				string text = File.ReadAllText(path);
				if ((text.Trim(' ', '\n', '\t') ?? "") == "")
				{
					continue;
				}
				Parser parser = new Parser(new StringReader(text));
				parser.Consume<YamlDotNet.Core.Events.StreamStart>();
				if (!parser.TryConsume<YamlDotNet.Core.Events.DocumentStart>(out var _))
				{
					continue;
				}
				parser.Consume<MappingStart>();
				int num = 0;
				bool flag = false;
				bool flag2 = false;
				YamlDotNet.Core.Events.Scalar event2;
				while (parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out event2))
				{
					if (flag)
					{
						for (int j = 0; j < num; j++)
						{
							parser.SkipThisAndNestedEvents();
							if (!parser.TryConsume<YamlDotNet.Core.Events.Scalar>(out var event3))
							{
								flag2 = true;
							}
							else
							{
								event2 = event3;
							}
						}
					}
					if (flag2)
					{
						break;
					}
					flag = false;
					num++;
					try
					{
						if (!AddFullMountToYaml.Contains(event2.Value))
						{
							parser.SkipThisAndNestedEvents();
							continue;
						}
						if (!customMounts.TryGetValue(event2.Value, out var value))
						{
							logger.LogWarning((object)("Could not find" + event2.Value + "in MountsToOverwrite, skipping write"));
							parser.SkipThisAndNestedEvents();
							continue;
						}
						MountToYaml graph = new MountToYaml(value);
						string value2 = formatMountYML(serializer.Serialize(graph), event2.Value);
						parser.SkipThisAndNestedEvents();
						string text2 = text.Remove(event2.Start.Index, parser.Current.Start.Index - 1 - event2.Start.Index).Insert(event2.Start.Index, value2);
						text = text2;
						AddFullMountToYaml.Remove(event2.Value);
						parser = new Parser(new StringReader(text));
						flag = true;
						parser.Consume<YamlDotNet.Core.Events.StreamStart>();
						parser.Consume<YamlDotNet.Core.Events.DocumentStart>();
						parser.Consume<MappingStart>();
					}
					catch
					{
						logger.LogWarning((object)("Failed to parse " + event2.Value + " from yaml, check to make sure this prefab is formated correctly"));
					}
				}
				File.WriteAllText(path, text);
				logger.LogMessage((object)"Overwrote existing creatures to yaml");
			}
			if (AddFullMountToYaml.Count <= 0)
			{
				return;
			}
			string text3 = "\n";
			foreach (string item in AddFullMountToYaml)
			{
				if (!customMounts.TryGetValue(item, out var value3))
				{
					logger.LogWarning((object)("Could not find" + item + "in MountsToOverwrite, skipping write"));
					continue;
				}
				logger.LogWarning((object)("writing " + item + " to " + files[0]));
				string text4 = formatMountYML(serializer.Serialize(new MountToYaml(value3)), item);
				text3 += text4;
			}
			File.AppendAllText(files[0], text3);
			logger.LogWarning((object)"Saved creatures to YML");
		}
		else
		{
			logger.LogWarning((object)"no MountList files, creating one");
			if (create_YML())
			{
				WriteMounts();
			}
		}
	}

	public static List<Mount> UseFileOpenReadTextWithSystemTextYaml()
	{
		string[] files = Directory.GetFiles(Path.GetDirectoryName(Paths.BepInExConfigPath), "MountUpRestored_CustomMounts*.yml");
		List<Mount> list = new List<Mount>();
		if (files.Count() > 0)
		{
			string[] array = files;
			foreach (string path in array)
			{
				string ymlContents = File.ReadAllText(path);
				List<Mount> list2 = ParseMounts(ymlContents);
				if (list2[0].PrefabName == "PrefabName")
				{
					list2.RemoveAt(0);
				}
				foreach (Mount mount in list2)
				{
					if (!list.Exists((Mount x) => x.PrefabName == mount.PrefabName) && !((mount.PrefabName ?? "") == ""))
					{
						list.Add(mount);
						if (!customMounts.ContainsKey(mount.PrefabName))
						{
							customMounts.Add(mount.PrefabName, mount);
						}
					}
				}
			}
		}
		else
		{
			logger.LogWarning((object)"no config files");
		}
		return list;
	}

	public static string StringVec(Vector3 vec)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		return $"{{\"x\":{vec.x:F2},\"y\":{vec.y:F2},\"z\":{vec.z:F2}" + "}";
	}

	public static void MakeMountable(Tameable tame, bool legacy = false)
	{
		string name = ((Object)tame).name;
		bool flag = false;
		if (name == "Lox")
		{
			return;
		}
		Mount value2;
		if (customMounts.TryGetValue(name, out var value))
		{
			if (int.TryParse(value.customSaddle, out var result) && result <= 8 && result >= 0)
			{
				tame.m_saddleItem = tieredSaddleItems[result];
			}
			else
			{
				bool flag2 = false;
				if ((value.customSaddle ?? "") != "")
				{
					GameObject prefab = PrefabManager.Instance.GetPrefab(value.customSaddle);
					if (Object.op_Implicit((Object)(object)prefab))
					{
						ItemDrop saddleItem = default(ItemDrop);
						if (prefab.TryGetComponent<ItemDrop>(ref saddleItem))
						{
							tame.m_saddleItem = saddleItem;
							flag2 = true;
						}
						else
						{
							logger.LogWarning((object)("Unable to find itemDrop in object :" + value.customSaddle + " to use as a custom saddle item for " + name + ". Please make sure to use the an items prefab name"));
						}
					}
					else
					{
						logger.LogWarning((object)("Unable to find GameObject :" + value.customSaddle + " to use as a custom saddle item for " + name + ". Please make sure to use the prefab name"));
					}
				}
				if (!flag2)
				{
					result = ((value.saddleTier == 0) ? 5 : value.saddleTier);
					tame.m_saddleItem = tieredSaddleItems[result];
				}
			}
			flag = true;
		}
		else if (removeMounts.TryGetValue(name, out value2))
		{
			tame.m_saddleItem = null;
			Mountable mountable = default(Mountable);
			if (((Component)tame).gameObject.TryGetComponent<Mountable>(ref mountable))
			{
				logger.LogWarning((object)("removed " + name + " from mountable"));
				Object.DestroyImmediate((Object)(object)mountable);
			}
			return;
		}
		if ((Object)(object)((Component)tame).gameObject.GetComponent<Mountable>() == (Object)null)
		{
			if (legacy)
			{
				((Component)tame).gameObject.AddComponent<Mountable_L>().Type = name;
			}
			else if (flag)
			{
				((Component)tame).gameObject.AddComponent<Mountable>().Type = name;
			}
		}
	}

	private static void SetupMountable()
	{
		Tameable[] array = Resources.FindObjectsOfTypeAll<Tameable>();
		for (int i = 0; i < array.Length; i++)
		{
			MakeMountable(array[i]);
		}
		PrefabManager.OnVanillaPrefabsAvailable -= SetupMountable;
	}

	private static void RemoveMounts()
	{
		Tameable[] array = (from m in Resources.FindObjectsOfTypeAll<Tameable>()
			where !((Object)m).name.Contains("(Clone)")
			select m).ToArray();
		Mountable mountable = default(Mountable);
		for (int i = 0; i < array.Length; i++)
		{
			if (((Component)array[i]).gameObject.TryGetComponent<Mountable>(ref mountable))
			{
				Object.DestroyImmediate((Object)(object)mountable);
				array[i].m_saddleItem = null;
			}
		}
		PrefabManager.OnVanillaPrefabsAvailable += SetupMountable;
	}

	public static void ResetAllMounts()
	{
		RemoveMounts();
		customMounts.Clear();
		removeMounts.Clear();
		UseFileOpenReadTextWithSystemTextYaml();
		LoadBuiltInMounts();
		CreateSaddles();
	}

	public static void CreateSaddles()
	{
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Expected O, but got Unknown
		List<string>[] array = new List<string>[9];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = new List<string>();
		}
		Character val = default(Character);
		foreach (KeyValuePair<string, Mount> customMount in customMounts)
		{
			int result = -1;
			GameObject prefab = PrefabManager.Instance.GetPrefab(customMount.Key);
			string item = customMount.Key;
			if (prefab.TryGetComponent<Character>(ref val))
			{
				item = val.m_name;
			}
			if (!int.TryParse(customMount.Value.customSaddle, out result) || result > 8 || result < 0)
			{
				result = ((customMount.Value.saddleTier == 0) ? 5 : customMount.Value.saddleTier);
			}
			array[result].Add(item);
		}
		for (int j = 0; j < array.Length; j++)
		{
			string text = "A smaller simpler saddle, it should be good for smaller calmer creatures such as ";
			if (j > 4)
			{
				text = "A well-made, sturdy saddle. It should be good for fiercer creatures such as ";
			}
			else if (j > 2)
			{
				text = "Well crafted saddle able to ride strong creatures such as ";
			}
			if (array[j].Count == 0)
			{
				text = text.Replace(" such as", ".");
			}
			text += string.Join(", ", array[j]);
			text = text.TrimEnd(',', ' ');
			CustomItem item2 = ItemManager.Instance.GetItem("SaddleT" + j);
			if (item2 != null)
			{
				item2.ItemDrop.m_itemData.m_shared.m_description = text;
				continue;
			}
			CustomItem val2 = new CustomItem(((Component)tieredSaddlePrefabs[j].transform.GetChild(1)).gameObject, true, CreateRecipes(j));
			ItemManager.Instance.AddItem(val2);
			tieredSaddleItems[j] = val2.ItemDrop;
			val2.ItemDrop.m_itemData.m_shared.m_name = "Tier " + j + " Saddle";
			val2.ItemDrop.m_itemData.m_dropPrefab = tieredSaddlePrefabs[j];
			val2.ItemDrop.m_itemData.m_shared.m_weight = 5f + (float)j;
			val2.ItemDrop.m_itemData.m_shared.m_description = text;
		}
		PrefabManager.OnVanillaPrefabsAvailable -= CreateSaddles;
		if (!RecipesMade)
		{
			RecipesMade = true;
		}
	}

	private static ItemConfig CreateRecipes(int recipeNum)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Expected O, but got Unknown
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Expected O, but got Unknown
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Expected O, but got Unknown
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Expected O, but got Unknown
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Expected O, but got Unknown
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Expected O, but got Unknown
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Expected O, but got Unknown
		//IL_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Expected O, but got Unknown
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Expected O, but got Unknown
		//IL_013e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Expected O, but got Unknown
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Expected O, but got Unknown
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_018a: Expected O, but got Unknown
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_019e: Expected O, but got Unknown
		//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Expected O, but got Unknown
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Expected O, but got Unknown
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Expected O, but got Unknown
		//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Expected O, but got Unknown
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_021c: Expected O, but got Unknown
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Expected O, but got Unknown
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Expected O, but got Unknown
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Expected O, but got Unknown
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Expected O, but got Unknown
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Expected O, but got Unknown
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ae: Expected O, but got Unknown
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Expected O, but got Unknown
		//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Expected O, but got Unknown
		//IL_02fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_0304: Expected O, but got Unknown
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0319: Expected O, but got Unknown
		//IL_0323: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Expected O, but got Unknown
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Expected O, but got Unknown
		//IL_0362: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Expected O, but got Unknown
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_0381: Expected O, but got Unknown
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Expected O, but got Unknown
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03aa: Expected O, but got Unknown
		ItemConfig val = new ItemConfig();
		switch (recipeNum)
		{
		case 1:
			val.AddRequirement(new RequirementConfig("LeatherScraps", 6, 0, false));
			val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false));
			val.AddRequirement(new RequirementConfig("HardAntler", 2, 0, false));
			val.AddRequirement(new RequirementConfig("Dandelion", 10, 0, false));
			val.CraftingStation = CraftingStations.Workbench;
			val.MinStationLevel = 1;
			break;
		case 2:
			val.AddRequirement(new RequirementConfig("TrollHide", 6, 0, false));
			val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false));
			val.AddRequirement(new RequirementConfig("Bronze", 4, 0, false));
			val.AddRequirement(new RequirementConfig("AncientSeed", 3, 0, false));
			val.CraftingStation = CraftingStations.Forge;
			val.MinStationLevel = 1;
			break;
		case 3:
			val.AddRequirement(new RequirementConfig("DeerHide", 15, 0, false));
			val.AddRequirement(new RequirementConfig("ElderBark", 10, 0, false));
			val.AddRequirement(new RequirementConfig("Iron", 6, 0, false));
			val.AddRequirement(new RequirementConfig("Guck", 10, 0, false));
			val.CraftingStation = CraftingStations.Forge;
			val.MinStationLevel = 2;
			break;
		case 4:
			val.AddRequirement(new RequirementConfig("WolfPelt", 6, 0, false));
			val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false));
			val.AddRequirement(new RequirementConfig("Obsidian", 2, 0, false));
			val.AddRequirement(new RequirementConfig("Silver", 5, 0, false));
			val.AddRequirement(new RequirementConfig("FreezeGland", 10, 0, false));
			val.CraftingStation = CraftingStations.Workbench;
			val.MinStationLevel = 4;
			break;
		case 5:
			val.AddRequirement(new RequirementConfig("LoxPelt", 6, 0, false));
			val.AddRequirement(new RequirementConfig("DeerHide", 4, 0, false));
			val.AddRequirement(new RequirementConfig("BlackMetal", 4, 0, false));
			val.AddRequirement(new RequirementConfig("TrophyLox", 1, 0, false));
			val.AddRequirement(new RequirementConfig("Tar", 5, 0, false));
			val.CraftingStation = CraftingStations.Forge;
			val.MinStationLevel = 3;
			break;
		case 6:
			val.AddRequirement(new RequirementConfig("ScaleHide", 15, 0, false));
			val.AddRequirement(new RequirementConfig("Obsidian", 6, 0, false));
			val.AddRequirement(new RequirementConfig("YggdrasilWood", 6, 0, false));
			val.AddRequirement(new RequirementConfig("Sap", 10, 0, false));
			val.AddRequirement(new RequirementConfig("Eitr", 3, 0, false));
			val.CraftingStation = CraftingStations.Workbench;
			val.MinStationLevel = 5;
			break;
		case 7:
			val.AddRequirement(new RequirementConfig("LoxPelt", 6, 0, false));
			val.AddRequirement(new RequirementConfig("DeerHide", 25, 0, false));
			val.AddRequirement(new RequirementConfig("Flametal", 6, 0, false));
			val.AddRequirement(new RequirementConfig("Tar", 5, 0, false));
			val.CraftingStation = CraftingStations.Forge;
			val.MinStationLevel = 4;
			break;
		case 8:
			val.AddRequirement(new RequirementConfig("WolfPelt", 20, 0, false));
			val.AddRequirement(new RequirementConfig("ScaleHide", 10, 0, false));
			val.AddRequirement(new RequirementConfig("TrophySeekerQueen", 1, 0, false));
			val.AddRequirement(new RequirementConfig("FreezeGland", 50, 0, false));
			val.CraftingStation = CraftingStations.Workbench;
			val.MinStationLevel = 5;
			break;
		}
		return val;
	}
}
namespace MountUp
{
	internal class AdjustmentPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetHoverText")]
		private static void Char_GetHoverText(Character __instance, ref string __result)
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			Mountable mountable = default(Mountable);
			if (!Setup.adjustCustom.Value || !(__instance.m_tamed & ((Component)__instance).gameObject.TryGetComponent<Mountable>(ref mountable)) || !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)
				{
					Debug.LogWarning((object)"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");
			__result = __result.Replace(text, text + "\n[<color=orange><b>Alt+E</b></color>] Sit in Saddle");
		}
	}
	[Serializable]
	public class CfgPackage
	{
		public MountSerialized[] mounts;

		public static ZPackage zpack;

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

		public ZPackage Pack()
		{
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: 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)
			{
				Setup.logger.LogWarning((object)("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)
			{
				Setup.logger.LogMessage((object)"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)
				{
					Setup.logger.LogMessage((object)("mount=" + mountSerialized.PrefabName));
					Setup.customMounts.Add(mountSerialized.PrefabName, new Mount(mountSerialized));
				}
				Setup.logger.LogMessage((object)"Successfully unpacked configs.");
			}
			else
			{
				Setup.logger.LogWarning((object)"Received bad config package. Unable to load.");
			}
		}
	}
	public class Mountable : MonoBehaviour
	{
		private GameObject mountPoint;

		private Transform mountPointBase;

		private GameObject saddle;

		private float flyStaminaDrain = 10f;

		public bool canfly = false;

		private Animator anim;

		public string Type;

		public static ManualLogSource logger;

		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;

		public void Awake()
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//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_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0723: 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_0845: Unknown result type (might be due to invalid IL or missing references)
			//IL_0854: Unknown result type (might be due to invalid IL or missing references)
			//IL_087f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0881: Unknown result type (might be due to invalid IL or missing references)
			//IL_0618: Unknown result type (might be due to invalid IL or missing references)
			//IL_061d: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a2: 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_08b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0899: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0657: Unknown result type (might be due to invalid IL or missing references)
			//IL_065c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: 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_067d: 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_096c: Unknown result type (might be due to invalid IL or missing references)
			//IL_097f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0992: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e9: Unknown result type (might be due to invalid IL or missing references)
			if (logger == null)
			{
				logger = Setup.logger;
			}
			Tameable component = ((Component)this).GetComponent<Tameable>();
			if ((Type ?? "") == "")
			{
				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 = rotationAdjust;
			if (!Setup.customMounts.TryGetValue(Type, out var value))
			{
				return;
			}
			string text = value.mountPath ?? "";
			if (text.Contains("\\"))
			{
				logger.LogWarning((object)(Type + " Mount Path should use '/' rather than '\\', trying to replace"));
				text.Replace('\\', '/');
				value.mountPath = text;
			}
			if (text != "")
			{
				mountPointBase = val.Find(text);
			}
			val2 = value.mountPoint;
			val3 = value.saddlePos;
			one = value.saddleScale;
			val4 = 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;
							logger.LogError((object)text4);
							return;
						}
						text2 += text3;
					}
					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 val5 in array6)
					{
						if (((Object)val5).name.ToLowerInvariant() == text5)
						{
							Transform val6 = val5;
							if (text5 == "neck")
							{
								val6 = val6.parent;
							}
							if ((Object)(object)mountPointBase == (Object)null)
							{
								mountPointBase = val6;
								text = GetPath(val6);
							}
							else if (text5 != "armature")
							{
								list.Add(GetPath(val6));
							}
							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 val7 in array9)
						{
							string text6 = ((Object)val7).name.ToLowerInvariant();
							if (text6.StartsWith(value2) || text6.EndsWith(value2))
							{
								if ((Object)(object)mountPointBase == (Object)null)
								{
									mountPointBase = val7;
									text = GetPath(val7);
								}
								else
								{
									list.Add(GetPath(val7));
								}
								break;
							}
						}
					}
				}
				if (!((Object)(object)mountPointBase != (Object)null))
				{
					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;
					val4 = value.saddleRotation + Setup.rotationAdjust;
				}
				logger.LogMessage((object)("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 = val4;
			saddle.transform.localEulerAngles = val4;
			saddle.GetComponent<Sadle>().m_maxStamina = value.stamina;
			flyStaminaDrain = value.flyingStamina;
			BaseAI baseAI = ((Character)component2).GetBaseAI();
			MonsterAI val8 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null);
			if ((Object)(object)val8 != (Object)null && val8.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 = Type + " Saddle";
			component3.m_attachPoint = mountPoint.transform;
			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 (val4 != rotationAdjust)
			{
				((Component)component3).GetComponentInChildren<Transform>().localEulerAngles = val4;
			}
			val2 += Setup.MountPointAdjustment.Value;
			mountPoint.transform.localPosition = val2;
			if ((Object)(object)component.m_saddle != (Object)null)
			{
				component.m_nview.Register("AddSaddle", (Action<long>)component.RPC_AddSaddle);
				component.m_nview.Register<bool>("SetSaddle", (Action<long, bool>)component.RPC_SetSaddle);
				component.SetSaddle(component.HaveSaddle());
			}
			mountPoint.transform.parent = mountPointBase;
			saddle.transform.parent = mountPointBase;
			mountPoint.transform.localEulerAngles = val4;
			saddle.transform.localEulerAngles = val4;
			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>();
		}

		public void setattacks(Humanoid humanoid)
		{
			if (humanoid.m_inventory != null)
			{
				List<ItemData> inventory = humanoid.m_inventory.m_inventory;
				bool[] array = new bool[4];
				for (int i = 0; i < inventory.Count; i++)
				{
					float totalDamage = ((DamageTypes)(ref inventory[i].m_shared.m_damages)).GetTotalDamage();
					if (totalDamage <= 0f)
					{
						continue;
					}
					if (inventory[i].m_shared.m_aiWhenFlying)
					{
						if (!array[2])
						{
							attackorder[2] = i;
							array[2] = true;
							continue;
						}
						if (array[3])
						{
							if (((DamageTypes)(ref inventory[attackorder[3]].m_shared.m_damages)).GetTotalDamage() < totalDamage)
							{
								attackorder[3] = i;
							}
							continue;
						}
						if (((DamageTypes)(ref inventory[attackorder[2]].m_shared.m_damages)).GetTotalDamage() > totalDamage)
						{
							attackorder[3] = attackorder[2];
							attackorder[2] = i;
						}
						else
						{
							attackorder[3] = i;
						}
						array[3] = true;
					}
					else if (!array[0])
					{
						attackorder[0] = i;
						array[0] = true;
					}
					else if (array[1])
					{
						if (((DamageTypes)(ref inventory[attackorder[1]].m_shared.m_damages)).GetTotalDamage() < totalDamage)
						{
							attackorder[1] = i;
						}
					}
					else
					{
						if (((DamageTypes)(ref inventory[attackorder[0]].m_shared.m_damages)).GetTotalDamage() > totalDamage)
						{
							attackorder[1] = attackorder[0];
							attackorder[0] = i;
						}
						else
						{
							attackorder[1] = i;
						}
						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
			{
				Debug.LogWarning((object)"Creature does not have attacks");
			}
		}

		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);
			}
		}

		public void ResetMountPoint()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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)
			if ((Object)(object)mountPoint == (Object)null)
			{
				Debug.Log((object)"mountPoint null");
			}
			if ((Object)(object)saddle == (Object)null)
			{
				Debug.Log((object)"saddle null");
			}
			if (Object.op_Implicit((Object)(object)mountPoint))
			{
				Transform transform = mountPoint.transform;
				transform.position -= mountPoint.transform.rotation * (MountUp.lossyfactor * (saddle.transform.lossyScale.z - 1f) * Vector3.forward);
			}
			else
			{
				logger.LogWarning((object)"null prefab");
			}
		}

		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 Mountable_L : MonoBehaviour
	{
		private GameObject mountPoint;

		private Transform mountPointBase;

		private GameObject saddle;

		private Vector3 SaddleToMountPoint;

		private float flyStaminaDrain = 10f;

		public bool canfly = false;

		private Animator anim;

		public string Type;

		public static ManualLogSource logger;

		public void Awake()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_0698: Unknown result type (might be due to invalid IL or missing references)
			//IL_069d: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_06d3: 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_07f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_084c: Unknown result type (might be due to invalid IL or missing references)
			//IL_084e: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0888: 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_0897: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bf: 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_0868: Unknown result type (might be due to invalid IL or missing references)
			//IL_0944: Unknown result type (might be due to invalid IL or missing references)
			//IL_0958: Unknown result type (might be due to invalid IL or missing references)
			//IL_095d: Unknown result type (might be due to invalid IL or missing references)
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a74: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aaa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aaf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac7: 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_0ad1: Unknown result type (might be due to invalid IL or missing references)
			if (logger == null)
			{
				logger = Setup.logger;
			}
			Humanoid component = ((Component)this).gameObject.GetComponent<Humanoid>();
			Transform val = ((Component)component).gameObject.transform.Find("Visual");
			mountPoint = new GameObject("MountPoint");
			mountPoint.transform.parent = val;
			mountPoint.transform.rotation = ((Component)this).transform.rotation;
			Tameable component2 = ((Component)this).GetComponent<Tameable>();
			Vector3 zero = Vector3.zero;
			Vector3 zero2 = Vector3.zero;
			Vector3 one = Vector3.one;
			Vector3 zero3 = Vector3.zero;
			if (!Setup.mountNameDict.ContainsKey(Type))
			{
				return;
			}
			logger.LogInfo((object)("Setting up old \"" + Type + "\" for riding."));
			string text = Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value;
			if (text.Contains("\\"))
			{
				logger.LogWarning((object)(Type + " Mount Path should use '/' rather than '\\', trying to replace"));
				text.Replace('\\', '/');
				Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text;
			}
			if (text != "")
			{
				mountPointBase = val.Find(text);
			}
			zero = Setup.customMountPoints[Setup.mountNameDict[Type]].Value;
			zero2 = Setup.customSaddlePos[Setup.mountNameDict[Type]].Value;
			one = Setup.customSaddleScale[Setup.mountNameDict[Type]].Value;
			zero3 = Setup.customSaddleRot[Setup.mountNameDict[Type]].Value;
			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)component).GetComponent<Tameable>().m_saddleItem = null;
							logger.LogError((object)text4);
							return;
						}
						text2 += text3;
					}
					logger.LogError((object)("Unknown error in setting up saddle and riding for " + Type + ", it will not be rideable"));
					((Component)component).GetComponent<Tameable>().m_saddleItem = null;
					return;
				}
				Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>();
				string[] array3 = new string[4] { "spine1", "tail2", "spine", "head" };
				List<string> list = new List<string>();
				array = array3;
				string[] array4 = array;
				foreach (string text5 in array4)
				{
					Transform[] array5 = componentsInChildren;
					Transform[] array6 = array5;
					foreach (Transform val2 in array6)
					{
						if (((Object)val2).name.ToLowerInvariant() == text5)
						{
							if ((Object)(object)mountPointBase == (Object)null)
							{
								mountPointBase = val2;
								text = GetPath(val2);
							}
							else
							{
								list.Add(GetPath(val2));
							}
							break;
						}
					}
				}
				if ((Object)(object)mountPointBase == (Object)null)
				{
					array = array3;
					string[] array7 = array;
					foreach (string value in array7)
					{
						Transform[] array8 = componentsInChildren;
						Transform[] array9 = array8;
						foreach (Transform val3 in array9)
						{
							string text6 = ((Object)val3).name.ToLowerInvariant();
							if (text6.StartsWith(value) || text6.EndsWith(value))
							{
								if ((Object)(object)mountPointBase == (Object)null)
								{
									mountPointBase = val3;
									text = GetPath(val3);
								}
								else
								{
									list.Add(GetPath(val3));
								}
								break;
							}
						}
					}
				}
				if (!((Object)(object)mountPointBase != (Object)null))
				{
					logger.LogError((object)("Could not find potential Mount Path for " + Type + ". " + Type + " will not be rideable"));
					((Component)component).GetComponent<Tameable>().m_saddleItem = null;
					return;
				}
				string text7 = "";
				if (list.Count > 0)
				{
					text7 = "\nPossible Alternatives:";
					foreach (string item in list)
					{
						text7 = text7 + "\n" + item;
					}
				}
				Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text;
				logger.LogMessage((object)("Found potential Mount Path for " + Type + ": " + text + text7));
			}
			mountPoint.transform.parent = val;
			Transform transform = mountPoint.transform;
			transform.rotation *= Quaternion.Euler(zero3);
			saddle = Object.Instantiate<GameObject>(Setup.tieredSaddlePrefabs[0], val);
			Transform transform2 = saddle.transform;
			transform2.rotation *= Quaternion.Euler(zero3);
			saddle.GetComponent<Sadle>().m_maxStamina = Setup.customStamina[Setup.mountNameDict[Type]].Value;
			flyStaminaDrain = Setup.customMountFlyStamina[Setup.mountNameDict[Type]].Value;
			BaseAI baseAI = ((Character)component).GetBaseAI();
			MonsterAI val4 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null);
			if ((Object)(object)val4 != (Object)null && val4.m_avoidLand)
			{
				saddle.GetComponent<Sadle>().m_swimStaminaDrain = 0f;
			}
			if (flyStaminaDrain > 0f || ((Character)component).IsFlying())
			{
				canfly = true;
			}
			Sadle component3 = saddle.GetComponent<Sadle>();
			component3.m_hoverText = Type + " Saddle";
			component3.m_attachPoint = mountPoint.transform;
			saddle.SetActive(false);
			component2.m_saddle = component3;
			((Component)component3).transform.localPosition = zero2;
			((Component)component3).transform.localScale = Vector3.Scale(one, Setup.legacyScale);
			if (Setup.adjustCustom.Value)
			{
				anim = ((Component)component).gameObject.GetComponentInChildren<Animator>();
				if ((Object)(object)anim != (Object)null)
				{
					((Behaviour)anim).enabled = false;
				}
			}
			if (zero3 != Vector3.zero)
			{
				((Component)component3).GetComponentInChildren<Transform>().localRotation = Quaternion.Euler(zero3);
			}
			Transform transform3 = ((Component)component3).transform;
			transform3.position += ((Component)component3).transform.rotation * Setup.legacyOffset;
			zero += Setup.MountPointAdjustment.Value;
			mountPoint.transform.localPosition = zero;
			if ((Object)(object)component2.m_saddle != (Object)null)
			{
				component2.m_nview.Register("AddSaddle", (Action<long>)component2.RPC_AddSaddle);
				component2.m_nview.Register<bool>("SetSaddle", (Action<long, bool>)component2.RPC_SetSaddle);
				component2.SetSaddle(component2.HaveSaddle());
			}
			mountPoint.transform.parent = mountPointBase;
			Transform transform4 = mountPoint.transform;
			transform4.localRotation *= Quaternion.Euler(180f, 180f, 180f);
			saddle.transform.parent = mountPointBase;
			Transform transform5 = saddle.transform;
			transform5.localRotation *= Quaternion.Euler(180f, 180f, 180f);
			SphereCollider component4 = saddle.GetComponent<SphereCollider>();
			SaddleToMountPoint = mountPoint.transform.position - saddle.transform.position;
			if (!Setup.customMounts.ContainsKey(Type))
			{
				Mount mount = new Mount();
				int index = Setup.mountNameDict[Type];
				mount.PrefabName = Type;
				mount.mountPath = text;
				mount.stamina = Setup.customStamina[index].Value;
				mount.saddleTier = Setup.customMountSaddleTiers[index].Value;
				mount.mountPoint = mountPoint.transform.localPosition;
				mount.saddlePos = saddle.transform.localPosition;
				mount.saddleScale = Vector3.Scale(Setup.customSaddleScale[index].Value, Setup.legacyScale);
				mount.saddleRotation = saddle.transform.localEulerAngles - Setup.rotationAdjust;
				mount.flyingStamina = Setup.customMountFlyStamina[index].Value;
				Setup.customMounts.Add(Type, mount);
				if (!Setup.AddFullMountToYaml.Contains(Type))
				{
					Setup.AddFullMountToYaml.Add(Type);
				}
				replaceOldMount(Type);
				Setup.writeYML();
			}
		}

		private static void replaceOldMount(string prefName)
		{
			GameObject prefab = PrefabManager.Instance.GetPrefab(prefName);
			Mountable_L mountable_L = default(Mountable_L);
			if (prefab.TryGetComponent<Mountable_L>(ref mountable_L))
			{
				Object.DestroyImmediate((Object)(object)mountable_L);
			}
			Mountable mountable = default(Mountable);
			if (!prefab.TryGetComponent<Mountable>(ref mountable))
			{
				mountable = prefab.AddComponent<Mountable>();
			}
			mountable.Type = prefName;
		}

		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;
		}
	}
	public class MountUp
	{
		public enum AdjustMode
		{
			None,
			Saddle,
			Mount,
			Rotation
		}

		[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 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 AdjustMode adjustMode;

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LevelEffects), "Start")]
		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(ZNetScene), "Shutdown")]
		[HarmonyPostfix]
		private static void Postfix()
		{
			Debug.Log((object)"Reseting Mounts");
			Setup.ResetAllMounts();
		}

		[HarmonyPostfix]
		[HarmonyPatch(typeof(LevelEffects), "SetupLevelVisualization")]
		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;
			KeyCode val = ((KeyboardShortcut)(ref value)).MainKey;
			text = text3 + "+" + ((object)(KeyCode)(ref val)).ToString() + "\n";
			string[] obj = new string[5] { text, null, null, null, null };
			val = (KeyCode)276;
			obj[1] = ((object)(KeyCode)(ref val)).ToString();
			obj[2] = "/";
			val = (KeyCode)275;
			obj[3] = ((object)(KeyCode)(ref val)).ToString();
			obj[4] = "\n";
			text = string.Concat(obj);
			string[] obj2 = new string[5] { text, null, null, null, null };
			val = (KeyCode)273;
			obj2[1] = ((object)(KeyCode)(ref val)).ToString();
			obj2[2] = "/";
			val = (KeyCode)274;
			obj2[3] = ((object)(KeyCode)(ref val)).ToString();
			obj2[4] = "\n";
			text = string.Concat(obj2);
			string[] obj3 = new string[5] { text, null, null, null, null };
			val = (KeyCode)280;
			obj3[1] = ((object)(KeyCode)(ref val)).ToString();
			obj3[2] = "/";
			val = (KeyCode)281;
			obj3[3] = ((object)(KeyCode)(ref val)).ToString();
			obj3[4] = "\n";
			text = string.Concat(obj3);
			string[] obj4 = new string[5] { text, null, null, null, null };
			val = (KeyCode)306;
			obj4[1] = ((object)(KeyCode)(ref val)).ToString();
			obj4[2] = "+";
			val = (KeyCode)115;
			obj4[3] = ((object)(KeyCode)(ref val)).ToString();
			obj4[4] = "\n";
			text = string.Concat(obj4);
			string text4 = text;
			val = (KeyCode)305;
			text = text4 + "\n" + ((object)(KeyCode)(ref val)).ToString() + "\n";
			string text5 = text;
			val = (KeyCode)303;
			text = text5 + ((object)(KeyCode)(ref val)).ToString() + "\n";
			string text6 = text;
			val = (KeyCode)307;
			text = text6 + ((object)(KeyCode)(ref val)).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 = "";
			CommandStringRot = "";
			CommandStringPos += "Cycle Edit Mode                 \n";
			CommandStringRot = CommandStringPos;
			CommandStringRot += "Tilt Left/Right                 \nRotate Forward/Back                 \nSpin Left/Right                 \n";
			CommandStringPos += "Move Left/Right                 \nMove Forward/Back                 \nMove Up/Down                 \n";
			string text = "Save to YML                 \n Finer Adjustment:\n0.5x (hold)                 \n0.1x (hold)                 \n0.05x (hold)                 \n";
			CommandStringPos += text;
			CommandStringRot += text;
			keyString = getKeybingsString();
		}

		[HarmonyPrefix]
		[HarmonyPatch(typeof(Player), "Update")]
		private static void PlayerUpdate_Patch(Player __instance)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0380: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_040a: Unknown result type (might be due to invalid IL or missing references)
			//IL_059d: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0576: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_043d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: 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_067a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0467: Unknown result type (might be due to invalid IL or missing references)
			//IL_046e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: 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_06d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: 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_063d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_065d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0662: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			if (!Setup.adjustCustom.Value)
			{
				displayKeybinds(active: false);
				return;
			}
			bool flag = false;
			bool flag2 = 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;
				default:
					text = "Adjust Mode: Unknown (error)";
					EditModeTitle.text = "Error: Not Editing";
					break;
				}
				((Character)__instance).Message((MessageType)1, text, 0, (Sprite)null);
			}
			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))
			{
				if (Object.op_Implicit((Object)(object)((Component)val.GetCharacter()).gameObject.GetComponent<Mountable_L>()))
				{
					((Character)__instance).Message((MessageType)1, "Please reload this creature to Modify Mounting", 0, (Sprite)null);
				}
				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;
			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 localEulerAngles = val2.localEulerAngles;
			if (adjustMode != AdjustMode.Rotation)
			{
				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);
				}
			}
			else
			{
				num2 *= 20f;
				if (rotateTransform(val2, num2) && (Object)(object)val3 != (Object)null)
				{
					rotateTransform(val3, num2);
				}
			}
			if (Vector3.Distance(val2.position, val3.position) > 2.5f)
			{
				((Character)__instance).Message((MessageType)2, "Saddle and Mount Point Must Stay closer,\n or player will dismount", 0, (Sprite)null);
				val2.localPosition = localPosition;
			}
			string text2 = ((Object)val.GetCharacter()).name.Replace("(Clone)", "");
			if (val2.localPosition != localPosition || flag)
			{
				Vector3 val4 = val2.localPosition - localPosition;
				if (Setup.customMounts.TryGetValue(text2, out var value2))
				{
					string text3 = text2 + " Saddle Position = ";
					if (adjustMode == AdjustMode.Mount)
					{
						text3 = text2 + " Mount Point = ";
					}
					string text4 = Setup.StringVec(val2.localPosition);
					Debug.Log((object)(text3 + text4));
				}
				if (adjustMode == AdjustMode.Mount)
				{
					Mount mount = value2;
					mount.mountPoint += val4;
				}
				else if (adjustMode == AdjustMode.Saddle)
				{
					Mount mount2 = value2;
					mount2.saddlePos += val4;
				}
			}
			else if (val2.localEulerAngles != localEulerAngles || flag2)
			{
				if (Setup.customMounts.TryGetValue(text2, out var value3))
				{
					string text5 = "Saddle Rotation = ";
					string text6 = Setup.StringVec(val2.localEulerAngles - Setup.rotationAdjust);
					Debug.Log((object)(text5 + text6));
				}
				value3.saddleRotation = val2.localEulerAngles - Setup.rotationAdjust;
			}
			if (((KeyboardShortcut)(ref Setup.saveMountKeys)).IsDown())
			{
				((Character)__instance).Message((MessageType)2, "Saving " + text2 + " to MountUp YML", 0, (Sprite)nul