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 MountYourFriends v3.2.23
BepInEx/plugins/MountYourFriends/MountUp-PlayersOnly.dll
Decompiled 4 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Reflection.Emit; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using AllTameable; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: AssemblyTitle("MountUp")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("Microsoft")] [assembly: AssemblyProduct("MountUp")] [assembly: AssemblyCopyright("Copyright © Microsoft 2021")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("9e1c6dc2-1a11-4768-96f1-0f71c70e1dbe")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.0.0")] [module: UnverifiableCode] namespace MountUp { public class Mountable : MonoBehaviour { private GameObject mountPoint; private Transform mountPointBase; private GameObject saddle; private Vector3 SaddleToMountPoint; public string Type; public static ManualLogSource logger; public void Awake() { //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_0065: Unknown result type (might be due to invalid IL or missing references) //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_007c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0088: Unknown result type (might be due to invalid IL or missing references) //IL_008a: 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_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00dd: Unknown result type (might be due to invalid IL or missing references) //IL_012b: 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_0807: Unknown result type (might be due to invalid IL or missing references) //IL_0815: 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_014b: Unknown result type (might be due to invalid IL or missing references) //IL_0199: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_0853: Unknown result type (might be due to invalid IL or missing references) //IL_0855: Unknown result type (might be due to invalid IL or missing references) //IL_085f: Expected I8, but got Unknown //IL_085f: Expected O, but got Unknown //IL_0874: Unknown result type (might be due to invalid IL or missing references) //IL_087a: Unknown result type (might be due to invalid IL or missing references) //IL_087f: Unknown result type (might be due to invalid IL or missing references) //IL_0884: Unknown result type (might be due to invalid IL or missing references) //IL_0890: Unknown result type (might be due to invalid IL or missing references) //IL_0868: Unknown result type (might be due to invalid IL or missing references) //IL_086a: Unknown result type (might be due to invalid IL or missing references) //IL_090f: Expected I8, but got O //IL_0923: Unknown result type (might be due to invalid IL or missing references) //IL_0954: Expected I8, but got O //IL_0968: Unknown result type (might be due to invalid IL or missing references) //IL_0994: Unknown result type (might be due to invalid IL or missing references) //IL_09a4: Unknown result type (might be due to invalid IL or missing references) //IL_09ae: Expected I8, but got Unknown //IL_09ae: Expected O, but got Unknown //IL_09ae: Unknown result type (might be due to invalid IL or missing references) //IL_029d: Unknown result type (might be due to invalid IL or missing references) //IL_02a2: Unknown result type (might be due to invalid IL or missing references) //IL_02bd: Unknown result type (might be due to invalid IL or missing references) //IL_02c2: Unknown result type (might be due to invalid IL or missing references) //IL_02de: Unknown result type (might be due to invalid IL or missing references) //IL_02e3: Unknown result type (might be due to invalid IL or missing references) //IL_02ff: Unknown result type (might be due to invalid IL or missing references) //IL_0304: Unknown result type (might be due to invalid IL or missing references) //IL_0709: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_0710: Unknown result type (might be due to invalid IL or missing references) //IL_0715: Unknown result type (might be due to invalid IL or missing references) //IL_073c: Unknown result type (might be due to invalid IL or missing references) //IL_0741: Unknown result type (might be due to invalid IL or missing references) //IL_0743: Unknown result type (might be due to invalid IL or missing references) //IL_0748: Unknown result type (might be due to invalid IL or missing references) if (logger == null) { logger = Setup.logger; } Humanoid component = ((Component)this).gameObject.GetComponent<Humanoid>(); Transform val = ((Component)component).gameObject.transform.Find("Visual"); mountPoint = new GameObject("MountPoint"); mountPoint.transform.parent = val; mountPoint.transform.rotation = ((Component)this).transform.rotation; Tameable component2 = ((Component)this).GetComponent<Tameable>(); Vector3 zero = Vector3.zero; Vector3 zero2 = Vector3.zero; Vector3 localScale = Vector3.one; Vector3 val2 = Vector3.zero; switch (Type) { case "Boar": logger.LogInfo((object)"Setting up Boar for riding."); zero = Setup.boarMountPos; mountPointBase = val.Find("CG/Pelvis/Spine/Spine1"); mountPoint.transform.parent = val; saddle = Object.Instantiate<GameObject>(Setup.boarSaddlePrefab, val); saddle.GetComponent<Sadle>().m_maxStamina = Setup.BoarStamina.Value; zero2 = Setup.boarSaddlePos; break; case "Wolf": logger.LogInfo((object)"Setting up Wolf for riding."); zero = Setup.wolfMountPos; mountPointBase = val.Find("WolfSmooth/CG/Pelvis/Spine/Spine1"); mountPoint.transform.parent = val; saddle = Object.Instantiate<GameObject>(Setup.wolfSaddlePrefab, val); saddle.GetComponent<Sadle>().m_maxStamina = Setup.WolfStamina.Value; zero2 = Setup.wolfSaddlePos; break; default: { logger.LogInfo((object)("Setting up \"" + Type + "MountPointOld")); if (!Setup.customMountsEnabled.Value || Setup.customMountCount.Value <= 0 || !Setup.mountNameDict.ContainsKey(Type)) { return; } string text = Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value; if (text.Contains("\\")) { logger.LogWarning((object)(Type + " Mount Path should use '/' rather than '\\', trying to replace")); text.Replace('\\', '/'); Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text; } if (text != "") { mountPointBase = val.Find(text); } zero = Setup.customMountPoints[Setup.mountNameDict[Type]].Value; zero2 = Setup.customSaddlePos[Setup.mountNameDict[Type]].Value; localScale = Setup.customSaddleScale[Setup.mountNameDict[Type]].Value; val2 = Setup.customSaddleRot[Setup.mountNameDict[Type]].Value; if ((Object)(object)mountPointBase == (Object)null) { string[] array; if (!(text == "")) { mountPoint.transform.parent = val; string text2 = ""; array = text.Split(new char[1] { '/' }); foreach (string text3 in array) { if (!text2.Equals("")) { text2 += "/"; } if ((Object)(object)val.Find(text2 + text3) == (Object)null) { string text4 = Type + " Mount Path '" + text + "' is not correct. "; if (text2 != "") { text4 = text4 + "'" + text2 + "' appears to work. "; } text4 = text4 + text3 + " cannot be found in " + Type + " body. " + Type + " will not be rideable."; ((Component)component).GetComponent<Tameable>().m_saddleItem = null; logger.LogError((object)text4); return; } text2 += text3; } logger.LogError((object)("Unknown error in setting up saddle and riding for " + Type + ", it will not be rideable")); ((Component)component).GetComponent<Tameable>().m_saddleItem = null; return; } Transform[] componentsInChildren = ((Component)val).GetComponentsInChildren<Transform>(); string[] array2 = new string[4] { "spine1", "tail2", "spine", "head" }; List<string> list = new List<string>(); array = array2; foreach (string text5 in array) { Transform[] array3 = componentsInChildren; foreach (Transform val3 in array3) { if (((Object)val3).name.ToLowerInvariant() == text5) { if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val3; text = GetPath(val3); } else { list.Add(GetPath(val3)); } break; } } } if ((Object)(object)mountPointBase == (Object)null) { array = array2; foreach (string value in array) { Transform[] array3 = componentsInChildren; foreach (Transform val4 in array3) { string text6 = ((Object)val4).name.ToLowerInvariant(); if (text6.StartsWith(value) || text6.EndsWith(value)) { if ((Object)(object)mountPointBase == (Object)null) { mountPointBase = val4; text = GetPath(val4); } else { list.Add(GetPath(val4)); } break; } } } } if (!((Object)(object)mountPointBase != (Object)null)) { logger.LogError((object)("Could not find potential Mount Path for " + Type + ". " + Type + " will not be rideable")); ((Component)component).GetComponent<Tameable>().m_saddleItem = null; return; } string text7 = ""; if (list.Count > 0) { text7 = "\nPossible Alternatives:"; foreach (string item in list) { text7 = text7 + "\n" + item; } } Setup.customTightMountPaths[Setup.mountNameDict[Type]].Value = text; logger.LogMessage((object)("Found potential Mount Path for " + Type + ": " + text + text7)); } mountPoint.transform.parent = val; Transform transform = mountPoint.transform; transform.rotation *= Quaternion.Euler(val2); saddle = Object.Instantiate<GameObject>(Setup.genericSaddlePrefab, val); Transform transform2 = saddle.transform; transform2.rotation *= Quaternion.Euler(val2); saddle.GetComponent<Sadle>().m_maxStamina = Setup.customStamina[Setup.mountNameDict[Type]].Value; BaseAI baseAI = ((Character)component).GetBaseAI(); MonsterAI val5 = (MonsterAI)(object)((baseAI is MonsterAI) ? baseAI : null); if ((Object)(object)val5 != (Object)null && val5.m_avoidLand) { saddle.GetComponent<Sadle>().m_swimStaminaDrain = 0f; } break; } } Sadle component3 = saddle.GetComponent<Sadle>(); component3.m_hoverText = Type + " Saddle"; component3.m_attachPoint = mountPoint.transform; saddle.SetActive(false); component2.m_saddle = component3; ((Component)component3).transform.localPosition = zero2; ((Component)component3).transform.localScale = localScale; if (Setup.adjustCustom.Value && Setup.customMountsEnabled.Value) { Animator componentInChildren = ((Component)component).gameObject.GetComponentInChildren<Animator>(); if ((Object)(object)componentInChildren != (Object)null) { ((Behaviour)componentInChildren).enabled = false; } } _ = (string)val2 != (long)Vector3.zero; if ((int)/*Error near IL_0861: Stack underflow*/ != 0) { ((Component)component3).GetComponentInChildren<Transform>().localRotation = Quaternion.Euler(val2); } zero += Setup.MountPointAdjustment.Value; mountPoint.transform.localPosition = zero; if ((Object)(object)component2.m_saddle != (Object)null) { /*Error near IL_08a5: Invalid field token*/; } mountPoint.transform.parent = mountPointBase; Player.GetPlayer((long)mountPoint.transform); ((Transform)180f).localRotation = (Quaternion)180f * (Quaternion)((Quaternion)180f).Euler(); saddle.transform.parent = mountPointBase; Player.GetPlayer((long)saddle.transform); ((Transform)180f).localRotation = (Quaternion)180f * (Quaternion)((Quaternion)180f).Euler(); SphereCollider component4 = saddle.GetComponent<SphereCollider>(); bool num = ((Player)component4.radius).IsAttached(); ((ZDO)this).Set((string)mountPoint.transform.position, (long)saddle.transform.position); ((Mountable)(object)component4).SaddleToMountPoint = (Vector3)num; } public void ResetMountPoint() { //IL_0031: 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_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) if ((Object)(object)mountPoint == (Object)null) { Debug.Log((object)"mountPoint"); } if ((Object)(object)saddle == (Object)null) { Debug.Log((object)"saddle"); } _ = SaddleToMountPoint; mountPoint.transform.position = saddle.transform.position + SaddleToMountPoint; } private string GetPath(Transform child) { string text = ((Object)child).name; Transform parent = child.parent; while (((Object)parent).name != "Visual") { text = ((Object)parent).name + "/" + text; parent = parent.parent; } return text; } } public class MountUp { public enum AdjustMode { None, , Mount } private sealed class <SadleUpdateRiding_Transpile>d__11 : IEnumerable<CodeInstruction>, IEnumerable, IEnumerator<CodeInstruction>, IDisposable, IEnumerator { private int <>1__state; private CodeInstruction <>2__current; private int <>l__initialThreadId; private IEnumerable<CodeInstruction> instructions; public IEnumerable<CodeInstruction> <>3__instructions; private bool <Ldfld>5__2; private bool <foundCall>5__3; private bool <executed>5__4; private IEnumerator<CodeInstruction> <>7__wrap4; private CodeInstruction <jumpcall>5__6; CodeInstruction IEnumerator<CodeInstruction>.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public <SadleUpdateRiding_Transpile>d__11(int <>1__state) { this.<>1__state = <>1__state; <>l__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = <>1__state; if (num == -3 || (uint)(num - 1) <= 7u) { try { } finally { <>m__Finally1(); } } } private bool MoveNext() { //IL_0181: Unknown result type (might be due to invalid IL or missing references) //IL_018b: Expected O, but got Unknown try { switch (<>1__state) { default: return false; case 0: <>1__state = -1; <Ldfld>5__2 = false; <foundCall>5__3 = false; <executed>5__4 = false; <>7__wrap4 = instructions.GetEnumerator(); <>1__state = -3; break; case 1: <>1__state = -3; break; case 2: <>1__state = -3; break; case 3: <>1__state = -3; <>2__current = new CodeInstruction(OpCodes.Ldarg_0, (object)null); <>1__state = 4; return true; case 4: <>1__state = -3; <>2__current = CodeInstruction.LoadField(typeof(Sadle), "m_swimStaminaDrain", false); <>1__state = 5; return true; case 5: <>1__state = -3; <>2__current = CodeInstruction.Call(typeof(MountUp), "HasSwimDrain", (Type[])null, (Type[])null); <>1__state = 6; return true; case 6: <>1__state = -3; <>2__current = <jumpcall>5__6; <>1__state = 7; return true; case 7: <>1__state = -3; <jumpcall>5__6 = null; break; case 8: <>1__state = -3; break; } if (<>7__wrap4.MoveNext()) { CodeInstruction current = <>7__wrap4.Current; if (!<executed>5__4 && !<Ldfld>5__2 && current.opcode == OpCodes.Ldfld) { <Ldfld>5__2 = true; <>2__current = current; <>1__state = 1; return true; } if ((!<executed>5__4 & <Ldfld>5__2) && !<foundCall>5__3 && current.opcode == OpCodes.Callvirt) { <foundCall>5__3 = true; <>2__current = current; <>1__state = 2; return true; } if ((!<executed>5__4 & <Ldfld>5__2 & <foundCall>5__3) && current.opcode == OpCodes.Brfalse) { <executed>5__4 = true; <jumpcall>5__6 = current; <>2__current = current; <>1__state = 3; return true; } <Ldfld>5__2 = false; <foundCall>5__3 = false; <>2__current = current; <>1__state = 8; return true; } <>m__Finally1(); <>7__wrap4 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void <>m__Finally1() { <>1__state = -1; if (<>7__wrap4 != null) { <>7__wrap4.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator<CodeInstruction> IEnumerable<CodeInstruction>.GetEnumerator() { <SadleUpdateRiding_Transpile>d__11 <SadleUpdateRiding_Transpile>d__; if (<>1__state == -2 && <>l__initialThreadId == Environment.CurrentManagedThreadId) { <>1__state = 0; <SadleUpdateRiding_Transpile>d__ = this; } else { <SadleUpdateRiding_Transpile>d__ = new <SadleUpdateRiding_Transpile>d__11(0); } <SadleUpdateRiding_Transpile>d__.instructions = <>3__instructions; return <SadleUpdateRiding_Transpile>d__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable<CodeInstruction>)this).GetEnumerator(); } } public static AdjustMode adjustMode; private static void LevelEffectsStart_Patch(LevelEffects __instance) { Mountable component = ((Component)__instance.m_character).GetComponent<Mountable>(); if (!((Object)(object)component == (Object)null)) { component.ResetMountPoint(); } } [HarmonyPatch(typeof(Player), "Update")] [HarmonyPostfix] private static void PlayerUpdate_Patch(Player __instance, ZNetView ___m_nview) { //IL_0111: Unknown result type (might be due to invalid IL or missing references) //IL_0118: Unknown result type (might be due to invalid IL or missing references) //IL_011d: Unknown result type (might be due to invalid IL or missing references) //IL_011f: Unknown result type (might be due to invalid IL or missing references) //IL_0124: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (___m_nview == null) { return; } ZDO zDO = ___m_nview.GetZDO(); if (zDO == null) { return; } if ((Object)(object)__instance == (Object)(object)Player.m_localPlayer) { if (Input.GetKeyDown((KeyCode)101)) { Character hoverCreature = __instance.GetHoverCreature(); Player val = (Player)(object)((hoverCreature is Player) ? hoverCreature : null); if (val != null) { zDO.Set("MountPoint", val.GetPlayerID()); zDO.Set("MountPointOld", val.GetPlayerID()); float ___m_lastHoverInteractTime = default(float); PlayerInteract_Patch(((Component)val).gameObject, hold: false, alt: false, ref ___m_lastHoverInteractTime, __instance); } } if (!__instance.IsAttached()) { zDO.Set("MountPoint", 0L); } return; } long num = zDO.GetLong("MountPoint", 0L); if (num != 0L) { Player player = Player.GetPlayer(num); if (player != null) { Physics.IgnoreCollision(((Component)__instance).gameObject.GetComponent<Collider>(), ((Component)player).gameObject.GetComponent<Collider>(), true); Transform transform = ((Character)player).GetVisual().transform; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0.6997871f, -0.2250879f); ((Component)__instance).transform.position = transform.position + transform.rotation * val2; ((Component)__instance).transform.rotation = transform.rotation; } return; } num = zDO.GetLong("MountPointOld", 0L); if (num != 0L) { Player val = Player.GetPlayer(num); if (val != null) { Physics.IgnoreCollision(((Component)__instance).gameObject.GetComponent<Collider>(), ((Component)val).gameObject.GetComponent<Collider>(), false); } } } private static void TeleportWorldTriggerOnTriggerEnter_Patch(Player P_0, ZNetView collider) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: 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) if (!Setup.teleportMounts.Value) { return; } Tameable component = ((Component)collider).GetComponent<Tameable>(); if (!((Object)(object)component != (Object)null) || !component.m_character.IsTamed() || !component.HaveRider()) { return; } ZDOID user = component.m_saddle.GetUser(); if (((ZDOID)(ref user)).IsNone()) { return; } GameObject val = ZNetScene.instance.FindInstance(user); if (!((Object)(object)val == (Object)null)) { Player component2 = val.GetComponent<Player>(); if (!((Object)(object)component2 == (Object)null) && !((Object)(object)Player.m_localPlayer != (Object)(object)component2)) { ((TeleportWorldTrigger)P_0).m_tp.Teleport(component2); } } } private static void TeleportWorldTeleport_Patch(Player player) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) if (Setup.teleportMounts.Value) { Character hoverCreature = player.GetHoverCreature(); Sadle val = (Sadle)(object)((hoverCreature is Sadle) ? hoverCreature : null); if ((Object)(object)val != (Object)null) { val.m_speed = (Speed)0; } } } private static void PlayerUpdateTeleport_Patch(ref bool ___m_nview, ref float ___m_teleportTimer, ref Vector3 ___m_teleportTargetPos, ref Quaternion ___m_teleportTargetRot, Player __instance) { //IL_0038: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_008d: Unknown result type (might be due to invalid IL or missing references) if (Setup.teleportMounts.Value && ___m_nview && (double)___m_teleportTimer > 2.0) { IDoodadController doodadController = __instance.m_doodadController; Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if ((Object)(object)val != (Object)null) { _ = __instance.m_teleportTargetRot * Vector3.forward; ((Component)val.GetCharacter()).transform.position = __instance.m_teleportTargetPos; ((Component)val.GetCharacter()).transform.rotation = __instance.m_teleportTargetRot; val.GetCharacter().m_body.velocity = Vector3.zero; val.m_speed = (Speed)0; } } } private static void PlayerInteract_Patch(GameObject go, bool hold, bool alt, ref float ___m_lastHoverInteractTime, Player __instance) { //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_00c0: Unknown result type (might be due to invalid IL or missing references) //IL_00c5: Unknown result type (might be due to invalid IL or missing references) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: 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) Player componentInParent = go.GetComponentInParent<Player>(); if (((((Object)(object)componentInParent != (Object)null) ? 1 : 0) & 1) != 0) { ___m_lastHoverInteractTime = Time.time; GameObject visual = ((Character)componentInParent).GetVisual(); if (((Object)((Component)visual.transform.GetChild(visual.transform.childCount - 1)).gameObject).name.Equals("MountPoint")) { Transform child = visual.transform.GetChild(visual.transform.childCount - 1); child.parent = null; Object.Destroy((Object)(object)((Component)child).gameObject); } GameObject val = new GameObject("MountPoint"); val.transform.parent = visual.transform; Vector3 localPosition = default(Vector3); ((Vector3)(ref localPosition))..ctor(0f, 0.6997871f, -0.2250879f); Quaternion rotation = visual.transform.rotation; val.transform.rotation = rotation; val.transform.localPosition = localPosition; Transform transform = val.transform; Vector3 val2 = default(Vector3); ((Vector3)(ref val2))..ctor(0f, 0f, 0f); ((Character)__instance).AttachStart(transform, visual, false, false, false, "attach_chair", val2, (Transform)null); } } public static bool HasSwimDrain(float swimDrain) { return swimDrain > 0f; } private static bool SadleUpdateDrown_Patch(Sadle __instance) { if (__instance.m_swimStaminaDrain > 0f) { return true; } return false; } private static void SadleUpdateStamina_Patch(Sadle __instance, float dt) { if (__instance.m_staminaRegenTimer > 0f || __instance.m_character.InAttack() || !__instance.m_character.IsSwiming() || __instance.m_swimStaminaDrain > 0f) { return; } float stamina = __instance.GetStamina(); float maxStamina = __instance.GetMaxStamina(); if (stamina < maxStamina || stamina > maxStamina) { float num = (__instance.m_tambable.IsHungry() ? __instance.m_staminaRegenHungry : __instance.m_staminaRegen); float num2 = num + (1f - stamina / maxStamina) * num; stamina += num2 * dt; if (stamina > maxStamina) { stamina = maxStamina; } __instance.SetStamina(stamina); } } private static IEnumerable<CodeInstruction> SadleUpdateRiding_Transpile(IEnumerable<CodeInstruction> instructions) { return new <SadleUpdateRiding_Transpile>d__11(-2) { <>3__instructions = instructions }; } } internal class Patches { public const string AllTameableGUID = "meldurson.valheim.AllTameable"; private static Harmony harmony; internal static void Apply() { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Expected O, but got Unknown harmony = new Harmony("Koosemose.MountUp"); harmony.PatchAll(typeof(MountUp)); } [HarmonyPatch(typeof(TeleportWorldTrigger), "OnTriggerEnter")] [HarmonyPostfix] [HarmonyPatch(typeof(TeleportWorld), "Teleport")] [HarmonyPostfix] public Patches() { } } [BepInPlugin("Koosemose.MountUp", "Mount Up", "3.2.23")] [BepInDependency(/*Could not decode attribute arguments.*/)] [BepInDependency(/*Could not decode attribute arguments.*/)] public class Setup : BaseUnityPlugin { public const string PluginGUID = "Koosemose.MountUp"; public const string PluginName = "Mount Up"; public const string PluginVersion = "3.2.10"; public static ManualLogSource logger; public static GameObject boarSaddlePrefab; public static ItemDrop boarSaddleItem; public static ItemDrop wolfSaddleItem; public static ItemDrop loxSaddleItem; public static GameObject wolfSaddlePrefab; public static GameObject genericSaddlePrefab; public static Vector3 loxMountPos = new Vector3(0f, 2.989f, 1.27f); public static Vector3 boarMountPos = new Vector3(0f, 0.9f, 0.5f); public static Vector3 wolfMountPos = new Vector3(-0.04f, 1.13f, 0.12f); public static Vector3 boarSaddlePos = new Vector3(0f, 0.826f, -0.016f); public static Vector3 wolfSaddlePos = new Vector3(0f, 1.148f, -0.21f); public static ConfigEntry<bool> canMountPlayer; public static ConfigEntry<float> BoarStamina; public static ConfigEntry<float> WolfStamina; public static ConfigEntry<bool> adjustCustom; public static ConfigEntry<KeyboardShortcut> adjustCustomModeSwitch; public static ButtonConfig adjustCustomModeSwitchButton; public static ConfigEntry<bool> teleportMounts; public static ConfigEntry<bool> customMountsEnabled; public static ConfigEntry<int> customMountCount; public static Dictionary<string, int> mountNameDict; public static List<ConfigEntry<string>> customMountNames; public static List<ConfigEntry<int>> customMountSaddleTiers; public static List<ConfigEntry<Vector3>> customMountPoints; public static List<ConfigEntry<Vector3>> customSaddlePos; public static List<ConfigEntry<Vector3>> customSaddleScale; public static List<ConfigEntry<Vector3>> customSaddleRot; public static List<ConfigEntry<float>> customStamina; public static List<ConfigEntry<string>> customTightMountPaths; public static ConfigEntry<Vector3> MountPointAdjustment; private static ConfigEntry<KeyCode> mountModifierKey; public static GameObject SalObj; private void Awake() { canMountPlayer = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Can Mount Player", true, "Experimental: Can Players be mounted"); Patches.Apply(); } private void LoadAssets() { AssetBundle obj = AssetUtils.LoadAssetBundleFromResources("saddle", typeof(Setup).Assembly); boarSaddlePrefab = obj.LoadAsset<GameObject>("Assets/Saddle/BoarSaddle.prefab"); wolfSaddlePrefab = obj.LoadAsset<GameObject>("Assets/Saddle/WolfSaddle.prefab"); genericSaddlePrefab = obj.LoadAsset<GameObject>("Assets/Saddle/GenericSaddle.prefab"); } public static string StringVec(Vector3 vec) { //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Unknown result type (might be due to invalid IL or missing references) return $"{{\"x\":{vec.x:F2},\"y\":{vec.y:F2},\"z\":{vec.z:F2}" + "}"; } public static void MakeMountable(Tameable tame) { if ((Object)(object)tame.m_saddleItem != (Object)null) { return; } string name = ((Object)tame).name; bool flag = false; switch (name) { case "Boar": tame.m_saddleItem = boarSaddleItem; flag = true; break; case "Wolf": tame.m_saddleItem = wolfSaddleItem; flag = true; break; case "Lox": return; default: if (customMountsEnabled.Value && mountNameDict.ContainsKey(name)) { switch (customMountSaddleTiers[mountNameDict[name]].Value) { case 1: tame.m_saddleItem = boarSaddleItem; break; case 2: tame.m_saddleItem = wolfSaddleItem; break; default: tame.m_saddleItem = loxSaddleItem; break; } flag = true; } break; } if ((Object)(object)((Component)tame).gameObject.GetComponent<Mountable>() == (Object)null && flag) { ((Component)tame).gameObject.AddComponent<Mountable>().Type = name; } } private static void SetupMountable() { Tameable[] array = Resources.FindObjectsOfTypeAll<Tameable>(); for (int i = 0; i < array.Length; i++) { MakeMountable(array[i]); } PrefabManager.OnVanillaPrefabsAvailable -= SetupMountable; } public void CreateSaddles() { //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0010: Expected O, but got Unknown //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: Expected O, but got Unknown CustomItem val = new CustomItem("SaddleBoar", "SaddleLox"); ItemManager.Instance.AddItem(val); boarSaddleItem = val.ItemDrop; boarSaddleItem.m_itemData.m_shared.m_name = (customMountsEnabled.Value ? "Basic Saddle" : "Boar Saddle"); boarSaddleItem.m_itemData.m_shared.m_description = "A smaller simpler saddle, it should be good for smaller calmer creatures."; boarSaddleItem.m_itemData.m_dropPrefab = val.ItemPrefab; boarSaddleItem.m_itemData.m_shared.m_weight = 5f; CustomItem val2 = new CustomItem("SaddleWolf", "SaddleLox"); ItemManager.Instance.AddItem(val2); wolfSaddleItem = val2.ItemDrop; wolfSaddleItem.m_itemData.m_shared.m_name = (customMountsEnabled.Value ? "Standard Saddle" : "Wolf Saddle"); wolfSaddleItem.m_itemData.m_shared.m_description = "A well-made, sturdy saddle. It should be good for fiercer creatures."; wolfSaddleItem.m_itemData.m_dropPrefab = val2.ItemPrefab; wolfSaddleItem.m_itemData.m_shared.m_weight = 7.5f; PrefabManager.OnVanillaPrefabsAvailable -= CreateSaddles; if (customMountsEnabled.Value) { loxSaddleItem = Cache.GetPrefab<ItemDrop>("SaddleLox"); loxSaddleItem.m_itemData.m_shared.m_name = "Advanced Saddle"; } CreateRecipes(); } private static void CreateRecipes() { //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Unknown result type (might be due to invalid IL or missing references) //IL_005a: Expected O, but got Unknown //IL_005c: 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_0071: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //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_0090: Unknown result type (might be due to invalid IL or missing references) //IL_0098: 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_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_0103: Unknown result type (might be due to invalid IL or missing references) //IL_010c: Expected O, but got Unknown //IL_010e: 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_0123: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_012d: Unknown result type (might be due to invalid IL or missing references) //IL_0132: 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_014b: Expected O, but got Unknown //IL_0153: Unknown result type (might be due to invalid IL or missing references) //IL_0159: Expected O, but got Unknown Recipe val = ScriptableObject.CreateInstance<Recipe>(); ((Object)val).name = "Recipe_BoarSaddle"; val.m_item = boarSaddleItem; val.m_craftingStation = Cache.GetPrefab<CraftingStation>("piece_workbench"); val.m_minStationLevel = 1; val.m_resources = (Requirement[])(object)new Requirement[3] { new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("LeatherScraps"), m_amount = 10 }, new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("DeerHide"), m_amount = 5 }, new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("Bronze"), m_amount = 5 } }; CustomRecipe val2 = new CustomRecipe(val, false, false); ItemManager.Instance.AddRecipe(val2); Recipe val3 = ScriptableObject.CreateInstance<Recipe>(); ((Object)val3).name = "Recipe_WolfSaddle"; val3.m_item = wolfSaddleItem; val3.m_craftingStation = Cache.GetPrefab<CraftingStation>("piece_workbench"); val3.m_minStationLevel = 1; val3.m_resources = (Requirement[])(object)new Requirement[3] { new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("LeatherScraps"), m_amount = 10 }, new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("Chain"), m_amount = 1 }, new Requirement { m_resItem = Cache.GetPrefab<ItemDrop>("Silver"), m_amount = 10 } }; CustomRecipe val4 = new CustomRecipe(val3, false, false); ItemManager.Instance.AddRecipe(val4); } } } namespace MountUp.ModCompat { internal class PatcherAllTamable { [HarmonyPatch(typeof(PetManager), "AddTame")] [HarmonyPostfix] private static void PetManTamePatch(GameObject go) { Debug.Log((object)("Making " + ((Object)go).name + " Mountable")); string name = ((Object)go).name; if (Setup.customMountsEnabled.Value && Setup.mountNameDict.ContainsKey(name)) { Setup.MakeMountable(go.GetComponent<Tameable>()); } } } }