Decompiled source of LoxSaddleBags v2.0.5

BepInEx/plugins/LoxSaddleBags/Loxsaddle.dll

Decompiled a month 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))
				{
					return;
				}
				Player localPlayer = Player.m_localPlayer;
				if ((Object)(object)localPlayer == (Object)null)
				{
					return;
				}
				GameObject hoverObject = ((Humanoid)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;
				}
				Container component2 = ((Component)componentInParent).GetComponent<Container>();
				if (!((Object)(object)component2 == (Object)null) && !((Object)(object)InventoryGui.instance == (Object)null))
				{
					if (InventoryGui.instance.IsContainerOpen())
					{
						InventoryGui.instance.Hide();
					}
					else
					{
						component2.Interact((Humanoid)(object)localPlayer, false, false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Tameable), "SetSaddle")]
		public static class TestModelPatch
		{
			private static void Postfix(Tameable __instance, bool enabled)
			{
				//IL_0359: Unknown result type (might be due to invalid IL or missing references)
				//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)
				Debug.Log((object)("HAS VANILLA SADDLE: " + ((Component)__instance).GetComponent<ZNetView>().GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false)));
				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);
					}
					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;
						}
					}
					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);
				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)
				{
				}
				if (!((Object)(object)val9.Find("TEST_BAGS") != (Object)null))
				{
					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;
				}
			}
		}

		[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;
				Character component = ((Component)__instance).GetComponent<Character>();
				if ((Object)(object)component == (Object)null)
				{
					return;
				}
				if (text == "LoxHealingTreat")
				{
					component.Heal(99999f, true);
				}
				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)
			{
				if ((Object)(object)__instance == (Object)null)
				{
					return true;
				}
				Tameable tameable = __instance.GetTameable();
				if ((Object)(object)tameable == (Object)null)
				{
					return true;
				}
				Container component = ((Component)tameable).GetComponent<Container>();
				int num = 0;
				if ((Object)(object)component != (Object)null && component.GetInventory() != null)
				{
					num = component.GetInventory().NrOfItems();
				}
				bool flag = LoxTrinketGrid.HasAnyEquippedTrinket(tameable);
				if (num > 0 || flag)
				{
					if ((Object)(object)Player.m_localPlayer != (Object)null && (Object)(object)ZNet.instance != (Object)null && sender == ZNet.GetUID())
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, LocalizationManager.Instance.TryTranslate("$loxsaddle_msg_empty_bags_first"), 0, (Sprite)null, false);
					}
					return false;
				}
				if ((Object)(object)component != (Object)null)
				{
					Object.Destroy((Object)(object)component);
				}
				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);
					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);
					BaseAI component2 = ((Component)__instance).GetComponent<BaseAI>();
				}
				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);
				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;
				}
			}
		}

		[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";
					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, "LoxTrinketTeleportItem", "$loxsaddle_item_trinket_teleport_name", "$loxsaddle_item_trinket_teleport_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 GameObject TeleportTrinketModel;

		public static Sprite TeleportTrinketIcon;

		public static GameObject TeleportStaffModel;

		public static AudioClip TeleportStaffSound;

		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 TeleportStaffIcon;

		public static Sprite icon_banner1;

		public static Sprite icon_banner2;

		public static Sprite icon_banner3;

		private void Awake()
		{
			//IL_0557: Unknown result type (might be due to invalid IL or missing references)
			//IL_055d: Expected O, but got Unknown
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "loxbundle");
			Bundle = AssetBundle.LoadFromFile(text);
			if ((Object)(object)Bundle != (Object)null)
			{
				TeleportStaffSound = Bundle.LoadAsset<AudioClip>("assets/loxbundle/teleportstaffsound.wav");
				string[] allAssetNames = Bundle.GetAllAssetNames();
				foreach (string text2 in allAssetNames)
				{
					Debug.Log((object)("ASSET: " + text2));
				}
				GameObject val = (SaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxsaddlebagsmodel.prefab"));
				GameObject enchantedSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/enchantedsaddlemodel.prefab");
				EnchantedSaddleModel = enchantedSaddleModel;
				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 val2 in componentsInChildren)
					{
						Debug.Log((object)("SMR: " + ((Object)val2).name));
					}
					MeshFilter[] componentsInChildren2 = val.GetComponentsInChildren<MeshFilter>(true);
					foreach (MeshFilter val3 in componentsInChildren2)
					{
						Debug.Log((object)("MESHFILTER: " + ((Object)val3).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");
				TeleportTrinketModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/teleportloxtrinket.prefab");
				TeleportStaffModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/teleportloxstaff.prefab");
				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");
				TeleportTrinketIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_teleporttrinket.png");
				TeleportStaffIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_teleportstaff.png");
				FluteModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/flute.prefab");
				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();
				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");
			}
			Harmony val4 = new Harmony("pl.twojnick.loxsaddlebags");
			val4.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);
		}

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

		private void CreateLoxFlute()
		{
			//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_0053: Expected O, but got Unknown
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Expected O, but got Unknown
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			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);
			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);
		}

		private void CreateLoxTeleportStaff()
		{
			//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_0074: Expected O, but got Unknown
			//IL_0076: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Expected O, but got Unknown
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Expected O, but got Unknown
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0247: Expected O, but got Unknown
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0258: Expected O, but got Unknown
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Expected O, but got Unknown
			ItemConfig val = new ItemConfig();
			val.CraftingStation = "piece_magetable";
			val.AddRequirement(new RequirementConfig
			{
				Item = "YggdrasilWood",
				Amount = 20
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "Crystal",
				Amount = 16
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "LoxFlute",
				Amount = 1
			});
			val.AddRequirement(new RequirementConfig
			{
				Item = "FlametalNew",
				Amount = 3
			});
			CustomItem val2 = new CustomItem("LoxTeleportStaff", "StaffShield", 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_teleportstaff_name";
				shared.m_description = "$loxsaddle_item_teleportstaff_desc";
				shared.m_maxStackSize = 1;
				shared.m_itemType = (ItemType)14;
				shared.m_skillType = (SkillType)0;
				shared.m_damages = default(DamageTypes);
				shared.m_damagesPerLevel = default(DamageTypes);
				shared.m_attackForce = 0f;
				shared.m_backstabBonus = 1f;
				shared.m_blockPower = 0f;
				shared.m_blockPowerPerLevel = 0f;
				shared.m_timedBlockBonus = 1f;
				shared.m_deflectionForce = 0f;
				shared.m_deflectionForcePerLevel = 0f;
				shared.m_blockAdrenaline = 0f;
				shared.m_perfectBlockAdrenaline = 0f;
				shared.m_movementModifier = 0f;
				shared.m_attackStatusEffect = null;
				shared.m_equipStatusEffect = null;
				shared.m_setStatusEffect = null;
				shared.m_setName = "";
				shared.m_setSize = 0;
				shared.m_useDurability = false;
				shared.m_canBeReparied = false;
				if (shared.m_attack != null)
				{
					shared.m_attack.m_attackAnimation = "staff_shield";
					shared.m_attack.m_attackEitr = 100f;
					shared.m_attack.m_attackStamina = 0f;
					shared.m_attack.m_attackHealthPercentage = 0f;
					shared.m_attack.m_startEffect = new EffectList();
					shared.m_attack.m_triggerEffect = new EffectList();
					shared.m_attack.m_trailStartEffect = new EffectList();
					shared.m_attack.m_hitEffect = new EffectList();
					shared.m_attack.m_attackProjectile = null;
				}
				if ((Object)(object)TeleportStaffIcon != (Object)null)
				{
					shared.m_icons = (Sprite[])(object)new Sprite[1] { TeleportStaffIcon };
				}
				Transform target = val2.ItemPrefab.transform.Find("attach");
				ReplaceTeleportStaffVisual(target, "LoxTeleportStaff_held");
				Transform target2 = val2.ItemPrefab.transform.Find("attach_back");
				ReplaceTeleportStaffVisual(target2, "LoxTeleportStaff_back");
			}
			ItemManager.Instance.AddItem(val2);
		}

		private void ReplaceTeleportStaffVisual(Transform target, string visualName)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target == (Object)null) && !((Object)(object)TeleportStaffModel == (Object)null))
			{
				Renderer[] componentsInChildren = ((Component)target).GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val in componentsInChildren)
				{
					val.enabled = false;
				}
				GameObject val2 = Object.Instantiate<GameObject>(TeleportStaffModel, target);
				((Object)val2).name = visualName;
				val2.transform.localScale = Vector3.one;
				if (visualName == "LoxTeleportStaff_held")
				{
					val2.transform.localPosition = new Vector3(0f, 0f, 0f);
					val2.transform.localRotation = Quaternion.Euler(90f, 0f, 0f);
				}
				else if (visualName == "LoxTeleportStaff_back")
				{
					val2.transform.localPosition = new Vector3(0f, 0f, 0f);
					val2.transform.localRotation = Quaternion.Euler(0f, 0f, 0f);
				}
				else
				{
					val2.transform.localPosition = Vector3.zero;
					val2.transform.localRotation = Quaternion.identity;
				}
				val2.SetActive(true);
				Renderer[] componentsInChildren2 = val2.GetComponentsInChildren<Renderer>(true);
				foreach (Renderer val3 in componentsInChildren2)
				{
					val3.enabled = true;
				}
			}
		}

		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_08b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08cf: Expected O, but got Unknown
			//IL_08d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08eb: Expected O, but got Unknown
			//IL_08ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f2: 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_0907: Expected O, but got Unknown
			//IL_0909: Unknown result type (might be due to invalid IL or missing references)
			//IL_090e: 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_0924: Expected O, but got Unknown
			//IL_0947: Unknown result type (might be due to invalid IL or missing references)
			//IL_094c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0958: Unknown result type (might be due to invalid IL or missing references)
			//IL_0962: Expected O, but got Unknown
			//IL_0964: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Unknown result type (might be due to invalid IL or missing references)
			//IL_0975: Unknown result type (might be due to invalid IL or missing references)
			//IL_097e: Expected O, but got Unknown
			//IL_0980: Unknown result type (might be due to invalid IL or missing references)
			//IL_0985: Unknown result type (might be due to invalid IL or missing references)
			//IL_0991: Unknown result type (might be due to invalid IL or missing references)
			//IL_099a: Expected O, but got Unknown
			//IL_099c: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_09b6: Expected O, but got Unknown
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_09de: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_09f3: Expected O, but got Unknown
			//IL_09f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_09fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a06: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a0f: Expected O, but got Unknown
			//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a16: 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_0a2b: Expected O, but got Unknown
			//IL_0a2d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a32: 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_0a48: Expected O, but got Unknown
			//IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a7c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a85: Expected O, but got Unknown
			//IL_0a87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a98: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa1: Expected O, but got Unknown
			//IL_0aa3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0abd: Expected O, but got Unknown
			//IL_0abf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ada: 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
			});
			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("LoxTrinketTeleportItem", TeleportTrinketModel, TeleportTrinketIcon, "piece_magetable", new RequirementConfig
			{
				Item = "FlametalNew",
				Amount = 10
			}, new RequirementConfig
			{
				Item = "TrophyDvergr",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "TrophyGhost",
				Amount = 1
			}, new RequirementConfig
			{
				Item = "Crystal",
				Amount = 2
			});
			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
			});
			CreateLoxTetherRope();
			CreateLoxBellBanners();
			CreateLoxFlute();
			CreateLoxTeleportStaff();
			CreateLoxBellSaddle();
			Debug.Log((object)"ADD ITEMS FINISHED");
		}
	}
	[HarmonyPatch(typeof(Tameable), "SpawnSaddle")]
	public static class SpawnSaddlePatch
	{
		private static bool Prefix(Tameable __instance, Vector3 flyDirection)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: 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);
			if (!flag && !flag2)
			{
				return true;
			}
			string text = ((!flag2) ? (flag3 ? "EnchantedLoxSaddleBags" : "LoxSaddleBags") : "LoxBellSaddle");
			GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text);
			if ((Object)(object)itemPrefab == (Object)null)
			{
				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);
			return false;
		}
	}
	public static class LoxTeleportNetwork
	{
		private enum SummonResult
		{
			Success,
			NoLox,
			MultipleLoxes,
			Tethered,
			Error
		}

		[HarmonyPatch(typeof(Game), "Start")]
		private static class RegisterRpcPatch
		{
			private static void Postfix()
			{
				if (ZRoutedRpc.instance != null)
				{
					ZRoutedRpc.instance.Register<ZPackage>("LoxSaddleBags_RequestLoxSummon", (Action<long, ZPackage>)RPC_RequestSummon);
					ZRoutedRpc.instance.Register<ZPackage>("LoxSaddleBags_LoxSummonResult", (Action<long, ZPackage>)RPC_SummonResult);
				}
			}
		}

		private const string RequestRpc = "LoxSaddleBags_RequestLoxSummon";

		private const string ResultRpc = "LoxSaddleBags_LoxSummonResult";

		private const string LoxPrefab = "Lox";

		private const string TeleportTrinketPrefab = "LoxTrinketTeleportItem";

		private const int SlotCount = 3;

		public static void RequestSummon(Player player)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_0099: 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_00d4: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null || ZRoutedRpc.instance == null)
			{
				return;
			}
			long playerID = player.GetPlayerID();
			Vector3 val = ((Component)player).transform.position + ((Component)player).transform.forward * 4f;
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				val.y = ZoneSystem.instance.GetSolidHeight(val) + 0.5f;
			}
			float y = ((Component)player).transform.eulerAngles.y;
			ZPackage val2 = new ZPackage();
			val2.Write(playerID);
			val2.Write(val);
			val2.Write(y);
			if ((Object)(object)ZNet.instance != (Object)null && ZNet.instance.IsServer())
			{
				((MonoBehaviour)ZNet.instance).StartCoroutine(ProcessSummonRequest(ZNet.GetUID(), playerID, val, y));
				return;
			}
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				Debug.LogWarning((object)"Lox Saddle Bags: ZNet is not available.");
				return;
			}
			ZNetPeer serverPeer = ZNet.instance.GetServerPeer();
			if (serverPeer == null)
			{
				Debug.LogWarning((object)"Lox Saddle Bags: Server peer was not found.");
				return;
			}
			ZRoutedRpc.instance.InvokeRoutedRPC(serverPeer.m_uid, "LoxSaddleBags_RequestLoxSummon", new object[1] { val2 });
		}

		private static void RPC_RequestSummon(long sender, ZPackage package)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (package != null && !((Object)(object)ZNet.instance == (Object)null) && ZNet.instance.IsServer())
			{
				long playerID = package.ReadLong();
				Vector3 destination = package.ReadVector3();
				float yaw = package.ReadSingle();
				((MonoBehaviour)ZNet.instance).StartCoroutine(ProcessSummonRequest(sender, playerID, destination, yaw));
			}
		}

		private static IEnumerator ProcessSummonRequest(long sender, long playerID, Vector3 destination, float yaw)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (ZDOMan.instance == null)
			{
				SendResult(sender, SummonResult.Error);
				yield break;
			}
			List<ZDO> matchingLoxes = new List<ZDO>();
			List<ZDO> batch = new List<ZDO>();
			int index = 0;
			bool finished = false;
			while (!finished)
			{
				batch.Clear();
				finished = ZDOMan.instance.GetAllZDOsWithPrefabIterative("Lox", batch, ref index);
				foreach (ZDO zdo in batch)
				{
					if (zdo != null && zdo.GetBool(ZDOVars.s_tamed, false) && zdo.GetBool("EnchantedLoxSaddleBags", false) && HasMatchingTeleportTrinket(zdo, playerID))
					{
						matchingLoxes.Add(zdo);
					}
				}
				if (!finished)
				{
					yield return null;
				}
			}
			if (matchingLoxes.Count == 0)
			{
				SendResult(sender, SummonResult.NoLox);
				yield break;
			}
			if (matchingLoxes.Count > 1)
			{
				SendResult(sender, SummonResult.MultipleLoxes);
				yield break;
			}
			ZDO loxZdo = matchingLoxes[0];
			Vector3 originalPosition = loxZdo.GetPosition();
			if (loxZdo.GetBool("LoxTethered", false))
			{
				SendResult(sender, SummonResult.Tethered);
				yield break;
			}
			Quaternion rotation = Quaternion.Euler(0f, yaw, 0f);
			loxZdo.SetOwner(sender);
			loxZdo.Set(ZDOVars.s_follow, "");
			loxZdo.Set("LoxSaddleBags_FluteFollowing", false);
			loxZdo.SetPosition(destination);
			loxZdo.SetRotation(rotation);
			ZDOMan.instance.ForceSendZDO(sender, loxZdo.m_uid);
			GameObject loxObject = null;
			if ((Object)(object)ZNetScene.instance != (Object)null)
			{
				loxObject = ZNetScene.instance.FindInstance(loxZdo.m_uid);
			}
			if ((Object)(object)loxObject == (Object)null && (Object)(object)ZNetScene.instance != (Object)null)
			{
				MethodInfo createObjectMethod = AccessTools.Method(typeof(ZNetScene), "CreateObject", new Type[1] { typeof(ZDO) }, (Type[])null);
				if (createObjectMethod != null)
				{
					object? obj = createObjectMethod.Invoke(ZNetScene.instance, new object[1] { loxZdo });
					loxObject = (GameObject)((obj is GameObject) ? obj : null);
				}
			}
			if ((Object)(object)loxObject == (Object)null)
			{
				Debug.LogWarning((object)"Lox Saddle Bags: Could not create summoned Lox instance.");
				SendResult(sender, SummonResult.Error);
				yield break;
			}
			ZNetView nview = loxObject.GetComponent<ZNetView>();
			if ((Object)(object)nview != (Object)null && nview.IsValid() && !nview.IsOwner())
			{
				nview.ClaimOwnership();
			}
			MonsterAI monsterAI = loxObject.GetComponent<MonsterAI>();
			if ((Object)(object)monsterAI != (Object)null)
			{
				monsterAI.SetFollowTarget((GameObject)null);
				((BaseAI)monsterAI).ResetPatrolPoint();
			}
			Rigidbody body = loxObject.GetComponent<Rigidbody>();
			if ((Object)(object)body != (Object)null)
			{
				body.linearVelocity = Vector3.zero;
				body.angularVelocity = Vector3.zero;
				body.position = destination;
				body.rotation = rotation;
				body.WakeUp();
			}
			loxObject.transform.SetPositionAndRotation(destination, rotation);
			loxZdo.SetPosition(destination);
			loxZdo.SetRotation(rotation);
			yield return (object)new WaitForFixedUpdate();
			if ((Object)(object)body != (Object)null)
			{
				body.linearVelocity = Vector3.zero;
				body.angularVelocity = Vector3.zero;
				body.position = destination;
				body.rotation = rotation;
			}
			loxObject.transform.SetPositionAndRotation(destination, rotation);
			loxZdo.SetPosition(destination);
			loxZdo.SetRotation(rotation);
			ZDOMan.instance.ForceSendZDO(sender, loxZdo.m_uid);
			if ((Object)(object)monsterAI != (Object)null)
			{
				monsterAI.SetFollowTarget((GameObject)null);
				((BaseAI)monsterAI).ResetPatrolPoint();
				((BaseAI)monsterAI).SetPatrolPoint();
			}
			SendResult(sender, SummonResult.Success, originalPosition, destination);
		}

		private static bool HasMatchingTeleportTrinket(ZDO zdo, long playerID)
		{
			if (zdo == null)
			{
				return false;
			}
			for (int i = 0; i < 3; i++)
			{
				string text = zdo.GetString("LoxTrinketSlot" + i, "");
				if (!(text != "LoxTrinketTeleportItem"))
				{
					long num = zdo.GetLong("LoxTrinketCrafterID" + i, 0L);
					if (num == playerID)
					{
						return true;
					}
				}
			}
			return false;
		}

		private static void SendResult(long targetPeer, SummonResult result)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			SendResult(targetPeer, result, Vector3.zero, Vector3.zero);
		}

		private static void SendResult(long targetPeer, SummonResult result, Vector3 originalPosition, Vector3 destination)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZPackage val = new ZPackage();
				val.Write((int)result);
				val.Write(originalPosition);
				val.Write(destination);
				ZRoutedRpc.instance.InvokeRoutedRPC(targetPeer, "LoxSaddleBags_LoxSummonResult", new object[1] { val });
			}
		}

		private static void PlayTeleportSmoke(Vector3 position)
		{
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab("Lox");
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			Character component = prefab.GetComponent<Character>();
			if ((Object)(object)component == (Object)null || component.m_deathEffects == null || component.m_deathEffects.m_effectPrefabs == null)
			{
				return;
			}
			EffectData[] effectPrefabs = component.m_deathEffects.m_effectPrefabs;
			foreach (EffectData val in effectPrefabs)
			{
				if (val == null || (Object)(object)val.m_prefab == (Object)null)
				{
					continue;
				}
				Ragdoll component2 = val.m_prefab.GetComponent<Ragdoll>();
				if (!((Object)(object)component2 == (Object)null))
				{
					EffectList removeEffect = component2.m_removeEffect;
					if (removeEffect != null && removeEffect.HasEffects())
					{
						removeEffect.Create(position, Quaternion.identity, (Transform)null, 1f, -1, default(ZDOID));
						return;
					}
				}
			}
			Debug.LogWarning((object)"Lox Saddle Bags: Lox teleport smoke effect was not found.");
		}

		private static IEnumerator FinalizeClientTeleport(Player player, Vector3 destination)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)player == (Object)null)
			{
				yield break;
			}
			long playerID = player.GetPlayerID();
			Character foundLox = null;
			float timeout = 3f;
			while (timeout > 0f)
			{
				foreach (Character character in Character.GetAllCharacters())
				{
					if ((Object)(object)character == (Object)null || !((Object)character).name.StartsWith("Lox"))
					{
						continue;
					}
					Tameable tameable = ((Component)character).GetComponent<Tameable>();
					if ((Object)(object)tameable == (Object)null || !tameable.IsTamed())
					{
						continue;
					}
					ZNetView nview = ((Component)character).GetComponent<ZNetView>();
					if (!((Object)(object)nview == (Object)null) && nview.IsValid())
					{
						ZDO zdo = nview.GetZDO();
						if (zdo.GetBool("EnchantedLoxSaddleBags", false) && HasMatchingTeleportTrinket(zdo, playerID))
						{
							foundLox = character;
							break;
						}
					}
				}
				if ((Object)(object)foundLox != (Object)null)
				{
					break;
				}
				timeout -= Time.unscaledDeltaTime;
				yield return null;
			}
			if ((Object)(object)foundLox == (Object)null)
			{
				Debug.LogWarning((object)"Lox Saddle Bags: Summoned Lox did not appear on client.");
				yield break;
			}
			ZNetView loxView = ((Component)foundLox).GetComponent<ZNetView>();
			if ((Object)(object)loxView != (Object)null && loxView.IsValid() && !loxView.IsOwner())
			{
				loxView.ClaimOwnership();
			}
			Quaternion rotation = Quaternion.Euler(0f, ((Component)player).transform.eulerAngles.y, 0f);
			MonsterAI monsterAI = ((Component)foundLox).GetComponent<MonsterAI>();
			if ((Object)(object)monsterAI != (Object)null)
			{
				monsterAI.SetFollowTarget((GameObject)null);
				((BaseAI)monsterAI).ResetPatrolPoint();
			}
			Rigidbody body = ((Component)foundLox).GetComponent<Rigidbody>();
			if ((Object)(object)body != (Object)null)
			{
				body.linearVelocity = Vector3.zero;
				body.angularVelocity = Vector3.zero;
				body.position = destination;
				body.rotation = rotation;
				body.WakeUp();
			}
			((Component)foundLox).transform.SetPositionAndRotation(destination, rotation);
			if ((Object)(object)loxView != (Object)null && loxView.IsValid())
			{
				ZDO zdo2 = loxView.GetZDO();
				zdo2.SetPosition(destination);
				zdo2.SetRotation(rotation);
				zdo2.Set(ZDOVars.s_follow, "");
				zdo2.Set("LoxSaddleBags_FluteFollowing", false);
			}
			yield return (object)new WaitForFixedUpdate();
			if ((Object)(object)body != (Object)null)
			{
				body.linearVelocity = Vector3.zero;
				body.angularVelocity = Vector3.zero;
				body.position = destination;
				body.rotation = rotation;
			}
			((Component)foundLox).transform.SetPositionAndRotation(destination, rotation);
			if ((Object)(object)monsterAI != (Object)null)
			{
				((BaseAI)monsterAI).ResetPatrolPoint();
				((BaseAI)monsterAI).SetPatrolPoint();
			}
			PlayTeleportSmoke(destination);
		}

		private static void RPC_SummonResult(long sender, ZPackage package)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			if (package == null)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if (!((Object)(object)localPlayer == (Object)null))
			{
				SummonResult summonResult = (SummonResult)package.ReadInt();
				Vector3 position = package.ReadVector3();
				Vector3 destination = package.ReadVector3();
				string text;
				switch (summonResult)
				{
				case SummonResult.Success:
					PlayTeleportSmoke(position);
					((MonoBehaviour)localPlayer).StartCoroutine(FinalizeClientTeleport(localPlayer, destination));
					text = "$loxsaddle_msg_teleport_success";
					break;
				case SummonResult.NoLox:
					text = "$loxsaddle_msg_teleport_no_lox";
					break;
				case SummonResult.MultipleLoxes:
					text = "$loxsaddle_msg_teleport_multiple_lox";
					break;
				case SummonResult.Tethered:
					text = "$loxsaddle_msg_teleport_tethered";
					break;
				default:
					Debug.LogWarning((object)"Lox Saddle Bags: Lox summon request failed.");
					return;
				}
				((Character)localPlayer).Message((MessageType)2, LocalizationManager.Instance.TryTranslate(text), 0, (Sprite)null, 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_da