Decompiled source of OdinHorse v1.9.5

OdinHorse.dll

Decompiled a week 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.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using CreatureManager;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using SoundMixManager;
using TMPro;
using UnityEngine;
using UnityEngine.Audio;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
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: AssemblyFileVersion("1.8.8.0")]
[assembly: Guid("150DFDAF-FF35-4302-B2CC-BEDCE69118D5")]
[assembly: ComVisible(false)]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCopyright("Copyright ©  2022")]
[assembly: AssemblyProduct("OdinHorse")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyDescription("https://valheim.thunderstore.io/package/OdinPlus/OdinHorse")]
[assembly: AssemblyTitle("OdinHorse")]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: CompilationRelaxations(8)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.8.0")]
[module: <a43b5e53-323a-43af-b8d6-96339859bda0>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<a7964fc6-7148-406f-a0f4-94a20241dbee>Embedded]
	internal sealed class <a7964fc6-7148-406f-a0f4-94a20241dbee>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<a7964fc6-7148-406f-a0f4-94a20241dbee>Embedded]
	internal sealed class <7dcbf2ae-e42f-44a7-a69b-5d9109479a97>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <7dcbf2ae-e42f-44a7-a69b-5d9109479a97>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <7dcbf2ae-e42f-44a7-a69b-5d9109479a97>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[<a7964fc6-7148-406f-a0f4-94a20241dbee>Embedded]
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<a7964fc6-7148-406f-a0f4-94a20241dbee>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <a43b5e53-323a-43af-b8d6-96339859bda0>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <a43b5e53-323a-43af-b8d6-96339859bda0>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace SoundMixManager
{
	[HarmonyPatch]
	public static class SoundMixMan
	{
		private static readonly List<AssetBundle> Bundles = new List<AssetBundle>();

		private static AudioMixerGroup _sfxGroup;

		private const int MaxFieldDepth = 4;

		private static readonly Dictionary<Type, FieldInfo[]> FieldCache = new Dictionary<Type, FieldInfo[]>();

		public static void PatchAssetBundle(AssetBundle assetBundle)
		{
			if ((Object)(object)assetBundle != (Object)null && !Bundles.Contains(assetBundle))
			{
				Bundles.Add(assetBundle);
			}
		}

		public static void PatchAssetBundle(string assetBundleFileName, string folderName = "assets")
		{
			if (string.IsNullOrEmpty(assetBundleFileName))
			{
				return;
			}
			AssetBundle val = ((IEnumerable<AssetBundle>)Resources.FindObjectsOfTypeAll<AssetBundle>()).FirstOrDefault((Func<AssetBundle, bool>)((AssetBundle a) => ((Object)a).name == assetBundleFileName));
			if ((Object)(object)val == (Object)null)
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string name = executingAssembly.GetName().Name + "." + folderName + "." + assetBundleFileName;
				try
				{
					using Stream stream = executingAssembly.GetManifestResourceStream(name);
					if (stream != null)
					{
						val = AssetBundle.LoadFromStream(stream);
					}
				}
				catch
				{
				}
			}
			PatchAssetBundle(val);
		}

		private static AudioMixerGroup ResolveSfxGroup(AudioMixer masterMixer)
		{
			if ((Object)(object)_sfxGroup != (Object)null)
			{
				return _sfxGroup;
			}
			if ((Object)(object)masterMixer == (Object)null)
			{
				return null;
			}
			_sfxGroup = ((IEnumerable<AudioMixerGroup>)masterMixer.FindMatchingGroups(string.Empty)).FirstOrDefault((Func<AudioMixerGroup, bool>)((AudioMixerGroup g) => string.Equals(((Object)g).name, "SFX", StringComparison.OrdinalIgnoreCase))) ?? masterMixer.FindMatchingGroups("SFX").FirstOrDefault() ?? masterMixer.FindMatchingGroups("Sfx").FirstOrDefault();
			return _sfxGroup;
		}

		[HarmonyPatch(typeof(AudioMan), "Awake")]
		[HarmonyPostfix]
		private static void AudioMan_Awake_Postfix(AudioMan __instance)
		{
			if (Bundles.Count == 0 || (Object)(object)__instance == (Object)null)
			{
				return;
			}
			AudioMixerGroup val = ResolveSfxGroup(__instance.m_masterMixer);
			if ((Object)(object)val == (Object)null)
			{
				Debug.LogWarning((object)("[" + Assembly.GetExecutingAssembly().GetName().Name + "] SoundMixMan: Valheim's SFX mixer group was not found; mod sounds will ignore the volume slider."));
				return;
			}
			HashSet<GameObject> hashSet = new HashSet<GameObject>();
			Queue<GameObject> queue = new Queue<GameObject>();
			int num = 0;
			int num2 = 0;
			foreach (AssetBundle bundle in Bundles)
			{
				if ((Object)(object)bundle == (Object)null)
				{
					continue;
				}
				GameObject[] array = bundle.LoadAllAssets<GameObject>();
				foreach (GameObject val2 in array)
				{
					if (!((Object)(object)val2 == (Object)null) && hashSet.Add(val2))
					{
						AudioSource[] componentsInChildren = val2.GetComponentsInChildren<AudioSource>(true);
						for (int j = 0; j < componentsInChildren.Length; j++)
						{
							componentsInChildren[j].outputAudioMixerGroup = val;
							num++;
						}
						CollectReferences(val2, queue);
					}
				}
			}
			while (queue.Count > 0)
			{
				GameObject val3 = queue.Dequeue();
				if ((Object)(object)val3 == (Object)null || !hashSet.Add(val3))
				{
					continue;
				}
				AudioSource[] componentsInChildren = val3.GetComponentsInChildren<AudioSource>(true);
				foreach (AudioSource val4 in componentsInChildren)
				{
					if (!((Object)(object)val4.outputAudioMixerGroup != (Object)null))
					{
						val4.outputAudioMixerGroup = val;
						num2++;
					}
				}
				CollectReferences(val3, queue);
			}
			Debug.Log((object)$"[{Assembly.GetExecutingAssembly().GetName().Name}] SoundMixMan: routed {num} bundled and {num2} referenced AudioSource(s) to mixer group '{((Object)val).name}'.");
		}

		private static void CollectReferences(GameObject prefab, Queue<GameObject> queue)
		{
			Component[] componentsInChildren = prefab.GetComponentsInChildren<Component>(true);
			foreach (Component val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && !(val is Transform))
				{
					CollectFromObject(val, ((object)val).GetType(), queue, 0);
				}
			}
		}

		private static void CollectFromObject(object owner, Type type, Queue<GameObject> queue, int depth)
		{
			FieldInfo[] fields = GetFields(type);
			foreach (FieldInfo fieldInfo in fields)
			{
				object value;
				try
				{
					value = fieldInfo.GetValue(owner);
				}
				catch
				{
					continue;
				}
				CollectFromValue(value, queue, depth);
			}
		}

		private static void CollectFromValue(object value, Queue<GameObject> queue, int depth)
		{
			if (value == null)
			{
				return;
			}
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if (val == null)
			{
				Component val2 = (Component)((value is Component) ? value : null);
				if (val2 == null)
				{
					if (value is Object || value is string)
					{
						return;
					}
					if (value is IEnumerable enumerable)
					{
						if (depth >= 4)
						{
							return;
						}
						{
							foreach (object item in enumerable)
							{
								CollectFromValue(item, queue, depth + 1);
							}
							return;
						}
					}
					Type type = value.GetType();
					if (depth < 4 && !type.IsPrimitive && !type.IsEnum && type.IsSerializable)
					{
						CollectFromObject(value, type, queue, depth + 1);
					}
				}
				else if ((Object)(object)val2 != (Object)null)
				{
					queue.Enqueue(val2.gameObject);
				}
			}
			else if ((Object)(object)val != (Object)null)
			{
				queue.Enqueue(val);
			}
		}

		private static FieldInfo[] GetFields(Type type)
		{
			if (FieldCache.TryGetValue(type, out var value))
			{
				return value;
			}
			List<FieldInfo> list = new List<FieldInfo>();
			Type type2 = type;
			while (type2 != null && type2 != typeof(MonoBehaviour) && type2 != typeof(Component) && type2 != typeof(object))
			{
				FieldInfo[] fields = type2.GetFields(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (!fieldInfo.IsNotSerialized)
					{
						Type fieldType = fieldInfo.FieldType;
						if (!fieldType.IsPrimitive && !fieldType.IsEnum && !(fieldType == typeof(string)) && !(fieldType == typeof(decimal)) && (!fieldInfo.IsPrivate || ((MemberInfo)fieldInfo).GetCustomAttribute<SerializeField>() != null || typeof(Object).IsAssignableFrom(fieldType) || IsCollectionOrSerializable(fieldType)))
						{
							list.Add(fieldInfo);
						}
					}
				}
				type2 = type2.BaseType;
			}
			FieldInfo[] array = list.ToArray();
			FieldCache[type] = array;
			return array;
		}

		private static bool IsCollectionOrSerializable(Type type)
		{
			if (!typeof(IEnumerable).IsAssignableFrom(type))
			{
				return type.IsSerializable;
			}
			return true;
		}
	}
}
namespace OdinHorse
{
	[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
	[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
	internal static class HorseJump
	{
		[HarmonyPatch(typeof(Player), "SetControls")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class SetControlsPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Player __instance, ref bool jump)
			{
				if (!jump || !Enabled.Value)
				{
					return;
				}
				Sadle val = RiddenHorseSaddle(__instance);
				if (val != null)
				{
					jump = false;
					if (val.m_nview.IsOwner())
					{
						DoJump(val);
					}
					else
					{
						val.m_nview.InvokeRPC("OdinHorse_Jump", Array.Empty<object>());
					}
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Sadle), "Awake")]
		private static class SadleAwakePatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Sadle __instance)
			{
				if ((Object)(object)__instance.m_character == (Object)null || !((Object)((Component)__instance.m_character).gameObject).name.Contains("rae_OdinHorse"))
				{
					return;
				}
				__instance.m_nview.Register("OdinHorse_Jump", (Action<long>)delegate
				{
					if (Enabled.Value && __instance.m_nview.IsOwner())
					{
						DoJump(__instance);
					}
				});
			}
		}

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> JumpForce;

		internal static ConfigEntry<float> JumpStamina;

		private const string HorsePrefabName = "rae_OdinHorse";

		private const string JumpRpc = "OdinHorse_Jump";

		[return: <7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static Sadle RiddenHorseSaddle(Player player)
		{
			IDoodadController doodadController = player.GetDoodadController();
			Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
			if (val == null || (Object)(object)val == (Object)null)
			{
				return null;
			}
			Character character = val.GetCharacter();
			if (!((Object)(object)character != (Object)null) || !((Object)((Component)character).gameObject).name.Contains("rae_OdinHorse"))
			{
				return null;
			}
			return val;
		}

		private static void DoJump(Sadle sadle)
		{
			Character character = sadle.GetCharacter();
			if (!((Object)(object)character == (Object)null) && character.IsOnGround())
			{
				float value = JumpStamina.Value;
				if (sadle.HaveStamina(value))
				{
					sadle.UseStamina(value);
					character.m_jumpForce = JumpForce.Value;
					character.Jump(false);
				}
			}
		}
	}
	internal static class GameShaders
	{
		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetSceneAwakePatch
		{
			private static void Postfix()
			{
				Fix();
			}
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
		private static readonly HashSet<string> Swapped = new HashSet<string> { "Custom/Gradient Mapped Particle (Unlit)" };

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static AssetBundle s_bundle;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static ManualLogSource s_logger;

		private static bool s_done;

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
		internal static void Init(AssetBundle bundle, ManualLogSource logger)
		{
			s_bundle = bundle;
			s_logger = logger;
		}

		private static void Fix()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Invalid comparison between Unknown and I4
			if (s_done || (Object)(object)s_bundle == (Object)null || (int)SystemInfo.graphicsDeviceType == 4)
			{
				return;
			}
			s_done = true;
			HashSet<Material> hashSet = new HashSet<Material>();
			GameObject[] array = s_bundle.LoadAllAssets<GameObject>();
			for (int i = 0; i < array.Length; i++)
			{
				Renderer[] componentsInChildren = array[i].GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					Material[] sharedMaterials = val.sharedMaterials;
					foreach (Material item in sharedMaterials)
					{
						hashSet.Add(item);
					}
					ParticleSystemRenderer val2 = (ParticleSystemRenderer)(object)((val is ParticleSystemRenderer) ? val : null);
					if (val2 != null)
					{
						hashSet.Add(val2.trailMaterial);
					}
				}
			}
			hashSet.RemoveWhere([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)] (Material m) => (Object)(object)m == (Object)null || (Object)(object)m.shader == (Object)null || !Swapped.Contains(((Object)m.shader).name));
			if (hashSet.Count == 0)
			{
				ManualLogSource obj = s_logger;
				if (obj != null)
				{
					obj.LogInfo((object)"GameShaders: no materials use the swapped shaders.");
				}
				return;
			}
			HashSet<Shader> hashSet2 = new HashSet<Shader>(hashSet.Select((Material m) => m.shader));
			Dictionary<string, Shader> dictionary = new Dictionary<string, Shader>();
			Shader[] array2 = Resources.FindObjectsOfTypeAll<Shader>();
			foreach (Shader val3 in array2)
			{
				if ((Object)(object)val3 != (Object)null && Swapped.Contains(((Object)val3).name) && !hashSet2.Contains(val3) && !dictionary.ContainsKey(((Object)val3).name))
				{
					dictionary[((Object)val3).name] = val3;
				}
			}
			foreach (Material item2 in hashSet)
			{
				if (dictionary.TryGetValue(((Object)item2.shader).name, out var value))
				{
					item2.shader = value;
					ManualLogSource obj2 = s_logger;
					if (obj2 != null)
					{
						obj2.LogInfo((object)("GameShaders: '" + ((Object)item2).name + "' now uses the game's '" + ((Object)value).name + "'."));
					}
				}
				else
				{
					ManualLogSource obj3 = s_logger;
					if (obj3 != null)
					{
						obj3.LogWarning((object)("Material '" + ((Object)item2).name + "': the game's '" + ((Object)item2.shader).name + "' isn't loaded; keeping the bundled copy."));
					}
				}
			}
		}
	}
	[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
	[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
	internal sealed class LanceStyle : MonoBehaviour, IEquipmentVisual
	{
		[HarmonyPatch(typeof(VisEquipment), "UpdateEquipmentVisuals")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class RightHandStylePatch
		{
			private static readonly int s_rightVariant = StringExtensionMethods.GetStableHashCode("OdinHorse_RightItemVariant");

			private static readonly int s_rightBackVariant = StringExtensionMethods.GetStableHashCode("OdinHorse_RightBackItemVariant");

			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(VisEquipment __instance)
			{
				ZNetView val = (((Object)(object)__instance.m_nViewOverride != (Object)null) ? __instance.m_nViewOverride : __instance.m_nview);
				if ((Object)(object)val == (Object)null || !val.IsValid())
				{
					return;
				}
				ZDO zDO = val.GetZDO();
				if (val.IsOwner())
				{
					Humanoid component = ((Component)__instance).GetComponent<Humanoid>();
					if (component != null)
					{
						int num = component.m_rightItem?.m_variant ?? 0;
						int num2 = component.m_hiddenRightItem?.m_variant ?? 0;
						if (zDO.GetInt(s_rightVariant, 0) != num)
						{
							zDO.Set(s_rightVariant, num, false);
						}
						if (zDO.GetInt(s_rightBackVariant, 0) != num2)
						{
							zDO.Set(s_rightBackVariant, num2, false);
						}
					}
				}
				Apply(__instance.m_rightItemInstance, zDO.GetInt(s_rightVariant, 0));
				Apply(__instance.m_rightBackItemInstance, zDO.GetInt(s_rightBackVariant, 0));
			}

			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
			private static void Apply(GameObject instance, int style)
			{
				if ((Object)(object)instance != (Object)null)
				{
					LanceStyle component = instance.GetComponent<LanceStyle>();
					if (component != null && component.m_applied != style)
					{
						component.Setup(style);
					}
				}
			}
		}

		public Material[] m_materials = Array.Empty<Material>();

		public Renderer[] m_renderers = Array.Empty<Renderer>();

		[NonSerialized]
		public int m_applied = -1;

		public void Setup(int style)
		{
			m_applied = style;
			if (m_materials.Length == 0)
			{
				return;
			}
			Material sharedMaterial = m_materials[Mathf.Clamp(style, 0, m_materials.Length - 1)];
			Renderer[] renderers = m_renderers;
			foreach (Renderer val in renderers)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.sharedMaterial = sharedMaterial;
				}
			}
		}

		internal static string[] Numbered(AssetBundle bundle, string baseName)
		{
			List<string> list = new List<string> { baseName };
			while (bundle.Contains($"{baseName}{list.Count}"))
			{
				list.Add($"{baseName}{list.Count}");
			}
			return list.ToArray();
		}

		internal static void AddTo(GameObject prefab, AssetBundle bundle, ManualLogSource logger, params string[] materialNames)
		{
			Transform val = prefab.transform.Find("attach");
			Material[] materials = materialNames.Select([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (string n) => bundle.LoadAsset<Material>(n)).ToArray();
			if ((Object)(object)val == (Object)null || materials.Any([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (Material m) => (Object)(object)m == (Object)null))
			{
				logger.LogWarning((object)(((Object)prefab).name + ": styles need an 'attach' child and the materials " + string.Join(", ", materialNames) + " in the bundle; it keeps one look."));
				return;
			}
			Renderer[] array = (from r in ((Component)val).GetComponentsInChildren<Renderer>(true)
				where (Object)(object)r.sharedMaterial == (Object)(object)materials[0]
				select r).ToArray();
			if (array.Length == 0)
			{
				array = ((Component)val).GetComponentsInChildren<MeshRenderer>(true).Cast<Renderer>().ToArray();
			}
			LanceStyle lanceStyle = ((Component)val).gameObject.AddComponent<LanceStyle>();
			lanceStyle.m_materials = materials;
			lanceStyle.m_renderers = array;
			SharedData shared = prefab.GetComponent<ItemDrop>().m_itemData.m_shared;
			if (shared.m_icons.Length < materials.Length)
			{
				logger.LogWarning((object)($"{((Object)prefab).name}: {materials.Length} styles but {shared.m_icons.Length} icon(s); render the " + "style icons with the Mounted Attack Baker."));
			}
			shared.m_variants = materials.Length;
		}
	}
	[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
	[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
	internal static class MountSeatsFile
	{
		internal const string FileName = "Raelaziel.OdinHorse.MountSeats.yml";

		private const string VersionLine = "# Odin Horse mount seats v3";

		private const string Header = "# Odin Horse mount seats v3\n# Rideable tames with mounted combat. Add a block to add a tame, delete one to remove it.\n#\n#   LegsOut      degrees, legs spread out\n#   ThighsDown   degrees, thighs swing down\n#   KneeBend     degrees, knees bend more\n#   FeetOut      degrees, lower legs swing out\n#   SeatHeight   meters, sit higher\n#   SeatForward  meters, sit further forward\n#   SeatTilt     degrees, whole rider tips forward\n#   LeanForward  degrees, upper body leans forward\n#   MeleeReach   meters, extra melee reach\n#   PickupReach  meters, extra pickup reach\n#   KeepRidingAnimation  true = keep the tame's own riding animation (attacks still work; only the reach values are used)\n#\n# Example (OdinBear): remove the '#' to use it.\n#MidgardBear:\n#  LegsOut: 14\n#  ThighsDown: 0\n#  KneeBend: 0\n#  FeetOut: 0\n#  SeatHeight: 0\n#  SeatForward: 0.16\n#  SeatTilt: 0\n#  LeanForward: 0\n#  MeleeReach: 0.25\n#  PickupReach: 0.25\n";

		private const string DefaultBlocks = "\nLox:\n  LegsOut: 11\n  ThighsDown: -41.4\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0\n  SeatForward: 0.1\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 1\n  PickupReach: 1\n  KeepRidingAnimation: false\n\nMoose:\n  LegsOut: 27\n  ThighsDown: -1.8\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.47\n  SeatTilt: 0\n  LeanForward: 11.9\n  MeleeReach: 0.75\n  PickupReach: 0.75\n  KeepRidingAnimation: false\n\nAsksvin:\n  LegsOut: 14\n  ThighsDown: 0\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.49\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 0\n  PickupReach: 0\n  KeepRidingAnimation: false\n";

		private const string DefaultText = "# Odin Horse mount seats v3\n# Rideable tames with mounted combat. Add a block to add a tame, delete one to remove it.\n#\n#   LegsOut      degrees, legs spread out\n#   ThighsDown   degrees, thighs swing down\n#   KneeBend     degrees, knees bend more\n#   FeetOut      degrees, lower legs swing out\n#   SeatHeight   meters, sit higher\n#   SeatForward  meters, sit further forward\n#   SeatTilt     degrees, whole rider tips forward\n#   LeanForward  degrees, upper body leans forward\n#   MeleeReach   meters, extra melee reach\n#   PickupReach  meters, extra pickup reach\n#   KeepRidingAnimation  true = keep the tame's own riding animation (attacks still work; only the reach values are used)\n#\n# Example (OdinBear): remove the '#' to use it.\n#MidgardBear:\n#  LegsOut: 14\n#  ThighsDown: 0\n#  KneeBend: 0\n#  FeetOut: 0\n#  SeatHeight: 0\n#  SeatForward: 0.16\n#  SeatTilt: 0\n#  LeanForward: 0\n#  MeleeReach: 0.25\n#  PickupReach: 0.25\n\nLox:\n  LegsOut: 11\n  ThighsDown: -41.4\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0\n  SeatForward: 0.1\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 1\n  PickupReach: 1\n  KeepRidingAnimation: false\n\nMoose:\n  LegsOut: 27\n  ThighsDown: -1.8\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.47\n  SeatTilt: 0\n  LeanForward: 11.9\n  MeleeReach: 0.75\n  PickupReach: 0.75\n  KeepRidingAnimation: false\n\nAsksvin:\n  LegsOut: 14\n  ThighsDown: 0\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.49\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 0\n  PickupReach: 0\n  KeepRidingAnimation: false\n";

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 2, 1 })]
		private static CustomSyncedValue<string> s_synced;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static ManualLogSource s_logger;

		private static string FilePath => Path.Combine(Paths.ConfigPath, "Raelaziel.OdinHorse.MountSeats.yml");

		internal static void Init(ConfigSync configSync, ManualLogSource logger)
		{
			s_logger = logger;
			string text = "# Odin Horse mount seats v3\n# Rideable tames with mounted combat. Add a block to add a tame, delete one to remove it.\n#\n#   LegsOut      degrees, legs spread out\n#   ThighsDown   degrees, thighs swing down\n#   KneeBend     degrees, knees bend more\n#   FeetOut      degrees, lower legs swing out\n#   SeatHeight   meters, sit higher\n#   SeatForward  meters, sit further forward\n#   SeatTilt     degrees, whole rider tips forward\n#   LeanForward  degrees, upper body leans forward\n#   MeleeReach   meters, extra melee reach\n#   PickupReach  meters, extra pickup reach\n#   KeepRidingAnimation  true = keep the tame's own riding animation (attacks still work; only the reach values are used)\n#\n# Example (OdinBear): remove the '#' to use it.\n#MidgardBear:\n#  LegsOut: 14\n#  ThighsDown: 0\n#  KneeBend: 0\n#  FeetOut: 0\n#  SeatHeight: 0\n#  SeatForward: 0.16\n#  SeatTilt: 0\n#  LeanForward: 0\n#  MeleeReach: 0.25\n#  PickupReach: 0.25\n\nLox:\n  LegsOut: 11\n  ThighsDown: -41.4\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0\n  SeatForward: 0.1\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 1\n  PickupReach: 1\n  KeepRidingAnimation: false\n\nMoose:\n  LegsOut: 27\n  ThighsDown: -1.8\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.47\n  SeatTilt: 0\n  LeanForward: 11.9\n  MeleeReach: 0.75\n  PickupReach: 0.75\n  KeepRidingAnimation: false\n\nAsksvin:\n  LegsOut: 14\n  ThighsDown: 0\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.49\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 0\n  PickupReach: 0\n  KeepRidingAnimation: false\n";
			try
			{
				if (!File.Exists(FilePath))
				{
					File.WriteAllText(FilePath, "# Odin Horse mount seats v3\n# Rideable tames with mounted combat. Add a block to add a tame, delete one to remove it.\n#\n#   LegsOut      degrees, legs spread out\n#   ThighsDown   degrees, thighs swing down\n#   KneeBend     degrees, knees bend more\n#   FeetOut      degrees, lower legs swing out\n#   SeatHeight   meters, sit higher\n#   SeatForward  meters, sit further forward\n#   SeatTilt     degrees, whole rider tips forward\n#   LeanForward  degrees, upper body leans forward\n#   MeleeReach   meters, extra melee reach\n#   PickupReach  meters, extra pickup reach\n#   KeepRidingAnimation  true = keep the tame's own riding animation (attacks still work; only the reach values are used)\n#\n# Example (OdinBear): remove the '#' to use it.\n#MidgardBear:\n#  LegsOut: 14\n#  ThighsDown: 0\n#  KneeBend: 0\n#  FeetOut: 0\n#  SeatHeight: 0\n#  SeatForward: 0.16\n#  SeatTilt: 0\n#  LeanForward: 0\n#  MeleeReach: 0.25\n#  PickupReach: 0.25\n\nLox:\n  LegsOut: 11\n  ThighsDown: -41.4\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0\n  SeatForward: 0.1\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 1\n  PickupReach: 1\n  KeepRidingAnimation: false\n\nMoose:\n  LegsOut: 27\n  ThighsDown: -1.8\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.47\n  SeatTilt: 0\n  LeanForward: 11.9\n  MeleeReach: 0.75\n  PickupReach: 0.75\n  KeepRidingAnimation: false\n\nAsksvin:\n  LegsOut: 14\n  ThighsDown: 0\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.49\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 0\n  PickupReach: 0\n  KeepRidingAnimation: false\n");
				}
				else
				{
					text = File.ReadAllText(FilePath);
					if (!text.StartsWith("# Odin Horse mount seats v3"))
					{
						text = UpgradeOld(text);
					}
				}
			}
			catch (Exception ex)
			{
				logger.LogError((object)("Couldn't read or create Raelaziel.OdinHorse.MountSeats.yml: " + ex.Message + ". Using the default seats."));
			}
			s_synced = new CustomSyncedValue<string>(configSync, "OdinHorse MountSeats", text);
			s_synced.ValueChanged += delegate
			{
				MountedAttacks.SetSeats(s_synced.Value);
			};
			MountedAttacks.SetSeats(s_synced.Value);
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, "Raelaziel.OdinHorse.MountSeats.yml");
			fileSystemWatcher.Changed += Reload;
			fileSystemWatcher.Created += Reload;
			fileSystemWatcher.Renamed += Reload;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private static string UpgradeOld(string old)
		{
			Dictionary<string, MountedAttacks.MountSeat> dictionary = Parse(old);
			foreach (KeyValuePair<string, MountedAttacks.MountSeat> item in Parse("\nLox:\n  LegsOut: 11\n  ThighsDown: -41.4\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0\n  SeatForward: 0.1\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 1\n  PickupReach: 1\n  KeepRidingAnimation: false\n\nMoose:\n  LegsOut: 27\n  ThighsDown: -1.8\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.47\n  SeatTilt: 0\n  LeanForward: 11.9\n  MeleeReach: 0.75\n  PickupReach: 0.75\n  KeepRidingAnimation: false\n\nAsksvin:\n  LegsOut: 14\n  ThighsDown: 0\n  KneeBend: 0\n  FeetOut: 0\n  SeatHeight: 0.06\n  SeatForward: 0.49\n  SeatTilt: 0\n  LeanForward: 0\n  MeleeReach: 0\n  PickupReach: 0\n  KeepRidingAnimation: false\n"))
			{
				if (!dictionary.TryGetValue(item.Key, out var value) || IsBlank(value))
				{
					dictionary[item.Key] = item.Value;
				}
			}
			string text = string.Concat("# Odin Horse mount seats v3\n# Rideable tames with mounted combat. Add a block to add a tame, delete one to remove it.\n#\n#   LegsOut      degrees, legs spread out\n#   ThighsDown   degrees, thighs swing down\n#   KneeBend     degrees, knees bend more\n#   FeetOut      degrees, lower legs swing out\n#   SeatHeight   meters, sit higher\n#   SeatForward  meters, sit further forward\n#   SeatTilt     degrees, whole rider tips forward\n#   LeanForward  degrees, upper body leans forward\n#   MeleeReach   meters, extra melee reach\n#   PickupReach  meters, extra pickup reach\n#   KeepRidingAnimation  true = keep the tame's own riding animation (attacks still work; only the reach values are used)\n#\n# Example (OdinBear): remove the '#' to use it.\n#MidgardBear:\n#  LegsOut: 14\n#  ThighsDown: 0\n#  KneeBend: 0\n#  FeetOut: 0\n#  SeatHeight: 0\n#  SeatForward: 0.16\n#  SeatTilt: 0\n#  LeanForward: 0\n#  MeleeReach: 0.25\n#  PickupReach: 0.25\n", string.Concat(dictionary.Values.Select(Block)));
			File.Copy(FilePath, FilePath + ".bak", overwrite: true);
			File.WriteAllText(FilePath, text);
			ManualLogSource obj = s_logger;
			if (obj != null)
			{
				obj.LogInfo((object)"Updated Raelaziel.OdinHorse.MountSeats.yml to the new layout (the old file is Raelaziel.OdinHorse.MountSeats.yml.bak).");
			}
			return text;
		}

		private static bool IsBlank(MountedAttacks.MountSeat s)
		{
			if (!s.Adjusts && s.MeleeReach == 0f)
			{
				return s.PickupReach == 0f;
			}
			return false;
		}

		private static string Block(MountedAttacks.MountSeat s)
		{
			string[] source = new string[8]
			{
				"LegsOut: " + F(s.LegsOut),
				"ThighsDown: " + F(s.ThighsDown),
				"KneeBend: " + F(s.KneeBend),
				"FeetOut: " + F(s.FeetOut),
				"SeatHeight: " + F(s.SeatHeight),
				"SeatForward: " + F(s.SeatForward),
				"SeatTilt: " + F(s.SeatTilt),
				"LeanForward: " + F(s.LeanForward)
			};
			List<string> list = new List<string>
			{
				"",
				s.Name + ":"
			};
			if (s.KeepRidingAnimation)
			{
				list.Add("  KeepRidingAnimation: true");
			}
			else
			{
				list.AddRange(source.Select([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (string l) => "  " + l));
			}
			list.Add("  MeleeReach: " + F(s.MeleeReach));
			list.Add("  PickupReach: " + F(s.PickupReach));
			if (!s.KeepRidingAnimation)
			{
				list.Add("  KeepRidingAnimation: false");
			}
			if (s.KeepRidingAnimation)
			{
				list.Add("  # Seat fitting: only used with KeepRidingAnimation: false (then remove the # in front of these).");
				list.AddRange(source.Select([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (string l) => "  #" + l));
			}
			return string.Join("\n", list) + "\n";
			static string F(float v)
			{
				return v.ToString("0.###", CultureInfo.InvariantCulture);
			}
		}

		private static void Reload(object sender, FileSystemEventArgs e)
		{
			if (s_synced == null || !File.Exists(FilePath))
			{
				return;
			}
			try
			{
				s_synced.AssignLocalValue(File.ReadAllText(FilePath));
			}
			catch (Exception ex)
			{
				ManualLogSource obj = s_logger;
				if (obj != null)
				{
					obj.LogError((object)("Couldn't reload Raelaziel.OdinHorse.MountSeats.yml: " + ex.Message));
				}
			}
		}

		internal static Dictionary<string, MountedAttacks.MountSeat> Parse(string text)
		{
			Dictionary<string, MountedAttacks.MountSeat> dictionary = new Dictionary<string, MountedAttacks.MountSeat>();
			MountedAttacks.MountSeat mountSeat = null;
			int num = 0;
			string[] array = text.Split(new char[1] { '\n' });
			foreach (string text2 in array)
			{
				num++;
				int num2 = text2.IndexOf('#');
				string text3 = ((num2 >= 0) ? text2.Substring(0, num2) : text2).TrimEnd(Array.Empty<char>());
				if (text3.Trim().Length == 0)
				{
					continue;
				}
				bool num3 = char.IsWhiteSpace(text3[0]);
				int num4 = text3.IndexOf(':');
				if (!num3)
				{
					string text4 = ((num4 >= 0) ? text3.Substring(0, num4) : text3).Trim().Trim('"', '\'');
					if (num4 < 0 || text4.Length == 0 || text3.Substring(num4 + 1).Trim().Length > 0)
					{
						ManualLogSource obj = s_logger;
						if (obj != null)
						{
							obj.LogWarning((object)string.Format("{0} line {1}: expected a mount name like 'Lox:', got '{2}'.", "Raelaziel.OdinHorse.MountSeats.yml", num, text3.Trim()));
						}
						mountSeat = null;
					}
					else
					{
						MountedAttacks.MountSeat mountSeat2 = (dictionary[text4] = new MountedAttacks.MountSeat(text4));
						mountSeat = mountSeat2;
					}
				}
				else
				{
					if (mountSeat == null)
					{
						continue;
					}
					string text5 = ((num4 >= 0) ? text3.Substring(0, num4).Replace(" ", "").Replace("_", "")
						.Trim()
						.ToLowerInvariant() : "");
					string text6 = ((num4 >= 0) ? text3.Substring(num4 + 1).Trim() : "");
					if (text5 == "keepridinganimation")
					{
						string text7 = text6.ToLowerInvariant();
						mountSeat.KeepRidingAnimation = text7 == "true" || text7 == "yes" || text7 == "1";
						if (!mountSeat.KeepRidingAnimation && text7 != "false" && text7 != "no" && text7 != "0")
						{
							ManualLogSource obj2 = s_logger;
							if (obj2 != null)
							{
								obj2.LogWarning((object)string.Format("{0} line {1}: KeepRidingAnimation is true or false, not '{2}'.", "Raelaziel.OdinHorse.MountSeats.yml", num, text6));
							}
						}
						continue;
					}
					if (!float.TryParse(text6, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
					{
						ManualLogSource obj3 = s_logger;
						if (obj3 != null)
						{
							obj3.LogWarning((object)string.Format("{0} line {1}: '{2}' isn't 'Key: number'.", "Raelaziel.OdinHorse.MountSeats.yml", num, text3.Trim()));
						}
						continue;
					}
					switch (text5)
					{
					case "legsout":
						mountSeat.LegsOut = result;
						continue;
					case "thighsdown":
						mountSeat.ThighsDown = result;
						continue;
					case "kneebend":
						mountSeat.KneeBend = result;
						continue;
					case "feetout":
						mountSeat.FeetOut = result;
						continue;
					case "seatheight":
						mountSeat.SeatHeight = result;
						continue;
					case "seatforward":
						mountSeat.SeatForward = result;
						continue;
					case "seattilt":
						mountSeat.SeatTilt = result;
						continue;
					case "leanforward":
						mountSeat.LeanForward = result;
						continue;
					case "meleereach":
						mountSeat.MeleeReach = result;
						continue;
					case "pickupreach":
						mountSeat.PickupReach = result;
						continue;
					}
					ManualLogSource obj4 = s_logger;
					if (obj4 != null)
					{
						obj4.LogWarning((object)string.Format("{0} line {1}: unknown setting '{2}' for {3}.", "Raelaziel.OdinHorse.MountSeats.yml", num, text3.Trim(), mountSeat.Name));
					}
				}
			}
			return dictionary;
		}
	}
	[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
	[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
	internal static class MountedAttacks
	{
		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		internal sealed class MountSeat
		{
			public readonly string Name;

			public readonly int Hash;

			public float LegsOut;

			public float ThighsDown;

			public float KneeBend;

			public float FeetOut;

			public float SeatHeight;

			public float SeatForward;

			public float SeatTilt;

			public float LeanForward;

			public bool KeepRidingAnimation;

			public float MeleeReach;

			public float PickupReach;

			public bool Adjusts
			{
				get
				{
					if (LegsOut == 0f && ThighsDown == 0f && KneeBend == 0f && FeetOut == 0f && SeatHeight == 0f && SeatForward == 0f && SeatTilt == 0f)
					{
						return LeanForward != 0f;
					}
					return true;
				}
			}

			public MountSeat(string name)
			{
				Name = name;
				Hash = StringExtensionMethods.GetStableHashCode(name);
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private sealed class MountOf
		{
			public int Version = -1;

			public bool Combat;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
			public MountSeat Seat;
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		internal sealed class WeaponFamily
		{
			public readonly string Name;

			public readonly string Description;

			public readonly string[] Clips;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
			public ConfigEntry<bool> Enabled;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
			public ConfigEntry<float> Reach;

			public float DefaultReach = -1f;

			public bool Original;

			public bool Available;

			public bool Melee => DefaultReach >= 0f;

			public WeaponFamily(string name, string description, params string[] clips)
			{
				Name = name;
				Description = description;
				Clips = clips;
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private enum LanceStage
		{
			Raised,
			Lowering,
			Couched,
			Raising
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
		private sealed class Rider
		{
			public RuntimeAnimatorController Original;

			public bool Mounted;

			public bool HoldingAttach;

			public float AimWeight;

			public float AimYaw;

			public float AimPitch;

			public float AimHeading;

			public float ChestYaw;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
			public readonly Quaternion[] AnimatedLocal = (Quaternion[])(object)new Quaternion[PoseBones.Length];

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
			public readonly Quaternion[] WrittenLocal = (Quaternion[])(object)new Quaternion[PoseBones.Length];

			public bool Wrote;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 1, 1, 0 })]
			public readonly Dictionary<Cloth, (float velocity, float acceleration)> CalmedCloth = new Dictionary<Cloth, (float, float)>();

			public float ClothScanTimer;

			public int[] GoodStates;

			public float[] GoodTimes;

			public Behaviour PausedPoseDriver;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
			public readonly List<Renderer> HiddenCape = new List<Renderer>();

			public string Variant;

			public bool Lance;

			public LanceStage LanceStage;

			public float LanceTime;

			public bool LanceInput;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
			public readonly Dictionary<int, float> LanceHits = new Dictionary<int, float>();

			public bool LanceExhausted;

			public MountSeat Seat;

			public int RideParam;

			public bool KeepRide;

			public int RideBool;

			public int RideState;

			public RuntimeAnimatorController FootOriginal;

			public bool Charging;

			public bool ChargeStabbed;

			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)]
			public readonly HashSet<int> ChargeHits = new HashSet<int>();

			public Vector3 AnimatedHips;

			public Vector3 WrittenHips;

			public bool Redirected
			{
				get
				{
					if (RideParam != 0)
					{
						return !KeepRide;
					}
					return false;
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private enum AimMode
		{
			None,
			Ready,
			Bow,
			Throw,
			Ranged,
			Melee,
			Lance
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Attack), "OnAttackTrigger")]
		private static class ChargeStabPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Attack __instance)
			{
				Humanoid character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && s_riders.TryGetValue(val, out var value) && value.Charging)
				{
					value.ChargeStabbed = true;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Awake")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class PlayerAwakePatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Player __instance)
			{
				if (!((Object)(object)((Character)__instance).m_nview == (Object)null) && ((Character)__instance).m_nview.GetZDO() != null)
				{
					Player player = __instance;
					((Character)__instance).m_nview.Register<Vector3, float>("OdinHorse_Unhorse", (Action<long, Vector3, float>)delegate(long _, Vector3 dir, float power)
					{
						//IL_0006: Unknown result type (might be due to invalid IL or missing references)
						Unhorse(player, dir, power);
					});
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "Update")]
		private static class PlayerUpdatePatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Player __instance)
			{
				Tick(__instance);
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "SetControls")]
		private static class SetControlsPatch
		{
			private static void Prefix([<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)] Player __instance, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, out (bool attack, bool attackHold, bool secondary, bool secondaryHold)? __state)
			{
				__state = null;
				if (!Enabled.Value || !IsRidingMount(__instance))
				{
					return;
				}
				if (HoldsLance((Humanoid)(object)__instance))
				{
					Rider orCreateValue = s_riders.GetOrCreateValue(__instance);
					bool flag = attack | attackHold;
					if (!flag)
					{
						orCreateValue.LanceExhausted = false;
					}
					orCreateValue.LanceInput = flag && !orCreateValue.LanceExhausted;
					attack = (attackHold = (secondaryAttack = (secondaryAttackHold = false)));
					return;
				}
				bool flag2 = (attack | attackHold) && HasMountedAttack((Humanoid)(object)__instance, secondary: false);
				bool flag3 = (secondaryAttack | secondaryAttackHold) && HasMountedAttack((Humanoid)(object)__instance, secondary: true);
				if (flag2 || flag3)
				{
					__state = (flag2 & attack, flag2 & attackHold, flag3 & secondaryAttack, flag3 & secondaryAttackHold);
					if (flag2)
					{
						attack = (attackHold = false);
					}
					if (flag3)
					{
						secondaryAttack = (secondaryAttackHold = false);
					}
				}
			}

			private static void Postfix([<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(1)] Player __instance, (bool attack, bool attackHold, bool secondary, bool secondaryHold)? __state)
			{
				if (__state.HasValue)
				{
					(bool, bool, bool, bool) valueOrDefault = __state.GetValueOrDefault();
					if (((Character)__instance).IsAttached())
					{
						((Character)__instance).m_attack = ((Character)__instance).m_attack | valueOrDefault.Item1;
						((Character)__instance).m_attackHold = ((Character)__instance).m_attackHold | valueOrDefault.Item2;
						((Character)__instance).m_secondaryAttack = ((Character)__instance).m_secondaryAttack | valueOrDefault.Item3;
						((Character)__instance).m_secondaryAttackHold = ((Character)__instance).m_secondaryAttackHold | valueOrDefault.Item4;
					}
				}
			}
		}

		[HarmonyPatch]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		private static class BetterRidingMountAttackPatch
		{
			private static MethodBase Target
			{
				get
				{
					Type type = FindType("BetterRiding.Behaviour.MountAttackController");
					if ((object)type == null)
					{
						return null;
					}
					return AccessTools.Method(type, "Update", (Type[])null, (Type[])null);
				}
			}

			private static bool Prepare()
			{
				return Target != null;
			}

			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static MethodBase TargetMethod()
			{
				return Target;
			}

			private static bool Prefix()
			{
				return !RiderFights(Player.m_localPlayer);
			}
		}

		[HarmonyPatch]
		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		private static class BetterRidingRestrictAttackPatch
		{
			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
			private static MethodBase Target
			{
				[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
				get
				{
					Type type = FindType("BetterRiding.Behaviour.MountAttackController+Ygg_RestrictPlayerAttack");
					if ((object)type == null)
					{
						return null;
					}
					return AccessTools.Method(type, "Prefix", (Type[])null, (Type[])null);
				}
			}

			private static bool Prepare()
			{
				return Target != null;
			}

			private static MethodBase TargetMethod()
			{
				return Target;
			}

			private static bool Prefix(Player __0)
			{
				return !RiderFights(__0);
			}
		}

		[HarmonyPatch]
		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		private static class BalrondAttachedCheckPatch
		{
			[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
			private static Type Coordinator
			{
				[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
				get
				{
					return FindType("Balrond.Features.Combat.EquipmentTransitionCoordinator");
				}
			}

			private static bool Prepare()
			{
				return Coordinator != null;
			}

			private static IEnumerable<MethodBase> TargetMethods()
			{
				return from method in ((IEnumerable<string>)new string[2] { "CanStartAttack", "AllowNativeHitTrigger" }).Select((Func<string, MethodBase>)([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (string name) => AccessTools.Method(Coordinator, name, (Type[])null, (Type[])null)))
					where method != null
					select method;
			}

			private static void Prefix(object __0)
			{
				Player val = (Player)((__0 is Player) ? __0 : null);
				Player val3;
				if (val == null)
				{
					Attack val2 = (Attack)((__0 is Attack) ? __0 : null);
					val3 = (Player)((val2 == null) ? null : /*isinst with value type is only supported in some contexts*/);
				}
				else
				{
					val3 = val;
				}
				Player val4 = val3;
				s_balrondRider = (RiderFights(val4) ? val4 : null);
			}

			private static void Finalizer()
			{
				s_balrondRider = null;
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Humanoid), "StartAttack")]
		private static class StartAttackPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Humanoid __instance, bool secondaryAttack)
			{
				if (Enabled.Value)
				{
					Player val = (Player)(object)((__instance is Player) ? __instance : null);
					if (val != null && IsRidingMount(val) && HasMountedAttack((Humanoid)(object)val, secondaryAttack))
					{
						s_seatedAttacker = val;
					}
				}
			}

			private static void Finalizer()
			{
				s_seatedAttacker = null;
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")]
		private static class UpdateAttackBowDrawPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Player __instance, ItemData weapon)
			{
				if (Enabled.Value && IsRidingMount(__instance) && weapon.m_shared.m_attack.m_drawAnimationState == "bow_aim")
				{
					s_drawingRider = __instance;
				}
			}

			private static void Finalizer()
			{
				s_drawingRider = null;
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Player), "IsAttached")]
		private static class IsAttachedPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Player __instance, ref bool __result)
			{
				if ((Object)(object)__instance == (Object)(object)s_drawingRider || (Object)(object)__instance == (Object)(object)s_balrondRider)
				{
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(CharacterAnimEvent), "UpdateFootIK")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class UpdateFootIKPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static bool Prefix(CharacterAnimEvent __instance)
			{
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				if (!IsMounted(__instance.m_character))
				{
					return true;
				}
				Foot[] feets = __instance.m_feets;
				foreach (Foot val in feets)
				{
					__instance.m_animator.SetIKPositionWeight(val.m_ikHandle, 0f);
					__instance.m_animator.SetIKRotationWeight(val.m_ikHandle, 0f);
					val.m_ikWeight = 0f;
				}
				return false;
			}
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		[HarmonyPatch(typeof(CharacterAnimEvent), "CustomLateUpdate")]
		private static class AimTwistPatch
		{
			private static void Postfix(CharacterAnimEvent __instance, float deltaTime)
			{
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0094: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				Character character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null || !s_riders.TryGetValue(val, out var value) || !value.Mounted)
				{
					return;
				}
				Animator animator = __instance.m_animator;
				RestoreAnimatedPose(animator, value);
				if (!value.KeepRide)
				{
					MountSeat seat = value.Seat;
					if (seat != null && seat.Adjusts)
					{
						ApplySeat(animator, AimBasis(val), seat);
					}
				}
				Aim(__instance, val, value, animator, deltaTime);
				for (int i = 0; i < PoseBones.Length; i++)
				{
					Transform boneTransform = animator.GetBoneTransform(PoseBones[i]);
					if ((Object)(object)boneTransform != (Object)null)
					{
						value.WrittenLocal[i] = boneTransform.localRotation;
					}
				}
				Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)0);
				if ((Object)(object)boneTransform2 != (Object)null)
				{
					value.WrittenHips = boneTransform2.localPosition;
				}
				value.Wrote = true;
			}

			private static void ApplySeat(Animator animator, Transform body, MountSeat seat)
			{
				//IL_0013: Unknown result type (might be due to invalid IL or missing references)
				//IL_0019: Unknown result type (might be due to invalid IL or missing references)
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: 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_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_011b: Unknown result type (might be due to invalid IL or missing references)
				//IL_012c: 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_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)0);
				if ((Object)(object)boneTransform != (Object)null)
				{
					boneTransform.position += body.up * seat.SeatHeight + body.forward * seat.SeatForward;
				}
				if ((Object)(object)boneTransform != (Object)null && seat.SeatTilt != 0f)
				{
					boneTransform.rotation = Quaternion.AngleAxis(seat.SeatTilt, body.right) * boneTransform.rotation;
				}
				if (seat.LeanForward != 0f)
				{
					Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)7);
					Transform boneTransform3 = animator.GetBoneTransform((HumanBodyBones)8);
					float num = (((Object)(object)boneTransform3 != (Object)null) ? 0.5f : 1f);
					if ((Object)(object)boneTransform2 != (Object)null)
					{
						boneTransform2.rotation = Quaternion.AngleAxis(seat.LeanForward * num, body.right) * boneTransform2.rotation;
					}
					if ((Object)(object)boneTransform3 != (Object)null)
					{
						boneTransform3.rotation = Quaternion.AngleAxis(seat.LeanForward * num, body.right) * boneTransform3.rotation;
					}
				}
				Leg(animator, (HumanBodyBones)1, (HumanBodyBones)3, (HumanBodyBones)5, -body.right, body, seat);
				Leg(animator, (HumanBodyBones)2, (HumanBodyBones)4, (HumanBodyBones)6, body.right, body, seat);
			}

			private static void Leg(Animator animator, HumanBodyBones upperBone, HumanBodyBones lowerBone, HumanBodyBones footBone, Vector3 outward, Transform body, MountSeat seat)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0009: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: 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_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0080: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0051: 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)
				//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e5: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00fb: 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_0110: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_016f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_017d: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0185: Unknown result type (might be due to invalid IL or missing references)
				//IL_018a: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: 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_0198: 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_019b: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ca: 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_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_013f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0140: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				Transform boneTransform = animator.GetBoneTransform(upperBone);
				Transform boneTransform2 = animator.GetBoneTransform(lowerBone);
				Transform boneTransform3 = animator.GetBoneTransform(footBone);
				if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null)
				{
					return;
				}
				if (seat.ThighsDown != 0f)
				{
					boneTransform.rotation = Quaternion.AngleAxis(seat.ThighsDown, body.right) * boneTransform.rotation;
				}
				Vector3 val = boneTransform2.position - boneTransform.position;
				Vector3 normalized = ((Vector3)(ref val)).normalized;
				Vector3 val2 = Vector3.Cross(normalized, outward);
				if (seat.LegsOut != 0f && ((Vector3)(ref val2)).sqrMagnitude > 1E-06f)
				{
					boneTransform.rotation = Quaternion.AngleAxis(seat.LegsOut, ((Vector3)(ref val2)).normalized) * boneTransform.rotation;
				}
				val = boneTransform2.position - boneTransform.position;
				normalized = ((Vector3)(ref val)).normalized;
				val = boneTransform3.position - boneTransform2.position;
				Vector3 normalized2 = ((Vector3)(ref val)).normalized;
				if (seat.FeetOut != 0f)
				{
					float num = ((Vector3.Dot(Vector3.Cross(normalized, normalized2), outward) >= 0f) ? 1f : (-1f));
					boneTransform.rotation = Quaternion.AngleAxis(seat.FeetOut * num, normalized) * boneTransform.rotation;
				}
				if (seat.KneeBend != 0f)
				{
					val = boneTransform2.position - boneTransform.position;
					normalized = ((Vector3)(ref val)).normalized;
					val = boneTransform3.position - boneTransform2.position;
					normalized2 = ((Vector3)(ref val)).normalized;
					Vector3 val3 = Vector3.Cross(normalized, normalized2);
					if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f)
					{
						val3 = body.right;
					}
					boneTransform2.rotation = Quaternion.AngleAxis(seat.KneeBend, ((Vector3)(ref val3)).normalized) * boneTransform2.rotation;
				}
			}

			private static void Aim(CharacterAnimEvent __instance, Player player, Rider rider, Animator animator, float deltaTime)
			{
				//IL_0089: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_009c: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0114: Unknown result type (might be due to invalid IL or missing references)
				//IL_0128: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0136: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0142: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_021f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0224: Unknown result type (might be due to invalid IL or missing references)
				//IL_0427: Unknown result type (might be due to invalid IL or missing references)
				//IL_042c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0433: Unknown result type (might be due to invalid IL or missing references)
				//IL_0438: Unknown result type (might be due to invalid IL or missing references)
				//IL_043d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0455: Unknown result type (might be due to invalid IL or missing references)
				//IL_045a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0464: Unknown result type (might be due to invalid IL or missing references)
				//IL_02fb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0302: Unknown result type (might be due to invalid IL or missing references)
				//IL_0307: Unknown result type (might be due to invalid IL or missing references)
				//IL_030c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0311: Unknown result type (might be due to invalid IL or missing references)
				//IL_0313: Unknown result type (might be due to invalid IL or missing references)
				//IL_031a: Unknown result type (might be due to invalid IL or missing references)
				//IL_032e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0335: Unknown result type (might be due to invalid IL or missing references)
				//IL_033c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0343: Unknown result type (might be due to invalid IL or missing references)
				//IL_0348: Unknown result type (might be due to invalid IL or missing references)
				//IL_0360: Unknown result type (might be due to invalid IL or missing references)
				//IL_0365: Unknown result type (might be due to invalid IL or missing references)
				//IL_0486: Unknown result type (might be due to invalid IL or missing references)
				//IL_0488: 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_0499: Unknown result type (might be due to invalid IL or missing references)
				//IL_049e: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
				AimMode aimMode = (rider.Lance ? AimMode.Lance : AimModeOf(animator));
				float num = ((AimBlendTime.Value > 0f) ? (deltaTime / AimBlendTime.Value) : 1f);
				rider.AimWeight = Mathf.MoveTowards(rider.AimWeight, (aimMode != AimMode.None) ? 1f : 0f, num);
				bool local = ((Character)player).m_nview.IsOwner();
				Vector3 val = (local ? ((Character)player).GetLookDir() : __instance.m_headLookDir);
				if (rider.AimWeight <= 0f || val == Vector3.zero)
				{
					return;
				}
				Transform val2 = AimBasis(player);
				Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)17);
				Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)18);
				AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
				float blend = (local ? 1f : (1f - Mathf.Exp(-12f * deltaTime)));
				Vector2 val4;
				if (aimMode == AimMode.Lance)
				{
					Vector3 val3 = val2.InverseTransformDirection(val);
					float num2 = Mathf.Atan2(val3.x, val3.z) * 57.29578f;
					float y = val3.y;
					val4 = new Vector2(val3.x, val3.z);
					float num3 = Mathf.Atan2(y, ((Vector2)(ref val4)).magnitude) * 57.29578f;
					rider.AimYaw = Approach(rider.AimYaw, Mathf.Clamp(num2, 0f - LanceTurnLeft.Value, LanceTurnRight.Value));
					rider.AimPitch = Approach(rider.AimPitch, Mathf.Clamp(num3, 0f - LancePitch.Value, LancePitch.Value));
					rider.AimHeading = rider.AimYaw;
				}
				else if ((aimMode == AimMode.Ready || (uint)(aimMode - 3) <= 2u) ? true : false)
				{
					if (aimMode == AimMode.Ready && !animator.IsInTransition(0))
					{
						rider.ChestYaw = Mathf.LerpAngle(rider.ChestYaw, ChestYaw(animator, val2), 1f - Mathf.Exp(-10f * deltaTime));
					}
					ClampAim(val2, val, out var yaw, out var pitch);
					float num4 = aimMode switch
					{
						AimMode.Throw => ThrowTurn.Value, 
						AimMode.Ranged => 1f, 
						_ => MeleeTurn.Value, 
					};
					if (aimMode == AimMode.Ready)
					{
						pitch = 0f;
					}
					float num5 = ((aimMode == AimMode.Throw) ? 0f : rider.ChestYaw);
					rider.AimYaw = Approach(rider.AimYaw, Mathf.DeltaAngle(num5, yaw * num4));
					rider.AimPitch = Approach(rider.AimPitch, pitch * num4);
					rider.AimHeading = yaw * num4;
				}
				else if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash == s_bowAimState && !animator.IsInTransition(0))
				{
					Vector3 val5 = val2.InverseTransformDirection(boneTransform.position - boneTransform2.position);
					float num6 = Mathf.Atan2(val5.x, val5.z) * 57.29578f;
					float y2 = val5.y;
					val4 = new Vector2(val5.x, val5.z);
					float num7 = Mathf.Atan2(y2, ((Vector2)(ref val4)).magnitude) * 57.29578f;
					ClampAim(val2, val, out var yaw2, out var pitch2);
					rider.AimYaw = Approach(rider.AimYaw, Mathf.DeltaAngle(num6, yaw2));
					rider.AimPitch = Approach(rider.AimPitch, pitch2 - num7);
					rider.AimHeading = yaw2;
				}
				float num8 = rider.AimYaw * rider.AimWeight;
				float num9 = rider.AimPitch * rider.AimWeight;
				float num10 = 0f;
				(HumanBodyBones, float)[] twistChain = TwistChain;
				for (int i = 0; i < twistChain.Length; i++)
				{
					var (val6, num11) = twistChain[i];
					if ((Object)(object)animator.GetBoneTransform(val6) != (Object)null)
					{
						num10 += num11;
					}
				}
				if (num10 <= 0f)
				{
					return;
				}
				Vector3 val7 = Quaternion.AngleAxis(rider.AimHeading, val2.up) * val2.right;
				twistChain = TwistChain;
				for (int i = 0; i < twistChain.Length; i++)
				{
					(HumanBodyBones, float) tuple2 = twistChain[i];
					HumanBodyBones item = tuple2.Item1;
					float item2 = tuple2.Item2;
					Transform boneTransform3 = animator.GetBoneTransform(item);
					if (!((Object)(object)boneTransform3 == (Object)null))
					{
						float num12 = item2 / num10;
						boneTransform3.rotation = Quaternion.AngleAxis((0f - num9) * num12, val7) * Quaternion.AngleAxis(num8 * num12, val2.up) * boneTransform3.rotation;
					}
				}
				float Approach(float current, float target)
				{
					if (!local || !(BodyTurnSpeed.Value > 0f))
					{
						return Mathf.Lerp(current, target, blend);
					}
					return Mathf.MoveTowards(current, target, BodyTurnSpeed.Value * deltaTime);
				}
			}
		}

		[HarmonyPatch(typeof(CharacterAnimEvent), "UpdateLookat")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class UpdateLookatPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(CharacterAnimEvent __instance)
			{
				Character character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && s_riders.TryGetValue(val, out var value) && value.Mounted && !(value.AimWeight <= 0f))
				{
					__instance.m_animator.SetLookAtWeight(__instance.m_lookAtWeight * (1f - value.AimWeight), 0f, __instance.m_headLookWeight, __instance.m_eyeLookWeight, __instance.m_lookClamp);
				}
			}
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		[HarmonyPatch(typeof(Player), "AutoPickup")]
		private static class AutoPickupPatch
		{
			[HarmonyPriority(800)]
			private static void Prefix(Player __instance, out float __state)
			{
				__state = __instance.m_autoPickupRange;
				if (Enabled.Value && IsRidingMount(__instance))
				{
					__instance.m_autoPickupRange += PickupReach.Value + (RiderSeat(__instance)?.PickupReach ?? 0f);
				}
			}

			[HarmonyPriority(800)]
			private static void Finalizer(Player __instance, float __state)
			{
				__instance.m_autoPickupRange = __state;
			}
		}

		[HarmonyPatch(typeof(Attack), "GetProjectileSpawnPoint")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class GetProjectileSpawnPointPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Attack __instance, ref Vector3 spawnPoint, ref Vector3 aimDir)
			{
				//IL_003f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_009d: Unknown result type (might be due to invalid IL or missing references)
				//IL_008f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				Humanoid character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && Enabled.Value && IsRidingMount(val))
				{
					Transform val2 = AimBasis(val);
					if (__instance.m_attackAnimation == "spear_throw")
					{
						ClampAim(val2, ((Character)val).GetLookDir(), out var yaw, out var pitch);
						aimDir = val2.rotation * (Quaternion.Euler(0f - pitch, yaw * ThrowTurn.Value, 0f) * Vector3.forward);
					}
					else
					{
						aimDir = ClampAim(val2, __instance.m_useCharacterFacing ? ((Humanoid)val).GetAimDir(spawnPoint) : aimDir, out var _, out var _);
					}
					Transform boneTransform = ((Character)val).m_animator.GetBoneTransform((HumanBodyBones)(__instance.m_bowDraw ? 17 : 18));
					if (!((Object)(object)boneTransform == (Object)null))
					{
						spawnPoint = boneTransform.position + ((Vector3)(ref aimDir)).normalized * 0.4f;
					}
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Attack), "GetMeleeAttackDir")]
		private static class GetMeleeAttackDirPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Attack __instance, ref Vector3 attackDir)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00af: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
				Humanoid character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && Enabled.Value && IsRidingMount(val))
				{
					Transform val2 = AimBasis(val);
					ClampAim(val2, ((Character)val).GetLookDir(), out var yaw, out var _);
					Vector3 val3 = val2.InverseTransformDirection(((Character)val).GetLookDir());
					float y = val3.y;
					Vector2 val4 = new Vector2(val3.x, val3.z);
					float num = Mathf.Clamp(Mathf.Atan2(y, ((Vector2)(ref val4)).magnitude) * 57.29578f, 0f - MeleeAimDown.Value, MeleeAimUp.Value);
					attackDir = val2.rotation * (Quaternion.Euler(0f - num, yaw, 0f) * Vector3.forward);
				}
			}
		}

		[HarmonyPatch(typeof(Attack), "Start")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class AttackStartPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Humanoid character, Rigidbody body)
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val != null && Enabled.Value && IsRidingMount(val) && !((Object)(object)val.m_attachPoint == (Object)null))
				{
					((Component)val).transform.rotation = val.m_attachPoint.rotation;
					if ((Object)(object)body != (Object)null)
					{
						body.rotation = val.m_attachPoint.rotation;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "RPC_Damage")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class RPC_DamagePatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Character __instance, HitData hit)
			{
				if (!Enabled.Value)
				{
					return;
				}
				float num = 1f;
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null)
				{
					if (IsRidingMount(val))
					{
						num = PlayerDamageTaken.Value;
					}
				}
				else if (((Object)((Component)__instance).gameObject).name.Contains("rae_OdinHorse"))
				{
					Sadle componentInChildren = ((Component)__instance).GetComponentInChildren<Sadle>();
					if (componentInChildren != null && componentInChildren.HaveValidUser())
					{
						num = HorseDamageTaken.Value;
					}
				}
				if (!Mathf.Approximately(num, 1f))
				{
					hit.ApplyModifier(num);
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(ZSyncAnimation), "RPC_SetTrigger")]
		private static class RPC_SetTriggerPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			[HarmonyPriority(0)]
			private static void Postfix(ZSyncAnimation __instance, string name)
			{
				Player component = ((Component)__instance).GetComponent<Player>();
				if (component != null && s_riders.TryGetValue(component, out var value) && value.Mounted)
				{
					Animator animator = ((Character)component).m_animator;
					if ((Object)(object)animator != (Object)null && ReclaimController(component, animator, value))
					{
						animator.SetTrigger(name);
					}
				}
			}
		}

		[HarmonyPatch(typeof(FejdStartup), "Awake")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class CompatPatch
		{
			private static bool s_done;

			private static void Postfix()
			{
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Expected O, but got Unknown
				if (s_done || Harmony == null)
				{
					return;
				}
				s_done = true;
				s_windstrideDriver = FindType("QuickMod.BowString.BowDrawDriver");
				if (s_windstrideDriver != null)
				{
					ManualLogSource s_logger = MountedAttacks.s_logger;
					if (s_logger != null)
					{
						s_logger.LogInfo((object)"Windstride's Bow Animations found: its bow poses are paused while riding an Odin Horse.");
					}
				}
				MethodInfo methodInfo = FindType("DualWield.DualWield")?.GetMethod("FastReplaceRAC", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				if (!(methodInfo == null))
				{
					Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(CompatPatch), "SkipWhileMounted", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					ManualLogSource s_logger2 = MountedAttacks.s_logger;
					if (s_logger2 != null)
					{
						s_logger2.LogInfo((object)"DualWield found: its animation swaps are paused while riding an Odin Horse.");
					}
				}
			}

			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static bool SkipWhileMounted(Player player)
			{
				return !IsMounted((Character)(object)player);
			}
		}

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(0)]
		[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
		private static class DoMeleeAttackPatch
		{
			private static void Prefix(Attack __instance, out float __state)
			{
				__state = __instance.m_attackRange;
				Humanoid character = __instance.m_character;
				Player val = (Player)(object)((character is Player) ? character : null);
				if (val == null || !Enabled.Value || !IsRidingMount(val))
				{
					return;
				}
				float attackRange = __instance.m_attackRange;
				float num = MeleeReachBonus.Value + (RiderSeat(val)?.MeleeReach ?? 0f);
				float num2;
				if (__instance.m_weapon != null)
				{
					WeaponFamily weaponFamily = FamilyOf(__instance.m_weapon, __instance);
					if (weaponFamily != null)
					{
						ConfigEntry<float> reach = weaponFamily.Reach;
						if (reach != null)
						{
							num2 = reach.Value;
							goto IL_0082;
						}
					}
				}
				num2 = 0f;
				goto IL_0082;
				IL_0082:
				__instance.m_attackRange = attackRange + (num + num2);
			}

			private static void Finalizer(Attack __instance, float __state)
			{
				__instance.m_attackRange = __state;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "GetAimDir")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class GetAimDirPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Humanoid __instance, ref Vector3 __result)
			{
				//IL_0026: 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)
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				Player val = (Player)(object)((__instance is Player) ? __instance : null);
				if (val != null && Enabled.Value && IsRidingMount(val))
				{
					__result = ClampAim(AimBasis(val), __result, out var _, out var _);
				}
			}
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		[HarmonyPatch(typeof(Character), "CanMove")]
		private static class CanMovePatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Postfix(Character __instance, ref bool __result)
			{
				if (!__result && !((Object)(object)__instance != (Object)(object)s_seatedAttacker))
				{
					__result = !__instance.IsStaggering() && __instance.GetNextOrCurrentAnimHash() == Character.s_animatorTagSitting;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "AttachStop")]
		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)]
		private static class AttachStopPatch
		{
			[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(1)]
			private static void Prefix(Player __instance)
			{
				if (__instance.m_attached && s_riders.TryGetValue(__instance, out var value) && (value.HoldingAttach || value.Redirected))
				{
					if (!string.IsNullOrEmpty(__instance.m_attachAnimation))
					{
						((Character)__instance).m_animator.SetBool(__instance.m_attachAnimation, true);
					}
					value.HoldingAttach = false;
				}
			}
		}

		internal static ConfigEntry<bool> Enabled = null;

		internal static ConfigEntry<bool> OtherTames = null;

		internal static ConfigEntry<float> BowTurnLeft = null;

		internal static ConfigEntry<float> BowTurnRight = null;

		internal static ConfigEntry<float> BowPitch = null;

		internal static ConfigEntry<float> MeleeTurn = null;

		internal static ConfigEntry<float> ThrowTurn = null;

		internal static ConfigEntry<float> LanceTurnRight = null;

		internal static ConfigEntry<float> LanceTurnLeft = null;

		internal static ConfigEntry<float> LancePitch = null;

		internal static ConfigEntry<bool> LanceUnhorse = null;

		internal static ConfigEntry<float> LanceUnhorsePower = null;

		internal static ConfigEntry<float> LanceStaminaDrain = null;

		internal static ConfigEntry<float> LanceHitInterval = null;

		internal static ConfigEntry<float> LanceMinSpeed = null;

		internal static ConfigEntry<float> LanceFullSpeed = null;

		internal static ConfigEntry<float> LanceMaxPower = null;

		internal static ConfigEntry<float> LanceChargeDamage = null;

		internal static ConfigEntry<float> LanceChargePush = null;

		internal static ConfigEntry<float> BodyTurnSpeed = null;

		internal static ConfigEntry<float> AimBlendTime = null;

		internal static ConfigEntry<float> MeleeReachBonus = null;

		internal static ConfigEntry<float> MeleeAimDown = null;

		internal static ConfigEntry<float> MeleeAimUp = null;

		internal static ConfigEntry<float> PickupReach = null;

		internal static ConfigEntry<bool> HideCape = null;

		internal static ConfigEntry<float> PlayerDamageTaken = null;

		internal static ConfigEntry<float> HorseDamageTaken = null;

		private const string HorsePrefabName = "rae_OdinHorse";

		private static Dictionary<string, MountSeat> s_seats = new Dictionary<string, MountSeat>();

		private static int s_mountsVersion;

		private static readonly ConditionalWeakTable<Sadle, MountOf> s_saddleMounts = new ConditionalWeakTable<Sadle, MountOf>();

		private static bool s_otherTames;

		private static readonly int s_mountSeatKey = StringExtensionMethods.GetStableHashCode("OdinHorse_MountSeat");

		private static readonly int s_mountRideKey = StringExtensionMethods.GetStableHashCode("OdinHorse_MountRide");

		private static readonly int s_mountKeepKey = StringExtensionMethods.GetStableHashCode("OdinHorse_MountKeepRide");

		private const float ReturnToRideFade = 0.2f;

		private const int ZSyncSalt = 438569;

		private static readonly int s_mountedKey = StringExtensionMethods.GetStableHashCode("OdinHorse_MountedAttacks");

		private static readonly int s_attachLox = ZSyncAnimation.GetHash("attach_lox");

		private static readonly int s_rideLox = Animator.StringToHash("Base Layer.RideLox");

		private static readonly int s_movement = Animator.StringToHash("Base Layer.Movement");

		private static readonly int s_bowAimState = Animator.StringToHash("Base Layer.bow aim");

		private static readonly int s_bowFireState = Animator.StringToHash("Base Layer.bow fire");

		private static readonly int s_spearThrowState = Animator.StringToHash("Base Layer.spear_throw");

		private static readonly int s_crossbowFireState = Animator.StringToHash("Base Layer.crossbow fire");

		private static readonly int s_blocking = ZSyncAnimation.GetHash("blocking");

		private static readonly Dictionary<int, int> BlockStates = new Dictionary<int, int>
		{
			{
				0,
				Animator.StringToHash("Base Layer.Unarmed Blocking")
			},
			{
				1,
				Animator.StringToHash("Base Layer.One handed Blocking")
			},
			{
				2,
				Animator.StringToHash("Base Layer.Two handed blocking")
			},
			{
				3,
				Animator.StringToHash("Base Layer.Bow blocking")
			},
			{
				4,
				Animator.StringToHash("Base Layer.Shield blocking")
			},
			{
				5,
				Animator.StringToHash("Base Layer.One handed Blocking")
			},
			{
				6,
				Animator.StringToHash("Base Layer.Shield blocking")
			},
			{
				7,
				Animator.StringToHash("Base Layer.Atgeir Blocking")
			},
			{
				8,
				Animator.StringToHash("Base Layer.Battleaxe Blocking")
			},
			{
				10,
				Animator.StringToHash("Base Layer.Crossbow Blocking")
			},
			{
				11,
				Animator.StringToHash("Base Layer.Dual Wield Blocking")
			},
			{
				12,
				Animator.StringToHash("Base Layer.Staff Blocking")
			},
			{
				13,
				Animator.StringToHash("Base Layer.Two handed blocking")
			},
			{
				14,
				Animator.StringToHash("Base Layer.One handed Blocking")
			},
			{
				15,
				Animator.StringToHash("Base Layer.Dual Wield Blocking")
			}
		};

		private static readonly HashSet<int> BlockStateHashes = new HashSet<int>(BlockStates.Values);

		private const float AimSmoothing = 12f;

		private const float ChestYawSmoothing = 10f;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 1, 0 })]
		private static readonly (HumanBodyBones bone, float share)[] TwistChain = new(HumanBodyBones, float)[3]
		{
			((HumanBodyBones)7, 0.3f),
			((HumanBodyBones)8, 0.3f),
			((HumanBodyBones)54, 0.4f)
		};

		private static readonly int s_bowAim = ZSyncAnimation.GetHash("bow_aim");

		private static readonly int s_attackTag = Animator.StringToHash("attack");

		private static readonly Dictionary<string, string> ClipMap = new Dictionary<string, string>
		{
			{ "Attack1", "Mounted_Attack1_2" },
			{ "Attack2", "Mounted_Attack2" },
			{ "Attack3", "Mounted_Attack3" },
			{ "Sword-Attack-R4", "Mounted_Sword-Attack-R4" },
			{ "axe_swing", "Mounted_axe_swing" },
			{ "Axe combo 2", "Mounted_Axe_combo_2" },
			{ "Axe combo 3", "Mounted_Axe_combo_3" },
			{ "Axe Secondary Attack", "Mounted_Axe_Secondary_Attack" },
			{ "MaceAltAttack", "Mounted_MaceAltAttack" },
			{ "Javelin Stab", "Mounted_Javelin_Stab" },
			{ "throw_spear", "Mounted_throw_spear" },
			{ "Bow Aim Idle 01", "Mounted_Bow_Aim_Idle_01" },
			{ "Bow Aim Walk Forward", "Mounted_Bow_Aim_Idle_01" },
			{ "Bow Aim Walk Back", "Mounted_Bow_Aim_Idle_01" },
			{ "Bow Aim Walk Left", "Mounted_Bow_Aim_Idle_01" },
			{ "Bow Aim Walk Right", "Mounted_Bow_Aim_Idle_01" },
			{ "Bow Aim Recoil", "Mounted_Bow_Aim_Recoil" },
			{ "Fire Crossbow", "Mounted_Fire_Crossbow" },
			{ "Reload Crossbow", "Mounted_Reload_Crossbow" }
		};

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 1, 0, 1, 1 })]
		private static readonly (string prefix, string mounted)[] BlockFamilies = new(string, string)[14]
		{
			("Block idle", "Mounted_Block_idle"),
			("Block TwoHand ", "Mounted_Block_idle"),
			("Block Atgeir ", "Mounted_Block_idle"),
			("Sword And Shield Idle", "Mounted_Sword_And_Shield_Idle"),
			("Block Shield ", "Mounted_Sword_And_Shield_Idle"),
			("fight idle", "Mounted_fight_idle"),
			("Block Unarmed ", "Mounted_fight_idle"),
			("Block Bow ", "Mounted_Block_Bow_Idle"),
			("Crossbow Idle Block", "Mounted_Crossbow_Idle_Block"),
			("Block Crossbow ", "Mounted_Crossbow_Idle_Block"),
			("Knife Idle Block", "Mounted_Knife_Idle_Block"),
			("Block DualWield ", "Mounted_Knife_Idle_Block"),
			("Block Idle Staff", "Mounted_Block_Idle_Staff"),
			("Block Staff ", "Mounted_Block_Idle_Staff")
		};

		internal static readonly WeaponFamily[] Families = new WeaponFamily[20]
		{
			new WeaponFamily("Swords", "one-handed swords", "Attack1_2", "Attack2", "Attack3", "Sword-Attack-R4")
			{
				DefaultReach = 0f,
				Original = true
			},
			new WeaponFamily("Axes", "one-handed axes", "axe_swing", "Axe combo 2", "Axe combo 3", "Axe Secondary Attack")
			{
				DefaultReach = 0f,
				Original = true
			},
			new WeaponFamily("Clubs", "clubs and maces", "Attack1_2", "Attack2", "Attack3", "MaceAltAttack")
			{
				DefaultReach = 0f,
				Original = true
			},
			new WeaponFamily("Spears", "spears (stab and throw)", "Javelin Stab", "throw_spear")
			{
				DefaultReach = 0f,
				Original = true
			},
			new WeaponFamily("Knives", "knives", "knife_slash0", "knife_slash1", "knife_slash2", "Knife JumpAttack")
			{
				DefaultReach = 0.75f
			},
			new WeaponFamily("Torches", "torches", "Attack1_2", "Attack2", "Attack3")
			{
				DefaultReach = 0.25f,
				Original = true
			},
			new WeaponFamily("Fists", "bare fists", "Punchstep 1_0", "Punchstep 2_0", "Kickstep")
			{
				DefaultReach = 0.75f
			},
			new WeaponFamily("Greatswords", "two-handed swords", "Greatsword BaseAttack (1)", "Greatsword BaseAttack (2)", "Greatsword BaseAttack (3)", "Greatsword Secondary Attack")
			{
				DefaultReach = 0f
			},
			new WeaponFamily("Battleaxes", "battleaxes", "BattleAxe1", "BattleAxe2", "BattleAxe_Combo3", "BattleAxeAltAttack")
			{
				DefaultReach = 0f
			},
			new WeaponFamily("Sledges", "sledges and two-handed clubs", "Sledge-Attack1")
			{
				DefaultReach = 0f
			},
			new WeaponFamily("Atgeirs", "atgeirs", "2Hand-Spear-Attack1", "2Hand-Spear-Attack9", "2Hand-Spear-Attack3", "Atgeir360Attack")
			{
				DefaultReach = 0f
			},
			new WeaponFamily("Dual Axes", "dual axes", "DualAxes Attack 1", "DualAxes Attack 2 2", "DualAxes Attack 3 2", "DualAxes Attack 4", "DualAxes Attack Cleave")
			{
				DefaultReach = 0.25f
			},
			new WeaponFamily("Dual Knives", "dual knives", "Knife Attack Combo (1)", "Knife Attack Combo (2)", "Knife Attack Combo (3)", "Knife Attack Leap")
			{
				DefaultReach = 0.75f
			},
			new WeaponFamily("Bows", "bows", "Bow Aim Idle 01", "Bow Aim Recoil")
			{
				Original = true
			},
			new WeaponFamily("Crossbows", "crossbows", "Fire Crossbow", "Reload Crossbow")
			{
				Original = true
			},
			new WeaponFamily("Elemental Staffs", "elemental magic staffs (fire, frost, lightning, beam)", "Fireball Staff Attacks (1)", "Fireball Staff Attacks (2)", "FrostShield", "Thunderstruck", "Lightning Staff Attack", "Fire Crossbow", "Beam Staff Attack", "Beam Staff Attack Loop", "Beam Staff Attack 2 FW"),
			new WeaponFamily("Blood Magic Staffs", "blood magic staffs (shield and summons)", "Ground Staff Attack", "Skeleton Summon", "Troll Summon"),
			new WeaponFamily("Pickaxes", "pickaxes", "swing_pickaxe")
			{
				DefaultReach = 0.25f
			},
			new WeaponFamily("Tools", "scythes and shovels", "Scything", "Attack Shovel 1 Upperbody", "Attack Shovel 2 Upperbody", "Attack Shovel 3", "Attack Shovel Secondary")
			{
				DefaultReach = 0.25f
			},
			new WeaponFamily("Bombs", "thrown bombs", "BombThrow")
		};

		private const string BowDrawState = "bow_aim";

		private static readonly Dictionary<int, string> RideVariants = new Dictionary<int, string>
		{
			{ 1, "1H" },
			{ 4, "Shield" },
			{ 5, "1H" },
			{ 6, "Shield" },
			{ 3, "Bow" },
			{ 2, "TwoHanded" },
			{ 7, "Atgeir" },
			{ 8, "Battleaxe" },
			{ 10, "Crossbow" },
			{ 11, "DualWield" },
			{ 12, "Staff" },
			{ 13, "Greatsword" },
			{ 14, "MagicItem" },
			{ 15, "DualWield" },
			{ 16, "Feaster" },
			{ 17, "Scythe" }
		};

		private static readonly string[] RideClips = new string[3] { "Riding_Idle", "Riding_Walk", "Riding_Canter" };

		private const string PlainVariant = "Plain";

		internal static readonly string[] LancePrefabNames = new string[10] { "Rae_OdinLance", "Rae_OdinWildwood_Lance", "Rae_OdinBronzepine_Lance", "Rae_OdinSerpent_Lance", "Rae_OdinMoonsilver_Lance", "Rae_OdinObsidian_Lance", "Rae_OdinBlackmetal_Lance", "Rae_OdinCarapace_Lance", "Rae_OdinBone_Lance", "Rae_OdinFrost_Lance" };

		private static readonly HashSet<string> s_lanceNames = new HashSet<string>(LancePrefabNames);

		private static readonly HashSet<int> s_lanceItems = new HashSet<int>(LancePrefabNames.Select([<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(0)] (string n) => StringExtensionMethods.GetStableHashCode(n)));

		private static readonly int s_lanceCouchKey = StringExtensionMethods.GetStableHashCode("OdinHorse_LanceCouched");

		private const string LanceBlockClip = "Mounted_Lance_Block";

		private const string LanceLowerClip = "Mounted_Lance_Lower";

		private const string LanceRaiseClip = "Mounted_Lance_Raise";

		private const float MountedClothVelocity = 0.25f;

		private const float MountedClothAcceleration = 0.1f;

		private const float ClothScanInterval = 1f;

		private const float MountedProjectileLead = 0.4f;

		private static readonly int s_statei = ZSyncAnimation.GetHash("statei");

		private static readonly HumanBodyBones[] PoseBones;

		private static readonly Dictionary<string, AnimationClip> s_clips;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 1, 0, 1, 2, 1 })]
		private static readonly Dictionary<(RuntimeAnimatorController, string), AnimatorOverrideController> s_overrides;

		private static readonly ConditionalWeakTable<Player, Rider> s_riders;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static Player s_seatedAttacker;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static Player s_drawingRider;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		internal static Harmony Harmony;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static ManualLogSource s_logger;

		private static readonly HashSet<int> ReadyStates;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static Type s_windstrideDriver;

		private static readonly List<Renderer> s_capeRenderers;

		internal const string ChargeClip = "Lance_Charge";

		private const string KnifeLeapClip = "Knife JumpAttack";

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(new byte[] { 1, 0, 1, 1, 1 })]
		private static readonly Dictionary<(RuntimeAnimatorController, string), AnimatorOverrideController> s_footOverrides;

		private const float LanceHitReach = 0.45f;

		private const float LanceHitRadius = 0.3f;

		private static readonly Collider[] s_lanceOverlap;

		private static int s_lanceMask;

		private const string UnhorseRpc = "OdinHorse_Unhorse";

		private const float UnhorsePush = 12f;

		[<7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static Player s_balrondRider;

		internal static void SetSeats(string yml)
		{
			Dictionary<string, MountSeat> dictionary = MountSeatsFile.Parse(yml);
			if (!dictionary.ContainsKey("rae_OdinHorse"))
			{
				dictionary["rae_OdinHorse"] = HorseSeat();
			}
			s_seats = dictionary;
			s_mountsVersion++;
		}

		private static MountSeat HorseSeat()
		{
			return new MountSeat("rae_OdinHorse")
			{
				ThighsDown = 13.8f,
				KneeBend = 3.7f,
				FeetOut = -0.9f,
				SeatHeight = 0.12f
			};
		}

		[return: <7dcbf2ae-e42f-44a7-a69b-5d9109479a97>Nullable(2)]
		private static MountSeat RiderSeat(Player player)
		{
			if (!s_riders.TryGetValue(player, out var value))
			{
				return null;
			}
			return value.Seat;
		}

		[<3c17a47d-0d11-4b53-b66e-cc71de3a99f5>NullableContext(2)]
		private static MountSeat SeatByHash(int hash)
		{
			if (hash == 0)
			{
				return null;
			}
			foreach (MountSeat value in s_seats.Values)
			{
				if (value.Hash == hash)
				{
					return value;
				}
			}
			return null;
		}

		private static MountOf MountInfo(Sadle sadle)
		{
			if (OtherTames.Value != s_otherTames)
			{
				s_otherTames = OtherTames.Value;
				s_mountsVersion++;
			}
			MountOf orCreateValue = s_saddleMounts.GetOrCreateValue(sadle);
			if (orCreateValue.Version == s_mountsVersion)
			{
				return orCreateValue;
			}
			orCreateValue.Version = s_mountsVersion;
			Character character = sadle.GetCharacter();
			string name = (((Object)(object)character != (Object)null) ? ((Object)((Component)character).gameObject).name : "");
			MountSeat mountSeat = (from s in s_seats.Values
				where name.Contains(s.Name)
				orderby s.Name.Length descending
				select s).FirstOrDefault();
			orCreateValue.Combat = name.Contains("rae_OdinHorse") || (s_otherTames && mountSeat != null);
			orCreateValue.Seat = (orCreateValue.Combat ? mountSeat : null);
			retur