Decompiled source of LoxSaddleBags v2.0.2

BepInEx/plugins/LoxSaddleBags/Loxsaddle.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using HarmonyLib;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("Loxsaddle")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Loxsaddle")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("b26fab7c-490a-447b-9602-2d6c8ce582f3")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
public static class LoxTrinketPanel
{
	private static GameObject _panel;

	public static void Create(Transform parent)
	{
	}

	public static void Show()
	{
		if ((Object)(object)_panel != (Object)null)
		{
			_panel.SetActive(true);
		}
	}

	public static void Hide()
	{
		if ((Object)(object)_panel != (Object)null)
		{
			_panel.SetActive(false);
		}
	}
}
namespace LoxSaddleBags
{
	[BepInPlugin("pl.twojnick.loxsaddlebags", "Lox Saddle Bags", "0.0.1")]
	public class Plugin : BaseUnityPlugin
	{
		public class LoxBagInput : MonoBehaviour
		{
			private void Update()
			{
				if (!Input.GetKeyDown((KeyCode)122) || (Object)(object)Player.m_localPlayer == (Object)null)
				{
					return;
				}
				GameObject hoverObject = ((Humanoid)Player.m_localPlayer).GetHoverObject();
				if ((Object)(object)hoverObject == (Object)null)
				{
					return;
				}
				Tameable componentInParent = hoverObject.GetComponentInParent<Tameable>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return;
				}
				ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid() || !component.GetZDO().GetBool("LoxSaddleBags", false))
				{
					return;
				}
				bool flag = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false);
				Container component2 = ((Component)componentInParent).GetComponent<Container>();
				Debug.Log((object)$"CONTAINER FOUND: {(Object)(object)component2 != (Object)null}");
				if ((Object)(object)component2 == (Object)null)
				{
					return;
				}
				if (InventoryGui.instance.IsContainerOpen())
				{
					InventoryGui.instance.Hide();
					Debug.Log((object)"CLOSE CONTAINER");
					return;
				}
				InventoryGui.instance.Show(component2, 1);
				if (flag)
				{
					Transform parent = ((Component)InventoryGui.instance).transform.Find("root");
					LoxTrinketGrid.OpenForLox(componentInParent, component2, parent);
				}
				else
				{
					LoxTrinketGrid.Hide();
				}
				Debug.Log((object)"OPEN CONTAINER");
			}
		}

		[HarmonyPatch(typeof(Tameable), "SetSaddle")]
		public static class TestModelPatch
		{
			private static void Postfix(Tameable __instance, bool enabled)
			{
				//IL_03e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0402: Unknown result type (might be due to invalid IL or missing references)
				//IL_0414: Unknown result type (might be due to invalid IL or missing references)
				Debug.Log((object)("HAS VANILLA SADDLE: " + ((Component)__instance).GetComponent<ZNetView>().GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false)));
				Debug.Log((object)$"SETSADDLE PATCH FIRED: {enabled}");
				if (!enabled)
				{
					Transform val = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "TEST_BAGS"));
					if ((Object)(object)val != (Object)null)
					{
						Object.Destroy((Object)(object)((Component)val).gameObject);
						Debug.Log((object)"TEST_BAGS REMOVED");
					}
					Transform val2 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Sadel"));
					if ((Object)(object)val2 != (Object)null)
					{
						Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true);
						foreach (Renderer val3 in componentsInChildren)
						{
							val3.enabled = true;
						}
						Debug.Log((object)"VANILLA SADDLE RESTORED");
					}
					return;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				bool flag = component.GetZDO().GetBool("LoxSaddleBags", false);
				bool flag2 = component.GetZDO().GetBool("LoxBellSaddle", false);
				Debug.Log((object)($"MODEL PATCH HAS BAGS: {flag}, " + $"HAS BELL SADDLE: {flag2}"));
				if (!flag && !flag2)
				{
					return;
				}
				bool flag3 = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false);
				GameObject val4 = ((!flag2) ? (flag3 ? EnchantedSaddleModel : SaddleModel) : BellSaddleModel);
				if ((Object)(object)val4 == (Object)null)
				{
					Debug.Log((object)"MODEL TO SPAWN IS NULL");
					return;
				}
				Transform val5 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Sadel"));
				Debug.Log((object)$"SADDLE FOUND: {(Object)(object)val5 != (Object)null}");
				if ((Object)(object)val5 != (Object)null)
				{
					if ((Object)(object)val5 != (Object)null)
					{
						Renderer[] componentsInChildren2 = ((Component)val5).GetComponentsInChildren<Renderer>(true);
						foreach (Renderer val6 in componentsInChildren2)
						{
							val6.enabled = false;
						}
						Debug.Log((object)"VANILLA SADDLE HIDDEN");
					}
					Renderer[] componentsInChildren3 = ((Component)val5).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val7 in componentsInChildren3)
					{
						Debug.Log((object)("RENDERER: " + ((Object)val7).name));
					}
					SkinnedMeshRenderer[] componentsInChildren4 = ((Component)val5).GetComponentsInChildren<SkinnedMeshRenderer>(true);
					foreach (SkinnedMeshRenderer val8 in componentsInChildren4)
					{
						Debug.Log((object)("SMR: " + ((Object)val8).name));
					}
				}
				Transform val9 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Mount"));
				if ((Object)(object)val9 == (Object)null)
				{
					Debug.Log((object)"MOUNT NOT FOUND");
				}
				else if (!((Object)(object)val9.Find("TEST_BAGS") != (Object)null))
				{
					Debug.Log((object)("SPAWNING MODEL: " + (flag3 ? "ENCHANTED" : "NORMAL")));
					GameObject val10 = Object.Instantiate<GameObject>(val4, val9);
					((Object)val10).name = "TEST_BAGS";
					val10.transform.localPosition = new Vector3(0f, -0.017f, 0.01f);
					val10.transform.localRotation = Quaternion.Euler(255f, 0f, 0f);
					val10.transform.localScale = Vector3.one;
					Debug.Log((object)"TEST MODEL SPAWNED");
				}
			}
		}

		[HarmonyPatch(typeof(Character), "GetSlideAngle")]
		public static class LoxMistlandsTrinketSlopePatch
		{
			private static bool Prefix(Character __instance, ref float __result)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				Tameable component = ((Component)__instance).GetComponent<Tameable>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				if (!((Object)__instance).name.StartsWith("Lox"))
				{
					return true;
				}
				if (!LoxTrinketGrid.HasEquippedTrinket(component, "LoxTrinketMistlandsItem"))
				{
					return true;
				}
				__result = 90f;
				return false;
			}
		}

		[HarmonyPatch(typeof(MonsterAI), "Awake")]
		public static class LoxFoodPatch
		{
			private static void Postfix(MonsterAI __instance)
			{
				if (((Object)__instance).name.StartsWith("Lox"))
				{
					GameObject itemPrefab = ObjectDB.instance.GetItemPrefab("LoxHealingTreat");
					ItemDrop val = ((itemPrefab != null) ? itemPrefab.GetComponent<ItemDrop>() : null);
					GameObject itemPrefab2 = ObjectDB.instance.GetItemPrefab("LoxEnergyTreat");
					ItemDrop val2 = ((itemPrefab2 != null) ? itemPrefab2.GetComponent<ItemDrop>() : null);
					if ((Object)(object)val != (Object)null && !__instance.m_consumeItems.Contains(val))
					{
						__instance.m_consumeItems.Add(val);
					}
					if ((Object)(object)val2 != (Object)null && !__instance.m_consumeItems.Contains(val2))
					{
						__instance.m_consumeItems.Add(val2);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "OnConsumedItem")]
		public static class LoxTreatPatch
		{
			private static void Postfix(Tameable __instance, ItemDrop item)
			{
				if ((Object)(object)__instance == (Object)null || (Object)(object)item == (Object)null)
				{
					return;
				}
				ItemData itemData = item.m_itemData;
				object obj;
				if (itemData == null)
				{
					obj = null;
				}
				else
				{
					GameObject dropPrefab = itemData.m_dropPrefab;
					obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
				}
				string text = (string)obj;
				Debug.Log((object)("CONSUMED: " + text));
				Character component = ((Component)__instance).GetComponent<Character>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				if (text == "LoxHealingTreat")
				{
					component.Heal(99999f, true);
					Debug.Log((object)"LOX HEALED TO FULL");
				}
				else
				{
					if (!(text == "LoxEnergyTreat"))
					{
						return;
					}
					Sadle componentInChildren = ((Component)__instance).GetComponentInChildren<Sadle>(true);
					if ((Object)(object)componentInChildren == (Object)null)
					{
						Debug.LogError((object)"LOX ENERGY TREAT: SADLE NOT FOUND");
						return;
					}
					ZNetView component2 = ((Component)__instance).GetComponent<ZNetView>();
					if ((Object)(object)component2 == (Object)null || !component2.IsValid())
					{
						Debug.LogError((object)"LOX ENERGY TREAT: ZNETVIEW INVALID");
						return;
					}
					float maxStamina = componentInChildren.GetMaxStamina();
					component2.GetZDO().Set(ZDOVars.s_stamina, maxStamina);
					Debug.Log((object)$"LOX STAMINA RESTORED TO {maxStamina}");
				}
			}
		}

		[HarmonyPatch(typeof(Sadle), "RPC_RemoveSaddle")]
		public static class PreventRemoveSaddlePatch
		{
			private static bool Prefix(Sadle __instance, long sender, Vector3 userPoint)
			{
				Tameable tameable = __instance.GetTameable();
				if ((Object)(object)tameable == (Object)null)
				{
					return true;
				}
				Container component = ((Component)tameable).GetComponent<Container>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				int num = component.GetInventory().NrOfItems();
				Debug.Log((object)$"ITEMS IN BAGS: {num}");
				if (num > 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_empty_bags_first"), 0, (Sprite)null, false);
					return false;
				}
				ZNetView component2 = ((Component)tameable).GetComponent<ZNetView>();
				Object.Destroy((Object)(object)component);
				Debug.Log((object)"CONTAINER REMOVED");
				return true;
			}
		}

		[HarmonyPatch(typeof(Sadle), "Interact")]
		public static class SaddleDebugPatch
		{
			private static void Prefix(Sadle __instance)
			{
				Debug.Log((object)"SADDLE INTERACT");
			}
		}

		[HarmonyPatch(typeof(Tameable), "Awake")]
		public static class RestoreContainerPatch
		{
			private static void Postfix(Tameable __instance)
			{
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					return;
				}
				bool flag = component.GetZDO().GetBool("LoxSaddleBags", false);
				bool flag2 = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false);
				if (flag)
				{
					GetOrCreateContainer(__instance);
					Debug.Log((object)"OPEN CONTAINER");
					if (flag2)
					{
						UpdateEnchantedState(__instance, enabled: true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(BaseAI), "FindEnemy")]
		public static class EnchantedLoxFindEnemyPatch
		{
			private static bool Prefix(BaseAI __instance, ref Character __result)
			{
				Tameable component = ((Component)__instance).GetComponent<Tameable>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				ZNetView component2 = ((Component)component).GetComponent<ZNetView>();
				if ((Object)(object)component2 == (Object)null || !component2.IsValid())
				{
					return true;
				}
				if (!component2.GetZDO().GetBool("EnchantedLoxSaddleBags", false))
				{
					return true;
				}
				__result = null;
				return false;
			}
		}

		[HarmonyPatch(typeof(MonsterAI), "OnDamaged")]
		public static class EnchantedLoxOnDamagedPatch
		{
			private static bool Prefix(MonsterAI __instance, float damage, Character attacker)
			{
				Tameable component = ((Component)__instance).GetComponent<Tameable>();
				if ((Object)(object)component == (Object)null)
				{
					return true;
				}
				ZNetView component2 = ((Component)component).GetComponent<ZNetView>();
				if ((Object)(object)component2 == (Object)null || !component2.IsValid())
				{
					return true;
				}
				if (!component2.GetZDO().GetBool("EnchantedLoxSaddleBags", false))
				{
					return true;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(Sadle), "RPC_RemoveSaddle")]
		public static class RemoveSaddleDebugPatch
		{
			private static void Prefix()
			{
				Debug.Log((object)"RPC_REMOVE_SADDLE");
			}

			private static void Postfix()
			{
				Debug.Log((object)"RPC_REMOVE_SADDLE DONE");
			}
		}

		[HarmonyPatch(typeof(Tameable), "UseItem")]
		public static class SaddleBagUsePatch
		{
			private static bool Prefix(Tameable __instance, Humanoid user, ItemData item, ref bool __result)
			{
				object obj;
				if (item == null)
				{
					obj = null;
				}
				else
				{
					GameObject dropPrefab = item.m_dropPrefab;
					obj = ((dropPrefab != null) ? ((Object)dropPrefab).name : null);
				}
				string text = (string)obj;
				bool flag = text == "LoxSaddleBags";
				bool flag2 = text == "EnchantedLoxSaddleBags";
				if (!flag && !flag2)
				{
					return true;
				}
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid())
				{
					__result = false;
					return false;
				}
				if (!__instance.IsTamed())
				{
					__result = false;
					return false;
				}
				if (component.GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false))
				{
					((Character)user).Message((MessageType)2, __instance.GetHoverName() + " $hud_saddle_already", 0, (Sprite)null, false);
					__result = true;
					return false;
				}
				component.GetZDO().Set("LoxSaddleBags", true);
				if (flag2)
				{
					component.GetZDO().Set("EnchantedLoxSaddleBags", true);
					UpdateEnchantedState(__instance, enabled: true);
					Debug.Log((object)("LOX AI: " + ((object)((Component)__instance).GetComponent<BaseAI>())?.GetType().Name));
				}
				Debug.Log((object)("ENCHANTED BEFORE ADDSADDLE: " + component.GetZDO().GetBool("EnchantedLoxSaddleBags", false)));
				component.InvokeRPC("AddSaddle", Array.Empty<object>());
				Debug.Log((object)("AFTER ADDSADDLE: " + component.GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false)));
				user.GetInventory().RemoveOneItem(item);
				((Character)user).Message((MessageType)2, __instance.GetHoverName() + " $hud_saddle_ready", 0, (Sprite)null, false);
				Debug.Log((object)"TRYING TO SPAWN MODEL FROM USEITEM");
				GetOrCreateContainer(__instance);
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Container), "Awake")]
		public static class ContainerAwakePatch
		{
			private static void Prefix(Container __instance)
			{
				if (!((Object)(object)((Component)__instance).GetComponent<Tameable>() == (Object)null))
				{
					__instance.m_name = "$loxsaddle_inventory_bags_name";
					__instance.m_width = 6;
					__instance.m_height = 4;
					Debug.Log((object)"PATCHED CONTAINER BEFORE AWAKE");
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "GetHoverText")]
		public static class TameableHoverPatch
		{
			private static void Postfix(Tameable __instance, ref string __result)
			{
				ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
				if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO().GetBool("LoxSaddleBags", false))
				{
					__result = __result + "\n" + LocalizationManager.Instance.TryTranslate("$loxsaddle_hover_open_bags");
				}
			}
		}

		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDBAwakePatch
		{
			private static void PatchItem(ObjectDB db, string prefabName, string name, string description)
			{
				GameObject itemPrefab = db.GetItemPrefab(prefabName);
				if ((Object)(object)itemPrefab == (Object)null)
				{
					Debug.Log((object)(prefabName + " prefab not found"));
					return;
				}
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component == (Object)null))
				{
					component.m_itemData.m_shared.m_name = name;
					component.m_itemData.m_shared.m_description = description;
				}
			}

			private static void Postfix(ObjectDB __instance)
			{
				GameObject itemPrefab = __instance.GetItemPrefab("LoxSaddleBags");
				if ((Object)(object)itemPrefab == (Object)null)
				{
					Debug.Log((object)"LoxSaddleBags prefab not found");
					return;
				}
				GameObject itemPrefab2 = __instance.GetItemPrefab("EnchantedLoxSaddleBags");
				if ((Object)(object)itemPrefab2 != (Object)null)
				{
					ItemDrop component = itemPrefab2.GetComponent<ItemDrop>();
					component.m_itemData.m_shared.m_name = "$loxsaddle_item_enchantedbags_name";
					component.m_itemData.m_shared.m_description = "$loxsaddle_item_enchantedbags_desc";
				}
				ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>();
				if (!((Object)(object)component2 == (Object)null))
				{
					component2.m_itemData.m_shared.m_name = "$loxsaddle_item_bags_name";
					component2.m_itemData.m_shared.m_description = "$loxsaddle_item_bags_desc";
					Debug.Log((object)"LOX SADDLE BAGS NAME PATCHED");
					GameObject itemPrefab3 = __instance.GetItemPrefab("LoxHealingTreat");
					if ((Object)(object)itemPrefab3 != (Object)null)
					{
						ItemDrop component3 = itemPrefab3.GetComponent<ItemDrop>();
						component3.m_itemData.m_shared.m_name = "$loxsaddle_item_healingtreat_name";
						component3.m_itemData.m_shared.m_description = "$loxsaddle_item_healingtreat_desc";
					}
					GameObject itemPrefab4 = __instance.GetItemPrefab("LoxEnergyTreat");
					if ((Object)(object)itemPrefab4 != (Object)null)
					{
						ItemDrop component4 = itemPrefab4.GetComponent<ItemDrop>();
						component4.m_itemData.m_shared.m_name = "$loxsaddle_item_energytreat_name";
						component4.m_itemData.m_shared.m_description = "$loxsaddle_item_energytreat_desc";
					}
					PatchItem(__instance, "LoxTrinketOceanItem", "$loxsaddle_item_trinket_ocean_name", "$loxsaddle_item_trinket_ocean_desc");
					PatchItem(__instance, "LoxTrinketUlvItem", "$loxsaddle_item_trinket_ulv_name", "$loxsaddle_item_trinket_ulv_desc");
					PatchItem(__instance, "LoxTrinketMistlandsItem", "$loxsaddle_item_trinket_mistlands_name", "$loxsaddle_item_trinket_mistlands_desc");
					PatchItem(__instance, "LoxTrinketAshlandsItem", "$loxsaddle_item_trinket_ashlands_name", "$loxsaddle_item_trinket_ashlands_desc");
					PatchItem(__instance, "LoxFlute", "$loxsaddle_item_flute_name", "$loxsaddle_item_flute_desc");
				}
			}
		}

		public const string ModGUID = "pl.twojnick.loxsaddlebags";

		public const string ModName = "Lox Saddle Bags";

		public const string ModVersion = "0.0.1";

		public static AssetBundle Bundle;

		public static GameObject SaddleModel;

		public static GameObject EnchantedSaddleModel;

		public static GameObject DropSaddleModel;

		public static GameObject BellSaddleModel;

		public static GameObject DropBellSaddleModel;

		public static GameObject EnchantedDropSaddleModel;

		public static GameObject HealingTreatModel;

		public static GameObject EnergyTreatModel;

		public static GameObject FluteModel;

		public static GameObject OceanTrinketModel;

		public static GameObject MistlandsTrinketModel;

		public static GameObject AshlandsTrinketModel;

		public static GameObject UlvTrinketModel;

		public static AudioClip[] FluteSounds;

		public static AudioClip[] BellSaddleSounds;

		public static Sprite OceanTrinketIcon;

		public static Sprite BellSaddleIcon;

		public static Sprite MistlandsTrinketIcon;

		public static Sprite AshlandsTrinketIcon;

		public static Sprite UlvTrinketIcon;

		public static Sprite FluteIcon;

		public static Sprite HealingTreatIcon;

		public static Sprite EnergyTreatIcon;

		public static Sprite SaddleIcon;

		public static Sprite EnchantedSaddleIcon;

		public static Sprite icon_banner1;

		public static Sprite icon_banner2;

		public static Sprite icon_banner3;

		private void Awake()
		{
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_0749: Expected O, but got Unknown
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "loxbundle");
			Bundle = AssetBundle.LoadFromFile(text);
			Debug.Log((object)$"BUNDLE LOADED: {(Object)(object)Bundle != (Object)null}");
			if ((Object)(object)Bundle != (Object)null)
			{
				string[] allAssetNames = Bundle.GetAllAssetNames();
				foreach (string text2 in allAssetNames)
				{
					Debug.Log((object)("ASSET: " + text2));
				}
				GameObject val = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxsaddlebagsmodel.prefab");
				Debug.Log((object)$"MODEL LOADED: {(Object)(object)val != (Object)null}");
				SaddleModel = val;
				GameObject val2 = Bundle.LoadAsset<GameObject>("assets/loxbundle/enchantedsaddlemodel.prefab");
				Debug.Log((object)$"NORMAL MODEL: {(Object)(object)val != (Object)null}");
				Debug.Log((object)$"ENCHANTED MODEL: {(Object)(object)val2 != (Object)null}");
				Debug.Log((object)$"ENCHANTED MODEL LOADED: {(Object)(object)val2 != (Object)null}");
				EnchantedSaddleModel = val2;
				string[] allAssetNames2 = Bundle.GetAllAssetNames();
				foreach (string text3 in allAssetNames2)
				{
					Debug.Log((object)("ASSET: " + text3));
				}
				if ((Object)(object)val != (Object)null)
				{
					SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren<SkinnedMeshRenderer>(true);
					foreach (SkinnedMeshRenderer val3 in componentsInChildren)
					{
						Debug.Log((object)("SMR: " + ((Object)val3).name));
					}
					MeshFilter[] componentsInChildren2 = val.GetComponentsInChildren<MeshFilter>(true);
					foreach (MeshFilter val4 in componentsInChildren2)
					{
						Debug.Log((object)("MESHFILTER: " + ((Object)val4).name));
					}
				}
				DropSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/dropsaddlebags.prefab");
				EnchantedDropSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/enchantedsaddle.prefab");
				HealingTreatModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtreathealth.prefab");
				EnergyTreatModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtreatstamina.prefab");
				OceanTrinketModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtrinketocean.prefab");
				UlvTrinketModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtrinketulv.prefab");
				MistlandsTrinketModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtrinketmistlands.prefab");
				AshlandsTrinketModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxtrinketashlands.prefab");
				Debug.Log((object)$"OCEAN MODEL: {(Object)(object)OceanTrinketModel != (Object)null}");
				Debug.Log((object)$"ULV MODEL: {(Object)(object)UlvTrinketModel != (Object)null}");
				Debug.Log((object)$"MISTLANDS MODEL: {(Object)(object)MistlandsTrinketModel != (Object)null}");
				Debug.Log((object)$"ASHLANDS MODEL: {(Object)(object)AshlandsTrinketModel != (Object)null}");
				BellSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/saddlebells.prefab");
				DropBellSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/saddlebellsitem.prefab");
				BellSaddleIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_saddlebells.png");
				Debug.Log((object)$"BELL SADDLE MODEL: {(Object)(object)BellSaddleModel != (Object)null}");
				Debug.Log((object)$"BELL SADDLE DROP MODEL: {(Object)(object)DropBellSaddleModel != (Object)null}");
				Debug.Log((object)$"BELL SADDLE ICON: {(Object)(object)BellSaddleIcon != (Object)null}");
				FluteModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/flute.prefab");
				Debug.Log((object)$"DROP MODEL: {(Object)(object)DropSaddleModel != (Object)null}");
				Debug.Log((object)$"ENCHANTED DROP MODEL: {(Object)(object)EnchantedDropSaddleModel != (Object)null}");
				SaddleIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxsaddlebags.png");
				EnchantedSaddleIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_enchantedloxsaddlebags.png");
				HealingTreatIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_treathealth.png");
				FluteIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_flute.png");
				string[] array = (from path in Bundle.GetAllAssetNames()
					where path.Contains("loxflutesound") && (path.EndsWith(".wav") || path.EndsWith(".ogg") || path.EndsWith(".mp3"))
					orderby path
					select path).ToArray();
				string[] array2 = array;
				foreach (string text4 in array2)
				{
					Debug.Log((object)("FLUTE SOUND PATH FOUND: " + text4));
				}
				FluteSounds = (from path in array
					select Bundle.LoadAsset<AudioClip>(path) into clip
					where (Object)(object)clip != (Object)null
					select clip).ToArray();
				Debug.Log((object)$"FLUTE SOUNDS LOADED: {FluteSounds.Length}");
				string[] array3 = (from path in Bundle.GetAllAssetNames()
					where path.Contains("chimes") && (path.EndsWith(".wav") || path.EndsWith(".ogg") || path.EndsWith(".mp3"))
					orderby path
					select path).ToArray();
				string[] array4 = array3;
				foreach (string text5 in array4)
				{
					Debug.Log((object)("BELL SOUND PATH FOUND: " + text5));
				}
				BellSaddleSounds = (from path in array3
					select Bundle.LoadAsset<AudioClip>(path) into clip
					where (Object)(object)clip != (Object)null
					select clip).ToArray();
				Debug.Log((object)$"BELL SOUNDS LOADED: {BellSaddleSounds.Length}");
				EnergyTreatIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_treatstamina.png");
				OceanTrinketIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxtrinketocean.png");
				UlvTrinketIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxtrinketulv.png");
				MistlandsTrinketIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxtrinketmistlands.png");
				AshlandsTrinketIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxtrinketashlands.png");
				Debug.Log((object)$"OCEAN ICON: {(Object)(object)OceanTrinketIcon != (Object)null}");
				Debug.Log((object)$"ULV ICON: {(Object)(object)UlvTrinketIcon != (Object)null}");
				Debug.Log((object)$"MISTLANDS ICON: {(Object)(object)MistlandsTrinketIcon != (Object)null}");
				Debug.Log((object)$"ASHLANDS ICON: {(Object)(object)AshlandsTrinketIcon != (Object)null}");
			}
			Harmony val5 = new Harmony("pl.twojnick.loxsaddlebags");
			val5.PatchAll();
			MethodInfo methodInfo = AccessTools.Method(typeof(Character), "GetSlideAngle", (Type[])null, (Type[])null);
			Debug.Log((object)("[MISTLANDS DEBUG] GetSlideAngle method found = " + $"{methodInfo != null}"));
			if (methodInfo != null)
			{
				Patches patchInfo = Harmony.GetPatchInfo((MethodBase)methodInfo);
				Debug.Log((object)("[MISTLANDS DEBUG] GetSlideAngle has patches = " + $"{patchInfo != null}"));
				if (patchInfo != null)
				{
					foreach (string owner in patchInfo.Owners)
					{
						Debug.Log((object)("[MISTLANDS DEBUG] Patch owner: " + owner));
					}
				}
			}
			PrefabManager.OnVanillaPrefabsAvailable += AddItems;
			((Component)this).gameObject.AddComponent<LoxBagInput>();
			((Component)this).gameObject.AddComponent<EnchantedLoxRiderProtectionUpdater>();
			GameObject prefab = PrefabManager.Instance.GetPrefab("InventoryGui");
			Debug.Log((object)$"InventoryGui prefab = {(Object)(object)prefab != (Object)null}");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"PLUGIN TEST 999");
		}

		public static void UpdateEnchantedState(Tameable tameable, bool enabled)
		{
			Character component = ((Component)tameable).GetComponent<Character>();
			if (!((Object)(object)component == (Object)null))
			{
				component.m_aiSkipTarget = enabled;
				Debug.Log((object)$"ENCHANTED STATE: {enabled}");
			}
		}

		private static void DropBagContents(Tameable tameable, Container container)
		{
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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)
			if ((Object)(object)container == (Object)null)
			{
				return;
			}
			Inventory inventory = container.GetInventory();
			if (inventory == null)
			{
				return;
			}
			List<ItemData> list = new List<ItemData>(inventory.GetAllItems());
			Debug.Log((object)$"DROPPING {list.Count} ITEMS");
			foreach (ItemData item in list)
			{
				ItemDrop.DropItem(item, item.m_stack, ((Component)tameable).transform.position + Vector3.up, Quaternion.identity);
			}
			inventory.RemoveAll();
		}

		public static Container GetOrCreateContainer(Tameable tameable)
		{
			Container container = ((Component)tameable).GetComponent<Container>();
			Character component = ((Component)tameable).GetComponent<Character>();
			if ((Object)(object)component != (Object)null)
			{
				component.m_onDeath = (Action)Delegate.Combine(component.m_onDeath, (Action)delegate
				{
					DropBagContents(tameable, container);
				});
				Debug.Log((object)"REGISTERED DEATH HANDLER");
			}
			if ((Object)(object)container == (Object)null)
			{
				container = ((Component)tameable).gameObject.AddComponent<Container>();
			}
			return container;
		}

		private void CreateBannerPieceFromVanilla(string piecePrefabName, string modelAssetPath, string iconAssetPath, string displayName, string description)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Expected O, but got Unknown
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Expected O, but got Unknown
			PieceConfig val = new PieceConfig();
			val.Name = displayName;
			val.Description = description;
			val.PieceTable = "Hammer";
			val.Category = "Furniture";
			val.CraftingStation = "piece_workbench";
			val.AddRequirement(new RequirementConfig
			{
				Item = "FineWood",
				Amount = 2,
				Recover = true
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "LeatherScraps",
				Amount = 2,
				Recover = true
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "LinenThread",
				Amount = 2,
				Recover = true
			});
			CustomPiece val2 = new CustomPiece(piecePrefabName, "piece_banner01", val);
			if ((Object)(object)val2.PiecePrefab == (Object)null)
			{
				Debug.LogError((object)("BANNER PIECE PREFAB NULL: " + piecePrefabName));
				return;
			}
			Sprite val3 = Bundle.LoadAsset<Sprite>(iconAssetPath);
			Piece component = val2.PiecePrefab.GetComponent<Piece>();
			if ((Object)(object)component != (Object)null && (Object)(object)val3 != (Object)null)
			{
				component.m_icon = val3;
			}
			GameObject val4 = Bundle.LoadAsset<GameObject>(modelAssetPath);
			if ((Object)(object)val4 == (Object)null)
			{
				Debug.LogError((object)("BANNER MODEL NOT FOUND: " + modelAssetPath));
			}
			else
			{
				ReplaceBannerVisual(val2.PiecePrefab, val4);
			}
			PieceManager.Instance.AddPiece(val2);
			Debug.Log((object)("REGISTERED LOX BELL BANNER: " + piecePrefabName));
		}

		private void ReplaceBannerVisual(GameObject piecePrefab, GameObject modelPrefab)
		{
			//IL_0045: 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_0067: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = piecePrefab.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				val.enabled = false;
			}
			GameObject val2 = Object.Instantiate<GameObject>(modelPrefab, piecePrefab.transform);
			((Object)val2).name = "LoxBellBanner_visual";
			val2.transform.localPosition = Vector3.zero;
			val2.transform.localRotation = Quaternion.identity;
			val2.transform.localScale = Vector3.one;
			val2.SetActive(true);
			Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val3 in componentsInChildren2)
			{
				val3.enabled = true;
				((Component)val3).gameObject.SetActive(true);
				MakeRendererDoubleSided(val3);
			}
			Collider[] componentsInChildren3 = val2.GetComponentsInChildren<Collider>(true);
			foreach (Collider val4 in componentsInChildren3)
			{
				val4.enabled = false;
			}
		}

		private void MakeRendererDoubleSided(Renderer renderer)
		{
			if ((Object)(object)renderer == (Object)null)
			{
				return;
			}
			Material[] materials = renderer.materials;
			Material[] array = materials;
			foreach (Material val in array)
			{
				if (!((Object)(object)val == (Object)null))
				{
					if (val.HasProperty("_Cull"))
					{
						val.SetInt("_Cull", 0);
					}
					if (val.HasProperty("_CullMode"))
					{
						val.SetInt("_CullMode", 0);
					}
					val.doubleSidedGI = true;
				}
			}
			renderer.materials = materials;
		}

		private void CreateLoxBellBanners()
		{
			CreateBannerPieceFromVanilla("piece_loxbellbanner01", "assets/loxbundle/bannerloxbell.prefab", "assets/loxbundle/icon_banner1.png", "$loxsaddle_piece_banner1_name", "$loxsaddle_piece_banner_desc");
			CreateBannerPieceFromVanilla("piece_loxbellbanner02", "assets/loxbundle/bannerloxbell2.prefab", "assets/loxbundle/icon_banner2.png", "$loxsaddle_piece_banner2_name", "$loxsaddle_piece_banner_desc");
			CreateBannerPieceFromVanilla("piece_loxbellbanner03", "assets/loxbundle/bannerloxbell3.prefab", "assets/loxbundle/icon_banner3.png", "$loxsaddle_piece_banner3_name", "$loxsaddle_piece_banner_desc");
		}

		private Vector3 GetTrinketPosition(string prefabName)
		{
			//IL_004a: 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_009f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(prefabName switch
			{
				"LoxTrinketAshlandsItem" => new Vector3(0f, 0.08f, 0f), 
				"LoxTrinketOceanItem" => new Vector3(0f, 0.08f, 0f), 
				"LoxTrinketMistlandsItem" => new Vector3(0f, 0.08f, 0f), 
				"LoxTrinketUlvItem" => new Vector3(0f, 0.08f, 0f), 
				_ => Vector3.zero, 
			});
		}

		private Quaternion GetTrinketRotation(string prefabName)
		{
			//IL_004a: 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_009f: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			return (Quaternion)(prefabName switch
			{
				"LoxTrinketOceanItem" => Quaternion.Euler(270f, 0f, 0f), 
				"LoxTrinketMistlandsItem" => Quaternion.Euler(270f, 0f, 0f), 
				"LoxTrinketAshlandsItem" => Quaternion.Euler(270f, 0f, 0f), 
				"LoxTrinketUlvItem" => Quaternion.Euler(90f, 0f, 0f), 
				_ => Quaternion.identity, 
			});
		}

		private Vector3 GetTrinketScale(string prefabName)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			return (Vector3)(prefabName switch
			{
				"LoxTrinketAshlandsItem" => Vector3.one * 180f, 
				"LoxTrinketOceanItem" => Vector3.one * 1f, 
				"LoxTrinketMistlandsItem" => Vector3.one * 1f, 
				"LoxTrinketUlvItem" => Vector3.one * 0.025f, 
				_ => Vector3.one, 
			});
		}

		private void CreateTrinket(string prefabName, GameObject model, Sprite icon, string craftingStation, params RequirementConfig[] requirements)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Expected O, but got Unknown
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig();
			val.CraftingStation = craftingStation;
			foreach (RequirementConfig val2 in requirements)
			{
				val.AddRequirement(val2);
			}
			CustomItem val3 = new CustomItem(prefabName, "Amber", val);
			ItemDrop component = val3.ItemPrefab.GetComponent<ItemDrop>();
			Rigidbody val4 = val3.ItemPrefab.GetComponent<Rigidbody>();
			if ((Object)(object)val4 == (Object)null)
			{
				val4 = val3.ItemPrefab.AddComponent<Rigidbody>();
			}
			val4.useGravity = true;
			val4.isKinematic = false;
			val4.mass = 1f;
			val4.drag = 2f;
			val4.angularDrag = 8f;
			val4.collisionDetectionMode = (CollisionDetectionMode)0;
			Collider component2 = val3.ItemPrefab.GetComponent<Collider>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.Destroy((Object)(object)component2);
			}
			BoxCollider val5 = val3.ItemPrefab.AddComponent<BoxCollider>();
			val5.size = new Vector3(0.45f, 0.18f, 0.45f);
			val5.center = new Vector3(0f, 0.09f, 0f);
			int num = LayerMask.NameToLayer("item");
			if (num >= 0)
			{
				val3.ItemPrefab.layer = num;
			}
			if ((Object)(object)component != (Object)null)
			{
				component.m_itemData.m_shared.m_name = prefabName;
				component.m_itemData.m_shared.m_description = "Lox trinket.";
				component.m_itemData.m_shared.m_itemType = (ItemType)1;
				component.m_itemData.m_shared.m_maxStackSize = 1;
				if ((Object)(object)icon != (Object)null)
				{
					component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { icon };
				}
				Transform val6 = val3.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val6 != (Object)null)
				{
					foreach (Transform item in val6)
					{
						Transform val7 = item;
						Object.Destroy((Object)(object)((Component)val7).gameObject);
					}
					if ((Object)(object)model == (Object)null)
					{
						Debug.LogError((object)("MODEL IS NULL FOR " + prefabName));
					}
					else
					{
						GameObject val8 = Object.Instantiate<GameObject>(model, val6);
						((Object)val8).name = prefabName + "_visual";
						val8.transform.localPosition = GetTrinketPosition(prefabName);
						val8.transform.localRotation = GetTrinketRotation(prefabName);
						val8.transform.localScale = GetTrinketScale(prefabName);
						val8.SetActive(true);
						Renderer[] componentsInChildren = val8.GetComponentsInChildren<Renderer>(true);
						Debug.Log((object)$"{prefabName} visual renderers: {componentsInChildren.Length}");
						Renderer[] array = componentsInChildren;
						foreach (Renderer val9 in array)
						{
							val9.enabled = true;
							((Component)val9).gameObject.SetActive(true);
							Debug.Log((object)$"{prefabName} renderer: {((Object)val9).name}, enabled={val9.enabled}");
						}
					}
				}
			}
			ItemManager.Instance.AddItem(val3);
			Debug.Log((object)("REGISTERED TRINKET: " + prefabName));
		}

		private void CreateLoxTetherRope()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			CustomItem val = new CustomItem("LoxTetherRope", "LeatherScraps");
			ItemDrop component = val.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = "$loxsaddle_item_tether_name";
				shared.m_description = "$loxsaddle_item_tether_desc";
				shared.m_itemType = (ItemType)1;
				shared.m_maxStackSize = 1;
				shared.m_weight = 1f;
			}
			ItemManager.Instance.AddItem(val);
			Debug.Log((object)"REGISTERED LOX TETHER ROPE");
		}

		private void CreateLoxBellSaddle()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig();
			val.CraftingStation = "blackforge";
			val.AddRequirement(new RequirementConfig
			{
				Item = "BlackMetal",
				Amount = 20
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "LinenThread",
				Amount = 20
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "FineWood",
				Amount = 10
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "TrophyUlv",
				Amount = 2
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "JuteRed",
				Amount = 10
			});
			CustomItem val2 = new CustomItem("LoxBellSaddle", "SaddleLox", val);
			ItemDrop component = val2.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = "$loxsaddle_item_bellsaddle_name";
				shared.m_description = "$loxsaddle_item_bellsaddle_desc";
				shared.m_maxStackSize = 1;
				if ((Object)(object)BellSaddleIcon != (Object)null)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { BellSaddleIcon };
				}
				Transform val3 = val2.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val3 != (Object)null && (Object)(object)DropBellSaddleModel != (Object)null)
				{
					Renderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val4 in componentsInChildren)
					{
						val4.enabled = false;
					}
					GameObject val5 = Object.Instantiate<GameObject>(DropBellSaddleModel, val3);
					((Object)val5).name = "LoxBellSaddle_drop_visual";
					val5.transform.localPosition = Vector3.zero;
					val5.transform.localRotation = Quaternion.identity;
					val5.transform.localScale = Vector3.one;
					val5.SetActive(true);
				}
			}
			ItemManager.Instance.AddItem(val2);
			Debug.Log((object)"REGISTERED LOX BELL SADDLE");
		}

		private void CreateLoxFlute()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Expected O, but got Unknown
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"CREATE LOX FLUTE START");
			ItemConfig val = new ItemConfig();
			val.CraftingStation = "piece_magetable";
			val.AddRequirement(new RequirementConfig
			{
				Item = "Copper",
				Amount = 15
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "Chitin",
				Amount = 1
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "Wisp",
				Amount = 1
			});
			CustomItem val2 = new CustomItem("LoxFlute", "CookedLoxMeat", val);
			Debug.Log((object)("LOX FLUTE PREFAB CREATED: " + $"{(Object)(object)val2.ItemPrefab != (Object)null}"));
			ItemDrop component = val2.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null)
			{
				SharedData shared = component.m_itemData.m_shared;
				shared.m_name = "$loxsaddle_item_flute_name";
				shared.m_description = "$loxsaddle_item_flute_desc";
				shared.m_maxStackSize = 1;
				shared.m_itemType = (ItemType)2;
				shared.m_food = 0f;
				shared.m_foodStamina = 0f;
				shared.m_foodBurnTime = 0f;
				shared.m_foodRegen = 0f;
				if ((Object)(object)FluteIcon != (Object)null)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { FluteIcon };
				}
				Transform val3 = val2.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val3 != (Object)null && (Object)(object)FluteModel != (Object)null)
				{
					Renderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val4 in componentsInChildren)
					{
						val4.enabled = false;
					}
					GameObject val5 = Object.Instantiate<GameObject>(FluteModel, val3);
					((Object)val5).name = "LoxFlute_visual";
					val5.transform.localPosition = Vector3.zero;
					val5.transform.localRotation = Quaternion.identity;
					val5.transform.localScale = Vector3.one;
					val5.SetActive(true);
					Renderer[] componentsInChildren2 = val5.GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val6 in componentsInChildren2)
					{
						val6.enabled = true;
					}
				}
			}
			ItemManager.Instance.AddItem(val2);
			Debug.Log((object)"REGISTERED LOX FLUTE");
		}

		private void AddItems()
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//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)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Expected O, but got Unknown
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Expected O, but got Unknown
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Expected O, but got Unknown
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0276: Unknown result type (might be due to invalid IL or missing references)
			//IL_0284: Expected O, but got Unknown
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Expected O, but got Unknown
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c6: Expected O, but got Unknown
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e6: Expected O, but got Unknown
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f9: Expected O, but got Unknown
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0416: Unknown result type (might be due to invalid IL or missing references)
			//IL_041d: Expected O, but got Unknown
			//IL_0436: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0447: Unknown result type (might be due to invalid IL or missing references)
			//IL_0455: Expected O, but got Unknown
			//IL_0458: Unknown result type (might be due to invalid IL or missing references)
			//IL_045d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0469: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Expected O, but got Unknown
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_047e: Unknown result type (might be due to invalid IL or missing references)
			//IL_048a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0498: Expected O, but got Unknown
			//IL_049b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ba: Expected O, but got Unknown
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ce: Expected O, but got Unknown
			//IL_037a: Unknown result type (might be due to invalid IL or missing references)
			//IL_038c: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_060e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0615: Expected O, but got Unknown
			//IL_062e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_063f: Unknown result type (might be due to invalid IL or missing references)
			//IL_064d: Expected O, but got Unknown
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			//IL_0655: Unknown result type (might be due to invalid IL or missing references)
			//IL_0661: Unknown result type (might be due to invalid IL or missing references)
			//IL_066f: Expected O, but got Unknown
			//IL_0672: Unknown result type (might be due to invalid IL or missing references)
			//IL_0677: Unknown result type (might be due to invalid IL or missing references)
			//IL_0683: Unknown result type (might be due to invalid IL or missing references)
			//IL_0691: Expected O, but got Unknown
			//IL_0694: Unknown result type (might be due to invalid IL or missing references)
			//IL_0699: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b2: Expected O, but got Unknown
			//IL_06bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Expected O, but got Unknown
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_0828: Unknown result type (might be due to invalid IL or missing references)
			//IL_0834: Unknown result type (might be due to invalid IL or missing references)
			//IL_083d: Expected O, but got Unknown
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0844: Unknown result type (might be due to invalid IL or missing references)
			//IL_0850: Unknown result type (might be due to invalid IL or missing references)
			//IL_0859: Expected O, but got Unknown
			//IL_085b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0860: Unknown result type (might be due to invalid IL or missing references)
			//IL_086c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Expected O, but got Unknown
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0888: Unknown result type (might be due to invalid IL or missing references)
			//IL_0892: Expected O, but got Unknown
			//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_08fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_090a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0913: Expected O, but got Unknown
			//IL_0915: Unknown result type (might be due to invalid IL or missing references)
			//IL_091a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0926: Unknown result type (might be due to invalid IL or missing references)
			//IL_092f: Expected O, but got Unknown
			//IL_0931: Unknown result type (might be due to invalid IL or missing references)
			//IL_0936: Unknown result type (might be due to invalid IL or missing references)
			//IL_0942: Unknown result type (might be due to invalid IL or missing references)
			//IL_094b: Expected O, but got Unknown
			//IL_094d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0952: Unknown result type (might be due to invalid IL or missing references)
			//IL_095e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0968: Expected O, but got Unknown
			//IL_098b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0990: Unknown result type (might be due to invalid IL or missing references)
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a5: Expected O, but got Unknown
			//IL_09a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c1: Expected O, but got Unknown
			//IL_09c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09dd: Expected O, but got Unknown
			//IL_09df: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Expected O, but got Unknown
			//IL_0a1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a22: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a2e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Expected O, but got Unknown
			//IL_0a39: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a4a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a53: Expected O, but got Unknown
			//IL_0a55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6f: Expected O, but got Unknown
			//IL_0a71: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a76: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a82: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8c: Expected O, but got Unknown
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f9: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig();
			val.CraftingStation = "piece_artisanstation";
			val.AddRequirement(new RequirementConfig
			{
				Item = "BlackMetal",
				Amount = 15
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "Iron",
				Amount = 15
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "WolfPelt",
				Amount = 10
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "LinenThread",
				Amount = 20
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "BarrelRings",
				Amount = 4
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "Wood",
				Amount = 30
			});
			CustomItem val2 = new CustomItem("LoxSaddleBags", "SaddleLox", val);
			if ((Object)(object)DropSaddleModel != (Object)null)
			{
				Transform val3 = val2.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val3 != (Object)null)
				{
					Renderer[] componentsInChildren = ((Component)val3).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val4 in componentsInChildren)
					{
						val4.enabled = false;
					}
					GameObject val5 = Object.Instantiate<GameObject>(DropSaddleModel, val3);
					val5.transform.localPosition = Vector3.zero;
					val5.transform.localRotation = Quaternion.identity;
					val5.transform.localScale = Vector3.one;
				}
			}
			ItemManager.Instance.AddItem(val2);
			ItemDrop component = val2.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component != (Object)null && (Object)(object)SaddleIcon != (Object)null)
			{
				component.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { SaddleIcon };
			}
			ItemConfig val6 = new ItemConfig();
			val6.CraftingStation = "piece_magetable";
			val6.AddRequirement(new RequirementConfig
			{
				Item = "LinenThread",
				Amount = 20
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "BlackMetal",
				Amount = 15
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "Copper",
				Amount = 15
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "YggdrasilWood",
				Amount = 30
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "JuteRed",
				Amount = 10
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "JuteBlue",
				Amount = 10
			});
			val6.AddRequirement(new RequirementConfig
			{
				Item = "Lantern",
				Amount = 2
			});
			CustomItem val7 = new CustomItem("EnchantedLoxSaddleBags", "SaddleLox", val6);
			if ((Object)(object)EnchantedDropSaddleModel != (Object)null)
			{
				Transform val8 = val7.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val8 != (Object)null)
				{
					Renderer[] componentsInChildren2 = ((Component)val8).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val9 in componentsInChildren2)
					{
						val9.enabled = false;
					}
					GameObject val10 = Object.Instantiate<GameObject>(EnchantedDropSaddleModel, val8);
					val10.transform.localPosition = Vector3.zero;
					val10.transform.localRotation = Quaternion.identity;
					val10.transform.localScale = Vector3.one;
				}
			}
			ItemManager.Instance.AddItem(val7);
			ItemDrop component2 = val7.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component2 != (Object)null && (Object)(object)EnchantedSaddleIcon != (Object)null)
			{
				component2.m_itemData.m_shared.m_icons = (Sprite[])(object)new Sprite[1] { EnchantedSaddleIcon };
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Lox saddle bags added");
			ItemConfig val11 = new ItemConfig();
			val11.CraftingStation = "piece_preptable";
			val11.Amount = 10;
			val11.AddRequirement(new RequirementConfig
			{
				Item = "FragrantBundle",
				Amount = 10
			});
			val11.AddRequirement(new RequirementConfig
			{
				Item = "SpiceMountains",
				Amount = 1
			});
			val11.AddRequirement(new RequirementConfig
			{
				Item = "Honey",
				Amount = 10
			});
			val11.AddRequirement(new RequirementConfig
			{
				Item = "Dandelion",
				Amount = 10
			});
			CustomItem val12 = new CustomItem("LoxHealingTreat", "CookedLoxMeat", val11);
			ItemManager.Instance.AddItem(val12);
			ItemDrop component3 = val12.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component3 != (Object)null)
			{
				SharedData shared = component3.m_itemData.m_shared;
				shared.m_food = 0f;
				shared.m_foodStamina = 0f;
				shared.m_foodBurnTime = 0f;
				shared.m_foodRegen = 0f;
				if ((Object)(object)HealingTreatIcon != (Object)null)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { HealingTreatIcon };
				}
				Transform val13 = val12.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val13 != (Object)null && (Object)(object)HealingTreatModel != (Object)null)
				{
					Renderer[] componentsInChildren3 = ((Component)val13).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val14 in componentsInChildren3)
					{
						val14.enabled = false;
					}
					GameObject val15 = Object.Instantiate<GameObject>(HealingTreatModel, val13);
					val15.transform.localPosition = Vector3.zero;
					val15.transform.localRotation = Quaternion.identity;
					val15.transform.localScale = Vector3.one;
				}
			}
			ItemConfig val16 = new ItemConfig();
			val16.CraftingStation = "piece_preptable";
			val16.Amount = 10;
			val16.AddRequirement(new RequirementConfig
			{
				Item = "Cloudberry",
				Amount = 10
			});
			val16.AddRequirement(new RequirementConfig
			{
				Item = "Honey",
				Amount = 10
			});
			val16.AddRequirement(new RequirementConfig
			{
				Item = "Blueberries",
				Amount = 10
			});
			val16.AddRequirement(new RequirementConfig
			{
				Item = "FreezeGland",
				Amount = 5
			});
			CustomItem val17 = new CustomItem("LoxEnergyTreat", "CookedLoxMeat", val16);
			ItemManager.Instance.AddItem(val17);
			ItemDrop component4 = val17.ItemPrefab.GetComponent<ItemDrop>();
			if ((Object)(object)component4 != (Object)null)
			{
				SharedData shared2 = component4.m_itemData.m_shared;
				shared2.m_food = 0f;
				shared2.m_foodStamina = 0f;
				shared2.m_foodBurnTime = 0f;
				shared2.m_foodRegen = 0f;
				if ((Object)(object)EnergyTreatIcon != (Object)null)
				{
					shared2.m_icons = (Sprite[])(object)new Sprite[1] { EnergyTreatIcon };
				}
				Transform val18 = val17.ItemPrefab.transform.Find("attach");
				if ((Object)(object)val18 != (Object)null && (Object)(object)EnergyTreatModel != (Object)null)
				{
					Renderer[] componentsInChildren4 = ((Component)val18).GetComponentsInChildren<Renderer>(true);
					foreach (Renderer val19 in componentsInChildren4)
					{
						val19.enabled = false;
					}
					GameObject val20 = Object.Instantiate<GameObject>(EnergyTreatModel, val18);
					val20.transform.localPosition = Vector3.zero;
					val20.transform.localRotation = Quaternion.identity;
					val20.transform.localScale = Vector3.one;
				}
			}
			CreateTrinket("LoxTrinketOceanItem", OceanTrinketModel, OceanTrinketIcon, "piece_magetable", new RequirementConfig
			{
				Item = "Fish12",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "TrophySerpent",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "AmberPearl",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Bronze",
				Amount = 10
			});
			Debug.Log((object)("ABOUT TO CREATE ULV TRINKET: " + $"MODEL={(Object)(object)UlvTrinketModel != (Object)null}, " + $"ICON={(Object)(object)UlvTrinketIcon != (Object)null}"));
			CreateTrinket("LoxTrinketUlvItem", UlvTrinketModel, UlvTrinketIcon, "piece_magetable", new RequirementConfig
			{
				Item = "TrophyUlv",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "WolfClaw",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Eitr",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Silver",
				Amount = 10
			});
			CreateTrinket("LoxTrinketMistlandsItem", MistlandsTrinketModel, MistlandsTrinketIcon, "piece_magetable", new RequirementConfig
			{
				Item = "TrophySGolem",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Wisp",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Mandible",
				Amount = 2
			}, new RequirementConfig
			{
				Item = "Copper",
				Amount = 10
			});
			CreateTrinket("LoxTrinketAshlandsItem", AshlandsTrinketModel, AshlandsTrinketIcon, "piece_magetable", new RequirementConfig
			{
				Item = "ProustitePowder",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "MoltenCore",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "CelestialFeather",
				Amount = 2
			}, new RequirementConfig
			{
				Item = "Silver",
				Amount = 10
			});
			Debug.Log((object)"ABOUT TO CREATE LOX FLUTE");
			CreateLoxTetherRope();
			CreateLoxBellBanners();
			CreateLoxFlute();
			CreateLoxBellSaddle();
			Debug.Log((object)"ADD ITEMS FINISHED");
		}
	}
	[HarmonyPatch(typeof(Tameable), "SpawnSaddle")]
	public static class SpawnSaddlePatch
	{
		private static bool Prefix(Tameable __instance, Vector3 flyDirection)
		{
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			Debug.Log((object)"SPAWN SADDLE PATCH");
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return true;
			}
			bool flag = component.GetZDO().GetBool("LoxSaddleBags", false);
			bool flag2 = component.GetZDO().GetBool("LoxBellSaddle", false);
			bool flag3 = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false);
			Plugin.UpdateEnchantedState(__instance, enabled: false);
			Debug.Log((object)$"HAS BAGS: {flag}");
			if (!flag && !flag2)
			{
				return true;
			}
			Debug.Log((object)$"HAS BAGS: {flag}");
			string text = ((!flag2) ? (flag3 ? "EnchantedLoxSaddleBags" : "LoxSaddleBags") : "LoxBellSaddle");
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				Debug.Log((object)"LoxSaddleBags prefab not found");
				return true;
			}
			Rigidbody component2 = Object.Instantiate<GameObject>(itemPrefab, ((Component)__instance).transform.TransformPoint(__instance.m_dropSaddleOffset), Quaternion.identity).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				Vector3 val = Vector3.up;
				if (((Vector3)(ref flyDirection)).magnitude > 0.1f)
				{
					flyDirection.y = 0f;
					((Vector3)(ref flyDirection)).Normalize();
					val += flyDirection;
				}
				component2.AddForce(val * __instance.m_dropItemVel, (ForceMode)2);
			}
			component.GetZDO().Set("LoxSaddleBags", false);
			component.GetZDO().Set("LoxBellSaddle", false);
			component.GetZDO().Set("EnchantedLoxSaddleBags", false);
			Debug.Log((object)("DROPPING: " + text));
			Debug.Log((object)"DROPPED BAG SADDLE");
			Debug.Log((object)"SPAWNING BAG SADDLE");
			return false;
		}
	}
	public class EnchantedLoxRiderProtectionUpdater : MonoBehaviour
	{
		private bool _protectionApplied;

		private bool _previousSkipTargetValue;

		private void Update()
		{
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			if (IsRidingEnchantedLox(localPlayer))
			{
				if (!_protectionApplied)
				{
					_previousSkipTargetValue = ((Character)localPlayer).m_aiSkipTarget;
					_protectionApplied = true;
				}
				((Character)localPlayer).m_aiSkipTarget = true;
			}
			else if (_protectionApplied)
			{
				((Character)localPlayer).m_aiSkipTarget = _previousSkipTargetValue;
				_protectionApplied = false;
			}
		}

		private static bool IsRidingEnchantedLox(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			IDoodadController doodadController = player.GetDoodadController();
			Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null);
			if (val == null)
			{
				return false;
			}
			Tameable tameable = val.GetTameable();
			if ((Object)(object)tameable == (Object)null)
			{
				return false;
			}
			Character character = val.GetCharacter();
			if ((Object)(object)character == (Object)null)
			{
				return false;
			}
			if (!((Object)character).name.StartsWith("Lox"))
			{
				return false;
			}
			ZNetView component = ((Component)tameable).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			return component.GetZDO().GetBool("EnchantedLoxSaddleBags", false);
		}
	}
	[HarmonyPatch(typeof(InventoryGui), "OnRightClickItem")]
	public static class LoxTrinketRightClickPatch
	{
		private static bool Prefix(InventoryGrid grid, ItemData item, Vector2i pos)
		{
			if ((Object)(object)InventoryGui.instance == (Object)null)
			{
				return true;
			}
			if (!LoxTrinketGrid.IsOpen)
			{
				return true;
			}
			if ((Object)(object)grid == (Object)null)
			{
				return true;
			}
			Inventory inventory = grid.GetInventory();
			if (!LoxTrinketGrid.IsValidTrinketSource(inventory))
			{
				return true;
			}
			if (LoxTrinketGrid.TryEquipFromInventory(item, inventory))
			{
				return false;
			}
			return true;
		}
	}
	internal static class LoxAshlandsTrinketHelper
	{
		public static bool HasAshlandsTrinket(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return false;
			}
			if (!((Object)character).name.StartsWith("Lox"))
			{
				return false;
			}
			Tameable component = ((Component)character).GetComponent<Tameable>();
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			return LoxTrinketGrid.HasEquippedTrinket(component, "LoxTrinketAshlandsItem");
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class LoxAshlandsTrinketDamagePatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Invalid comparison between Unknown and I4
			if (!((Object)(object)__instance == (Object)null) && hit != null && LoxAshlandsTrinketHelper.HasAshlandsTrinket(__instance))
			{
				hit.m_damage.m_fire = 0f;
				if ((int)hit.m_hitType == 5)
				{
					hit.m_damage.m_damage = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "UpdateLava")]
	public static class LoxAshlandsTrinketLavaPatch
	{
		private static readonly FieldInfo LavaHeatLevelField = AccessTools.Field(typeof(Character), "m_lavaHeatLevel");

		private static void Postfix(Character __instance)
		{
			if (LoxAshlandsTrinketHelper.HasAshlandsTrinket(__instance))
			{
				LavaHeatLevelField?.SetValue(__instance, 0f);
			}
		}
	}
	public class LoxBellHerdController : MonoBehaviour
	{
		private Tameable _tameable;

		private ZNetView _nview;

		private float _nextUpdate;

		private const float FollowRadius = 38f;

		private const float InnerRingRadius = 10f;

		private const float RingSpacing = 4f;

		private const int SlotsPerRing = 8;

		private readonly Dictionary<int, GameObject> _followTargets = new Dictionary<int, GameObject>();

		private static readonly MethodInfo SetFollowTargetMethod = AccessTools.Method(typeof(MonsterAI), "SetFollowTarget", new Type[1] { typeof(GameObject) }, (Type[])null);

		private void Awake()
		{
			_tameable = ((Component)this).GetComponent<Tameable>();
			_nview = ((Component)this).GetComponent<ZNetView>();
		}

		private void OnDestroy()
		{
			foreach (GameObject value in _followTargets.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			_followTargets.Clear();
		}

		private void Update()
		{
			if (!(Time.time < _nextUpdate))
			{
				_nextUpdate = Time.time + 0.75f;
				if ((Object)(object)_tameable == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid())
				{
					ClearAllTargets();
				}
				else if (!LoxBellSaddle.HasBellSaddle(_tameable))
				{
					ClearAllTargets();
				}
				else
				{
					CallNearbyLoxes();
				}
			}
		}

		private void CallNearbyLoxes()
		{
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			List<Character> list = new List<Character>();
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)null || (Object)(object)((Component)allCharacter).gameObject == (Object)(object)((Component)this).gameObject || !((Object)allCharacter).name.StartsWith("Lox"))
				{
					continue;
				}
				Tameable component = ((Component)allCharacter).GetComponent<Tameable>();
				if (!((Object)(object)component == (Object)null) && component.IsTamed() && !LoxBellSaddle.HasBellSaddle(component))
				{
					float num = Vector3.Distance(((Component)this).transform.position, ((Component)allCharacter).transform.position);
					if (!(num > 38f))
					{
						list.Add(allCharacter);
					}
				}
			}
			list.Sort((Character a, Character b) => ((Object)a).GetInstanceID().CompareTo(((Object)b).GetInstanceID()));
			HashSet<int> hashSet = new HashSet<int>();
			for (int num2 = 0; num2 < list.Count; num2++)
			{
				Character val = list[num2];
				if (!((Object)(object)val == (Object)null))
				{
					MonsterAI component2 = ((Component)val).GetComponent<MonsterAI>();
					if (!((Object)(object)component2 == (Object)null))
					{
						int instanceID = ((Object)val).GetInstanceID();
						hashSet.Add(instanceID);
						GameObject orCreateFollowTarget = GetOrCreateFollowTarget(instanceID);
						orCreateFollowTarget.transform.position = GetSlotPosition(num2);
						SetFollowTarget(component2, orCreateFollowTarget);
					}
				}
			}
			RemoveUnusedTargets(hashSet);
		}

		private Vector3 GetSlotPosition(int index)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: 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_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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)
			int num = index / 8;
			int num2 = index % 8;
			float num3 = 10f + (float)num * 4f;
			float num4 = (float)num2 * 45f;
			num4 += (float)num * 22.5f;
			float num5 = num4 * ((float)Math.PI / 180f);
			Vector3 val = new Vector3(Mathf.Sin(num5), 0f, Mathf.Cos(num5)) * num3;
			Vector3 result = ((Component)this).transform.position + val;
			result.y = ((Component)this).transform.position.y;
			return result;
		}

		private GameObject GetOrCreateFollowTarget(int id)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			if (_followTargets.TryGetValue(id, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			value = new GameObject("LoxBellFollowTarget_" + id);
			((Object)value).hideFlags = (HideFlags)61;
			_followTargets[id] = value;
			return value;
		}

		private void RemoveUnusedTargets(HashSet<int> activeIds)
		{
			List<int> list = new List<int>();
			foreach (KeyValuePair<int, GameObject> followTarget in _followTargets)
			{
				if (!activeIds.Contains(followTarget.Key))
				{
					list.Add(followTarget.Key);
				}
			}
			foreach (int item in list)
			{
				GameObject val = _followTargets[item];
				if ((Object)(object)val != (Object)null)
				{
					Object.Destroy((Object)(object)val);
				}
				_followTargets.Remove(item);
			}
		}

		private void ClearAllTargets()
		{
			foreach (GameObject value in _followTargets.Values)
			{
				if ((Object)(object)value != (Object)null)
				{
					Object.Destroy((Object)(object)value);
				}
			}
			_followTargets.Clear();
		}

		private static void SetFollowTarget(MonsterAI ai, GameObject target)
		{
			if (!((Object)(object)ai == (Object)null))
			{
				if (SetFollowTargetMethod == null)
				{
					Debug.LogError((object)"MonsterAI.SetFollowTarget(GameObject) not found.");
					return;
				}
				SetFollowTargetMethod.Invoke(ai, new object[1] { target });
			}
		}
	}
	[HarmonyPatch(typeof(Tameable), "Awake")]
	public static class LoxBellHerdRestorePatch
	{
		private static void Postfix(Tameable __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && LoxBellSaddle.IsLox((Component)(object)__instance) && !((Object)(object)((Component)__instance).GetComponent<LoxBellHerdController>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<LoxBellHerdController>();
			}
		}
	}
	public class LoxBellSaddleChimeController : MonoBehaviour
	{
		private Tameable _tameable;

		private ZNetView _nview;

		private Rigidbody _rigidbody;

		private AudioSource _audioSource;

		private float _nextChimeTime;

		private const float StandingSpeed = 0.15f;

		private const float RunningSpeed = 4.5f;

		private const float WalkMinDelay = 4.5f;

		private const float WalkMaxDelay = 8.5f;

		private const float RunMinDelay = 1.2f;

		private const float RunMaxDelay = 2.8f;

		private const float CheckAgainDelay = 0.5f;

		private const float Volume = 0.42f;

		private void Awake()
		{
			_tameable = ((Component)this).GetComponent<Tameable>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			_rigidbody = ((Component)this).GetComponent<Rigidbody>();
			_audioSource = ((Component)this).gameObject.AddComponent<AudioSource>();
			_audioSource.playOnAwake = false;
			_audioSource.loop = false;
			_audioSource.spatialBlend = 1f;
			_audioSource.minDistance = 3f;
			_audioSource.maxDistance = 24f;
			_audioSource.rolloffMode = (AudioRolloffMode)1;
			ScheduleNextCheck(0.5f);
		}

		private void Update()
		{
			if (Time.time < _nextChimeTime)
			{
				return;
			}
			if ((Object)(object)_tameable == (Object)null || (Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				ScheduleNextCheck(0.5f);
				return;
			}
			if (!LoxBellSaddle.HasBellSaddle(_tameable))
			{
				ScheduleNextCheck(0.5f);
				return;
			}
			float horizontalSpeed = GetHorizontalSpeed();
			if (horizontalSpeed < 0.15f)
			{
				ScheduleNextCheck(0.5f);
				return;
			}
			PlayRandomChime(horizontalSpeed);
			if (horizontalSpeed >= 4.5f)
			{
				ScheduleNextChime(1.2f, 2.8f);
			}
			else
			{
				ScheduleNextChime(4.5f, 8.5f);
			}
		}

		private float GetHorizontalSpeed()
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_rigidbody == (Object)null)
			{
				return 0f;
			}
			Vector3 velocity = _rigidbody.velocity;
			velocity.y = 0f;
			return ((Vector3)(ref velocity)).magnitude;
		}

		private void PlayRandomChime(float speed)
		{
			if (Plugin.BellSaddleSounds == null || Plugin.BellSaddleSounds.Length == 0)
			{
				return;
			}
			AudioClip val = Plugin.BellSaddleSounds[Random.Range(0, Plugin.BellSaddleSounds.Length)];
			if (!((Object)(object)val == (Object)null))
			{
				if (speed >= 4.5f)
				{
					_audioSource.pitch = Random.Range(1.02f, 1.12f);
				}
				else
				{
					_audioSource.pitch = Random.Range(0.92f, 1.04f);
				}
				_audioSource.PlayOneShot(val, 0.42f);
			}
		}

		private void ScheduleNextChime(float minDelay, float maxDelay)
		{
			_nextChimeTime = Time.time + Random.Range(minDelay, maxDelay);
		}

		private void ScheduleNextCheck(float delay)
		{
			_nextChimeTime = Time.time + delay;
		}
	}
	[HarmonyPatch(typeof(Tameable), "Awake")]
	public static class LoxBellSaddleChimeRestorePatch
	{
		private static void Postfix(Tameable __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && LoxBellSaddle.IsLox((Component)(object)__instance) && !((Object)(object)((Component)__instance).GetComponent<LoxBellSaddleChimeController>() != (Object)null))
			{
				((Component)__instance).gameObject.AddComponent<LoxBellSaddleChimeController>();
			}
		}
	}
	public static class LoxBellSaddle
	{
		public const string PrefabName = "LoxBellSaddle";

		public const string ZdoKey = "LoxBellSaddle";

		public const float AuraRadius = 30f;

		public static bool IsBellSaddle(ItemData item)
		{
			if ((Object)(object)item?.m_dropPrefab == (Object)null)
			{
				return false;
			}
			return ((Object)item.m_dropPrefab).name == "LoxBellSaddle";
		}

		public static bool IsLox(Component component)
		{
			if ((Object)(object)component == (Object)null)
			{
				return false;
			}
			Character component2 = component.GetComponent<Character>();
			if ((Object)(object)component2 == (Object)null)
			{
				return false;
			}
			return ((Object)component2).name.StartsWith("Lox");
		}

		public static bool HasBellSaddle(Tameable tameable)
		{
			if ((Object)(object)tameable == (Object)null)
			{
				return false;
			}
			ZNetView component = ((Component)tameable).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				return false;
			}
			return component.GetZDO().GetBool("LoxBellSaddle", false);
		}

		public static bool HasBellSaddle(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return false;
			}
			Tameable component = ((Component)character).GetComponent<Tameable>();
			return HasBellSaddle(component);
		}

		public static bool IsRepelledEnemy(Character character)
		{
			if ((Object)(object)character == (Object)null)
			{
				return false;
			}
			string text = ((Object)character).name.Replace("(Clone)", "").ToLowerInvariant();
			return text.Contains("deathsquito") || text.Contains("seeker") || text.Contains("tick") || text.Contains("gjall");
		}

		public static bool IsProtectedLox(Character character)
		{
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)character == (Object)null)
			{
				return false;
			}
			if (!((Object)character).name.StartsWith("Lox"))
			{
				return false;
			}
			Tameable component = ((Component)character).GetComponent<Tameable>();
			if ((Object)(object)component == (Object)null || !component.IsTamed())
			{
				return false;
			}
			if (HasBellSaddle(component))
			{
				return true;
			}
			foreach (Character allCharacter in Character.GetAllCharacters())
			{
				if ((Object)(object)allCharacter == (Object)null || (Object)(object)allCharacter == (Object)(object)character || !((Object)allCharacter).name.StartsWith("Lox"))
				{
					continue;
				}
				Tameable component2 = ((Component)allCharacter).GetComponent<Tameable>();
				if (!((Object)(object)component2 == (Object)null) && component2.IsTamed() && HasBellSaddle(component2))
				{
					float num = Vector3.Distance(((Component)character).transform.position, ((Component)allCharacter).transform.position);
					if (num <= 30f)
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Tameable), "UseItem")]
	public static class LoxBellSaddleUsePatch
	{
		private static bool Prefix(Tameable __instance, Humanoid user, ItemData item, ref bool __result)
		{
			if (!LoxBellSaddle.IsBellSaddle(item))
			{
				return true;
			}
			Player val = (Player)(object)((user is Player) ? user : null);
			if ((Object)(object)val == (Object)null)
			{
				__result = false;
				return false;
			}
			if (!LoxBellSaddle.IsLox((Component)(object)__instance))
			{
				((Character)val).Message((MessageType)2, LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_saddle_only_lox"), 0, (Sprite)null, false);
				__result = false;
				return false;
			}
			if (!__instance.IsTamed())
			{
				((Character)val).Message((MessageType)2, LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_lox_must_be_tamed"), 0, (Sprite)null, false);
				__result = false;
				return false;
			}
			ZNetView component = ((Component)__instance).GetComponent<ZNetView>();
			if ((Object)(object)component == (Object)null || !component.IsValid())
			{
				__result = false;
				return false;
			}
			if (component.GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false))
			{
				((Character)val).Message((MessageType)2, __instance.GetHoverName() + " $hud_saddle_already", 0, (Sprite)null, false);
				__result = true;
				return false;
			}
			component.GetZDO().Set("LoxBellSaddle", true);
			component.GetZDO().Set("LoxSaddleBags", false);
			component.GetZDO().Set("EnchantedLoxSaddleBags", false);
			component.InvokeRPC("AddSaddle", Array.Empty<object>());
			((Humanoid)val).GetInventory().RemoveOneItem(item);
			((Character)val).Message((MessageType)2, __instance.GetHoverName() + " $hud_saddle_ready", 0, (Sprite)null, false);
			if ((Object)(object)((Component)__instance).GetComponent<LoxBellHerdController>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<LoxBellHerdController>();
			}
			__result = true;
			return false;
		}
	}
	[HarmonyPatch(typeof(BaseAI), "IsEnemy", new Type[]
	{
		typeof(Character),
		typeof(Character)
	})]
	public static class LoxBellSaddleIsEnemyPatch
	{
		private static bool Prefix(Character a, Character b, ref bool __result)
		{
			if (ShouldBlockEnemyRelation(a, b))
			{
				__result = false;
				return false;
			}
			return true;
		}

		private static bool ShouldBlockEnemyRelation(Character a, Character b)
		{
			if ((Object)(object)a == (Object)null || (Object)(object)b == (Object)null)
			{
				return false;
			}
			bool flag = LoxBellSaddle.IsProtectedLox(a);
			bool flag2 = LoxBellSaddle.IsProtectedLox(b);
			bool flag3 = LoxBellSaddle.IsRepelledEnemy(a);
			bool flag4 = LoxBellSaddle.IsRepelledEnemy(b);
			if (flag3 && flag2)
			{
				return true;
			}
			if (flag && flag4)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(BaseAI), "FindEnemy")]
	public static class LoxBellSaddleFindEnemyPatch
	{
		private static void Postfix(BaseAI __instance, ref Character __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__result == (Object)null)
			{
				return;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if (!((Object)(object)component == (Object)null))
			{
				if (LoxBellSaddle.IsRepelledEnemy(component) && LoxBellSaddle.IsProtectedLox(__result))
				{
					__result = null;
				}
				else if (LoxBellSaddle.IsProtectedLox(component) && LoxBellSaddle.IsRepelledEnemy(__result))
				{
					__result = null;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Character), "Damage")]
	public static class LoxBellSaddleDamagePatch
	{
		private static void Prefix(Character __instance, HitData hit)
		{
			if (!((Object)(object)__instance == (Object)null) && hit != null && LoxBellSaddle.IsProtectedLox(__instance))
			{
				Character attacker = hit.GetAttacker();
				if (LoxBellSaddle.IsRepelledEnemy(attacker))
				{
					hit.m_damage.m_damage = 0f;
					hit.m_damage.m_blunt = 0f;
					hit.m_damage.m_slash = 0f;
					hit.m_damage.m_pierce = 0f;
					hit.m_damage.m_chop = 0f;
					hit.m_damage.m_pickaxe = 0f;
					hit.m_damage.m_fire = 0f;
					hit.m_damage.m_frost = 0f;
					hit.m_damage.m_lightning = 0f;
					hit.m_damage.m_poison = 0f;
					hit.m_damage.m_spirit = 0f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(MonsterAI), "OnDamaged")]
	public static class LoxBellSaddleOnDamagedPatch
	{
		private static bool Prefix(MonsterAI __instance, float damage, Character attacker)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if (!LoxBellSaddle.IsProtectedLox(component))
			{
				return true;
			}
			if (!LoxBellSaddle.IsRepelledEnemy(attacker))
			{
				return true;
			}
			return false;
		}
	}
	public static class LoxFlute
	{
		private struct FluteResult
		{
			public int Count;

			public bool StartedFollowing;
		}

		private static GameObject _activeUseVisual;

		private static Coroutine _highlightCoroutine;

		private const string FluteFollowKey = "LoxSaddleBags_FluteFollowing";

		private static readonly FieldInfo RightHandField = AccessTools.Field(typeof(Humanoid), "m_rightHand");

		private static readonly FieldInfo ZanimField = AccessTools.Field(typeof(Character), "m_zanim");

		public const string PrefabName = "LoxFlute";

		public const float SummonRadius = 100f;

		private static int _lastSoundIndex = -1;

		public static bool IsFlute(ItemData item)
		{
			if ((Object)(object)item?.m_dropPrefab == (Object)null)
			{
				return false;
			}
			return ((Object)item.m_dropPrefab).name == "LoxFlute";
		}

		public static void Use(Player player, ItemData item)
		{
			if (!((Object)(object)player == (Object)null))
			{
				HighlightInventoryIcon(player, item);
				PlayUseAnimation(player);
				PlayUseVisual(player);
				PlayFluteSound(player);
				FluteResult fluteResult = SummonEnchantedLoxes(player);
				if (fluteResult.Count == 0)
				{
					((Character)player).Message((MessageType)2, LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_no_lox_heard"), 0, (Sprite)null, false);
				}
				else if (fluteResult.StartedFollowing)
				{
					string text = ((fluteResult.Count == 1) ? LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_lox_coming") : (fluteResult.Count + " " + LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_loxes_coming")));
					((Character)player).Message((MessageType)2, text, 0, (Sprite)null, false);
				}
				else
				{
					string text2 = ((fluteResult.Count == 1) ? LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_lox_stopped") : (fluteResult.Count + " " + LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_loxes_stopped")));
					((Character)player).Message((MessageType)2, text2, 0, (Sprite)null, false);
				}
			}
		}

		private static void HighlightInventoryIcon(Player player, ItemData item)
		{
			if (!((Object)(object)player == (Object)null) && item != null)
			{
				if (_highlightCoroutine != null)
				{
					((MonoBehaviour)player).StopCoroutine(_highlightCoroutine);
					_highlightCoroutine = null;
				}
				_highlightCoroutine = ((MonoBehaviour)player).StartCoroutine(HighlightInventoryIconRoutine(item));
			}
		}

		private static IEnumerator HighlightInventoryIconRoutine(ItemData item)
		{
			if (item != null)
			{
				item.m_equipped = true;
				yield return (object)new WaitForSeconds(0.8f);
				if (item != null)
				{
					item.m_equipped = false;
				}
				_highlightCoroutine = null;
			}
		}

		private static void PlayUseAnimation(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			object obj = ZanimField?.GetValue(player);
			if (obj == null)
			{
				Debug.LogError((object)"LOX FLUTE: m_zanim not found");
				return;
			}
			MethodInfo methodInfo = AccessTools.Method(obj.GetType(), "SetTrigger", new Type[1] { typeof(string) }, (Type[])null);
			if (methodInfo == null)
			{
				Debug.LogError((object)"LOX FLUTE: SetTrigger no