Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of LoxSaddleBags v1.0.0
plugins/LoxSaddleBags/Loxsaddle.dll
Decompiled a day agousing System; 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 UnityEngine; [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")] namespace LoxSaddleBags; [BepInPlugin("pl.twojnick.loxsaddlebags", "Lox Saddle Bags", "0.0.1")] public class Plugin : BaseUnityPlugin { 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 EnchantedDropSaddleModel; public static Sprite SaddleIcon; public static Sprite EnchantedSaddleIcon; private void Awake() { //IL_028e: Unknown result type (might be due to invalid IL or missing references) //IL_0294: Expected O, but got Unknown string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "loxbundle"); Bundle = AssetBundle.LoadFromFile(text); Debug.Log((object)$"BUNDLE LOADED: {(Object)(object)Bundle != (Object)null}"); if ((Object)(object)Bundle != (Object)null) { string[] allAssetNames = Bundle.GetAllAssetNames(); foreach (string text2 in allAssetNames) { Debug.Log((object)("ASSET: " + text2)); } GameObject val = Bundle.LoadAsset<GameObject>("assets/loxbundle/loxsaddlebagsmodel.prefab"); Debug.Log((object)$"MODEL LOADED: {(Object)(object)val != (Object)null}"); SaddleModel = val; GameObject val2 = Bundle.LoadAsset<GameObject>("assets/loxbundle/enchantedsaddlemodel.prefab"); Debug.Log((object)$"NORMAL MODEL: {(Object)(object)val != (Object)null}"); Debug.Log((object)$"ENCHANTED MODEL: {(Object)(object)val2 != (Object)null}"); Debug.Log((object)$"ENCHANTED MODEL LOADED: {(Object)(object)val2 != (Object)null}"); EnchantedSaddleModel = val2; string[] allAssetNames2 = Bundle.GetAllAssetNames(); foreach (string text3 in allAssetNames2) { Debug.Log((object)("ASSET: " + text3)); } if ((Object)(object)val != (Object)null) { SkinnedMeshRenderer[] componentsInChildren = val.GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val3 in componentsInChildren) { Debug.Log((object)("SMR: " + ((Object)val3).name)); } MeshFilter[] componentsInChildren2 = val.GetComponentsInChildren<MeshFilter>(true); foreach (MeshFilter val4 in componentsInChildren2) { Debug.Log((object)("MESHFILTER: " + ((Object)val4).name)); } } DropSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/dropsaddlebags.prefab"); EnchantedDropSaddleModel = Bundle.LoadAsset<GameObject>("assets/loxbundle/enchantedsaddle.prefab"); Debug.Log((object)$"DROP MODEL: {(Object)(object)DropSaddleModel != (Object)null}"); Debug.Log((object)$"ENCHANTED DROP MODEL: {(Object)(object)EnchantedDropSaddleModel != (Object)null}"); SaddleIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_loxsaddlebags.png"); EnchantedSaddleIcon = Bundle.LoadAsset<Sprite>("assets/icons/icon_enchantedloxsaddlebags.png"); } Harmony val5 = new Harmony("pl.twojnick.loxsaddlebags"); val5.PatchAll(); PrefabManager.OnVanillaPrefabsAvailable += AddItems; ((Component)this).gameObject.AddComponent<LoxBagInput>(); ((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 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_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) 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"); } } public class LoxBagInput : MonoBehaviour { private void Update() { if (!Input.GetKeyDown((KeyCode)122) || (Object)(object)Player.m_localPlayer == (Object)null) { return; } GameObject hoverObject = ((Humanoid)Player.m_localPlayer).GetHoverObject(); if ((Object)(object)hoverObject == (Object)null) { return; } Tameable componentInParent = hoverObject.GetComponentInParent<Tameable>(); if ((Object)(object)componentInParent == (Object)null) { return; } ZNetView component = ((Component)componentInParent).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid() || !component.GetZDO().GetBool("LoxSaddleBags", false)) { return; } Container component2 = ((Component)componentInParent).GetComponent<Container>(); Debug.Log((object)$"CONTAINER FOUND: {(Object)(object)component2 != (Object)null}"); if (!((Object)(object)component2 == (Object)null)) { if (InventoryGui.instance.IsContainerOpen()) { InventoryGui.instance.Hide(); Debug.Log((object)"CLOSE CONTAINER"); } else { InventoryGui.instance.Show(component2, 1); Debug.Log((object)"OPEN CONTAINER"); } } } } [HarmonyPatch(typeof(Tameable), "SetSaddle")] public static class TestModelPatch { private static void Postfix(Tameable __instance, bool enabled) { //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03be: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) Debug.Log((object)("HAS VANILLA SADDLE: " + ((Component)__instance).GetComponent<ZNetView>().GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false))); Debug.Log((object)$"SETSADDLE PATCH FIRED: {enabled}"); if (!enabled) { Transform val = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "TEST_BAGS")); if ((Object)(object)val != (Object)null) { Object.Destroy((Object)(object)((Component)val).gameObject); Debug.Log((object)"TEST_BAGS REMOVED"); } Transform val2 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Sadel")); if ((Object)(object)val2 != (Object)null) { Renderer[] componentsInChildren = ((Component)val2).GetComponentsInChildren<Renderer>(true); foreach (Renderer val3 in componentsInChildren) { val3.enabled = true; } Debug.Log((object)"VANILLA SADDLE RESTORED"); } return; } ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return; } bool flag = component.GetZDO().GetBool("LoxSaddleBags", false); Debug.Log((object)$"MODEL PATCH HAS BAGS: {flag}"); if (!flag) { return; } bool flag2 = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false); GameObject val4 = (flag2 ? Plugin.EnchantedSaddleModel : Plugin.SaddleModel); if ((Object)(object)val4 == (Object)null) { Debug.Log((object)"MODEL TO SPAWN IS NULL"); return; } Transform val5 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Sadel")); Debug.Log((object)$"SADDLE FOUND: {(Object)(object)val5 != (Object)null}"); if ((Object)(object)val5 != (Object)null) { if ((Object)(object)val5 != (Object)null) { Renderer[] componentsInChildren2 = ((Component)val5).GetComponentsInChildren<Renderer>(true); foreach (Renderer val6 in componentsInChildren2) { val6.enabled = false; } Debug.Log((object)"VANILLA SADDLE HIDDEN"); } Renderer[] componentsInChildren3 = ((Component)val5).GetComponentsInChildren<Renderer>(true); foreach (Renderer val7 in componentsInChildren3) { Debug.Log((object)("RENDERER: " + ((Object)val7).name)); } SkinnedMeshRenderer[] componentsInChildren4 = ((Component)val5).GetComponentsInChildren<SkinnedMeshRenderer>(true); foreach (SkinnedMeshRenderer val8 in componentsInChildren4) { Debug.Log((object)("SMR: " + ((Object)val8).name)); } } Transform val9 = ((IEnumerable<Transform>)((Component)__instance).GetComponentsInChildren<Transform>(true)).FirstOrDefault((Func<Transform, bool>)((Transform x) => ((Object)x).name == "Mount")); if ((Object)(object)val9 == (Object)null) { Debug.Log((object)"MOUNT NOT FOUND"); } else if (!((Object)(object)val9.Find("TEST_BAGS") != (Object)null)) { Debug.Log((object)("SPAWNING MODEL: " + (flag2 ? "ENCHANTED" : "NORMAL"))); GameObject val10 = Object.Instantiate<GameObject>(val4, val9); ((Object)val10).name = "TEST_BAGS"; val10.transform.localPosition = new Vector3(0f, -0.017f, 0.01f); val10.transform.localRotation = Quaternion.Euler(255f, 0f, 0f); val10.transform.localScale = Vector3.one; Debug.Log((object)"TEST MODEL SPAWNED"); } } } [HarmonyPatch(typeof(Sadle), "RPC_RemoveSaddle")] public static class PreventRemoveSaddlePatch { private static bool Prefix(Sadle __instance, long sender, Vector3 userPoint) { Tameable tameable = __instance.GetTameable(); if ((Object)(object)tameable == (Object)null) { return true; } Container component = ((Component)tameable).GetComponent<Container>(); if ((Object)(object)component == (Object)null) { return true; } int num = component.GetInventory().NrOfItems(); Debug.Log((object)$"ITEMS IN BAGS: {num}"); if (num > 0) { ((Character)Player.m_localPlayer).Message((MessageType)2, "first empty lox's inventory", 0, (Sprite)null); return false; } ZNetView component2 = ((Component)tameable).GetComponent<ZNetView>(); Object.Destroy((Object)(object)component); Debug.Log((object)"CONTAINER REMOVED"); return true; } } [HarmonyPatch(typeof(Sadle), "Interact")] public static class SaddleDebugPatch { private static void Prefix(Sadle __instance) { Debug.Log((object)"SADDLE INTERACT"); } } [HarmonyPatch(typeof(Tameable), "Awake")] public static class RestoreContainerPatch { private static void Postfix(Tameable __instance) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if ((Object)(object)component == (Object)null || !component.IsValid()) { return; } bool flag = component.GetZDO().GetBool("LoxSaddleBags", false); bool flag2 = component.GetZDO().GetBool("EnchantedLoxSaddleBags", false); if (flag) { Plugin.GetOrCreateContainer(__instance); Debug.Log((object)"OPEN CONTAINER"); if (flag2) { Plugin.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); __result = true; return false; } component.GetZDO().Set("LoxSaddleBags", true); if (flag2) { component.GetZDO().Set("EnchantedLoxSaddleBags", true); Plugin.UpdateEnchantedState(__instance, enabled: true); Debug.Log((object)("LOX AI: " + ((object)((Component)__instance).GetComponent<BaseAI>())?.GetType().Name)); } Debug.Log((object)("ENCHANTED BEFORE ADDSADDLE: " + component.GetZDO().GetBool("EnchantedLoxSaddleBags", false))); component.InvokeRPC("AddSaddle", Array.Empty<object>()); Debug.Log((object)("AFTER ADDSADDLE: " + component.GetZDO().GetBool(ZDOVars.s_haveSaddleHash, false))); user.GetInventory().RemoveOneItem(item); ((Character)user).Message((MessageType)2, __instance.GetHoverName() + " $hud_saddle_ready", 0, (Sprite)null); Debug.Log((object)"TRYING TO SPAWN MODEL FROM USEITEM"); Plugin.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 = "Saddle bags"; __instance.m_width = 6; __instance.m_height = 4; Debug.Log((object)"PATCHED CONTAINER BEFORE AWAKE"); } } } [HarmonyPatch(typeof(Tameable), "GetHoverText")] public static class TameableHoverPatch { private static void Postfix(Tameable __instance, ref string __result) { ZNetView component = ((Component)__instance).GetComponent<ZNetView>(); if (!((Object)(object)component == (Object)null) && component.IsValid() && component.GetZDO().GetBool("LoxSaddleBags", false)) { __result += "\n[<color=yellow><b>Z</b></color>] Open saddle bags"; } } } [HarmonyPatch(typeof(ObjectDB), "Awake")] public static class ObjectDBAwakePatch { 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 = "Enchanted Lox Saddle Bags"; component.m_itemData.m_shared.m_description = "Magical saddle for lox with containers. It has an aura of peace. The lox does not fight and is not attacked by enemies."; } ItemDrop component2 = itemPrefab.GetComponent<ItemDrop>(); if (!((Object)(object)component2 == (Object)null)) { component2.m_itemData.m_shared.m_name = "Lox Saddle Bags"; component2.m_itemData.m_shared.m_description = "A durable saddle with containers for lox. This saddle allows you to carry heavy loads and supplies."; Debug.Log((object)"LOX SADDLE BAGS NAME PATCHED"); } } } [HarmonyPatch(typeof(Tameable), "SpawnSaddle")] public static class SpawnSaddlePatch { private static bool Prefix(Tameable __instance, Vector3 flyDirection) { //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ee: Unknown result type (might be due to invalid IL or missing references) //IL_00f3: Unknown result type (might be due to invalid IL or missing references) //IL_0112: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0157: Unknown result type (might be due to invalid IL or missing references) //IL_0142: Unknown result type (might be due to invalid IL or missing references) //IL_0144: Unknown result type (might be due to invalid IL or missing references) //IL_0145: Unknown result type (might be due to invalid IL or missing references) //IL_014a: 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("EnchantedLoxSaddleBags", false); Plugin.UpdateEnchantedState(__instance, enabled: false); Debug.Log((object)$"HAS BAGS: {flag}"); if (!flag) { return true; } Debug.Log((object)$"HAS BAGS: {flag}"); string text = (flag2 ? "EnchantedLoxSaddleBags" : "LoxSaddleBags"); GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(text); if ((Object)(object)itemPrefab == (Object)null) { Debug.Log((object)"LoxSaddleBags prefab not found"); return true; } Rigidbody component2 = Object.Instantiate<GameObject>(itemPrefab, ((Component)__instance).transform.TransformPoint(__instance.m_dropSaddleOffset), Quaternion.identity).GetComponent<Rigidbody>(); if (Object.op_Implicit((Object)(object)component2)) { Vector3 val = Vector3.up; if (((Vector3)(ref flyDirection)).magnitude > 0.1f) { flyDirection.y = 0f; ((Vector3)(ref flyDirection)).Normalize(); val += flyDirection; } component2.AddForce(val * __instance.m_dropItemVel, (ForceMode)2); } component.GetZDO().Set("LoxSaddleBags", false); component.GetZDO().Set("EnchantedLoxSaddleBags", false); Debug.Log((object)("DROPPING: " + text)); Debug.Log((object)"DROPPED BAG SADDLE"); Debug.Log((object)"SPAWNING BAG SADDLE"); return false; } }