Decompiled source of MountUpRestored v3.4.4

MountUpRestored.dll

Decompiled a month 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 JetBrains.Annotations;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using MountUp;
using MountUp.ModCompat;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using ValheimVRMod.Patches;
using ValheimVRMod.VRCore.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.ObjectPool;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.BufferedDeserialization;
using YamlDotNet.Serialization.BufferedDeserialization.TypeDiscriminators;
using YamlDotNet.Serialization.Callbacks;
using YamlDotNet.Serialization.Converters;
using YamlDotNet.Serialization.EventEmitters;
using YamlDotNet.Serialization.NamingConventions;
using YamlDotNet.Serialization.NodeDeserializers;
using YamlDotNet.Serialization.NodeTypeResolvers;
using YamlDotNet.Serialization.ObjectFactories;
using YamlDotNet.Serialization.ObjectGraphTraversalStrategies;
using YamlDotNet.Serialization.ObjectGraphVisitors;
using YamlDotNet.Serialization.Schemas;
using YamlDotNet.Serialization.TypeInspectors;
using YamlDotNet.Serialization.TypeResolvers;
using YamlDotNet.Serialization.Utilities;
using YamlDotNet.Serialization.ValueDeserializers;

[assembly: AssemblyCompany("")]
[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: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyProduct("MountUp")]
[assembly: ComVisible(false)]
[assembly: Guid("9e1c6dc2-1a11-4768-96f1-0f71c70e1dbe")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyTrademark("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("meldurson.MountUpRestored", "Mount Up Restored", "3.4.4")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class Setup : BaseUnityPlugin
{
	[CompilerGenerated]
	private sealed class <jot_RPCClientReceive>d__71 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public long sender;

		public ZPackage package;

		public Setup <>4__this;

		private Dictionary<string, Mount>.Enumerator <>s__1;

		private KeyValuePair<string, Mount> <key>5__2;

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

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

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

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>s__1 = default(Dictionary<string, Mount>.Enumerator);
			<key>5__2 = default(KeyValuePair<string, Mount>);
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				logger.LogWarning((object)"Client received MountList RPC");
				removeMounts = customMounts;
				<>2__current = null;
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				CfgPackage.Unpack(package);
				LateLoadMounts.Clear();
				<>s__1 = customMounts.GetEnumerator();
				try
				{
					while (<>s__1.MoveNext())
					{
						<key>5__2 = <>s__1.Current;
						LateLoadMounts.Add(<key>5__2.Key);
						<key>5__2 = default(KeyValuePair<string, Mount>);
					}
				}
				finally
				{
					((IDisposable)<>s__1).Dispose();
				}
				<>s__1 = default(Dictionary<string, Mount>.Enumerator);
				SetupMountable(fromServer: true);
				return false;
			}
		}

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

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

	private const string ModGUID = "meldurson.MountUpRestored";

	public static ManualLogSource logger;

	public static GameObject boarSaddlePrefab;

	public static ItemDrop boarSaddleItem;

	public static ItemDrop wolfSaddleItem;

	public static ItemDrop loxSaddleItem;

	public static GameObject wolfSaddlePrefab;

	public static GameObject genericSaddlePrefab;

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

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

	public static bool lateLoad = false;

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

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

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

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

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

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

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

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

	public static ConfigEntry<bool> canMountPlayer;

	public static ConfigEntry<float> BoarStamina;

	public static ConfigEntry<float> WolfStamina;

	public static ConfigEntry<float> LoxStamina;

	public static ConfigEntry<float> AsksvinStamina;

	public static ConfigEntry<float> FedStaminaMultiplier;

	public static ConfigEntry<bool> adjustCustom;

	public static ConfigEntry<KeyboardShortcut> adjustCustomModeSwitch;

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

	public static ButtonConfig adjustCustomModeSwitchButton;

	public static ConfigEntry<bool> teleportMounts;

	public static ConfigEntry<int> customMountCount;

	public static Dictionary<string, int> mountNameDict;

	public static List<ConfigEntry<string>> customMountNames;

	public static List<ConfigEntry<int>> customMountSaddleTiers;

	public static List<ConfigEntry<Vector3>> customMountPoints;

	public static List<ConfigEntry<Vector3>> customSaddlePos;

	public static List<ConfigEntry<Vector3>> customSaddleScale;

	public static List<ConfigEntry<Vector3>> customSaddleRot;

	public static List<ConfigEntry<float>> customMountFlyStamina;

	public static List<ConfigEntry<float>> customStamina;

	public static List<ConfigEntry<string>> customTightMountPaths;

	public static ConfigEntry<Vector3> MountPointAdjustment;

	private static ConfigEntry<KeyboardShortcut> mountModifierKey;

	public static ConfigEntry<bool> useBlockforSecondary;

	public static ConfigEntry<string> saddleNames;

	public static ConfigEntry<bool> canAttackMounted;

	public static ConfigEntry<bool> mountsCanDrown;

	public static GameObject SalObj;

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

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

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

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

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

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

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

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

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

	public static bool isWritingYML = false;

	public static bool RecipesMade = false;

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

	public static CustomRPC jot_MountlistRPC;

	public static bool MountUpdate = false;

	public GameObject Root;

	internal readonly Harmony _harmony = new Harmony("meldurson.MountUpRestored");

	public static Setup instance = null;

	public static bool localizeLoaded = false;

	private void Awake()
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0062: 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_0070: Expected O, but got Unknown
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Expected O, but got Unknown
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Expected O, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Expected O, but got Unknown
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Expected O, but got Unknown
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Expected O, but got Unknown
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0127: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Expected O, but got Unknown
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_013a: Expected O, but got Unknown
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: Expected O, but got Unknown
		//IL_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Expected O, but got Unknown
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Expected O, but got Unknown
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Expected O, but got Unknown
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: 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)
		//IL_023a: 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_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0276: Expected O, but got Unknown
		//IL_0276: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Expected O, but got Unknown
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Expected O, but got Unknown
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Expected O, but got Unknown
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Expected O, but got Unknown
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: Unknown result type (might be due to invalid IL or missing references)
		//IL_031d: Expected O, but got Unknown
		//IL_031d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0327: Expected O, but got Unknown
		//IL_034c: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b8: Expected O, but got Unknown
		instance = this;
		canMountPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Mount Player", false, new ConfigDescription("Experimental: Can Players be mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		teleportMounts = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Teleport Mounts", true, new ConfigDescription("Allow Mounts to Teleport with their rider", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		BoarStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Boar Stamina", 60f, new ConfigDescription("Mounted Boar Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		WolfStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Wolf Stamina", 120f, new ConfigDescription("Mounted Wolf Stamina", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		LoxStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Lox Stamina Override", -1f, new ConfigDescription("Override Lox Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		AsksvinStamina = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Asksvin Stamina Override", -1f, new ConfigDescription("Override Asksvin Stamina, set -1 to not modify", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		FedStaminaMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Stamina", "Stamina Regen Multiplier", 1f, new ConfigDescription("Multiply stamina regen rate when mount is fed", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		MountPointAdjustment = ((BaseUnityPlugin)this).Config.Bind<Vector3>("Micromanagement", "Mount Point Adjustment", Vector3.zero, (ConfigDescription)null);
		mountModifierKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("General", "Player Mount Modifier Key", new KeyboardShortcut((KeyCode)304, Array.Empty<KeyCode>()), "This key plus your interact key will attempt to mount another player");
		adjustCustom = ((BaseUnityPlugin)this).Config.Bind<bool>("Custom Mounts", "Enable Adjust Custom Mounts", false, new ConfigDescription("Enable Controls to adjust custom mount's mount points and saddle position", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		canAttackMounted = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Attack Mounted", true, new ConfigDescription("Allow mount to attack using attack keys while mounted", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		mountsCanDrown = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Land Mounts can Drown", true, new ConfigDescription("Do land mounts start to take damage if you run out of stamina when swimming", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		useBlockforSecondary = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Use Block Key to Perform Secondary", true, new ConfigDescription("Determines if while mounted the block key also performs secondary attack", (AcceptableValueBase)null, Array.Empty<object>()));
		saddleNames = ((BaseUnityPlugin)this).Config.Bind<string>("General", "Saddle Names", "Meadows Saddle,Forest Saddle,Swamp Saddle,Mountain Saddle,Plains Saddle,Mistlands Saddle,Ashlands Saddle,Deep North Saddle,", new ConfigDescription("Set the names of the different tiers of Saddle", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true
		} }));
		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);
		logger = ((BaseUnityPlugin)this).Logger;
		UseFileOpenReadTextWithSystemTextYaml();
		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 + ", ";
			LateLoadMounts.Add(customMount.Key);
		}
		logger.LogMessage((object)text.TrimEnd(',', ' '));
		Root = ((Component)this).gameObject;
		PrefabManager.OnVanillaPrefabsAvailable += LoadAssets;
		PrefabManager.OnVanillaPrefabsAvailable += CreateSaddles;
		PieceManager.OnPiecesRegistered += SetupMountable;
		lateLoad = true;
		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);
	}

	public void Start()
	{
		Patches.setup = this;
		Patches.Apply();
	}

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

	[IteratorStateMachine(typeof(<jot_RPCClientReceive>d__71))]
	private IEnumerator jot_RPCClientReceive(long sender, ZPackage package)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <jot_RPCClientReceive>d__71(0)
		{
			<>4__this = this,
			sender = sender,
			package = package
		};
	}

	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)
	{
		<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser <0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser = new <0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser(new StringReader(ymlContents));
		<1fc59466-35d1-4acd-83a5-05fdf00c1020>IDeserializer <1fc59466-35d1-4acd-83a5-05fdf00c1020>IDeserializer = new <b36fc286-2012-4118-bc04-b50b4c744f41>DeserializerBuilder().WithNamingConvention(<93e6cdda-f5a0-4c5b-8577-8da8c58e2f41>CamelCaseNamingConvention.Instance).Build();
		<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<642935da-8b65-49dc-9752-03e422a4bcf9>StreamStart>();
		if (!<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.TryConsume<<1f312e5d-c08e-4556-b513-cb7571629b74>DocumentStart>(out var _))
		{
			return new List<Mount>();
		}
		<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<a44bed1d-8ef0-4532-bdc0-01bf2ab5c3a5>MappingStart>();
		List<Mount> list = new List<Mount>();
		<5c195cfd-9139-44a4-b7bb-5fb08738ba4b>Scalar event2;
		while (<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.TryConsume<<5c195cfd-9139-44a4-b7bb-5fb08738ba4b>Scalar>(out event2))
		{
			try
			{
				Mount mount;
				if (<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Current.GetType() != typeof(<a44bed1d-8ef0-4532-bdc0-01bf2ab5c3a5>MappingStart))
				{
					if ((event2.Value ?? "") == "")
					{
						continue;
					}
					mount = new Mount();
					goto IL_00c5;
				}
				mount = new Mount(<1fc59466-35d1-4acd-83a5-05fdf00c1020>IDeserializer.Deserialize<MountSerialized>(<0f596eef-208f-4c53-a46d-6e75fa4b925a>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 https://thunderstore.io/c/valheim/p/Meldurson/MountUpRestored/wiki/1368-premade-configs/ 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)
		{
			<e756ed19-ae01-481a-8f44-5aa38dea8a52>ISerializer <e756ed19-ae01-481a-8f44-5aa38dea8a52>ISerializer = new <25da76e7-224d-4e6e-82ee-5f3236342851>SerializerBuilder().WithNamingConvention(<93e6cdda-f5a0-4c5b-8577-8da8c58e2f41>CamelCaseNamingConvention.Instance).Build();
			string[] array = files;
			foreach (string text in array)
			{
				string text2 = File.ReadAllText(text);
				if ((text2.Trim(' ', '\n', '\t') ?? "") == "")
				{
					continue;
				}
				<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser <0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser = new <0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser(new StringReader(text2));
				<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<642935da-8b65-49dc-9752-03e422a4bcf9>StreamStart>();
				if (!<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.TryConsume<<1f312e5d-c08e-4556-b513-cb7571629b74>DocumentStart>(out var _))
				{
					continue;
				}
				<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<a44bed1d-8ef0-4532-bdc0-01bf2ab5c3a5>MappingStart>();
				int num = 0;
				bool flag = false;
				bool flag2 = false;
				<5c195cfd-9139-44a4-b7bb-5fb08738ba4b>Scalar event2;
				while (<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.TryConsume<<5c195cfd-9139-44a4-b7bb-5fb08738ba4b>Scalar>(out event2))
				{
					if (flag)
					{
						for (int j = 0; j < num; j++)
						{
							<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.SkipThisAndNestedEvents();
							if (!<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.TryConsume<<5c195cfd-9139-44a4-b7bb-5fb08738ba4b>Scalar>(out var event3))
							{
								flag2 = true;
							}
							else
							{
								event2 = event3;
							}
						}
					}
					if (flag2)
					{
						break;
					}
					flag = false;
					num++;
					try
					{
						if (!AddFullMountToYaml.Contains(event2.Value))
						{
							<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.SkipThisAndNestedEvents();
							continue;
						}
						if (!customMounts.TryGetValue(event2.Value, out var value))
						{
							logger.LogWarning((object)("Could not find" + event2.Value + "in MountsToOverwrite, skipping write"));
							<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.SkipThisAndNestedEvents();
							continue;
						}
						MountToYaml graph = new MountToYaml(value);
						string value2 = formatMountYML(<e756ed19-ae01-481a-8f44-5aa38dea8a52>ISerializer.Serialize(graph), event2.Value);
						<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.SkipThisAndNestedEvents();
						bool flag3 = (int)<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Current.Start.Index >= text2.Length;
						string text3 = text2.Remove((int)event2.Start.Index, (int)(<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Current.Start.Index - ((!flag3) ? 1 : 0) - event2.Start.Index)).Insert((int)event2.Start.Index, value2);
						text2 = text3;
						AddFullMountToYaml.Remove(event2.Value);
						<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser = new <0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser(new StringReader(text2));
						flag = true;
						<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<642935da-8b65-49dc-9752-03e422a4bcf9>StreamStart>();
						<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<1f312e5d-c08e-4556-b513-cb7571629b74>DocumentStart>();
						<0f596eef-208f-4c53-a46d-6e75fa4b925a>Parser.Consume<<a44bed1d-8ef0-4532-bdc0-01bf2ab5c3a5>MappingStart>();
					}
					catch
					{
						logger.LogWarning((object)("Failed to parse " + event2.Value + " from yaml, check to make sure this prefab is formated correctly"));
					}
				}
				File.WriteAllText(text, text2);
				logger.LogMessage((object)("Overwrote existing creatures to " + text));
			}
			if (AddFullMountToYaml.Count <= 0)
			{
				return;
			}
			string text4 = "\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 text5 = formatMountYML(<e756ed19-ae01-481a-8f44-5aa38dea8a52>ISerializer.Serialize(new MountToYaml(value3)), item);
				text4 += text5;
			}
			File.AppendAllText(files[0], text4);
			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 ($"[{vec.x:F2}/{vec.y:F2}/{vec.z:F2}" + "]").Replace(',', '.').Replace('/', ',');
	}

	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))
		{
			logger.LogMessage((object)("Making " + ((Object)tame).name + " Mountable" + (legacy ? "(legacy)" : "")));
			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;
							logger.LogInfo((object)("Set custom Saddle: " + value.customSaddle + " for " + name));
						}
						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 if (value.customSaddle.StartsWith("attach_"))
					{
						logger.LogWarning((object)("Will attempt to use custom mounting animation (" + value.customSaddle + ") for " + 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;
			LateLoadMounts.Remove(name);
		}
		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 && flag)
		{
			((Component)tame).gameObject.AddComponent<Mountable>().Type = name;
		}
	}

	private static void SetupMountable()
	{
		SetupMountable(fromServer: false);
	}

	private static void SetupMountable(bool fromServer = false)
	{
		if (!fromServer && !ZNet.instance.IsServer())
		{
			logger.LogMessage((object)"Not Server, will wait for RPC");
			return;
		}
		if (LateLoadMounts.Count > 0)
		{
			for (int num = LateLoadMounts.Count - 1; num >= 0; num--)
			{
				bool flag = true;
				logger.LogMessage((object)("Late mount load for " + LateLoadMounts[num]));
				GameObject prefab = PrefabManager.Instance.GetPrefab(LateLoadMounts[num]);
				if ((Object)(object)prefab == (Object)null)
				{
					logger.LogWarning((object)("Go is null for " + LateLoadMounts[num]));
				}
				else
				{
					Tameable val = prefab.GetComponent<Tameable>();
					if ((Object)(object)val == (Object)null)
					{
						if ((Object)(object)prefab.GetComponent<MonsterAI>() == (Object)null)
						{
							logger.LogWarning((object)(LateLoadMounts[num] + " cannot be mounted as does not have a MonsterAI"));
							flag = false;
						}
						else
						{
							logger.LogWarning((object)("Manually added Tameable for " + LateLoadMounts[num]));
							val = prefab.AddComponent<Tameable>();
						}
					}
					if (flag)
					{
						MakeMountable(val);
					}
				}
			}
		}
		if (LoxStamina.Value != -1f)
		{
			SetMountStamina(PrefabManager.Instance.GetPrefab("Lox"), LoxStamina.Value);
		}
		if (AsksvinStamina.Value != -1f)
		{
			SetMountStamina(PrefabManager.Instance.GetPrefab("Asksvin"), AsksvinStamina.Value);
		}
		UpdateSaddleDesc();
		PieceManager.OnPiecesRegistered -= SetupMountable;
	}

	public static void SetMountStamina(GameObject go, float newStam)
	{
		Tameable val = default(Tameable);
		if (!((Object)(object)go == (Object)null) && go.TryGetComponent<Tameable>(ref val) && !((Object)(object)val.m_saddle == (Object)null))
		{
			logger.LogWarning((object)("Set Stamina of " + ((Object)go).name + " to " + newStam));
			val.m_saddle.m_maxStamina = newStam;
		}
	}

	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))
			{
				Debug.Log((object)("Clearing mountable from " + ((Object)array[i]).name));
				Object.DestroyImmediate((Object)(object)mountable);
				array[i].m_saddleItem = null;
			}
		}
		PieceManager.OnPiecesRegistered += SetupMountable;
	}

	public static void ResetAllMounts()
	{
		RemoveMounts();
		customMounts.Clear();
		removeMounts.Clear();
		UseFileOpenReadTextWithSystemTextYaml();
		LoadBuiltInMounts();
		LateLoadMounts.Clear();
		foreach (KeyValuePair<string, Mount> customMount in customMounts)
		{
			LateLoadMounts.Add(customMount.Key);
		}
	}

	public static void CreateSaddles()
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		for (int i = 0; i < tieredSaddlePrefabs.Length; i++)
		{
			string description = "No current creatures can be mounted with this saddle (an error might have occurred)";
			CustomItem item = ItemManager.Instance.GetItem("SaddleT" + i);
			if (item != null)
			{
				item.ItemDrop.m_itemData.m_shared.m_description = description;
				continue;
			}
			CustomItem val = new CustomItem(((Component)tieredSaddlePrefabs[i].transform.GetChild(1)).gameObject, true, CreateRecipes(i));
			ItemManager.Instance.AddItem(val);
			tieredSaddleItems[i] = val.ItemDrop;
			val.ItemDrop.m_itemData.m_shared.m_name = "Tier " + i + " Saddle";
			val.ItemDrop.m_itemData.m_dropPrefab = tieredSaddlePrefabs[i];
			val.ItemDrop.m_itemData.m_shared.m_weight = 5f + (float)i;
			val.ItemDrop.m_itemData.m_shared.m_description = description;
		}
		PrefabManager.OnVanillaPrefabsAvailable -= CreateSaddles;
		if (!RecipesMade)
		{
			RecipesMade = true;
		}
	}

	public static void UpdateSaddleDesc()
	{
		//IL_0387: Unknown result type (might be due to invalid IL or missing references)
		//IL_038e: 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 text = customMount.Key;
			if ((Object)(object)prefab == (Object)null)
			{
				Debug.LogWarning((object)("go null for " + text + " skipping"));
				continue;
			}
			if (prefab.TryGetComponent<Character>(ref val))
			{
				text = val.m_name;
			}
			string text2 = customMount.Value.customSaddle ?? "";
			if (int.TryParse(text2, out result) || result > 8 || result < 0)
			{
				array[result].Add(text);
			}
			else if (text2.Length > 1)
			{
				if (text2.Contains("SaddleT"))
				{
					string text3 = text2.Substring(7, text2.Length - 7);
					Debug.Log((object)(customMount.Key + " has custom saddle with tier " + text3));
					if (int.TryParse(text3, out var result2) && result2 <= 8 && result2 >= 0)
					{
						customMount.Value.customSaddle = text3;
						array[result2].Add(text);
					}
				}
			}
			else
			{
				result = ((customMount.Value.saddleTier == 0) ? 5 : customMount.Value.saddleTier);
				array[result].Add(text);
			}
		}
		TieredSaddleNames = saddleNames.Value.Split(new char[1] { ',' });
		for (int j = 0; j < array.Length; j++)
		{
			string text4 = "$custsaddle_desc";
			if (j > 4)
			{
				text4 = "$custsaddle2_desc";
			}
			else if (j > 2)
			{
				text4 = "$custsaddle3_desc";
			}
			if (array[j].Count > 0)
			{
				text4 += " $custsaddle_has_multi ";
			}
			text4 += string.Join(", ", array[j]);
			text4 = text4.TrimEnd(',', ' ');
			CustomItem item = ItemManager.Instance.GetItem("SaddleT" + j);
			if (item != null)
			{
				Debug.Log((object)("Updating Saddle item for Tier " + j));
				item.ItemDrop.m_itemData.m_shared.m_description = text4;
				if (j > 0)
				{
					item.Recipe.Recipe.m_enabled = array[j].Count > 0;
					if (j <= TieredSaddleNames.Length)
					{
						Debug.Log((object)("Updating Saddle Name:" + j + " to " + TieredSaddleNames[j - 1]));
						item.ItemDrop.m_itemData.m_shared.m_name = TieredSaddleNames[j - 1];
					}
				}
				continue;
			}
			item = new CustomItem(((Component)tieredSaddlePrefabs[j].transform.GetChild(1)).gameObject, true, CreateRecipes(j));
			text4 = Localization.instance.Localize(text4);
			ItemManager.Instance.AddItem(item);
			tieredSaddleItems[j] = item.ItemDrop;
			if (j < array.Length)
			{
				item.ItemDrop.m_itemData.m_shared.m_name = TieredSaddleNames[j - 1];
			}
			else
			{
				item.ItemDrop.m_itemData.m_shared.m_name = "Tier " + j + " Saddle";
			}
			item.ItemDrop.m_itemData.m_dropPrefab = tieredSaddlePrefabs[j];
			item.ItemDrop.m_itemData.m_shared.m_weight = 5f + (float)j;
			item.ItemDrop.m_itemData.m_shared.m_description = text4;
		}
		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_02fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: 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", 10, 0, false));
			val.AddRequirement(new RequirementConfig("MorgenHeart", 2, 0, false));
			val.AddRequirement(new RequirementConfig("FlametalNew", 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("GemstoneBlue", 1, 0, false));
			val.AddRequirement(new RequirementConfig("FreezeGland", 50, 0, false));
			val.CraftingStation = CraftingStations.ArtisanTable;
			val.MinStationLevel = 2;
			break;
		}
		return val;
	}
}
namespace MountUp
{
	internal class AdjustmentPatches
	{
		[HarmonyPostfix]
		[HarmonyPatch(typeof(Character), "GetHoverText")]
		private static void Char_GetHoverText(Character __instance, ref string __result)
		{
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			Mountable mountable = default(Mountable);
			if (!__instance.m_tamed || !((Component)__instance).gameObject.TryGetComponent<Mountable>(ref mountable) || !Setup.adjustCustom.Value || !ZNet.instance.IsServer() || (Object)(object)mountable.getSaddle() == (Object)null || !mountable.getSaddle().activeSelf)
			{
				return;
			}
			KeyboardShortcut val = new KeyboardShortcut((KeyCode)101, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 });
			if (((KeyboardShortcut)(ref val)).IsDown())
			{
				Player localPlayer = Player.m_localPlayer;
				Sadle component = mountable.getSaddle().GetComponent<Sadle>();
				if ((Object)(object)component != (Object)null && (Object)(object)localPlayer != (Object)null)
				{
					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");
			string text2 = Localization.instance.Localize("$sitinsaddle");
			__result = __result.Replace(text, text + "\n[<color=orange><b>Alt+E</b></color>] " + text2);
		}
	}
	[Serializable]
	public class CfgPackage
	{
		public MountSerialized[] mounts;

		public static ZPackage zpack;

		public ZPackage PackMountlist()
		{
			//IL_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
	{
		public 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;

		private bool setCustomAttacks = false;

		private float updateTime = 0.7f;

		public ZNetView m_nview;

		public void Awake()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_076c: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0653: Unknown result type (might be due to invalid IL or missing references)
			//IL_0675: Unknown result type (might be due to invalid IL or missing references)
			//IL_068d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0692: Unknown result type (might be due to invalid IL or missing references)
			//IL_0697: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_091e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0924: Unknown result type (might be due to invalid IL or missing references)
			//IL_0929: Unknown result type (might be due to invalid IL or missing references)
			//IL_092e: Unknown result type (might be due to invalid IL or missing references)
			//IL_093a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a1e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a44: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a49: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a65: Unknown result type (might be due to invalid IL or missing references)
			if (logger == null)
			{
				logger = Setup.logger;
			}
			Tameable component = ((Component)this).GetComponent<Tameable>();
			Type = ((Object)component).name.Replace("(Clone)", "");
			Humanoid component2 = ((Component)this).gameObject.GetComponent<Humanoid>();
			Transform val = ((Component)component2).gameObject.transform.Find("Visual");
			mountPoint = new GameObject("MountPoint");
			mountPoint.transform.parent = val;
			mountPoint.transform.rotation = ((Component)this).transform.rotation;
			Vector3 val2 = posDefault;
			Vector3 val3 = posDefault;
			Vector3 one = Vector3.one;
			Vector3 val4 = rotationAdjust;
			m_nview = ((Component)this).gameObject.GetComponent<ZNetView>();
			m_nview.Register("RPC_SetMountPoint", (Action<long>)RPC_SetMountPoint);
			if (!Setup.customMounts.TryGetValue(Type, out var value))
			{
				logger.LogWarning((object)(Type + " is not in custom mounts list, removing mountable"));
				Object.Destroy((Object)(object)this);
				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 = (basePos = 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 = ((Character)component2).m_name + " $mu_saddle";
			component3.m_attachPoint = mountPoint.transform;
			if ((value.customSaddle ?? "") != "" && value.customSaddle.StartsWith("attach_"))
			{
				component3.m_attachAnimation = value.customSaddle;
			}
			saddle.SetActive(false);
			component.m_saddle = component3;
			((Component)component3).transform.localPosition = val3;
			((Component)component3).transform.localScale = one;
			if (Setup.adjustCustom.Value)
			{
				anim = ((Component)component2).gameObject.GetComponentInChildren<Animator>();
			}
			if (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>();
			if (!((value.customAttackOrder ?? "") != ""))
			{
				return;
			}
			string[] array10 = value.customAttackOrder.Split(new char[1] { ',' });
			int num = Math.Min(4, array10.Length);
			for (int n = 0; n < num; n++)
			{
				if (int.TryParse(array10[n], out var result))
				{
					attackorder[n] = result;
				}
				else
				{
					logger.LogWarning((object)("Failed to set custom attack order for " + array10[n]));
				}
			}
			setCustomAttacks = true;
		}

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

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

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

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

		public bool hasInitAttacks()
		{
			return initAttacks;
		}

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

		public float getFlyStaminaDrain()
		{
			return flyStaminaDrain;
		}

		public GameObject getSaddle()
		{
			return saddle;
		}

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

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

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

		[HarmonyPatch(typeof(Tameable), "SetSaddle")]
		public static class InterceptSetSaddle
		{
			[CompilerGenerated]
			private sealed class <Transpiler>d__0 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
			{
				private int <>1__state;

				private CodeInstruction <>2__current;

				private int <>l__initialThreadId;

				private IEnumerable<CodeInstruction> instructions;

				public IEnumerable<CodeInstruction> <>3__instructions;

				private bool <skipped>5__1;

				private IEnumerator<CodeInstruction> <>s__2;

				private CodeInstruction <instruction>5__3;

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

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

				[DebuggerHidden]
				public <Transpiler>d__0(int <>1__state)
				{
					this.<>1__state = <>1__state;
					<>l__initialThreadId = Environment.CurrentManagedThreadId;
				}

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					int num = <>1__state;
					if (num == -3 || num == 1)
					{
						try
						{
						}
						finally
						{
							<>m__Finally1();
						}
					}
					<>s__2 = null;
					<instruction>5__3 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					try
					{
						int num = <>1__state;
						if (num != 0)
						{
							if (num != 1)
							{
								return false;
							}
							<>1__state = -3;
							goto IL_00aa;
						}
						<>1__state = -1;
						<skipped>5__1 = false;
						<>s__2 = instructions.GetEnumerator();
						<>1__state = -3;
						goto IL_00b2;
						IL_00aa:
						<instruction>5__3 = null;
						goto IL_00b2;
						IL_00b2:
						if (<>s__2.MoveNext())
						{
							<instruction>5__3 = <>s__2.Current;
							if (<instruction>5__3.opcode == OpCodes.Ldarg_0)
							{
								<skipped>5__1 = true;
							}
							if (<skipped>5__1)
							{
								<>2__current = <instruction>5__3;
								<>1__state = 1;
								return true;
							}
							goto IL_00aa;
						}
						<>m__Finally1();
						<>s__2 = null;
						return false;
					}
					catch
					{
						//try-fault
						((IDisposable)this).Dispose();
						throw;
					}
				}

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

				private void <>m__Finally1()
				{
					<>1__state = -1;
					if (<>s__2 != null)
					{
						<>s__2.Dispose();
					}
				}

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

				[DebuggerHidden]
				IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
				{
					<Transpiler>d__0 <Transpiler>d__;
					if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
					{
						<>1__state = 0;
						<Transpiler>d__ = this;
					}
					else
					{
						<Transpiler>d__ = new <Transpiler>d__0(0);
					}
					<Transpiler>d__.instructions = <>3__instructions;
					return <Transpiler>d__;
				}

				[DebuggerHidden]
				IEnumerator IEnumerable.GetEnumerator()
				{
					return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
				}
			}

			[IteratorStateMachine(typeof(<Transpiler>d__0))]
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <Transpiler>d__0(-2)
				{
					<>3__instructions = instructions
				};
			}
		}

		[CompilerGenerated]
		private sealed class <SadleUpdateRiding_Transpile>d__42 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private CodeInstruction <>2__current;

			private int <>l__initialThreadId;

			private IEnumerable<CodeInstruction> instructions;

			public IEnumerable<CodeInstruction> <>3__instructions;

			private bool <Ldfld>5__1;

			private bool <foundCall>5__2;

			private bool <executed>5__3;

			private IEnumerator<CodeInstruction> <>s__4;

			private CodeInstruction <instruction>5__5;

			private CodeInstruction <jumpcall>5__6;

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

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

			[DebuggerHidden]
			public <SadleUpdateRiding_Transpile>d__42(int <>1__state)
			{
				this.<>1__state = <>1__state;
				<>l__initialThreadId = Environment.CurrentManagedThreadId;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || (uint)(num - 1) <= 7u)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>s__4 = null;
				<instruction>5__5 = null;
				<jumpcall>5__6 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f5: Expected O, but got Unknown
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<Ldfld>5__1 = false;
						<foundCall>5__2 = false;
						<executed>5__3 = false;
						<>s__4 = instructions.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						goto IL_02c6;
					case 2:
						<>1__state = -3;
						goto IL_02c6;
					case 3:
						<>1__state = -3;
						<>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null);
						<>1__state = 4;
						return true;
					case 4:
						<>1__state = -3;
						<>2__current = CodeInstruction.LoadField(typeof(Sadle), "m_swimStaminaDrain", false);
						<>1__state = 5;
						return true;
					case 5:
						<>1__state = -3;
						<>2__current = CodeInstruction.Call(typeof(MountUp), "HasSwimDrain", (Type[])null, (Type[])null);
						<>1__state = 6;
						return true;
					case 6:
						<>1__state = -3;
						<>2__current = <jumpcall>5__6;
						<>1__state = 7;
						return true;
					case 7:
						<>1__state = -3;
						<jumpcall>5__6 = null;
						goto IL_02c6;
					case 8:
						{
							<>1__state = -3;
							goto IL_02c6;
						}
						IL_02c6:
						<instruction>5__5 = null;
						break;
					}
					if (<>s__4.MoveNext())
					{
						<instruction>5__5 = <>s__4.Current;
						if (!<executed>5__3 && !<Ldfld>5__1 && <instruction>5__5.opcode == OpCodes.Ldfld)
						{
							<Ldfld>5__1 = true;
							<>2__current = <instruction>5__5;
							<>1__state = 1;
							return true;
						}
						if ((!<executed>5__3 & <Ldfld>5__1) && !<foundCall>5__2 && <instruction>5__5.opcode == OpCodes.Callvirt)
						{
							<foundCall>5__2 = true;
							<>2__current = <instruction>5__5;
							<>1__state = 2;
							return true;
						}
						if ((!<executed>5__3 & <Ldfld>5__1 & <foundCall>5__2) && <instruction>5__5.opcode == OpCodes.Brfalse)
						{
							<executed>5__3 = true;
							<jumpcall>5__6 = <instruction>5__5;
							<>2__current = <instruction>5__5;
							<>1__state = 3;
							return true;
						}
						<Ldfld>5__1 = false;
						<foundCall>5__2 = false;
						<>2__current = <instruction>5__5;
						<>1__state = 8;
						return true;
					}
					<>m__Finally1();
					<>s__4 = null;
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				if (<>s__4 != null)
				{
					<>s__4.Dispose();
				}
			}

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

			[DebuggerHidden]
			IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator()
			{
				<SadleUpdateRiding_Transpile>d__42 <SadleUpdateRiding_Transpile>d__;
				if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId)
				{
					<>1__state = 0;
					<SadleUpdateRiding_Transpile>d__ = this;
				}
				else
				{
					<SadleUpdateRiding_Transpile>d__ = new <SadleUpdateRiding_Transpile>d__42(0);
				}
				<SadleUpdateRiding_Transpile>d__.instructions = <>3__instructions;
				return <SadleUpdateRiding_Transpile>d__;
			}

			[DebuggerHidden]
			IEnumerator IEnumerable.GetEnumerator()
			{
				return ((IEnumerable<CodeInstruction>)this).GetEnumerator();
			}
		}

		public static GameObject keyDisplayPanel;

		public static Text EditModeTitle;

		public static Text commandDisplay;

		public static Text keyDisplay;

		public static string CommandStringPos = "";

		public static string CommandStringRot = "";

		public static string CommandStringScale = "";

		public static string keyString = "";

		public static float dampingPercent = 0.9f;

		public static float AdjustSpeed = 0.9f;

		public static Vector3 sumOffset = Vector3.zero;

		public static int countOffset = 0;

		public static Vector3 avgOffset = Vector3.zero;

		public static Vector3 lastPos = Vector3.zero;

		public static Vector3 speedMulti = Vector3.one;

		public static float max_dist = 2f;

		public static float lossyfactor = 0.25f;

		public static bool useSmooth = true;

		public static AdjustMode adjustMode;

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

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

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

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

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

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

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

		public static string getKeybingsString()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			string text = "";
			string text2 = text;
			KeyboardShortcut value = Setup.adjustCustomModeSwitch.Value;
			text = text2 + string.Join("+", ((KeyboardShortcut)(ref value)).Modifiers);
			string text3 = text;
			value = Setup.adjustCustomModeSwitch.Value;
			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 = "Cycle Edit Mode                 \n";
			CommandStringRot = CommandStringPos;
			CommandStringScale = CommandStringPos;
			CommandStringRot += "Tilt Left/Right                 \nRotate Forward/Back                 \nSpin Left/Right                 \n";
			CommandStringPos += "Move Left/Right                 \nMove Forward/Back                 \nMove Up/Down                 \n";
			CommandStringScale += "Width Decrease/Increase                 \nLength Decrease/Increase                 \nHeight Decrease/Increase                 \n";
			string text = "Save to YML                 \n Finer Adjustment:\n0.5x (hold)                 \n0.1x (hold)                 \n0.05x (hold)                 \n";
			CommandStringPos += text;
			CommandStringRot += text;
			CommandStringScale += text;
			keyString = getKeybingsString();
		}

		[HarmonyPatch(typeof(Player), "Update")]
		[HarmonyPrefix]
		private static void PlayerUpdate_Patch(Player __instance)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: 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_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: 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_05ec: 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_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0604: Unknown result type (might be due to invalid IL or missing references)
			//IL_0609: Unknown result type (might be due to invalid IL or missing references)
			//IL_0478: Unknown result type (might be due to invalid IL or missing references)
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0494: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Unknown result type (might be due to invalid IL or missing references)
			//IL_0750: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0630: Unknown result type (might be due to invalid IL or missing references)
			//IL_0637: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0641: Unknown result type (might be due to invalid IL or missing references)
			//IL_0646: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_066d: 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_067e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0509: Unknown result type (might be due to invalid IL or missing references)
			//IL_050e: Unknown result type (might be due to invalid IL or missing references)
			//IL_087b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0880: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c0: 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_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_06fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_056c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0583: Unknown result type (might be due to invalid IL or missing references)
			//IL_0588: Unknown result type (might be due to invalid IL or missing references)
			//IL_08df: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: 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_0839: Unknown result type (might be due to invalid IL or missing references)
			//IL_083e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0840: Unknown result type (might be due to invalid IL or missing references)
			//IL_080b: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0724: Unknown result type (might be due to invalid IL or missing references)
			//IL_072b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0730: Unknown result type (might be due to invalid IL or missing references)
			//IL_0735: Unknown result type (might be due to invalid IL or missing references)
			//IL_073a: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0953: Unknown result type (might be due to invalid IL or missing references)
			//IL_0933: Unknown result type (might be due to invalid IL or missing references)
			//IL_0860: Unknown result type (might be due to invalid IL or missing references)
			//IL_0865: Unknown result type (might be due to invalid IL or missing references)
			//IL_0867: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)ZNet.instance) || !ZNet.instance.IsServer())
			{
				displayKeybinds(active: false);
				return;
			}
			if (!Setup.adjustCustom.Value)
			{
				displayKeybinds(active: false);
				return;
			}
			bool flag = false;
			bool flag2 = false;
			bool flag3 = false;
			bool num = ZInput.instance != null;
			KeyboardShortcut value = Setup.adjustCustomModeSwitch.Value;
			if (num & ((KeyboardShortcut)(ref value)).IsDown())
			{
				adjustMode = (AdjustMode)((int)(adjustMode + 1) % Enum.GetValues(typeof(AdjustMode)).Length);
				string text = "";
				if (CommandStringPos == "")
				{
					SetCommandsStrings();
				}
				switch (adjustMode)
				{
				case AdjustMode.None:
					text = "Adjust Mode: None";
					EditModeTitle.text = "Not Editing";
					commandDisplay.text = CommandStringPos.Substring(0, CommandStringPos.IndexOf('\n'));
					keyDisplay.text = keyString.Substring(0, keyString.IndexOf('\n'));
					break;
				case AdjustMode.Saddle:
					text = "Adjust Mode: Saddle Position";
					EditModeTitle.text = "Adjust Mode: Saddle Position";
					commandDisplay.text = CommandStringPos;
					keyDisplay.text = keyString;
					flag = true;
					break;
				case AdjustMode.Mount:
					text = "Adjust Mode: Player Mount Position";
					EditModeTitle.text = "Adjust Mode: Player Mount Position";
					commandDisplay.text = CommandStringPos;
					keyDisplay.text = keyString;
					flag = true;
					break;
				case AdjustMode.Rotation:
					text = "Adjust Mode: Saddle Rotation";
					EditModeTitle.text = "Adjust Mode: Rotation";
					commandDisplay.text = CommandStringRot;
					keyDisplay.text = keyString;
					flag2 = true;
					break;
				case AdjustMode.Scale:
					text = "Adjust Mode: Saddle Scale";
					EditModeTitle.text = "Adjust Mode: Scale";
					commandDisplay.text = CommandStringScale;
					keyDisplay.text = keyString;
					flag3 =