Decompiled source of OdinHorse v1.6.1

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 CreatureManager;
using HarmonyLib;
using ItemManager;
using JetBrains.Annotations;
using LocalizationManager;
using Microsoft.CodeAnalysis;
using PieceManager;
using ServerSync;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using YamlDotNet.Core;
using YamlDotNet.Core.Events;
using YamlDotNet.Core.Tokens;
using YamlDotNet.Helpers;
using YamlDotNet.Serialization;
using YamlDotNet.Serialization.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.2.7.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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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.2.7.0")]
[module: <ca17ce5c-c752-4e86-ad51-bc052d246a50>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<4a24035f-546a-4ca5-acfb-045346217fc7>Embedded]
	internal sealed class <4a24035f-546a-4ca5-acfb-045346217fc7>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)]
	[<4a24035f-546a-4ca5-acfb-045346217fc7>Embedded]
	internal sealed class <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[<4a24035f-546a-4ca5-acfb-045346217fc7>Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class <4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[<4a24035f-546a-4ca5-acfb-045346217fc7>Embedded]
	[CompilerGenerated]
	internal sealed class <ca17ce5c-c752-4e86-ad51-bc052d246a50>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <ca17ce5c-c752-4e86-ad51-bc052d246a50>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OdinHorse
{
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	[BepInPlugin("Raelaziel.OdinHorse", "OdinHorse", "1.6.1")]
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	public class OdinHorse : BaseUnityPlugin
	{
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		internal enum Toggle
		{
			On = 1,
			Off = 0
		}

		[HarmonyPatch(typeof(Character), "Awake")]
		[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
		public static class CharacterAwakePatch
		{
			[CompilerGenerated]
			private sealed class <ApplyHorseMaterial>d__1 : IEnumerator<object>, IDisposable, IEnumerator
			{
				private int <>1__state;

				[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				private object <>2__current;

				[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				public Character character;

				[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				public ZNetView znv;

				[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				private SkinnedMeshRenderer <renderer>5__1;

				private int <materialIndex>5__2;

				object IEnumerator<object>.Current
				{
					[DebuggerHidden]
					[return: <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
					get
					{
						return <>2__current;
					}
				}

				object IEnumerator.Current
				{
					[DebuggerHidden]
					[return: <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
					get
					{
						return <>2__current;
					}
				}

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

				[DebuggerHidden]
				void IDisposable.Dispose()
				{
					<renderer>5__1 = null;
					<>1__state = -2;
				}

				private bool MoveNext()
				{
					//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ae: Expected O, but got Unknown
					//IL_0141: Unknown result type (might be due to invalid IL or missing references)
					//IL_014b: Expected O, but got Unknown
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>2__current = null;
						<>1__state = 1;
						return true;
					case 1:
						<>1__state = -1;
						<renderer>5__1 = ((Component)character).GetComponentInChildren<SkinnedMeshRenderer>();
						if ((Object)(object)<renderer>5__1 == (Object)null)
						{
							return false;
						}
						<materialIndex>5__2 = znv.GetZDO().GetInt("HorseMaterial", -1);
						if (<materialIndex>5__2 == -1)
						{
							<>2__current = (object)new WaitForSeconds(0.5f);
							<>1__state = 2;
							return true;
						}
						break;
					case 2:
						<>1__state = -1;
						<materialIndex>5__2 = znv.GetZDO().GetInt("HorseMaterial", -1);
						if (<materialIndex>5__2 == -1 && znv.IsOwner())
						{
							<materialIndex>5__2 = Random.Range(0, horseMaterials.Count);
							znv.GetZDO().Set("HorseMaterial", <materialIndex>5__2);
						}
						else if (<materialIndex>5__2 == -1)
						{
							<>2__current = (object)new WaitForSeconds(1f);
							<>1__state = 3;
							return true;
						}
						break;
					case 3:
						<>1__state = -1;
						<materialIndex>5__2 = znv.GetZDO().GetInt("HorseMaterial", 0);
						break;
					}
					if (<materialIndex>5__2 < 0 || <materialIndex>5__2 >= horseMaterials.Count)
					{
						<materialIndex>5__2 = 0;
					}
					((Renderer)<renderer>5__1).material = horseMaterials[<materialIndex>5__2];
					return false;
				}

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

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

			private static void Postfix(Character __instance)
			{
				if (!(((Object)__instance).name != "rae_OdinHorse(Clone)"))
				{
					ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
					if (!((Object)(object)component == (Object)null) && component.IsValid())
					{
						((MonoBehaviour)__instance).StartCoroutine(ApplyHorseMaterial(__instance, component));
					}
				}
			}

			[IteratorStateMachine(typeof(<ApplyHorseMaterial>d__1))]
			private static IEnumerator ApplyHorseMaterial(Character character, ZNetView znv)
			{
				//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
				return new <ApplyHorseMaterial>d__1(0)
				{
					character = character,
					znv = znv
				};
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Character), "SetLevel")]
		public static class Character_SetLevel_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Character __instance)
			{
				if (!((Object)((Component)__instance).gameObject).name.Contains("rae_OdinHorse"))
				{
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				SkinnedMeshRenderer componentInChildren = ((Component)__instance).GetComponentInChildren<SkinnedMeshRenderer>();
				if (!((Object)(object)componentInChildren == (Object)null))
				{
					int @int = component.GetZDO().GetInt("HorseMaterial", -1);
					if (@int >= 0 && @int < horseMaterials.Count)
					{
						((Renderer)componentInChildren).material = horseMaterials[@int];
					}
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Tameable), "Awake")]
		private static class AddRPCForHorseArmorTameableAwakePatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Tameable __instance)
			{
				if (!((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse"))
				{
					return;
				}
				if ((Object)(object)__instance.m_character != (Object)null)
				{
					Character character = __instance.m_character;
					character.m_onDeath = (Action)Delegate.Remove(character.m_onDeath, new Action(__instance.OnHorseDeath));
					Character character2 = __instance.m_character;
					character2.m_onDeath = (Action)Delegate.Combine(character2.m_onDeath, new Action(__instance.OnHorseDeath));
				}
				if (!((Object)(object)__instance.m_nview == (Object)null) && __instance.m_nview.IsValid())
				{
					__instance.m_nview.Register("AddArmor", (Action<long>)delegate(long sender)
					{
						__instance.RPC_AddArmor(sender);
					});
					__instance.m_nview.Register<bool>("SetArmor", (Action<long, bool>)delegate(long sender, bool enabled)
					{
						__instance.RPC_SetArmor(sender, enabled);
					});
					__instance.m_nview.Register<Vector3>("RemoveArmor", (Action<long, Vector3>)delegate(long sender, Vector3 position)
					{
						//IL_0007: Unknown result type (might be due to invalid IL or missing references)
						__instance.RPC_RemoveArmor(sender, position);
					});
					__instance.m_nview.Register("ToggleWait", (Action<long>)delegate(long sender)
					{
						__instance.RPC_ToggleWait(sender);
					});
					__instance.m_nview.Register<bool>("SetWait", (Action<long, bool>)delegate(long sender, bool enabled)
					{
						__instance.RPC_SetWait(sender, enabled);
					});
					__instance.SetArmor(__instance.HaveArmor());
					__instance.SetWaitAnimation(__instance.IsWaiting());
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		private static class AddTextForRemovalOfArmorTameableGetHoverTextPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Tameable __instance, ref string __result)
			{
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00be: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_0086: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_011f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0124: Unknown result type (might be due to invalid IL or missing references)
				if (!((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse"))
				{
					return;
				}
				if (!__instance.m_nview.IsValid())
				{
					__result = __result ?? "";
				}
				KeyboardShortcut value;
				if (__instance.HaveArmor() && __instance.m_character.IsTamed())
				{
					string obj = __result;
					string text;
					if (ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive())
					{
						Localization instance = Localization.instance;
						value = RemoveArmorHotKey.Value;
						text = instance.Localize("\n[<color=yellow><b>" + ((object)(KeyboardShortcut)(ref value)).ToString() + " + $KEY_Use</b></color>] Remove Armor");
					}
					else
					{
						Localization instance2 = Localization.instance;
						value = RemoveArmorHotKey.Value;
						text = instance2.Localize("\n[<color=yellow><b>" + ((object)(KeyboardShortcut)(ref value)).ToString() + " + $KEY_Use</b></color>] Remove Armor");
					}
					__result = obj + text;
				}
				if (__instance.m_character.IsTamed())
				{
					bool flag = __instance.IsWaiting();
					string obj2 = __result;
					string text2;
					if (ZInput.IsNonClassicFunctionality() && ZInput.IsGamepadActive())
					{
						Localization instance3 = Localization.instance;
						value = WaitHotKey.Value;
						text2 = instance3.Localize("\n[<color=yellow><b>" + ((object)(KeyboardShortcut)(ref value)).ToString() + " + $KEY_Use</b></color>] " + (flag ? "Resume" : "Wait Here"));
					}
					else
					{
						Localization instance4 = Localization.instance;
						value = WaitHotKey.Value;
						text2 = instance4.Localize("\n[<color=yellow><b>" + ((object)(KeyboardShortcut)(ref value)).ToString() + " + $KEY_Use</b></color>] " + (flag ? "Resume" : "Wait Here"));
					}
					__result = obj2 + text2;
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "Interact")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private static class RemoveArmorTameableInteractPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0081: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.m_nview.IsValid() || hold)
				{
					return false;
				}
				if (!((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse"))
				{
					return true;
				}
				if (RemoveArmorHotKey.Value.IsKeyHeld() && __instance.HaveArmor())
				{
					__instance.m_nview.InvokeRPC("RemoveArmor", new object[1] { ((Component)user).transform.position });
					return false;
				}
				if (WaitHotKey.Value.IsKeyHeld())
				{
					__instance.m_nview.InvokeRPC("ToggleWait", Array.Empty<object>());
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Tameable), "Interact")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private static class CycleHorseStateTameableInteractPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Tameable __instance, Humanoid user, bool hold, bool alt, bool __result)
			{
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				if (!(!__instance.m_nview.IsValid() || hold || alt) && ((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse") && !RemoveArmorHotKey.Value.IsKeyHeld() && !WaitHotKey.Value.IsKeyHeld() && __instance.IsTamed() && __instance.IsWaiting())
				{
					__instance.m_nview.InvokeRPC("ToggleWait", Array.Empty<object>());
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "UseItem")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private static class UseArmorOnHorseTameableUseItemPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Tameable __instance, Humanoid user, ItemData item)
			{
				if (((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse") && __instance.m_nview.IsValid() && !((Object)(object)__instance.GetArmorItem() == (Object)null) && __instance.m_character.IsTamed() && !(item.m_shared.m_name != __instance.GetArmorItem().m_itemData.m_shared.m_name))
				{
					if (__instance.HaveArmor())
					{
						((Character)user).Message((MessageType)2, __instance.m_character.GetHoverName() + " Armor Already equipped", 0, (Sprite)null);
						return;
					}
					__instance.m_nview.InvokeRPC("AddArmor", new object[1] { ZNet.GetUID() });
					user.GetInventory().RemoveOneItem(item);
					((Character)user).Message((MessageType)2, __instance.m_character.GetHoverName() + " Armor added", 0, (Sprite)null);
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		public enum HorseBeasts
		{
			player,
			horse
		}

		[HarmonyPatch(typeof(Vagon), "LateUpdate")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private class LateUpdate_Vagon_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Prefix(ref Vagon __instance, ref ConfigurableJoint ___m_attachJoin, ref Rigidbody ___m_body)
			{
				try
				{
					if ((Object)(object)___m_attachJoin != (Object)null && (Object)(object)((Joint)___m_attachJoin).connectedBody == (Object)null)
					{
						__instance.Detach();
					}
				}
				catch (Exception ex)
				{
					Debug.LogError((object)ex);
				}
			}
		}

		[HarmonyPatch(typeof(Vagon), "InUse")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private class InUse_Vagon_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(ref bool __result, ref Vagon __instance)
			{
				if (Object.op_Implicit((Object)(object)__instance.m_container) && __instance.m_container.IsInUse())
				{
					__result = true;
				}
				else if (__instance.IsAttached())
				{
					__result = Object.op_Implicit((Object)(object)((Component)((Joint)__instance.m_attachJoin).connectedBody).gameObject.GetComponent<Player>());
				}
				else
				{
					__result = false;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Vagon), "FixedUpdate")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private class Vagon_FixedUpdate_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(Vagon __instance)
			{
				//IL_0131: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.m_nview.IsValid())
				{
					return false;
				}
				if (__instance.IsAttached())
				{
					ConfigurableJoint attachJoin = __instance.m_attachJoin;
					if ((Object)(object)((attachJoin != null) ? ((Joint)attachJoin).connectedBody : null) == (Object)null)
					{
						__instance.Detach();
						return false;
					}
				}
				__instance.UpdateAudio(Time.fixedDeltaTime);
				if (__instance.m_nview.IsOwner())
				{
					if (Object.op_Implicit((Object)(object)__instance.m_useRequester))
					{
						if (__instance.IsAttached())
						{
							__instance.Detach();
						}
						else
						{
							Character val = FindClosestAttachableAnimal(__instance);
							if ((Object)(object)val != (Object)null)
							{
								AttachCartTo(val, __instance);
							}
							else if (__instance.CanAttach(((Component)__instance.m_useRequester).gameObject))
							{
								AttachCartTo((Character)(object)__instance.m_useRequester, __instance);
							}
							else
							{
								((Character)__instance.m_useRequester).Message((MessageType)2, "Not in the right position", 0, (Sprite)null);
							}
						}
						__instance.m_useRequester = null;
					}
					if (__instance.IsAttached())
					{
						__instance.m_detachDistance = GetCartDetachDistance(AttachedCharacter(__instance));
						if (!__instance.CanAttach(((Component)((Joint)__instance.m_attachJoin).connectedBody).gameObject))
						{
							__instance.Detach();
						}
					}
				}
				else if (__instance.IsAttached())
				{
					__instance.Detach();
				}
				return false;
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(BaseAI), "Follow")]
		private class Tamed_Follow_patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(GameObject go, float dt, ref BaseAI __instance)
			{
				//IL_0049: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.m_character.IsTamed())
				{
					return true;
				}
				BaseAI obj = __instance;
				if ((Object)(object)((MonsterAI)((obj is MonsterAI) ? obj : null)).GetFollowTarget().GetComponent<Player>() == (Object)null)
				{
					return true;
				}
				float num = Vector3.Distance(go.transform.position, ((Component)__instance).transform.position);
				HorseBeasts horseBeasts = ParseCharacterType(__instance.m_character);
				HorseBeasts horseBeasts2 = horseBeasts;
				if (horseBeasts2 == HorseBeasts.horse)
				{
					float num2 = 3f;
					bool flag = num > num2 * 3f;
					if (num < num2)
					{
						__instance.StopMoving();
					}
					else
					{
						__instance.MoveTo(dt, go.transform.position, 0f, flag);
					}
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private class MonsterAI_UpdateAI_WaitPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(MonsterAI __instance, ref bool __result)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				if ((Object)(object)((Component)__instance).gameObject == (Object)null)
				{
					return true;
				}
				if (!((Object)((Component)__instance).gameObject).name.Contains("rae_OdinHorse"))
				{
					return true;
				}
				Tameable component = ((Component)__instance).GetComponent<Tameable>();
				if ((Object)(object)component != (Object)null && component.IsWaiting())
				{
					((BaseAI)__instance).StopMoving();
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Sadle), "UseItem")]
		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		private class Sadle_UseItem_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Sadle __instance, bool __result)
			{
				if (__result)
				{
					Tameable componentInParent = ((Component)__instance).GetComponentInParent<Tameable>();
					if ((Object)(object)componentInParent != (Object)null && componentInParent.IsWaiting())
					{
						componentInParent.m_nview.InvokeRPC("ToggleWait", Array.Empty<object>());
					}
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Character), "Damage")]
		private class Character_Damage_Patch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Character __instance, HitData hit)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("rae_OdinHorse"))
				{
					Tameable component = ((Component)__instance).GetComponent<Tameable>();
					if ((Object)(object)component != (Object)null && component.IsWaiting())
					{
						component.m_nview.InvokeRPC("ToggleWait", Array.Empty<object>());
					}
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		private static class SaddlebagHoverTextPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static void Postfix(Tameable __instance, ref string __result)
			{
				//IL_0082: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse") && SaddleBagsEnabled.Value != 0 && __instance.m_nview.IsValid() && __instance.IsTamed() && __instance.HaveSaddle())
				{
					__result += Localization.instance.Localize($"\n[<color=yellow><b>{SaddleBagsHotKey.Value} + $KEY_Use</b></color>] Open Saddlebags");
				}
			}
		}

		[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)]
		[HarmonyPatch(typeof(Tameable), "Interact")]
		private static class SaddlebagInteractPatch
		{
			[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
			private static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt)
			{
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				if (hold || alt)
				{
					return true;
				}
				if (!((Object)((Component)((Component)__instance).transform.root).gameObject).name.Contains("rae_OdinHorse"))
				{
					return true;
				}
				if (SaddleBagsEnabled.Value == Toggle.Off)
				{
					return true;
				}
				if (!__instance.m_nview.IsValid())
				{
					return true;
				}
				if (!__instance.IsTamed())
				{
					return true;
				}
				if (!__instance.HaveSaddle())
				{
					return true;
				}
				if (!SaddleBagsHotKey.Value.IsKeyHeld())
				{
					return true;
				}
				HorseSaddlebags.Open(__instance);
				return false;
			}
		}

		[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
		public static class CustomMapPins
		{
			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			public class CustomPinhandlerHorse : MonoBehaviour
			{
				public Sprite icon;

				public string pinName;

				private PinData pin;

				private void Awake()
				{
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					//IL_0030: Expected O, but got Unknown
					//IL_0037: Unknown result type (might be due to invalid IL or missing references)
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_0068: Unknown result type (might be due to invalid IL or missing references)
					//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
					//IL_00ae: Invalid comparison between Unknown and I4
					//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
					//IL_00dd: Expected O, but got Unknown
					if (!((Component)this).gameObject.GetComponent<Tameable>().HaveSaddle())
					{
						Object.DestroyImmediate((Object)(object)this);
						return;
					}
					pin = new PinData();
					pin.m_type = (PinType)0;
					pin.m_name = Localization.instance.Localize(pinName);
					pin.m_pos = ((Component)this).transform.position;
					pin.m_icon = icon;
					pin.m_save = false;
					pin.m_checked = false;
					pin.m_ownerID = 0L;
					RectTransform val = (((int)Minimap.instance.m_mode == 2) ? Minimap.instance.m_pinNameRootLarge : Minimap.instance.m_pinNameRootSmall);
					pin.m_NamePinData = new PinNameData(pin);
					Minimap.instance.CreateMapNamePin(pin, val);
					pin.m_NamePinData.PinNameText.richText = true;
					pin.m_NamePinData.PinNameText.overrideColorTags = false;
					Minimap.instance?.m_pins?.Add(pin);
				}

				private void LateUpdate()
				{
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					pin.m_checked = false;
					pin.m_pos = ((Component)this).transform.position;
				}

				private void OnDestroy()
				{
					if (pin != null)
					{
						if (Object.op_Implicit((Object)(object)pin.m_uiElement))
						{
							Minimap.instance.DestroyPinMarker(pin);
						}
						Minimap.instance?.m_pins?.Remove(pin);
					}
				}
			}

			public static void RegisterCustomPin(GameObject go, string name, Sprite icon)
			{
				CustomPinhandlerHorse customPinhandlerHorse = go.AddComponent<CustomPinhandlerHorse>();
				customPinhandlerHorse.pinName = name;
				customPinhandlerHorse.icon = icon;
			}
		}

		[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
		public static class CustomMapPins_Cart
		{
			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			public class CustomPinhandler_Generic_Cart : MonoBehaviour
			{
				public Sprite icon;

				public string pinName;

				private PinData pin;

				private void Awake()
				{
					//IL_0002: Unknown result type (might be due to invalid IL or missing references)
					//IL_000c: Expected O, but got Unknown
					//IL_0013: Unknown result type (might be due to invalid IL or missing references)
					//IL_003f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0044: Unknown result type (might be due to invalid IL or missing references)
					//IL_0084: Unknown result type (might be due to invalid IL or missing references)
					//IL_008a: Invalid comparison between Unknown and I4
					//IL_00af: Unknown result type (might be due to invalid IL or missing references)
					//IL_00b9: Expected O, but got Unknown
					pin = new PinData();
					pin.m_type = (PinType)0;
					pin.m_name = Localization.instance.Localize(pinName);
					pin.m_pos = ((Component)this).transform.position;
					pin.m_icon = icon;
					pin.m_save = false;
					pin.m_checked = false;
					pin.m_ownerID = 0L;
					RectTransform val = (((int)Minimap.instance.m_mode == 2) ? Minimap.instance.m_pinNameRootLarge : Minimap.instance.m_pinNameRootSmall);
					pin.m_NamePinData = new PinNameData(pin);
					Minimap.instance.CreateMapNamePin(pin, val);
					pin.m_NamePinData.PinNameText.richText = true;
					pin.m_NamePinData.PinNameText.overrideColorTags = false;
					Minimap.instance?.m_pins?.Add(pin);
				}

				private void LateUpdate()
				{
					//IL_0019: Unknown result type (might be due to invalid IL or missing references)
					//IL_001e: Unknown result type (might be due to invalid IL or missing references)
					pin.m_checked = false;
					pin.m_pos = ((Component)this).transform.position;
				}

				private void OnDestroy()
				{
					if (pin != null)
					{
						if ((Object)(object)pin.m_uiElement != (Object)null)
						{
							Minimap.instance.DestroyPinMarker(pin);
						}
						Minimap.instance?.m_pins?.Remove(pin);
					}
				}
			}

			public static void RegisterCustomPinGeneric(GameObject go, string name, Sprite icon)
			{
				CustomPinhandler_Generic_Cart customPinhandler_Generic_Cart = go.AddComponent<CustomPinhandler_Generic_Cart>();
				customPinhandler_Generic_Cart.pinName = name;
				customPinhandler_Generic_Cart.icon = icon;
			}
		}

		private const string ModName = "OdinHorse";

		private const string ModVersion = "1.6.1";

		private const string ModGUID = "Raelaziel.OdinHorse";

		private static readonly ConfigSync configSync = new ConfigSync("Raelaziel.OdinHorse")
		{
			DisplayName = "OdinHorse",
			CurrentVersion = "1.6.1",
			MinimumRequiredVersion = "1.6.1"
		};

		private static ConfigEntry<Toggle> serverConfigLocked = null;

		internal static Creature raeHorse;

		internal static ConfigEntry<int> HorseRunningSpeed = null;

		internal static ConfigEntry<int> HorseWalkingSpeed = null;

		internal static ConfigEntry<int> HorseSpeed = null;

		internal static ConfigEntry<int> HorseTurnSpeed = null;

		internal static ConfigEntry<int> HorseRunningTurnSpeed = null;

		internal static ConfigEntry<int> HorseHealth = null;

		internal static ConfigEntry<float> HorseStamina = null;

		internal static ConfigEntry<float> HorseStaminaRegen = null;

		internal static ConfigEntry<float> HorseStaminaRegenHungry = null;

		internal static ConfigEntry<float> HorseProcreationUpdateInterval;

		internal static ConfigEntry<float> HorseProcreationTotalCheckRange;

		internal static ConfigEntry<int> HorseProcreationMaxCreatures;

		internal static ConfigEntry<float> HorseProcreationPartnerCheckRange;

		internal static ConfigEntry<float> HorseProcreationPregnancyChance;

		internal static ConfigEntry<float> HorseProcreationPregnancyDuration;

		internal static ConfigEntry<int> HorseProcreationRequiredLovePoints;

		internal static ConfigEntry<int> HorseOffspringHealth = null;

		internal static ConfigEntry<int> HorseOffspringGrowupTime = null;

		internal static ConfigEntry<float> HorseOffspringMeatDropChance = null;

		internal static ConfigEntry<int> HorseOffspringMeatDropMinimum = null;

		internal static ConfigEntry<int> HorseOffspringMeatDropMaximum = null;

		internal static ConfigEntry<float> HorseOffspringHideDropChance = null;

		internal static ConfigEntry<int> HorseOffspringHideDropMinimum = null;

		internal static ConfigEntry<int> HorseOffspringHideDropMaximum = null;

		internal static ConfigEntry<KeyboardShortcut> RemoveArmorHotKey = null;

		internal static ConfigEntry<KeyboardShortcut> WaitHotKey = null;

		internal static ConfigEntry<KeyboardShortcut> SaddleBagsHotKey = null;

		internal static ConfigEntry<Toggle> SaddleBagsEnabled = null;

		internal static ConfigEntry<int> SaddleBagsWidth = null;

		internal static ConfigEntry<int> SaddleBagsHeight = null;

		internal static ConfigEntry<bool> HideHorsePin;

		internal static ConfigEntry<bool> HideCartPin;

		private static List<Material> horseMaterials;

		private static AssetBundle horseAssetBundle;

		private static string ConfigFileName = "Raelaziel.OdinHorse.cfg";

		private static string ConfigFileFullPath;

		private ConfigEntry<T> config<[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(2)] T>(string group, string name, T value, ConfigDescription description, bool synchronizedSetting = true)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(description.Description + (synchronizedSetting ? " [Synced with Server]" : " [Not Synced with Server]"), description.AcceptableValues, description.Tags);
			ConfigEntry<T> val2 = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, value, val);
			SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val2);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val2;
		}

		private ConfigEntry<T> config<[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(2)] T>(string group, string name, T value, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, value, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		public void Awake()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Expected O, but got Unknown
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Expected O, but got Unknown
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Expected O, but got Unknown
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02eb: Expected O, but got Unknown
			//IL_030b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0316: Expected O, but got Unknown
			//IL_0332: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Expected O, but got Unknown
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Expected O, but got Unknown
			//IL_0384: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Expected O, but got Unknown
			//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Expected O, but got Unknown
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Expected O, but got Unknown
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_040f: Expected O, but got Unknown
			//IL_0426: Unknown result type (might be due to invalid IL or missing references)
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_0473: Expected O, but got Unknown
			//IL_048f: Unknown result type (might be due to invalid IL or missing references)
			//IL_049a: Expected O, but got Unknown
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Expected O, but got Unknown
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f4: Expected O, but got Unknown
			//IL_1086: Unknown result type (might be due to invalid IL or missing references)
			//IL_10fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_163a: Unknown result type (might be due to invalid IL or missing references)
			//IL_163f: Unknown result type (might be due to invalid IL or missing references)
			//IL_164b: Unknown result type (might be due to invalid IL or missing references)
			//IL_165b: Unknown result type (might be due to invalid IL or missing references)
			//IL_166b: Unknown result type (might be due to invalid IL or missing references)
			//IL_167b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1682: Unknown result type (might be due to invalid IL or missing references)
			//IL_168e: Expected O, but got Unknown
			//IL_169b: Unknown result type (might be due to invalid IL or missing references)
			//IL_16a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_16bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_16cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_16dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_16e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_16ef: Expected O, but got Unknown
			//IL_17a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_17af: Expected O, but got Unknown
			Localizer.Load();
			LoadAssetBundle();
			bool saveOnConfigSet = ((BaseUnityPlugin)this).Config.SaveOnConfigSet;
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			serverConfigLocked = config("General", "Lock Configuration", Toggle.On, "If on, the configuration is locked and can be changed by server admins only.");
			configSync.AddLockingConfigEntry<Toggle>(serverConfigLocked);
			HorseRunningSpeed = config("Horse", "Running Speed", 12, new ConfigDescription("Horse's gallop speed when sprinting/riding. Affects unmounted running too.", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseWalkingSpeed = config("Horse", "Walking Speed", 5, new ConfigDescription("Horse's walking speed when not tamed or mounted. Has no effect on mounted walk speed — use Speed Modifier for that.", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseSpeed = config("Horse", "Speed Modifier", 1, new ConfigDescription("Global speed multiplier applied on top of all other speed values. Affects walking, running, and mounted movement. Setting this to 2 doubles all speeds. Primary control for mounted walk speed.", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseTurnSpeed = config("Horse", "Turn Speed", 75, new ConfigDescription("Declare turning speed for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseRunningTurnSpeed = config("Horse", "Run Turn Speed", 120, new ConfigDescription("Declare turning speed when running for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseHealth = config("Horse", "Health", 200, new ConfigDescription("Declare health points for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseStamina = config("Horse", "Stamina", 400f, new ConfigDescription("Declare stamina for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseStaminaRegen = config("Horse", "Stamina Regen", 2f, new ConfigDescription("Declare stamina regen for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseStaminaRegenHungry = config("Horse", "Stamina Regen Hungry", 1f, new ConfigDescription("Declare stamina regen when hungry for Horse", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseProcreationUpdateInterval = config("Horse Procreation", "Update Interval", 10f, "Time interval in seconds to check for procreation.");
			HorseProcreationTotalCheckRange = config("Horse Procreation", "Total Check Range", 10f, "Range in meters to check for total creatures.");
			HorseProcreationMaxCreatures = config("Horse Procreation", "Max Creatures", 4, "Maximum number of creatures allowed in range.");
			HorseProcreationPartnerCheckRange = config("Horse Procreation", "Partner Check Range", 3f, "Range in meters to find a procreation partner.");
			HorseProcreationPregnancyChance = config("Horse Procreation", "Pregnancy Chance", 0.5f, "Chance of becoming pregnant per check.");
			HorseProcreationPregnancyDuration = config("Horse Procreation", "Pregnancy Duration", 10f, "Duration of pregnancy in seconds.");
			HorseProcreationRequiredLovePoints = config("Horse Procreation", "Required Love Points", 4, "Number of love points required to trigger pregnancy.");
			HorseOffspringHealth = config("Horse Offspring", "Health", 60, new ConfigDescription("Declare health points for Horse Offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringGrowupTime = config("Horse Offspring", "Grow-up time", 2000, new ConfigDescription("Declare growup time needed to convert offspring into Horse. Time in seconds.", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringMeatDropChance = config("Horse Offspring", "Meat Drop Chance", 1f, new ConfigDescription("Declare drop chance for Horse Meat from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringMeatDropMinimum = config("Horse Offspring", "Meat Amount Min", 1, new ConfigDescription("Declare minimum amount of Horse Meat to drop from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringMeatDropMaximum = config("Horse Offspring", "Meat Amount Max", 2, new ConfigDescription("Declare maximum amount of Horse Meat to drop from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringHideDropChance = config("Horse Offspring", "Hide Drop Chance", 0.33f, new ConfigDescription("Declare drop chance for Horse Hide from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringHideDropMinimum = config("Horse Offspring", "Hide Amount Min", 1, new ConfigDescription("Declare minimum amount of Horse Hide to drop from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			HorseOffspringHideDropMaximum = config("Horse Offspring", "Hide Amount Max", 1, new ConfigDescription("Declare maximum amount of Horse Hide to drop from offspring", (AcceptableValueBase)null, Array.Empty<object>()));
			RemoveArmorHotKey = config<KeyboardShortcut>("Hotkeys", "Remove Armor Key", new KeyboardShortcut((KeyCode)114, Array.Empty<KeyCode>()), new ConfigDescription("The key needed to be held while interacting with the horse to remove the armor.", (AcceptableValueBase)null, Array.Empty<object>()));
			WaitHotKey = config<KeyboardShortcut>("Hotkeys", "Wait Here Key", new KeyboardShortcut((KeyCode)116, Array.Empty<KeyCode>()), new ConfigDescription("The key needed to be held while interacting with the horse to make it wait in place.", (AcceptableValueBase)null, Array.Empty<object>()));
			SaddleBagsHotKey = config<KeyboardShortcut>("Hotkeys", "Saddlebags Key", new KeyboardShortcut((KeyCode)98, Array.Empty<KeyCode>()), new ConfigDescription("The key needed to be held while interacting with the saddled horse to open its saddlebag inventory.", (AcceptableValueBase)null, Array.Empty<object>()));
			SaddleBagsEnabled = config("Saddlebags", "Disable", Toggle.On, new ConfigDescription("If On, a saddlebag inventory is available on tamed, saddled horses, this setting is still being tested. For performance reasons and memory usage, it is off by default.", (AcceptableValueBase)null, Array.Empty<object>()));
			SaddleBagsWidth = config("Saddlebags", "Width", 2, new ConfigDescription("Number of columns in the saddlebag inventory.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 8), Array.Empty<object>()));
			SaddleBagsHeight = config("Saddlebags", "Height", 1, new ConfigDescription("Number of rows in the saddlebag inventory.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 4), Array.Empty<object>()));
			HideHorsePin = config("Map Icons", "HideHorsePin", value: false, "If true, disables the map icon for the Odin Horse.");
			HideCartPin = config("Map Icons", "HideCartPin", value: false, "If true, disables the map icon for the Odin Cart.");
			Item item = new Item("horsesets", "rae_HorseMeat");
			Item item2 = new Item("horsesets", "rae_HorseHide");
			Item item3 = new Item("horsesets", "rae_OdinHorse_Trophy");
			Item item4 = new Item("horsesets", "rae_CookedHorseMeat");
			Item item5 = new Item("horsesets", "rae_SaddleHorse");
			item5.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item5.MaximumRequiredStationLevel = 5;
			item5.RequiredItems.Add("Bronze", 1);
			item5.RequiredItems.Add("rae_HorseHide", 8);
			item5.CraftAmount = 1;
			Item item6 = new Item("horsesets", "rae_iron_HorseArmor");
			item6.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item6.MaximumRequiredStationLevel = 5;
			item6.RequiredItems.Add("Iron", 10);
			item6.RequiredItems.Add("rae_HorseHide", 20);
			item6.CraftAmount = 1;
			TameableExtensions.m_armorItem = item6.Prefab.GetComponent<ItemDrop>();
			Item item7 = new Item("horsesets", "rae_HorseSticks");
			item7.Configurable = Configurability.Full;
			item7.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1);
			item7.MaximumRequiredStationLevel = 10;
			item7.RequiredItems.Add("rae_HorseMeat", 3);
			item7.RequiredItems.Add("Coal", 1);
			item7.RequiredItems.Add("Dandelion", 2);
			item7.CraftAmount = 2;
			Item item8 = new Item("horsesets", "rae_HorseSoup");
			item8.Configurable = Configurability.Full;
			item8.Crafting.Add(ItemManager.CraftingTable.Cauldron, 1);
			item8.MaximumRequiredStationLevel = 10;
			item8.RequiredItems.Add("rae_HorseMeat", 2);
			item8.RequiredItems.Add("Carrot", 2);
			item8.RequiredItems.Add("Dandelion", 3);
			item8.CraftAmount = 1;
			Item item9 = new Item("horsesets", "rae_HorseMeatSkewer");
			item9.Configurable = Configurability.Full;
			item9.Crafting.Add(ItemManager.CraftingTable.Cauldron, 2);
			item9.MaximumRequiredStationLevel = 10;
			item9.RequiredItems.Add("rae_HorseMeat", 3);
			item9.RequiredItems.Add("Mushroom", 2);
			item9.RequiredItems.Add("NeckTail", 1);
			item9.CraftAmount = 2;
			Item item10 = new Item("horsesets", "rae_Horseaker");
			item10.Configurable = Configurability.Full;
			item10.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item10.MaximumRequiredStationLevel = 10;
			item10.RequiredItems.Add("Iron", 20);
			item10.RequiredItems.Add("rae_OdinHorse_Trophy", 1);
			item10.RequiredItems.Add("ElderBark", 35);
			item10.RequiredUpgradeItems.Add("Iron", 5);
			item10.RequiredUpgradeItems.Add("ElderBark", 10);
			item10.CraftAmount = 1;
			Item item11 = new Item("horsesets", "rae_OdinHorse_Helmet");
			item11.Configurable = Configurability.Full;
			item11.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item11.MaximumRequiredStationLevel = 10;
			item11.RequiredItems.Add("Tin", 10);
			item11.RequiredItems.Add("rae_OdinHorse_Trophy", 1);
			item11.RequiredItems.Add("rae_HorseHide", 5);
			item11.RequiredUpgradeItems.Add("rae_HorseHide", 4);
			item11.RequiredUpgradeItems.Add("Tin", 2);
			item11.CraftAmount = 1;
			Item item12 = new Item("horsesets", "rae_CapeHorseHide");
			item12.Configurable = Configurability.Full;
			item12.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item12.MaximumRequiredStationLevel = 10;
			item12.RequiredItems.Add("rae_HorseHide", 10);
			item12.RequiredItems.Add("rae_OdinHorse_Trophy", 1);
			item12.RequiredItems.Add("Tin", 2);
			item12.RequiredUpgradeItems.Add("rae_HorseHide", 10);
			item12.RequiredUpgradeItems.Add("Tin", 2);
			item12.CraftAmount = 1;
			Item item13 = new Item("horsesets", "ArmorHorseClothHelmet_T1");
			item13.Configurable = Configurability.Full;
			item13.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item13.MaximumRequiredStationLevel = 10;
			item13.RequiredItems.Add("rae_HorseHide", 4);
			item13.RequiredItems.Add("LeatherScraps", 6);
			item13.RequiredItems.Add("rae_OdinHorse_Trophy", 1);
			item13.RequiredUpgradeItems.Add("rae_HorseHide", 2);
			item13.RequiredUpgradeItems.Add("LeatherScraps", 3);
			item13.CraftAmount = 1;
			Item item14 = new Item("horsesets", "ArmorHorseClothHelmet_T2");
			item14.Configurable = Configurability.Full;
			item14.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item14.MaximumRequiredStationLevel = 10;
			item14.RequiredItems.Add("rae_HorseHide", 6);
			item14.RequiredItems.Add("Iron", 15);
			item14.RequiredItems.Add("LeatherScraps", 4);
			item14.RequiredItems.Add("rae_OdinHorse_Trophy", 1);
			item14.RequiredUpgradeItems.Add("rae_HorseHide", 3);
			item14.RequiredUpgradeItems.Add("Iron", 5);
			item14.RequiredUpgradeItems.Add("LeatherScraps", 2);
			item14.CraftAmount = 1;
			Item item15 = new Item("horsesets", "ArmorHorseClothChest_T1");
			item15.Configurable = Configurability.Full;
			item15.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item15.MaximumRequiredStationLevel = 10;
			item15.RequiredItems.Add("rae_HorseHide", 4);
			item15.RequiredItems.Add("LeatherScraps", 8);
			item15.RequiredUpgradeItems.Add("rae_HorseHide", 2);
			item15.RequiredUpgradeItems.Add("LeatherScraps", 4);
			item15.CraftAmount = 1;
			Item item16 = new Item("horsesets", "ArmorHorseClothChest_T2");
			item16.Configurable = Configurability.Full;
			item16.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item16.MaximumRequiredStationLevel = 10;
			item16.RequiredItems.Add("rae_HorseHide", 6);
			item16.RequiredItems.Add("Iron", 20);
			item16.RequiredItems.Add("LeatherScraps", 8);
			item16.RequiredUpgradeItems.Add("rae_HorseHide", 2);
			item16.RequiredUpgradeItems.Add("Iron", 5);
			item16.RequiredUpgradeItems.Add("LeatherScraps", 4);
			item16.CraftAmount = 1;
			Item item17 = new Item("horsesets", "ArmorHorseClothLegs_T1");
			item17.Configurable = Configurability.Full;
			item17.Crafting.Add(ItemManager.CraftingTable.Workbench, 1);
			item17.MaximumRequiredStationLevel = 10;
			item17.RequiredItems.Add("rae_HorseHide", 4);
			item17.RequiredItems.Add("LeatherScraps", 8);
			item17.RequiredUpgradeItems.Add("rae_HorseHide", 2);
			item17.RequiredUpgradeItems.Add("LeatherScraps", 4);
			item17.CraftAmount = 1;
			Item item18 = new Item("horsesets", "ArmorHorseClothLegs_T2");
			item18.Configurable = Configurability.Full;
			item18.Crafting.Add(ItemManager.CraftingTable.Forge, 1);
			item18.MaximumRequiredStationLevel = 10;
			item18.RequiredItems.Add("rae_HorseHide", 6);
			item18.RequiredItems.Add("Iron", 20);
			item18.RequiredItems.Add("LeatherScraps", 8);
			item18.RequiredUpgradeItems.Add("rae_HorseHide", 2);
			item18.RequiredUpgradeItems.Add("Iron", 5);
			item18.RequiredUpgradeItems.Add("LeatherScraps", 4);
			item18.CraftAmount = 1;
			BuildPiece buildPiece = new BuildPiece("horsesets", "rae_OdinHorse_Rug");
			buildPiece.RequiredItems.Add("rae_HorseHide", 20, recover: true);
			buildPiece.Category.Set(BuildPieceCategory.Furniture);
			buildPiece.Crafting.Set(PieceManager.CraftingTable.Workbench);
			BuildPiece buildPiece2 = new BuildPiece("horsesets", "rae_OdinHorse_Rug_Headless");
			buildPiece2.RequiredItems.Add("rae_HorseHide", 20, recover: true);
			buildPiece2.Category.Set(BuildPieceCategory.Furniture);
			buildPiece2.Crafting.Set(PieceManager.CraftingTable.Workbench);
			BuildPiece buildPiece3 = new BuildPiece("horsesets", "rae_HorseChair");
			buildPiece3.RequiredItems.Add("rae_HorseHide", 2, recover: true);
			buildPiece3.RequiredItems.Add("FineWood", 3, recover: true);
			buildPiece3.Category.Set(BuildPieceCategory.Furniture);
			buildPiece3.Crafting.Set(PieceManager.CraftingTable.Workbench);
			BuildPiece buildPiece4 = new BuildPiece("horsesets", "rae_HorseCart");
			buildPiece4.RequiredItems.Add("BronzeNails", 60, recover: true);
			buildPiece4.RequiredItems.Add("FineWood", 40, recover: true);
			buildPiece4.Category.Set(BuildPieceCategory.Misc);
			buildPiece4.Crafting.Set(PieceManager.CraftingTable.Workbench);
			buildPiece4.Prefab.GetComponent<Vagon>().m_breakForce = float.MaxValue;
			GameObject val = ItemManager.PrefabManager.RegisterPrefab("horsesets", "rae_Offspring_Normal");
			GameObject val2 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "rae_Offspring_Normal_ragdoll");
			GameObject val3 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "rae_OdinHorse_ragdoll");
			GameObject val4 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "sfx_horse_idle");
			GameObject val5 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "sfx_horse_birth");
			GameObject val6 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "vfx_horse_birth");
			GameObject val7 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "sfx_horse_hit");
			GameObject val8 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "vfx_horse_death");
			GameObject val9 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "Sfx_horse_love");
			GameObject val10 = ItemManager.PrefabManager.RegisterPrefab("horsesets", "vfx_horse_love");
			Item item19 = new Item("horsesets", "horse_bite_attack");
			item19.Configurable = Configurability.Stats;
			raeHorse = new Creature("horsesets", "rae_OdinHorse")
			{
				ConfigurationEnabled = true,
				TamingTime = 1600f,
				FedDuration = 300f,
				Biome = (Biome)1,
				CanSpawn = true,
				CanBeTamed = true,
				CanHaveStars = true,
				FoodItems = "Blueberries, Carrot, Cloudberry, Barley",
				SpawnChance = 15f,
				GroupSize = new CreatureManager.Range(1f, 2f),
				CheckSpawnInterval = 2000,
				SpecificSpawnTime = SpawnTime.Day,
				SpecificSpawnArea = SpawnArea.Center,
				RequiredWeather = Weather.ClearSkies,
				AttackImmediately = false,
				ForestSpawn = Forest.Both,
				CreatureFaction = (Faction)2,
				Maximum = 1
			};
			raeHorse.Drops["rae_HorseMeat"].Amount = new CreatureManager.Range(1f, 2f);
			raeHorse.Drops["rae_HorseMeat"].DropChance = 100f;
			raeHorse.Drops["rae_HorseHide"].Amount = new CreatureManager.Range(1f, 2f);
			raeHorse.Drops["rae_HorseHide"].DropChance = 100f;
			raeHorse.Drops["rae_OdinHorse_Trophy"].Amount = new CreatureManager.Range(1f, 2f);
			raeHorse.Drops["rae_OdinHorse_Trophy"].DropChance = 10f;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_runSpeed = HorseRunningSpeed.Value;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_walkSpeed = HorseWalkingSpeed.Value;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_speed = HorseSpeed.Value;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_turnSpeed = HorseTurnSpeed.Value;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_runTurnSpeed = HorseRunningTurnSpeed.Value;
			((Character)raeHorse.Prefab.GetComponent<Humanoid>()).m_health = HorseHealth.Value;
			raeHorse.Prefab.GetComponentInChildren<Sadle>(true).m_maxStamina = HorseStamina.Value;
			raeHorse.Prefab.GetComponentInChildren<Sadle>(true).m_staminaRegen = HorseStaminaRegen.Value;
			raeHorse.Prefab.GetComponentInChildren<Sadle>(true).m_staminaRegenHungry = HorseStaminaRegenHungry.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_updateInterval = HorseProcreationUpdateInterval.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_totalCheckRange = HorseProcreationTotalCheckRange.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_maxCreatures = HorseProcreationMaxCreatures.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_partnerCheckRange = HorseProcreationPartnerCheckRange.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_pregnancyChance = HorseProcreationPregnancyChance.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_pregnancyDuration = HorseProcreationPregnancyDuration.Value;
			raeHorse.Prefab.GetComponentInChildren<Procreation>(true).m_requiredLovePoints = HorseProcreationRequiredLovePoints.Value;
			HorseRunningSpeed.SettingChanged += ApplyHorseConfig;
			HorseWalkingSpeed.SettingChanged += ApplyHorseConfig;
			HorseSpeed.SettingChanged += ApplyHorseConfig;
			HorseTurnSpeed.SettingChanged += ApplyHorseConfig;
			HorseRunningTurnSpeed.SettingChanged += ApplyHorseConfig;
			HorseHealth.SettingChanged += ApplyHorseConfig;
			HorseStamina.SettingChanged += ApplyHorseConfig;
			HorseStaminaRegen.SettingChanged += ApplyHorseConfig;
			HorseStaminaRegenHungry.SettingChanged += ApplyHorseConfig;
			HorseProcreationUpdateInterval.SettingChanged += ApplyHorseConfig;
			HorseProcreationTotalCheckRange.SettingChanged += ApplyHorseConfig;
			HorseProcreationMaxCreatures.SettingChanged += ApplyHorseConfig;
			HorseProcreationPartnerCheckRange.SettingChanged += ApplyHorseConfig;
			HorseProcreationPregnancyChance.SettingChanged += ApplyHorseConfig;
			HorseProcreationPregnancyDuration.SettingChanged += ApplyHorseConfig;
			HorseProcreationRequiredLovePoints.SettingChanged += ApplyHorseConfig;
			val.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = item2.Prefab,
				m_amountMin = HorseOffspringHideDropMinimum.Value,
				m_amountMax = HorseOffspringHideDropMaximum.Value,
				m_chance = HorseOffspringHideDropChance.Value,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			val.GetComponent<CharacterDrop>().m_drops.Add(new Drop
			{
				m_prefab = item.Prefab,
				m_amountMin = HorseOffspringMeatDropMinimum.Value,
				m_amountMax = HorseOffspringMeatDropMaximum.Value,
				m_chance = HorseOffspringMeatDropChance.Value,
				m_levelMultiplier = true,
				m_onePerPlayer = false
			});
			((Character)val.GetComponent<Humanoid>()).m_health = HorseOffspringHealth.Value;
			val.GetComponent<Growup>().m_growTime = HorseOffspringGrowupTime.Value;
			if (!HideHorsePin.Value)
			{
				CustomMapPins.RegisterCustomPin(raeHorse.Prefab, "$horse_odin", item3.Prefab.GetComponent<ItemDrop>().m_itemData.m_shared.m_icons[0]);
			}
			if (!HideCartPin.Value)
			{
				CustomMapPins_Cart.RegisterCustomPinGeneric(buildPiece4.Prefab, "$pin_cart", buildPiece4.Prefab.GetComponent<Piece>().m_icon);
			}
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			Harmony val11 = new Harmony("Raelaziel.OdinHorse");
			val11.PatchAll(executingAssembly);
			if (saveOnConfigSet)
			{
				((BaseUnityPlugin)this).Config.SaveOnConfigSet = saveOnConfigSet;
				((BaseUnityPlugin)this).Config.Save();
			}
			SetupWatcher();
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
		}

		private void SetupWatcher()
		{
			FileSystemWatcher fileSystemWatcher = new FileSystemWatcher(Paths.ConfigPath, ConfigFileName);
			fileSystemWatcher.Changed += ReadConfigValues;
			fileSystemWatcher.Created += ReadConfigValues;
			fileSystemWatcher.Renamed += ReadConfigValues;
			fileSystemWatcher.IncludeSubdirectories = true;
			fileSystemWatcher.SynchronizingObject = ThreadingHelper.SynchronizingObject;
			fileSystemWatcher.EnableRaisingEvents = true;
		}

		private void ReadConfigValues(object sender, FileSystemEventArgs e)
		{
			if (!File.Exists(ConfigFileFullPath))
			{
				return;
			}
			try
			{
				((BaseUnityPlugin)this).Config.Reload();
			}
			catch
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("There was an issue loading your " + ConfigFileName));
				((BaseUnityPlugin)this).Logger.LogError((object)"Please check your config entries for spelling and format!");
			}
		}

		private void LoadAssetBundle()
		{
			string text = "OdinHorse.assets.horsesets";
			using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream(text);
			if (stream == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Failed to load embedded resource: " + text));
				return;
			}
			horseAssetBundle = AssetBundle.LoadFromStream(stream);
			if ((Object)(object)horseAssetBundle == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load AssetBundle from stream.");
				return;
			}
			horseMaterials = new List<Material>
			{
				horseAssetBundle.LoadAsset<Material>("Horse_color_Black_Tobiano_pinto"),
				horseAssetBundle.LoadAsset<Material>("Horse_color_brown"),
				horseAssetBundle.LoadAsset<Material>("Horse_color_grays"),
				horseAssetBundle.LoadAsset<Material>("Horse_color_palomino"),
				horseAssetBundle.LoadAsset<Material>("Horse_color_white"),
				horseAssetBundle.LoadAsset<Material>("Horse_color_dark_grey")
			};
		}

		private void RegisterHorseWithCreatureManager()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			Creature creature = new Creature("horsesets", "rae_OdinHorse")
			{
				ConfigurationEnabled = true,
				TamingTime = 1600f,
				FedDuration = 300f,
				Biome = (Biome)1,
				CanSpawn = true,
				CanBeTamed = true,
				CanHaveStars = true,
				FoodItems = "Blueberries, Carrot, Cloudberry, Barley",
				SpawnChance = 15f,
				GroupSize = new CreatureManager.Range(1f, 2f),
				CheckSpawnInterval = 2000,
				SpecificSpawnTime = SpawnTime.Day,
				SpecificSpawnArea = SpawnArea.Center,
				RequiredWeather = Weather.ClearSkies,
				AttackImmediately = false,
				ForestSpawn = Forest.Both,
				CreatureFaction = (Faction)2,
				Maximum = 1
			};
			creature.Drops["rae_HorseMeat"].Amount = new CreatureManager.Range(1f, 2f);
			creature.Drops["rae_HorseMeat"].DropChance = 100f;
			creature.Drops["rae_HorseHide"].Amount = new CreatureManager.Range(1f, 2f);
			creature.Drops["rae_HorseHide"].DropChance = 100f;
			creature.Drops["rae_OdinHorse_Trophy"].Amount = new CreatureManager.Range(1f, 2f);
			creature.Drops["rae_OdinHorse_Trophy"].DropChance = 10f;
		}

		private void OnPrefabPostLoad(GameObject prefab)
		{
			SkinnedMeshRenderer componentInChildren = prefab.GetComponentInChildren<SkinnedMeshRenderer>();
			if (!((Object)(object)componentInChildren == (Object)null))
			{
				((Renderer)componentInChildren).material = horseMaterials[0];
			}
		}

		public static HorseBeasts ParseCharacterType(Character c)
		{
			if (c.IsPlayer())
			{
				return HorseBeasts.player;
			}
			if (c.m_nview.IsValid())
			{
				string name = ((Object)ZNetScene.instance.GetPrefab(c.m_nview.GetZDO().GetPrefab())).name;
				string text = name;
				if (text == "rae_OdinHorse")
				{
					return HorseBeasts.horse;
				}
				return HorseBeasts.horse;
			}
			return HorseBeasts.horse;
		}

		public static Vector3 GetCartOffsetVectorForCharacter(Character c)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)c))
			{
				return new Vector3(0f, 0.8f, 0f - c.GetRadius());
			}
			return new Vector3(0f, 0.8f, 0f);
		}

		public static bool IsAttachableCharacter(Character c)
		{
			return ParseCharacterType(c) switch
			{
				HorseBeasts.player => false, 
				HorseBeasts.horse => true, 
				_ => true, 
			};
		}

		public static float GetCartDetachDistance(Character c)
		{
			if (Object.op_Implicit((Object)(object)c))
			{
				if (c.IsPlayer())
				{
					return 2f;
				}
				return c.GetRadius() * 3f;
			}
			return 0f;
		}

		private static Character FindClosestAttachableAnimal(Vagon cart)
		{
			//IL_00cd: 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_00db: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: 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_00ec: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cart == (Object)null || (Object)(object)cart.m_attachPoint == (Object)null)
			{
				return null;
			}
			Transform attachPoint = cart.m_attachPoint;
			Character result = null;
			float num = float.MaxValue;
			if (!Object.op_Implicit((Object)(object)cart.m_attachPoint))
			{
				return null;
			}
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!((Object)(object)allCharacter == (Object)null) && allCharacter.m_nview.IsValid() && !allCharacter.IsDead() && Object.op_Implicit((Object)(object)allCharacter) && !allCharacter.IsPlayer() && allCharacter.IsTamed() && IsAttachableCharacter(allCharacter))
				{
					Vector3 cartOffsetVectorForCharacter = GetCartOffsetVectorForCharacter(allCharacter);
					Vector3 position = ((Component)allCharacter).transform.position;
					float num2 = Vector3.Distance(position + cartOffsetVectorForCharacter, attachPoint.position);
					float cartDetachDistance = GetCartDetachDistance(allCharacter);
					if (num2 < cartDetachDistance && num2 < num)
					{
						result = allCharacter;
						num = num2;
					}
				}
			}
			return result;
		}

		private static Character AttachedCharacter(Vagon cart)
		{
			if (Object.op_Implicit((Object)(object)cart) && cart.IsAttached())
			{
				return ((Component)((Joint)cart.m_attachJoin).connectedBody).gameObject.GetComponent<Character>();
			}
			return null;
		}

		private static void LogCartContents(Vagon cart)
		{
			Container container = cart.m_container;
			foreach (ItemData allItem in container.GetInventory().GetAllItems())
			{
			}
		}

		private static void AttachCartTo(Character attachTarget, Vagon cart)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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_00a8: 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_00d9: Unknown result type (might be due to invalid IL or missing references)
			cart.m_attachOffset = GetCartOffsetVectorForCharacter(attachTarget);
			cart.m_attachJoin = ((Component)cart).gameObject.AddComponent<ConfigurableJoint>();
			((Joint)cart.m_attachJoin).autoConfigureConnectedAnchor = false;
			((Joint)cart.m_attachJoin).anchor = cart.m_attachPoint.localPosition;
			((Joint)cart.m_attachJoin).connectedAnchor = cart.m_attachOffset;
			((Joint)cart.m_attachJoin).breakForce = cart.m_breakForce;
			cart.m_attachJoin.xMotion = (ConfigurableJointMotion)1;
			cart.m_attachJoin.yMotion = (ConfigurableJointMotion)1;
			cart.m_attachJoin.zMotion = (ConfigurableJointMotion)1;
			SoftJointLimit linearLimit = default(SoftJointLimit);
			((SoftJointLimit)(ref linearLimit)).limit = 0.05f;
			cart.m_attachJoin.linearLimit = linearLimit;
			SoftJointLimitSpring linearLimitSpring = default(SoftJointLimitSpring);
			((SoftJointLimitSpring)(ref linearLimitSpring)).spring = cart.m_spring;
			((SoftJointLimitSpring)(ref linearLimitSpring)).damper = cart.m_springDamping;
			cart.m_attachJoin.linearLimitSpring = linearLimitSpring;
			cart.m_attachJoin.zMotion = (ConfigurableJointMotion)0;
			((Joint)cart.m_attachJoin).connectedBody = ((Component)attachTarget).gameObject.GetComponent<Rigidbody>();
		}

		private static void ApplyHorseConfig(object sender, EventArgs e)
		{
			if ((Object)(object)raeHorse?.Prefab != (Object)null)
			{
				Humanoid component = raeHorse.Prefab.GetComponent<Humanoid>();
				if ((Object)(object)component != (Object)null)
				{
					((Character)component).m_runSpeed = HorseRunningSpeed.Value;
					((Character)component).m_walkSpeed = HorseWalkingSpeed.Value;
					((Character)component).m_speed = HorseSpeed.Value;
					((Character)component).m_turnSpeed = HorseTurnSpeed.Value;
					((Character)component).m_runTurnSpeed = HorseRunningTurnSpeed.Value;
					((Character)component).m_health = HorseHealth.Value;
				}
				Sadle componentInChildren = raeHorse.Prefab.GetComponentInChildren<Sadle>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.m_maxStamina = HorseStamina.Value;
					componentInChildren.m_staminaRegen = HorseStaminaRegen.Value;
					componentInChildren.m_staminaRegenHungry = HorseStaminaRegenHungry.Value;
				}
				Procreation componentInChildren2 = raeHorse.Prefab.GetComponentInChildren<Procreation>(true);
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					componentInChildren2.m_updateInterval = HorseProcreationUpdateInterval.Value;
					componentInChildren2.m_totalCheckRange = HorseProcreationTotalCheckRange.Value;
					componentInChildren2.m_maxCreatures = HorseProcreationMaxCreatures.Value;
					componentInChildren2.m_partnerCheckRange = HorseProcreationPartnerCheckRange.Value;
					componentInChildren2.m_pregnancyChance = HorseProcreationPregnancyChance.Value;
					componentInChildren2.m_pregnancyDuration = HorseProcreationPregnancyDuration.Value;
					componentInChildren2.m_requiredLovePoints = HorseProcreationRequiredLovePoints.Value;
				}
			}
			foreach (Character s_character in Character.s_characters)
			{
				if (((Object)((Component)s_character).gameObject).name.Contains("rae_OdinHorse"))
				{
					Humanoid component2 = ((Component)s_character).GetComponent<Humanoid>();
					if ((Object)(object)component2 != (Object)null)
					{
						((Character)component2).m_runSpeed = HorseRunningSpeed.Value;
						((Character)component2).m_walkSpeed = HorseWalkingSpeed.Value;
						((Character)component2).m_speed = HorseSpeed.Value;
						((Character)component2).m_turnSpeed = HorseTurnSpeed.Value;
						((Character)component2).m_runTurnSpeed = HorseRunningTurnSpeed.Value;
					}
					Sadle componentInChildren3 = ((Component)s_character).GetComponentInChildren<Sadle>(true);
					if ((Object)(object)componentInChildren3 != (Object)null)
					{
						componentInChildren3.m_maxStamina = HorseStamina.Value;
						componentInChildren3.m_staminaRegen = HorseStaminaRegen.Value;
						componentInChildren3.m_staminaRegenHungry = HorseStaminaRegenHungry.Value;
					}
					Procreation componentInChildren4 = ((Component)s_character).GetComponentInChildren<Procreation>(true);
					if ((Object)(object)componentInChildren4 != (Object)null)
					{
						componentInChildren4.m_updateInterval = HorseProcreationUpdateInterval.Value;
						componentInChildren4.m_totalCheckRange = HorseProcreationTotalCheckRange.Value;
						componentInChildren4.m_maxCreatures = HorseProcreationMaxCreatures.Value;
						componentInChildren4.m_partnerCheckRange = HorseProcreationPartnerCheckRange.Value;
						componentInChildren4.m_pregnancyChance = HorseProcreationPregnancyChance.Value;
						componentInChildren4.m_pregnancyDuration = HorseProcreationPregnancyDuration.Value;
						componentInChildren4.m_requiredLovePoints = HorseProcreationRequiredLovePoints.Value;
					}
				}
			}
		}

		static OdinHorse()
		{
			string configPath = Paths.ConfigPath;
			char directorySeparatorChar = Path.DirectorySeparatorChar;
			ConfigFileFullPath = configPath + directorySeparatorChar + ConfigFileName;
		}
	}
	public static class KeyboardExtensions
	{
		public static bool IsKeyDown(this KeyboardShortcut shortcut)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKeyDown(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}

		public static bool IsKeyHeld(this KeyboardShortcut shortcut)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			return (int)((KeyboardShortcut)(ref shortcut)).MainKey != 0 && Input.GetKey(((KeyboardShortcut)(ref shortcut)).MainKey) && ((KeyboardShortcut)(ref shortcut)).Modifiers.All((Func<KeyCode, bool>)Input.GetKey);
		}
	}
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	public static class TameableExtensions
	{
		public static ItemDrop m_armorItem = null;

		public static readonly int s_haveArmorHash = StringExtensionMethods.GetStableHashCode("HaveArmor");

		public static readonly int s_isWaitingHash = StringExtensionMethods.GetStableHashCode("IsWaiting");

		public static ItemDrop GetArmorItem(this Tameable tameable)
		{
			return m_armorItem;
		}

		public static bool IsWaiting(this Tameable tameable)
		{
			return tameable.m_nview.IsValid() && tameable.m_nview.GetZDO().GetBool(s_isWaitingHash, false);
		}

		public static void RPC_ToggleWait(this Tameable tameable, long sender)
		{
			if (tameable.m_nview.IsOwner())
			{
				bool flag = !tameable.IsWaiting();
				tameable.m_nview.GetZDO().Set(s_isWaitingHash, flag);
				tameable.m_nview.InvokeRPC(ZNetView.Everybody, "SetWait", new object[1] { flag });
			}
		}

		public static void RPC_SetWait(this Tameable tameable, long sender, bool enabled)
		{
			tameable.SetWaitAnimation(enabled);
		}

		public static void SetWaitAnimation(this Tameable tameable, bool enabled)
		{
			MonsterAI component = ((Component)tameable).GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null && (Object)(object)((BaseAI)component).m_animator != (Object)null)
			{
				((BaseAI)component).m_animator.SetBool("isWaiting", enabled);
			}
		}

		public static void RPC_AddArmor(this Tameable tameable, long sender)
		{
			if (tameable.m_nview.IsOwner() && !tameable.HaveArmor())
			{
				float num = tameable.m_character.GetHealth() / tameable.m_character.GetMaxHealth();
				tameable.m_character.SetMaxHealth(tameable.m_character.GetMaxHealth() + 200f);
				tameable.m_character.SetHealth(tameable.m_character.GetMaxHealth() * num);
				tameable.m_nview.GetZDO().Set(s_haveArmorHash, true);
				tameable.m_nview.InvokeRPC(ZNetView.Everybody, "SetArmor", new object[1] { true });
			}
		}

		public static void RPC_SetArmor(this Tameable tameable, long sender, bool enabled)
		{
			tameable.SetArmor(enabled);
		}

		public static void RPC_RemoveArmor(this Tameable tameable, long sender, Vector3 userPoint)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (tameable.m_nview.IsOwner())
			{
				Character character = tameable.m_character;
				float num = character.GetHealth() / character.GetMaxHealth();
				character.SetMaxHealth(character.GetMaxHealth() - 200f);
				character.SetHealth(character.GetMaxHealth() * num);
				tameable.DropArmor(userPoint);
			}
		}

		public static void SetArmor(this Tameable tameable, bool enabled)
		{
			ZLog.Log((object)("Setting armor:" + enabled));
			if (!((Object)(object)tameable.GetArmorItem() == (Object)null))
			{
				SetArmorObjectsOn(tameable, enabled);
			}
		}

		public static void SetArmorObjectsOn(Tameable tameable, bool enabled)
		{
			((Component)Utils.FindChild(((Component)tameable).transform, "Horse_mask", (IterativeSearchType)0)).gameObject.SetActive(enabled);
			((Component)Utils.FindChild(((Component)tameable).transform, "horse_armor", (IterativeSearchType)0)).gameObject.SetActive(enabled);
		}

		public static bool HaveArmor(this Tameable tameable)
		{
			return tameable.m_nview.IsValid() && tameable.m_nview.GetZDO().GetBool(s_haveArmorHash, false);
		}

		public static bool DropArmor(this Tameable tameable, Vector3 userPoint)
		{
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (!tameable.HaveArmor())
			{
				return false;
			}
			tameable.m_nview.GetZDO().Set(s_haveArmorHash, false);
			tameable.m_nview.InvokeRPC(ZNetView.Everybody, "SetArmor", new object[1] { false });
			tameable.SpawnArmor(userPoint - ((Component)tameable).transform.position);
			return true;
		}

		public static void SpawnArmor(this Tameable tameable, Vector3 flyDirection)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_0040: 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_007e: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			Rigidbody component = Object.Instantiate<GameObject>(((Component)m_armorItem).gameObject, ((Component)tameable).transform.TransformPoint(tameable.m_dropSaddleOffset), Quaternion.identity).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Vector3 val = Vector3.up;
				if ((double)((Vector3)(ref flyDirection)).magnitude > 0.10000000149011612)
				{
					flyDirection.y = 0f;
					((Vector3)(ref flyDirection)).Normalize();
					val += flyDirection;
				}
				component.AddForce(val * tameable.m_dropItemVel, (ForceMode)2);
			}
		}

		public static void OnHorseDeath(this Tameable tameable)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			ZLog.Log((object)("Valid " + tameable.m_nview.IsValid()));
			ZLog.Log((object)("On death " + tameable.HaveArmor()));
			if (tameable.HaveArmor() && tameable.m_dropSaddleOnDeath)
			{
				ZLog.Log((object)"Spawning armor ");
				tameable.SpawnArmor(Vector3.zero);
			}
			if (tameable.m_nview.IsValid() && tameable.m_nview.IsOwner())
			{
				HorseSaddlebags.DropAll(tameable.m_nview, ((Component)tameable).transform.position);
			}
		}
	}
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	public class CoroutineRunner : MonoBehaviour
	{
		private static CoroutineRunner s_instance;

		public static void Run(IEnumerator routine)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			if ((Object)(object)s_instance == (Object)null)
			{
				GameObject val = new GameObject("OdinHorse_CoroutineRunner");
				Object.DontDestroyOnLoad((Object)(object)val);
				s_instance = val.AddComponent<CoroutineRunner>();
			}
			((MonoBehaviour)s_instance).StartCoroutine(routine);
		}
	}
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	public static class HorseSaddlebags
	{
		[CompilerGenerated]
		private sealed class <SpawnItemsOverTime>d__6 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			private object <>2__current;

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(new byte[] { 0, 1 })]
			public List<ItemData> items;

			public Vector3 position;

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			public ZNetView nview;

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(new byte[] { 0, 1 })]
			private List<ItemData>.Enumerator <>s__1;

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			private ItemData <item>5__2;

			private Vector3 <scatter>5__3;

			private Quaternion <rot>5__4;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				[return: <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				[return: <2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
				get
				{
					return <>2__current;
				}
			}

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<>s__1 = default(List<ItemData>.Enumerator);
				<item>5__2 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//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_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: Unknown result type (might be due to invalid IL or missing references)
				//IL_007e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_0088: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
				//IL_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_014a: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
						<>1__state = -1;
						<>s__1 = items.GetEnumerator();
						<>1__state = -3;
						break;
					case 1:
						<>1__state = -3;
						<item>5__2 = null;
						break;
					}
					if (<>s__1.MoveNext())
					{
						<item>5__2 = <>s__1.Current;
						<scatter>5__3 = position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.4f;
						<rot>5__4 = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
						ItemDrop.DropItem(<item>5__2, 0, <scatter>5__3, <rot>5__4);
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>s__1 = default(List<ItemData>.Enumerator);
					if (nview.IsValid())
					{
						nview.GetZDO().Set(s_saddleBagsHash, "");
						s_containerCache.Remove(nview.GetZDO().m_uid);
					}
					return false;
				}
				catch
				{
					//try-fault
					((IDisposable)this).Dispose();
					throw;
				}
			}

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

			private void <>m__Finally1()
			{
				<>1__state = -1;
				((IDisposable)<>s__1).Dispose();
			}

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

		private static readonly int s_saddleBagsHash = StringExtensionMethods.GetStableHashCode("rae_saddlebags");

		private static readonly Dictionary<ZDOID, Container> s_containerCache = new Dictionary<ZDOID, Container>();

		private static readonly FieldInfo f_inventory = typeof(Container).GetField("m_inventory", BindingFlags.Instance | BindingFlags.NonPublic);

		public static void Open(Tameable tameable)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Expected O, but got Unknown
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Expected O, but got Unknown
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			if (!tameable.m_nview.IsValid())
			{
				return;
			}
			ZNetView nview = tameable.m_nview;
			ZDOID uid = nview.GetZDO().m_uid;
			if (s_containerCache.TryGetValue(uid, out var value) && (Object)(object)value == (Object)null)
			{
				s_containerCache.Remove(uid);
			}
			if (!s_containerCache.TryGetValue(uid, out var value2) || (Object)(object)value2 == (Object)null)
			{
				int value3 = OdinHorse.SaddleBagsWidth.Value;
				int value4 = OdinHorse.SaddleBagsHeight.Value;
				Inventory inv = new Inventory("Saddlebags", (Sprite)null, value3, value4);
				string @string = nview.GetZDO().GetString(s_saddleBagsHash, "");
				if (!string.IsNullOrEmpty(@string))
				{
					inv.Load(new ZPackage(@string));
				}
				GameObject val = new GameObject("SaddlebagContainer");
				val.SetActive(false);
				val.transform.SetParent(((Component)nview).transform, false);
				value2 = val.AddComponent<Container>();
				value2.m_rootObjectOverride = nview;
				value2.m_name = "Saddlebags";
				value2.m_width = value3;
				value2.m_height = value4;
				value2.m_privacy = (PrivacySetting)2;
				value2.m_checkGuardStone = false;
				value2.m_autoDestroyEmpty = false;
				val.SetActive(true);
				f_inventory?.SetValue(value2, inv);
				Inventory obj = inv;
				obj.m_onChanged = (Action)Delegate.Combine(obj.m_onChanged, (Action)delegate
				{
					Save(nview, inv);
				});
				s_containerCache[uid] = value2;
			}
			nview.ClaimOwnership();
			InventoryGui.instance.Show(value2, 1);
		}

		public static void Save(ZNetView nview, Inventory inv)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if (nview.IsValid() && nview.IsOwner())
			{
				ZPackage val = new ZPackage();
				inv.Save(val);
				nview.GetZDO().Set(s_saddleBagsHash, val.GetBase64());
			}
		}

		public static void DropAll(ZNetView nview, Vector3 position)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			if (!nview.IsValid() || !nview.IsOwner())
			{
				return;
			}
			string @string = nview.GetZDO().GetString(s_saddleBagsHash, "");
			if (!string.IsNullOrEmpty(@string))
			{
				Inventory val = new Inventory("Saddlebags", (Sprite)null, 8, 4);
				val.Load(new ZPackage(@string));
				List<ItemData> allItems = val.GetAllItems();
				if (allItems.Count != 0)
				{
					CoroutineRunner.Run(SpawnItemsOverTime(allItems, position, nview));
				}
			}
		}

		[IteratorStateMachine(typeof(<SpawnItemsOverTime>d__6))]
		private static IEnumerator SpawnItemsOverTime(List<ItemData> items, Vector3 position, ZNetView nview)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <SpawnItemsOverTime>d__6(0)
			{
				items = items,
				position = position,
				nview = nview
			};
		}
	}
	[HarmonyPatch(typeof(CookingStation))]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	public static class CookingStationPatch
	{
		private static bool ConversionAdded;

		[HarmonyPatch("Awake")]
		[HarmonyPostfix]
		public static void Awake_Postfix(CookingStation __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				Debug.LogError((object)"CookingStation instance is null in Awake_Postfix.");
				return;
			}
			if (__instance.m_conversion == null)
			{
				__instance.m_conversion = new List<ItemConversion>();
			}
			AddCustomConversion(__instance);
		}

		private static void AddCustomConversion(CookingStation station)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			try
			{
				if ((Object)(object)station == (Object)null || station.m_conversion == null)
				{
					Debug.LogError((object)"CookingStation or m_conversion is null during AddCustomConversion.");
				}
				else
				{
					if (station.m_conversion.Exists([<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (ItemConversion c) => ((Object)c.m_from).name == "rae_HorseMeat" && ((Object)c.m_to).name == "rae_CookedHorseMeat"))
					{
						return;
					}
					ItemConversion val = new ItemConversion
					{
						m_from = ObjectDB.instance.GetItemPrefab("rae_HorseMeat").GetComponent<ItemDrop>(),
						m_to = ObjectDB.instance.GetItemPrefab("rae_CookedHorseMeat").GetComponent<ItemDrop>(),
						m_cookTime = 25f
					};
					if ((Object)(object)val.m_from == (Object)null || (Object)(object)val.m_to == (Object)null)
					{
						Debug.LogError((object)"Could not find prefabs for 'rae_HorseMeat' or 'rae_CookedHorseMeat'.");
						return;
					}
					station.m_conversion.Add(val);
					if (!ConversionAdded)
					{
						Debug.Log((object)$"Added custom conversion: {((Object)val.m_from).name} -> {((Object)val.m_to).name} with cook time {val.m_cookTime}s.");
						ConversionAdded = true;
					}
				}
			}
			catch (Exception arg)
			{
				Debug.LogError((object)$"Exception in AddCustomConversion: {arg}");
			}
		}
	}
}
namespace CreatureManager
{
	public enum Toggle
	{
		On,
		Off
	}
	[PublicAPI]
	public enum GlobalKey
	{
		[InternalName("")]
		None,
		[InternalName("defeated_bonemass")]
		KilledBonemass,
		[InternalName("defeated_gdking")]
		KilledElder,
		[InternalName("defeated_goblinking")]
		KilledYagluth,
		[InternalName("defeated_dragon")]
		KilledModer,
		[InternalName("defeated_eikthyr")]
		KilledEikthyr,
		[InternalName("KilledTroll")]
		KilledTroll,
		[InternalName("killed_surtling")]
		KilledSurtling
	}
	[PublicAPI]
	[Flags]
	public enum Weather
	{
		[InternalName("")]
		None = 0,
		[InternalName("Clear")]
		ClearSkies = 1,
		[InternalName("Heath clear")]
		MeadowsClearSkies = 4,
		[InternalName("LightRain")]
		LightRain = 8,
		[InternalName("Rain")]
		Rain = 0x10,
		[InternalName("ThunderStorm")]
		ThunderStorm = 0x20,
		[InternalName("nofogts")]
		ClearThunderStorm = 0x40,
		[InternalName("SwampRain")]
		SwampRain = 0x80,
		[InternalName("Darklands_dark")]
		MistlandsDark = 0x100,
		[InternalName("Ashrain")]
		AshlandsAshrain = 0x200,
		[InternalName("Snow")]
		MountainSnow = 0x400,
		[InternalName("SnowStorm")]
		MountainBlizzard = 0x800,
		[InternalName("DeepForest Mist")]
		BlackForestFog = 0x1000,
		[InternalName("Misty")]
		Fog = 0x2000,
		[InternalName("Twilight_Snow")]
		DeepNorthSnow = 0x4000,
		[InternalName("Twilight_SnowStorm")]
		DeepNorthSnowStorm = 0x8000,
		[InternalName("Twilight_Clear")]
		DeepNorthClear = 0x10000,
		[InternalName("Eikthyr")]
		EikthyrsThunderstorm = 0x20000,
		[InternalName("GDKing")]
		EldersHaze = 0x40000,
		[InternalName("Bonemass")]
		BonemassDownpour = 0x80000,
		[InternalName("Moder")]
		ModersVortex = 0x100000,
		[InternalName("GoblinKing")]
		YagluthsMagicBlizzard = 0x200000,
		[InternalName("Crypt")]
		Crypt = 0x400000,
		[InternalName("SunkenCrypt")]
		SunkenCrypt = 0x800000
	}
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	public enum DropOption
	{
		Disabled,
		Default,
		Custom
	}
	public enum SpawnOption
	{
		Disabled,
		Default,
		Custom
	}
	public enum SpawnTime
	{
		Day,
		Night,
		Always
	}
	public enum SpawnArea
	{
		Center,
		Edge,
		Everywhere
	}
	public enum Forest
	{
		Yes,
		No,
		Both
	}
	[PublicAPI]
	public struct Range
	{
		public float min;

		public float max;

		public Range(float min, float max)
		{
			this.min = min;
			this.max = max;
		}
	}
	[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
	[PublicAPI]
	[<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(1)]
	public class Creature
	{
		[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
		[PublicAPI]
		public class DropList
		{
			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(0)]
			internal class SerializedDrops
			{
				[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(new byte[] { 1, 0, 1, 1 })]
				public readonly List<KeyValuePair<string, Drop>> Drops;

				public SerializedDrops(DropList drops, Creature creature)
				{
					Drops = (drops.drops ?? creature.Prefab.GetComponent<CharacterDrop>()?.m_drops.ToDictionary([<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (Drop drop) => ((Object)drop.m_prefab).name, [<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (Drop drop) => new Drop
					{
						Amount = new Range(drop.m_amountMin, drop.m_amountMax),
						DropChance = drop.m_chance,
						DropOnePerPlayer = drop.m_onePerPlayer,
						MultiplyDropByLevel = drop.m_levelMultiplier
					}) ?? new Dictionary<string, Drop>()).ToList();
				}

				public SerializedDrops([<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(new byte[] { 1, 0, 1, 1 })] List<KeyValuePair<string, Drop>> drops)
				{
					Drops = drops;
				}

				public SerializedDrops(string reqs)
				{
					Drops = (from r in reqs.Split(new char[1] { ',' })
						select r.Split(new char[1] { ':' })).ToDictionary([<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (string[] l) => l[0], [<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (string[] parts) =>
					{
						Range amount = new Range(1f, 1f);
						if (parts.Length > 1)
						{
							string[] array = parts[1].Split(new char[1] { '-' });
							if (!int.TryParse(array[0], out var result))
							{
								result = 1;
							}
							if (array.Length == 1 || !int.TryParse(array[0], out var result2))
							{
								result2 = result;
							}
							amount = new Range(result, result2);
						}
						float result3;
						return new Drop
						{
							Amount = amount,
							DropChance = ((parts.Length > 2 && float.TryParse(parts[2], out result3)) ? result3 : 100f),
							DropOnePerPlayer = (parts.Length > 3 && parts[3] == "onePerPlayer"),
							MultiplyDropByLevel = (parts.Length > 4 && parts[4] == "multiplyByLevel")
						};
					}).ToList();
				}

				public override string ToString()
				{
					return string.Join(",", Drops.Select([<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (KeyValuePair<string, Drop> kv) => string.Format("{0}:{1}-{2}:{3}:{4}:{5}", kv.Key, kv.Value.Amount.min, kv.Value.Amount.max, kv.Value.DropChance, kv.Value.DropOnePerPlayer ? "onePerPlayer" : "unrestricted", kv.Value.MultiplyDropByLevel ? "multiplyByLevel" : "unaffectedByLevel")));
				}
			}

			[<2abb5b8f-7e7b-4743-a476-e224d1d5c2c5>Nullable(new byte[] { 2, 1, 1 })]
			private Dictionary<string, Drop> drops = null;

			public Drop this[string prefabName]
			{
				get
				{
					Drop result;
					if (!(drops ?? (drops = new Dictionary<string, Drop>())).TryGetValue(prefabName, out var value))
					{
						Drop drop2 = (drops[prefabName] = new Drop());
						result = drop2;
					}
					else
					{
						result = value;
					}
					return result;
				}
			}

			public void None()
			{
				drops = new Dictionary<string, Drop>();
			}

			[HarmonyPriority(700)]
			internal static void AddDropsToCreature()
			{
				foreach (Creature registeredCreature in registeredCreatures)
				{
					UpdateDrops(registeredCreature);
				}
			}

			internal static void UpdateDrops(Creature creature)
			{
				DropOption dropOption = creatureConfigs[creature].Drops.get();
				if (dropOption == DropOption.Default && creature.Drops.drops == null)
				{
					return;
				}
				CharacterDrop val = creature.Prefab.GetComponent<CharacterDrop>() ?? creature.Prefab.AddComponent<CharacterDrop>();
				DropOption dropOption2 = creatureConfigs[creature].Drops.get();
				if (1 == 0)
				{
				}
				List<KeyValuePair<string, Drop>> source = dropOption2 switch
				{
					DropOption.Custom => new SerializedDrops(creatureConfigs[creature].CustomDrops.get()).Drops, 
					DropOption.Disabled => new List<KeyValuePair<string, Drop>>(), 
					_ => creature.Drops.drops.ToList(), 
				};
				if (1 == 0)
				{
				}
				val.m_drops = (from d in ((IEnumerable<KeyValuePair<string, Drop>>)source).Select((Func<KeyValuePair<string, Drop>, Drop>)([<4462215f-ae19-4a07-b420-c70ef12aa6d8>NullableContext(0)] (KeyValuePair<string, Drop> kv) =>
					{
						//IL_0079: Unknown result type (might be due to invalid IL or missing references)
						//IL_007e: Unknown result type (might be due to invalid IL or missing references)
						//IL_0085: 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_00b5: 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_00df: Unknown result type (might be due to invalid IL or missing references)
						//IL_00f2: Expected O, but got Unknown
						if (kv.Key == "" || ZNetScene.instance == null)
						{
							return null;
						}
						GameObject prefab = ZNetScene.instance.GetPrefab(kv.Key);
						if (prefab == null)
						{
							Debug.LogWarning((object)("Found invalid prefab name " + kv.Key + " for creature " + ((Object)creature.Prefab).name));
							return null;
						}
						return new Drop
						{
							m_prefab = prefab,
							m_amountMin = (int)kv.Value.Amount.min,
							m_amountMax = (int)kv.Value.Amount.max,
							m_chance = kv.Value.DropChance / 100f,
							m_onePerPlayer = kv.Value.DropOnePerPlayer,
							m_levelMultiplier = kv.Value.MultiplyDropByLevel
						};
					}))