Decompiled source of OdinHorse v1.6.5

OdinHorse.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using 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: <beeb0bad-d833-495e-aac1-aba4d22884f5>RefSafetyRules(11)]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[<16c5b04a-8022-408c-baab-11b9cf5b1fce>Embedded]
	internal sealed class <16c5b04a-8022-408c-baab-11b9cf5b1fce>EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[<16c5b04a-8022-408c-baab-11b9cf5b1fce>Embedded]
	[CompilerGenerated]
	internal sealed class <762e58ce-4084-4faf-85f5-2b0f93ddd49f>NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public <762e58ce-4084-4faf-85f5-2b0f93ddd49f>NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public <762e58ce-4084-4faf-85f5-2b0f93ddd49f>NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	[<16c5b04a-8022-408c-baab-11b9cf5b1fce>Embedded]
	internal sealed class <db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public <db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[<16c5b04a-8022-408c-baab-11b9cf5b1fce>Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class <beeb0bad-d833-495e-aac1-aba4d22884f5>RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public <beeb0bad-d833-495e-aac1-aba4d22884f5>RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace OdinHorse
{
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[BepInPlugin("Raelaziel.OdinHorse", "OdinHorse", "1.6.5")]
	public class OdinHorse : BaseUnityPlugin
	{
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		internal enum Toggle
		{
			On = 1,
			Off = 0
		}

		[HarmonyPatch(typeof(Character), "Awake")]
		[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
		public static class CharacterAwakePatch
		{
			private static void Postfix(Character __instance)
			{
				//IL_0066: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)__instance).name != "rae_OdinHorse(Clone)")
				{
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				if (component.IsOwner() && component.GetZDO().GetInt("HorseMaterial", -1) == -1)
				{
					int num = FindNearbyOffspringInheritedColor(((Component)__instance).transform.position, 3f);
					if (num != -1)
					{
						component.GetZDO().Set("HorseMaterial", num);
					}
				}
				((MonoBehaviour)__instance).StartCoroutine(ApplyHorseMaterial(__instance, component));
			}

			private static IEnumerator ApplyHorseMaterial(Character character, ZNetView znv)
			{
				yield return null;
				SkinnedMeshRenderer renderer = ((Component)character).GetComponentInChildren<SkinnedMeshRenderer>();
				if ((Object)(object)renderer == (Object)null)
				{
					yield break;
				}
				int materialIndex = znv.GetZDO().GetInt("HorseMaterial", -1);
				if (materialIndex == -1)
				{
					yield return (object)new WaitForSeconds(0.5f);
					materialIndex = znv.GetZDO().GetInt("HorseMaterial", -1);
					if (materialIndex == -1 && znv.IsOwner())
					{
						materialIndex = PickSpawnColorIndex(character);
						znv.GetZDO().Set("HorseMaterial", materialIndex);
					}
					else if (materialIndex == -1)
					{
						yield return (object)new WaitForSeconds(1f);
						materialIndex = znv.GetZDO().GetInt("HorseMaterial", 0);
					}
				}
				if (materialIndex < 0 || materialIndex >= horseMaterials.Count)
				{
					materialIndex = 0;
				}
				((Renderer)renderer).material = horseMaterials[materialIndex];
			}
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		[HarmonyPatch(typeof(Character), "Awake")]
		public static class OffspringAwakePatch
		{
			private const float ParentSearchRadius = 5f;

			[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
			private static void Postfix(Character __instance)
			{
				//IL_006e: Unknown result type (might be due to invalid IL or missing references)
				if (((Object)((Component)__instance).gameObject).name != "rae_Offspring_Normal(Clone)")
				{
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid() && component.IsOwner() && component.GetZDO().GetInt("HorseMaterial", -1) == -1)
				{
					int num = FindNearbyParentColor(((Component)__instance).transform.position, 5f);
					if (num != -1)
					{
						component.GetZDO().Set("HorseMaterial", num);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Character), "SetLevel")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		public static class Character_SetLevel_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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 num = component.GetZDO().GetInt("HorseMaterial", -1);
					if (num >= 0 && num < horseMaterials.Count)
					{
						((Renderer)componentInChildren).material = horseMaterials[num];
					}
				}
				Sadle componentInChildren2 = ((Component)__instance).GetComponentInChildren<Sadle>(true);
				if ((Object)(object)componentInChildren2 != (Object)null)
				{
					int num2 = Mathf.Max(0, __instance.GetLevel() - 1);
					componentInChildren2.m_maxStamina = HorseStamina.Value + (float)num2 * HorseStaminaPerStar.Value;
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "Awake")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class AddRPCForHorseArmorTameableAwakePatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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());
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class AddTextForRemovalOfArmorTameableGetHoverTextPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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"))
				{
					if (!__instance.m_nview.IsValid())
					{
						__result = __result ?? "";
					}
					if (__instance.HaveArmor() && __instance.m_character.IsTamed())
					{
						__result += ((!ZInput.IsNonClassicFunctionality() || !ZInput.IsGamepadActive()) ? Localization.instance.Localize("\n[<color=yellow><b>" + ((object)RemoveArmorHotKey.Value/*cast due to .constrained prefix*/).ToString() + " + $KEY_Use</b></color>] Remove Armor") : Localization.instance.Localize("\n[<color=yellow><b>" + ((object)RemoveArmorHotKey.Value/*cast due to .constrained prefix*/).ToString() + " + $KEY_Use</b></color>] Remove Armor"));
					}
					if (__instance.m_character.IsTamed())
					{
						bool flag = __instance.IsWaiting();
						__result += ((!ZInput.IsNonClassicFunctionality() || !ZInput.IsGamepadActive()) ? Localization.instance.Localize("\n[<color=yellow><b>" + ((object)WaitHotKey.Value/*cast due to .constrained prefix*/).ToString() + " + $KEY_Use</b></color>] " + (flag ? "Resume" : "Wait Here")) : Localization.instance.Localize("\n[<color=yellow><b>" + ((object)WaitHotKey.Value/*cast due to .constrained prefix*/).ToString() + " + $KEY_Use</b></color>] " + (flag ? "Resume" : "Wait Here")));
					}
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "Interact")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class RemoveArmorTameableInteractPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class CycleHorseStateTameableInteractPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class UseArmorOnHorseTameableUseItemPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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);
				}
			}
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		public enum HorseBeasts
		{
			player,
			horse
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		[HarmonyPatch(typeof(Vagon), "LateUpdate")]
		private class LateUpdate_Vagon_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private class InUse_Vagon_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private class Vagon_FixedUpdate_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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;
			}
		}

		[HarmonyPatch(typeof(BaseAI), "Follow")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private class Tamed_Follow_patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private class MonsterAI_UpdateAI_WaitPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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;
			}
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		[HarmonyPatch(typeof(Sadle), "UseItem")]
		private class Sadle_UseItem_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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>());
					}
				}
			}
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		[HarmonyPatch(typeof(Character), "Damage")]
		private class Character_Damage_Patch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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>());
					}
				}
			}
		}

		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		private static class SaddlebagHoverTextPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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 != Toggle.Off && __instance.m_nview.IsValid() && __instance.IsTamed() && __instance.HaveSaddle())
				{
					__result += Localization.instance.Localize($"\n[<color=yellow><b>{SaddleBagsHotKey.Value} + $KEY_Use</b></color>] Open Saddlebags");
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "Interact")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class SaddlebagInteractPatch
		{
			[<db074712-fd07-40f9-927b-f6ffe2914d6d>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;
			}
		}

		[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
		public static class CustomMapPins
		{
			[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>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;
			}
		}

		[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
		public static class CustomMapPins_Cart
		{
			[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>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;
			}
		}

		[HarmonyPatch(typeof(Terminal), "InitTerminal")]
		[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(0)]
		private static class Terminal_HorseSetColor_Patch
		{
			[Serializable]
			[CompilerGenerated]
			private sealed class <>c
			{
				public static readonly <>c <>9 = new <>c();

				public static ConsoleEvent <>9__0_0;

				internal void <Postfix>b__0_0(ConsoleEventArgs args)
				{
					if (args.Length < 2 || !int.TryParse(args[1], out var result) || result < 0 || result >= horseMaterials.Count)
					{
						args.Context.AddString($"Usage: horse_setcolor <0-{horseMaterials.Count - 1}>");
						return;
					}
					Character val = FindTargetHorse();
					if ((Object)(object)val == (Object)null)
					{
						args.Context.AddString("No Odin Horse found nearby.");
						return;
					}
					ZNetView component = ((Component)val).GetComponent<ZNetView>();
					if ((Object)(object)component == (Object)null || !component.IsValid())
					{
						args.Context.AddString("That horse isn't networked properly.");
						return;
					}
					component.ClaimOwnership();
					component.GetZDO().Set("HorseMaterial", result);
					SkinnedMeshRenderer componentInChildren = ((Component)val).GetComponentInChildren<SkinnedMeshRenderer>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						((Renderer)componentInChildren).material = horseMaterials[result];
					}
					args.Context.AddString($"Set horse color to index {result}.");
				}
			}

			private static void Postfix()
			{
				//IL_004f: 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_0046: Expected O, but got Unknown
				string text = $"<0-{Math.Max(0, horseMaterials.Count - 1)}> - Sets the color of the Odin Horse you're looking at (or the nearest one nearby).";
				object obj = <>c.<>9__0_0;
				if (obj == null)
				{
					ConsoleEvent val = delegate(ConsoleEventArgs args)
					{
						if (args.Length < 2 || !int.TryParse(args[1], out var result) || result < 0 || result >= horseMaterials.Count)
						{
							args.Context.AddString($"Usage: horse_setcolor <0-{horseMaterials.Count - 1}>");
						}
						else
						{
							Character val2 = FindTargetHorse();
							if ((Object)(object)val2 == (Object)null)
							{
								args.Context.AddString("No Odin Horse found nearby.");
							}
							else
							{
								ZNetView component = ((Component)val2).GetComponent<ZNetView>();
								if ((Object)(object)component == (Object)null || !component.IsValid())
								{
									args.Context.AddString("That horse isn't networked properly.");
								}
								else
								{
									component.ClaimOwnership();
									component.GetZDO().Set("HorseMaterial", result);
									SkinnedMeshRenderer componentInChildren = ((Component)val2).GetComponentInChildren<SkinnedMeshRenderer>();
									if ((Object)(object)componentInChildren != (Object)null)
									{
										((Renderer)componentInChildren).material = horseMaterials[result];
									}
									args.Context.AddString($"Set horse color to index {result}.");
								}
							}
						}
					};
					<>c.<>9__0_0 = val;
					obj = (object)val;
				}
				new ConsoleCommand("horse_setcolor", text, (ConsoleEvent)obj, true, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
			}

			[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
			private static Character FindTargetHorse()
			{
				//IL_0031: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return null;
				}
				Camera mainCamera = Utils.GetMainCamera();
				RaycastHit val = default(RaycastHit);
				if ((Object)(object)mainCamera != (Object)null && Physics.Raycast(((Component)mainCamera).transform.position, ((Component)mainCamera).transform.forward, ref val, 50f))
				{
					Character componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<Character>();
					if ((Object)(object)componentInParent != (Object)null && ((Object)((Component)componentInParent).gameObject).name.Contains("rae_OdinHorse"))
					{
						return componentInParent;
					}
				}
				Character result = null;
				float num = 10f;
				foreach (Character allCharacter in Character.GetAllCharacters())
				{
					if (((Object)((Component)allCharacter).gameObject).name.Contains("rae_OdinHorse"))
					{
						float num2 = Vector3.Distance(((Component)allCharacter).transform.position, ((Component)localPlayer).transform.position);
						if (num2 < num)
						{
							result = allCharacter;
							num = num2;
						}
					}
				}
				return result;
			}
		}

		private const string ModName = "OdinHorse";

		private const string ModVersion = "1.6.5";

		private const string ModGUID = "Raelaziel.OdinHorse";

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

		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> HorseStaminaPerStar = 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;

		internal static ConfigEntry<Toggle> EnableBiomeColors = null;

		internal static ConfigEntry<Biome>[] HorseColorBiomes = null;

		private static readonly string[] HorseColorNames = new string[6] { "Black Tobiano Pinto", "Brown", "Grays", "Palomino", "White", "Dark Grey" };

		private static List<Material> horseMaterials;

		private static AssetBundle horseAssetBundle;

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

		private static string ConfigFileFullPath;

		private ConfigEntry<T> config<[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>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<[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>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_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: 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_0336: Unknown result type (might be due to invalid IL or missing references)
			//IL_0341: Expected O, but got Unknown
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: 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_03af: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Expected O, but got Unknown
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e1: Expected O, but got Unknown
			//IL_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Expected O, but got Unknown
			//IL_041f: Unknown result type (might be due to invalid IL or missing references)
			//IL_042f: Unknown result type (might be due to invalid IL or missing references)
			//IL_043a: Expected O, but got Unknown
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			//IL_0461: Unknown result type (might be due to invalid IL or missing references)
			//IL_046c: Expected O, but got Unknown
			//IL_0483: Unknown result type (might be due to invalid IL or missing references)
			//IL_0493: Unknown result type (might be due to invalid IL or missing references)
			//IL_049e: Expected O, but got Unknown
			//IL_04ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c5: Expected O, but got Unknown
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Expected O, but got Unknown
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_051f: Expected O, but got Unknown
			//IL_1173: Unknown result type (might be due to invalid IL or missing references)
			//IL_11e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_174d: Unknown result type (might be due to invalid IL or missing references)
			//IL_1752: Unknown result type (might be due to invalid IL or missing references)
			//IL_175e: Unknown result type (might be due to invalid IL or missing references)
			//IL_176e: Unknown result type (might be due to invalid IL or missing references)
			//IL_177e: Unknown result type (might be due to invalid IL or missing references)
			//IL_178e: Unknown result type (might be due to invalid IL or missing references)
			//IL_1795: Unknown result type (might be due to invalid IL or missing references)
			//IL_17a1: Expected O, but got Unknown
			//IL_17ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_17b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_17bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_17cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_17df: Unknown result type (might be due to invalid IL or missing references)
			//IL_17ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_17f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_1802: Expected O, but got Unknown
			//IL_18bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_18c2: 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>()));
			HorseStaminaPerStar = config("Horse", "Stamina Per Star", 0f, new ConfigDescription("Extra max stamina granted per star above the base. A 3-star horse gets +2x this value on top of the base Stamina setting. Set to 0 to disable (default vanilla behavior - stamina is the same regardless of star level).", (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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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>()), synchronizedSetting: false);
			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.");
			EnableBiomeColors = config("Horse Colors", "Enable Biome-Based Colors", Toggle.Off, "If on, wild-spawned horses will prefer colors restricted to the biome they spawn in below. Tamed/bred horses always ignore this and get a random color, same as before.");
			HorseColorBiomes = new ConfigEntry<Biome>[HorseColorNames.Length];
			for (int i = 0; i < HorseColorNames.Length; i++)
			{
				HorseColorBiomes[i] = config<Biome>("Horse Colors", $"Color {i} - {HorseColorNames[i]} Biomes", (Biome)0, "Biomes where the '" + HorseColorNames[i] + "' color is allowed to spawn on wild horses. Leave as None for no restriction (can spawn anywhere).");
			}
			Item item = new Item("horsesets", "rae_HorseMeat");
			item.Configurable = Configurability.Recipe | Configurability.Stats;
			Item item2 = new Item("horsesets", "rae_HorseHide");
			item2.Configurable = Configurability.Recipe | Configurability.Stats;
			Item item3 = new Item("horsesets", "rae_OdinHorse_Trophy");
			item3.Configurable = Configurability.Recipe | Configurability.Stats;
			Item item4 = new Item("horsesets", "rae_CookedHorseMeat");
			item4.Configurable = Configurability.Recipe | Configurability.Stats;
			Item item5 = new Item("horsesets", "rae_SaddleHorse");
			item5.Configurable = Configurability.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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.Recipe | Configurability.Stats;
			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;
			HorseStaminaPerStar.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];
			}
		}

		private static int FindNearbyParentColor(Vector3 position, float radius)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			List<int> list = new List<int>();
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (!((Object)((Component)allCharacter).gameObject).name.Contains("rae_OdinHorse") || !allCharacter.IsTamed() || Vector3.Distance(((Component)allCharacter).transform.position, position) > radius)
				{
					continue;
				}
				ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					int num = component.GetZDO().GetInt("HorseMaterial", -1);
					if (num >= 0 && num < horseMaterials.Count)
					{
						list.Add(num);
					}
				}
			}
			return (list.Count > 0) ? list[Random.Range(0, list.Count)] : (-1);
		}

		private static int PickSpawnColorIndex(Character character)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Invalid comparison between Unknown and I4
			if (!character.IsTamed() && EnableBiomeColors.Value == Toggle.On)
			{
				Biome val = Heightmap.FindBiome(((Component)character).transform.position);
				List<int> list = new List<int>();
				for (int i = 0; i < HorseColorBiomes.Length; i++)
				{
					Biome value = HorseColorBiomes[i].Value;
					if ((int)value == 0 || (value & val) > 0)
					{
						list.Add(i);
					}
				}
				if (list.Count > 0)
				{
					return list[Random.Range(0, list.Count)];
				}
			}
			return Random.Range(0, horseMaterials.Count);
		}

		private static int FindNearbyOffspringInheritedColor(Vector3 position, float radius)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if (((Object)((Component)allCharacter).gameObject).name != "rae_Offspring_Normal(Clone)" || Vector3.Distance(((Component)allCharacter).transform.position, position) > radius)
				{
					continue;
				}
				ZNetView component = ((Component)allCharacter).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid())
				{
					int num = component.GetZDO().GetInt("HorseMaterial", -1);
					if (num >= 0 && num < horseMaterials.Count)
					{
						return num;
					}
				}
			}
			return -1;
		}

		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)
					{
						int num = Mathf.Max(0, s_character.GetLevel() - 1);
						componentInChildren3.m_maxStamina = HorseStamina.Value + (float)num * HorseStaminaPerStar.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);
		}
	}
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>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);
			}
		}
	}
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>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);
		}
	}
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	public static class HorseSaddlebags
	{
		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 text = nview.GetZDO().GetString(s_saddleBagsHash, "");
				if (!string.IsNullOrEmpty(text))
				{
					inv.Load(new ZPackage(text));
				}
				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 text = nview.GetZDO().GetString(s_saddleBagsHash, "");
			if (!string.IsNullOrEmpty(text))
			{
				Inventory val = new Inventory("Saddlebags", (Sprite)null, 8, 4);
				val.Load(new ZPackage(text));
				List<ItemData> allItems = val.GetAllItems();
				if (allItems.Count != 0)
				{
					CoroutineRunner.Run(SpawnItemsOverTime(allItems, position, nview));
				}
			}
		}

		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)
			foreach (ItemData item in items)
			{
				Vector3 scatter = position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.4f;
				Quaternion rot = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f);
				ItemDrop.DropItem(item, 0, scatter, rot);
				yield return null;
			}
			if (nview.IsValid())
			{
				nview.GetZDO().Set(s_saddleBagsHash, "");
				s_containerCache.Remove(nview.GetZDO().m_uid);
			}
		}
	}
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[HarmonyPatch(typeof(CookingStation))]
	public static class CookingStationPatch
	{
		private static bool ConversionAdded;

		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		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([<db074712-fd07-40f9-927b-f6ffe2914d6d>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 ItemManager
{
	[PublicAPI]
	public enum CraftingTable
	{
		Disabled,
		Inventory,
		[InternalName("piece_workbench")]
		Workbench,
		[InternalName("piece_cauldron")]
		Cauldron,
		[InternalName("piece_MeadCauldron")]
		MeadCauldron,
		[InternalName("forge")]
		Forge,
		[InternalName("piece_artisanstation")]
		ArtisanTable,
		[InternalName("piece_stonecutter")]
		StoneCutter,
		[InternalName("piece_magetable")]
		MageTable,
		[InternalName("piece_preptable")]
		PrepTable,
		[InternalName("blackforge")]
		BlackForge,
		Custom
	}
	[PublicAPI]
	public enum ConversionPiece
	{
		Disabled,
		[InternalName("smelter")]
		Smelter,
		[InternalName("charcoal_kiln")]
		CharcoalKiln,
		[InternalName("blastfurnace")]
		BlastFurnace,
		[InternalName("windmill")]
		Windmill,
		[InternalName("piece_spinningwheel")]
		SpinningWheel,
		[InternalName("eitrrefinery")]
		EitrRefinery,
		Custom
	}
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	public class InternalName : Attribute
	{
		public readonly string internalName;

		public InternalName(string internalName)
		{
			this.internalName = internalName;
		}
	}
	[PublicAPI]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	public class RequiredResourceList
	{
		public readonly List<Requirement> Requirements = new List<Requirement>();

		public bool Free = false;

		public void Add(string itemName, int amount, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amount = amount,
				quality = quality
			});
		}

		public void Add(string itemName, ConfigEntry<int> amountConfig, int quality = 0)
		{
			Requirements.Add(new Requirement
			{
				itemName = itemName,
				amountConfig = amountConfig,
				quality = quality
			});
		}
	}
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	[PublicAPI]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	public class CraftingStationList
	{
		public readonly List<CraftingStationConfig> Stations = new List<CraftingStationConfig>();

		public void Add(CraftingTable table, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = table,
				level = level
			});
		}

		public void Add(string customTable, int level)
		{
			Stations.Add(new CraftingStationConfig
			{
				Table = CraftingTable.Custom,
				level = level,
				custom = customTable
			});
		}
	}
	[PublicAPI]
	[<db074712-fd07-40f9-927b-f6ffe2914d6d>NullableContext(1)]
	[<762e58ce-4084-4faf-85f5-2b0f93ddd49f>Nullable(0)]
	public class ItemRecipe
	{
		public readonly RequiredResourceList RequiredItems = new RequiredResourceList();

		public readonly RequiredResourceList RequiredUpgradeItems = new RequiredResourceList();

		public readonly CraftingStationList Crafting = new CraftingSt