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 OdinMountedCombat v1.0.1
OdinMountedCombat.dll
Decompiled a day ago
The result has been truncated due to the large size, download it to view full contents!
using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Globalization; using System.IO; using System.IO.Compression; using System.Linq; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.Serialization; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using System.Text.RegularExpressions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using JetBrains.Annotations; using Microsoft.CodeAnalysis; using ServerSync; using TMPro; 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("OdinMountedCombat")] [assembly: AssemblyDescription("https://valheim.thunderstore.io/package/OdinPlus/OdinMountedCombat")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("OdinMountedCombat")] [assembly: AssemblyCopyright("Copyright © 2026")] [assembly: AssemblyTrademark("")] [assembly: ComVisible(false)] [assembly: Guid("15dcdf94-b864-403a-9f84-2be15640ecb1")] [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] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace OdinMountedCombat { internal static class MountedAttacks { internal sealed class MountSeat { public readonly string Name; public readonly int Hash; public float LegsOut; public float ThighsDown; public float KneeBend; public float FeetOut; public float SeatHeight; public float SeatForward; public float SeatTilt; public float LeanForward; public bool KeepRidingAnimation; public float MeleeReach; public float PickupReach; public bool Adjusts => LegsOut != 0f || ThighsDown != 0f || KneeBend != 0f || FeetOut != 0f || SeatHeight != 0f || SeatForward != 0f || SeatTilt != 0f || LeanForward != 0f; public MountSeat(string name) { Name = name; Hash = StringExtensionMethods.GetStableHashCode(name); } } private sealed class MountOf { public int Version = -1; public bool Combat; public MountSeat? Seat; } internal sealed class WeaponFamily { public readonly string Name; public readonly string Description; public readonly string[] Clips; public ConfigEntry<bool>? Enabled; public ConfigEntry<float>? Reach; public float DefaultReach = -1f; public bool Original; public bool Available; public bool Melee => DefaultReach >= 0f; public WeaponFamily(string name, string description, params string[] clips) { Name = name; Description = description; Clips = clips; } } private enum LanceStage { Raised, Lowering, Couched, Raising } private sealed class Rider { public RuntimeAnimatorController? Original; public bool Mounted; public bool HoldingAttach; public float AimWeight; public float AimYaw; public float AimPitch; public float AimHeading; public float ChestYaw; public readonly Quaternion[] AnimatedLocal = (Quaternion[])(object)new Quaternion[PoseBones.Length]; public readonly Quaternion[] WrittenLocal = (Quaternion[])(object)new Quaternion[PoseBones.Length]; public bool Wrote; public readonly Dictionary<Cloth, (float velocity, float acceleration)> CalmedCloth = new Dictionary<Cloth, (float, float)>(); public float ClothScanTimer; public int[]? GoodStates; public float[]? GoodTimes; public Behaviour? PausedPoseDriver; public readonly List<Renderer> HiddenCape = new List<Renderer>(); public string? Variant; public bool Lance; public LanceStage LanceStage; public float LanceTime; public bool LanceInput; public readonly Dictionary<int, float> LanceHits = new Dictionary<int, float>(); public bool LanceExhausted; public MountSeat? Seat; public int RideParam; public bool KeepRide; public int RideBool; public int RideState; public RuntimeAnimatorController? FootOriginal; public bool Charging; public bool ChargeStabbed; public readonly HashSet<int> ChargeHits = new HashSet<int>(); public Vector3 AnimatedHips; public Vector3 WrittenHips; public bool Redirected => RideParam != 0 && !KeepRide; } private enum AimMode { None, Ready, Bow, Throw, Ranged, Melee, Lance } [HarmonyPatch(typeof(Attack), "OnAttackTrigger")] private static class ChargeStabPatch { private static void Prefix(Attack __instance) { Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && s_riders.TryGetValue(val, out Rider value) && value.Charging) { value.ChargeStabbed = true; } } } [HarmonyPatch(typeof(Player), "Awake")] private static class PlayerAwakePatch { private static void Postfix(Player __instance) { if (!((Object)(object)((Character)__instance).m_nview == (Object)null) && ((Character)__instance).m_nview.GetZDO() != null) { Player player = __instance; ((Character)__instance).m_nview.Register<Vector3, float>("OdinMountedCombat_Unhorse", (Action<long, Vector3, float>)delegate(long _, Vector3 dir, float power) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) Unhorse(player, dir, power); }); } } } [HarmonyPatch(typeof(Player), "Update")] private static class PlayerUpdatePatch { private static void Postfix(Player __instance) { Tick(__instance); } } [HarmonyPatch(typeof(Player), "SetControls")] private static class SetControlsPatch { private static void Prefix(Player __instance, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, out (bool attack, bool attackHold, bool secondary, bool secondaryHold)? __state) { __state = null; if (!Enabled.Value || !IsRidingMount(__instance)) { return; } if (HoldsLance((Humanoid)(object)__instance)) { Rider orCreateValue = s_riders.GetOrCreateValue(__instance); bool flag = attack | attackHold; if (!flag) { orCreateValue.LanceExhausted = false; } orCreateValue.LanceInput = flag && !orCreateValue.LanceExhausted; attack = (attackHold = (secondaryAttack = (secondaryAttackHold = false))); return; } bool flag2 = (attack | attackHold) && HasMountedAttack((Humanoid)(object)__instance, secondary: false); bool flag3 = (secondaryAttack | secondaryAttackHold) && HasMountedAttack((Humanoid)(object)__instance, secondary: true); if (flag2 || flag3) { __state = (flag2 & attack, flag2 & attackHold, flag3 & secondaryAttack, flag3 & secondaryAttackHold); if (flag2) { attack = (attackHold = false); } if (flag3) { secondaryAttack = (secondaryAttackHold = false); } } } private static void Postfix(Player __instance, (bool attack, bool attackHold, bool secondary, bool secondaryHold)? __state) { if (__state.HasValue) { (bool, bool, bool, bool) valueOrDefault = __state.GetValueOrDefault(); if (((Character)__instance).IsAttached()) { ((Character)__instance).m_attack = ((Character)__instance).m_attack | valueOrDefault.Item1; ((Character)__instance).m_attackHold = ((Character)__instance).m_attackHold | valueOrDefault.Item2; ((Character)__instance).m_secondaryAttack = ((Character)__instance).m_secondaryAttack | valueOrDefault.Item3; ((Character)__instance).m_secondaryAttackHold = ((Character)__instance).m_secondaryAttackHold | valueOrDefault.Item4; } } } } [HarmonyPatch] private static class BetterRidingMountAttackPatch { private static MethodBase? Target { get { Type type = AccessTools.TypeByName("BetterRiding.Behaviour.MountAttackController"); return ((object)type != null) ? AccessTools.Method(type, "Update", (Type[])null, (Type[])null) : null; } } private static bool Prepare() { return Target != null; } private static MethodBase TargetMethod() { return Target; } private static bool Prefix() { return !RiderFights(Player.m_localPlayer); } } [HarmonyPatch] private static class BetterRidingRestrictAttackPatch { private static MethodBase? Target { get { Type type = AccessTools.TypeByName("BetterRiding.Behaviour.MountAttackController+Ygg_RestrictPlayerAttack"); return ((object)type != null) ? AccessTools.Method(type, "Prefix", (Type[])null, (Type[])null) : null; } } private static bool Prepare() { return Target != null; } private static MethodBase TargetMethod() { return Target; } private static bool Prefix(Player __0) { return !RiderFights(__0); } } [HarmonyPatch(typeof(Humanoid), "StartAttack")] private static class StartAttackPatch { private static void Prefix(Humanoid __instance, bool secondaryAttack) { if (Enabled.Value) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && IsRidingMount(val) && HasMountedAttack((Humanoid)(object)val, secondaryAttack)) { s_seatedAttacker = val; } } } private static void Finalizer() { s_seatedAttacker = null; } } [HarmonyPatch(typeof(Player), "UpdateAttackBowDraw")] private static class UpdateAttackBowDrawPatch { private static void Prefix(Player __instance, ItemData weapon) { if (Enabled.Value && IsRidingMount(__instance) && weapon.m_shared.m_attack.m_drawAnimationState == "bow_aim") { s_drawingRider = __instance; } } private static void Finalizer() { s_drawingRider = null; } } [HarmonyPatch(typeof(Player), "IsAttached")] private static class IsAttachedPatch { private static void Postfix(Player __instance, ref bool __result) { if ((Object)(object)__instance == (Object)(object)s_drawingRider) { __result = false; } } } [HarmonyPatch(typeof(CharacterAnimEvent), "UpdateFootIK")] private static class UpdateFootIKPatch { private static bool Prefix(CharacterAnimEvent __instance) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) //IL_0049: Unknown result type (might be due to invalid IL or missing references) if (!IsMounted(__instance.m_character)) { return true; } Foot[] feets = __instance.m_feets; foreach (Foot val in feets) { __instance.m_animator.SetIKPositionWeight(val.m_ikHandle, 0f); __instance.m_animator.SetIKRotationWeight(val.m_ikHandle, 0f); val.m_ikWeight = 0f; } return false; } } [HarmonyPatch(typeof(CharacterAnimEvent), "CustomLateUpdate")] private static class AimTwistPatch { private static void Postfix(CharacterAnimEvent __instance, float deltaTime) { //IL_00b0: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val == null || !s_riders.TryGetValue(val, out Rider value) || !value.Mounted) { return; } Animator animator = __instance.m_animator; RestoreAnimatedPose(animator, value); if (!value.KeepRide) { MountSeat seat = value.Seat; if (seat != null && seat.Adjusts) { ApplySeat(animator, AimBasis(val), seat); } } Aim(__instance, val, value, animator, deltaTime); for (int i = 0; i < PoseBones.Length; i++) { Transform boneTransform = animator.GetBoneTransform(PoseBones[i]); if ((Object)(object)boneTransform != (Object)null) { value.WrittenLocal[i] = boneTransform.localRotation; } } Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)0); if ((Object)(object)boneTransform2 != (Object)null) { value.WrittenHips = boneTransform2.localPosition; } value.Wrote = true; } private static void ApplySeat(Animator animator, Transform body, MountSeat seat) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //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_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_0080: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0149: Unknown result type (might be due to invalid IL or missing references) //IL_015b: Unknown result type (might be due to invalid IL or missing references) //IL_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Unknown result type (might be due to invalid IL or missing references) //IL_00f8: 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) //IL_0122: Unknown result type (might be due to invalid IL or missing references) //IL_0127: Unknown result type (might be due to invalid IL or missing references) //IL_012e: Unknown result type (might be due to invalid IL or missing references) //IL_0133: Unknown result type (might be due to invalid IL or missing references) Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)0); if ((Object)(object)boneTransform != (Object)null) { boneTransform.position += body.up * seat.SeatHeight + body.forward * seat.SeatForward; } if ((Object)(object)boneTransform != (Object)null && seat.SeatTilt != 0f) { boneTransform.rotation = Quaternion.AngleAxis(seat.SeatTilt, body.right) * boneTransform.rotation; } if (seat.LeanForward != 0f) { Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)7); Transform boneTransform3 = animator.GetBoneTransform((HumanBodyBones)8); float num = (((Object)(object)boneTransform3 != (Object)null) ? 0.5f : 1f); if ((Object)(object)boneTransform2 != (Object)null) { boneTransform2.rotation = Quaternion.AngleAxis(seat.LeanForward * num, body.right) * boneTransform2.rotation; } if ((Object)(object)boneTransform3 != (Object)null) { boneTransform3.rotation = Quaternion.AngleAxis(seat.LeanForward * num, body.right) * boneTransform3.rotation; } } Leg(animator, (HumanBodyBones)1, (HumanBodyBones)3, (HumanBodyBones)5, -body.right, body, seat); Leg(animator, (HumanBodyBones)2, (HumanBodyBones)4, (HumanBodyBones)6, body.right, body, seat); } private static void Leg(Animator animator, HumanBodyBones upperBone, HumanBodyBones lowerBone, HumanBodyBones footBone, Vector3 outward, Transform body, MountSeat seat) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_000a: Unknown result type (might be due to invalid IL or missing references) //IL_0012: 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_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_008d: Unknown result type (might be due to invalid IL or missing references) //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0096: 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_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009a: 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_006c: 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_00ec: Unknown result type (might be due to invalid IL or missing references) //IL_00f2: 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_00fc: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0105: Unknown result type (might be due to invalid IL or missing references) //IL_0107: Unknown result type (might be due to invalid IL or missing references) //IL_010d: 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_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00d5: Unknown result type (might be due to invalid IL or missing references) //IL_00db: Unknown result type (might be due to invalid IL or missing references) //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_013a: 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_013d: 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_019d: Unknown result type (might be due to invalid IL or missing references) //IL_01a3: Unknown result type (might be due to invalid IL or missing references) //IL_01a8: Unknown result type (might be due to invalid IL or missing references) //IL_01ad: Unknown result type (might be due to invalid IL or missing references) //IL_01b1: Unknown result type (might be due to invalid IL or missing references) //IL_01b6: 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_01be: Unknown result type (might be due to invalid IL or missing references) //IL_01c3: Unknown result type (might be due to invalid IL or missing references) //IL_01c8: Unknown result type (might be due to invalid IL or missing references) //IL_01cc: Unknown result type (might be due to invalid IL or missing references) //IL_01d1: Unknown result type (might be due to invalid IL or missing references) //IL_01d3: Unknown result type (might be due to invalid IL or missing references) //IL_01d4: Unknown result type (might be due to invalid IL or missing references) //IL_01d6: Unknown result type (might be due to invalid IL or missing references) //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_0204: Unknown result type (might be due to invalid IL or missing references) //IL_0209: Unknown result type (might be due to invalid IL or missing references) //IL_020f: Unknown result type (might be due to invalid IL or missing references) //IL_0214: Unknown result type (might be due to invalid IL or missing references) //IL_01f3: Unknown result type (might be due to invalid IL or missing references) //IL_01f8: Unknown result type (might be due to invalid IL or missing references) //IL_0169: Unknown result type (might be due to invalid IL or missing references) //IL_016a: Unknown result type (might be due to invalid IL or missing references) //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0175: Unknown result type (might be due to invalid IL or missing references) Transform boneTransform = animator.GetBoneTransform(upperBone); Transform boneTransform2 = animator.GetBoneTransform(lowerBone); Transform boneTransform3 = animator.GetBoneTransform(footBone); if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null || (Object)(object)boneTransform3 == (Object)null) { return; } if (seat.ThighsDown != 0f) { boneTransform.rotation = Quaternion.AngleAxis(seat.ThighsDown, body.right) * boneTransform.rotation; } Vector3 val = boneTransform2.position - boneTransform.position; Vector3 normalized = ((Vector3)(ref val)).normalized; Vector3 val2 = Vector3.Cross(normalized, outward); if (seat.LegsOut != 0f && ((Vector3)(ref val2)).sqrMagnitude > 1E-06f) { boneTransform.rotation = Quaternion.AngleAxis(seat.LegsOut, ((Vector3)(ref val2)).normalized) * boneTransform.rotation; } val = boneTransform2.position - boneTransform.position; normalized = ((Vector3)(ref val)).normalized; val = boneTransform3.position - boneTransform2.position; Vector3 normalized2 = ((Vector3)(ref val)).normalized; if (seat.FeetOut != 0f) { float num = ((Vector3.Dot(Vector3.Cross(normalized, normalized2), outward) >= 0f) ? 1f : (-1f)); boneTransform.rotation = Quaternion.AngleAxis(seat.FeetOut * num, normalized) * boneTransform.rotation; } if (seat.KneeBend != 0f) { val = boneTransform2.position - boneTransform.position; normalized = ((Vector3)(ref val)).normalized; val = boneTransform3.position - boneTransform2.position; normalized2 = ((Vector3)(ref val)).normalized; Vector3 val3 = Vector3.Cross(normalized, normalized2); if (((Vector3)(ref val3)).sqrMagnitude < 1E-06f) { val3 = body.right; } boneTransform2.rotation = Quaternion.AngleAxis(seat.KneeBend, ((Vector3)(ref val3)).normalized) * boneTransform2.rotation; } } private static void Aim(CharacterAnimEvent __instance, Player player, Rider rider, Animator animator, float deltaTime) { //IL_008a: Unknown result type (might be due to invalid IL or missing references) //IL_0082: Unknown result type (might be due to invalid IL or missing references) //IL_008f: 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_009e: 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_00d9: Unknown result type (might be due to invalid IL or missing references) //IL_0119: Unknown result type (might be due to invalid IL or missing references) //IL_011a: 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_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0128: 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_0143: 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) //IL_0151: Unknown result type (might be due to invalid IL or missing references) //IL_0156: Unknown result type (might be due to invalid IL or missing references) //IL_0421: Unknown result type (might be due to invalid IL or missing references) //IL_0426: Unknown result type (might be due to invalid IL or missing references) //IL_0430: Unknown result type (might be due to invalid IL or missing references) //IL_0477: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0483: Unknown result type (might be due to invalid IL or missing references) //IL_0488: Unknown result type (might be due to invalid IL or missing references) //IL_048d: Unknown result type (might be due to invalid IL or missing references) //IL_0338: Unknown result type (might be due to invalid IL or missing references) //IL_033f: Unknown result type (might be due to invalid IL or missing references) //IL_0344: Unknown result type (might be due to invalid IL or missing references) //IL_0349: Unknown result type (might be due to invalid IL or missing references) //IL_034e: Unknown result type (might be due to invalid IL or missing references) //IL_0350: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_036b: Unknown result type (might be due to invalid IL or missing references) //IL_0372: Unknown result type (might be due to invalid IL or missing references) //IL_0379: Unknown result type (might be due to invalid IL or missing references) //IL_0380: Unknown result type (might be due to invalid IL or missing references) //IL_0385: Unknown result type (might be due to invalid IL or missing references) //IL_039d: Unknown result type (might be due to invalid IL or missing references) //IL_03a2: Unknown result type (might be due to invalid IL or missing references) //IL_0247: Unknown result type (might be due to invalid IL or missing references) //IL_024c: Unknown result type (might be due to invalid IL or missing references) //IL_04a6: Unknown result type (might be due to invalid IL or missing references) //IL_04ab: Unknown result type (might be due to invalid IL or missing references) //IL_04b6: Unknown result type (might be due to invalid IL or missing references) //IL_04de: Unknown result type (might be due to invalid IL or missing references) //IL_04e0: Unknown result type (might be due to invalid IL or missing references) //IL_04ec: Unknown result type (might be due to invalid IL or missing references) //IL_04f1: Unknown result type (might be due to invalid IL or missing references) //IL_04f6: Unknown result type (might be due to invalid IL or missing references) //IL_04fd: Unknown result type (might be due to invalid IL or missing references) //IL_0502: Unknown result type (might be due to invalid IL or missing references) AimMode aimMode = (rider.Lance ? AimMode.Lance : AimModeOf(animator)); float num = ((AimBlendTime.Value > 0f) ? (deltaTime / AimBlendTime.Value) : 1f); rider.AimWeight = Mathf.MoveTowards(rider.AimWeight, (aimMode != AimMode.None) ? 1f : 0f, num); bool local = ((Character)player).m_nview.IsOwner(); Vector3 val = (local ? ((Character)player).GetLookDir() : __instance.m_headLookDir); if (rider.AimWeight <= 0f || val == Vector3.zero) { return; } Transform val2 = AimBasis(player); Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)17); Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)18); AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); float blend = (local ? 1f : (1f - Mathf.Exp(-12f * deltaTime))); Vector2 val4; if (aimMode == AimMode.Lance) { Vector3 val3 = val2.InverseTransformDirection(val); float num2 = Mathf.Atan2(val3.x, val3.z) * 57.29578f; float y = val3.y; val4 = new Vector2(val3.x, val3.z); float num3 = Mathf.Atan2(y, ((Vector2)(ref val4)).magnitude) * 57.29578f; rider.AimYaw = Approach(rider.AimYaw, Mathf.Clamp(num2, 0f - LanceTurnLeft.Value, LanceTurnRight.Value)); rider.AimPitch = Approach(rider.AimPitch, Mathf.Clamp(num3, 0f - LancePitch.Value, LancePitch.Value)); rider.AimHeading = rider.AimYaw; } else if ((aimMode == AimMode.Ready || (uint)(aimMode - 3) <= 2u) ? true : false) { if (aimMode == AimMode.Ready && !animator.IsInTransition(0)) { rider.ChestYaw = Mathf.LerpAngle(rider.ChestYaw, ChestYaw(animator, val2), 1f - Mathf.Exp(-10f * deltaTime)); } ClampAim(val2, val, out var yaw, out var pitch); if (1 == 0) { } float num4 = aimMode switch { AimMode.Throw => ThrowTurn.Value, AimMode.Ranged => 1f, _ => MeleeTurn.Value, }; if (1 == 0) { } float num5 = num4; if (aimMode == AimMode.Ready) { pitch = 0f; } float num6 = ((aimMode == AimMode.Throw) ? 0f : rider.ChestYaw); rider.AimYaw = Approach(rider.AimYaw, Mathf.DeltaAngle(num6, yaw * num5)); rider.AimPitch = Approach(rider.AimPitch, pitch * num5); rider.AimHeading = yaw * num5; } else if ((Object)(object)boneTransform != (Object)null && (Object)(object)boneTransform2 != (Object)null && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash == s_bowAimState && !animator.IsInTransition(0)) { Vector3 val5 = val2.InverseTransformDirection(boneTransform.position - boneTransform2.position); float num7 = Mathf.Atan2(val5.x, val5.z) * 57.29578f; float y2 = val5.y; val4 = new Vector2(val5.x, val5.z); float num8 = Mathf.Atan2(y2, ((Vector2)(ref val4)).magnitude) * 57.29578f; ClampAim(val2, val, out var yaw2, out var pitch2); rider.AimYaw = Approach(rider.AimYaw, Mathf.DeltaAngle(num7, yaw2)); rider.AimPitch = Approach(rider.AimPitch, pitch2 - num8); rider.AimHeading = yaw2; } float num9 = rider.AimYaw * rider.AimWeight; float num10 = rider.AimPitch * rider.AimWeight; float num11 = 0f; (HumanBodyBones, float)[] twistChain = TwistChain; for (int i = 0; i < twistChain.Length; i++) { var (val6, num12) = twistChain[i]; if ((Object)(object)animator.GetBoneTransform(val6) != (Object)null) { num11 += num12; } } if (num11 <= 0f) { return; } Vector3 val7 = Quaternion.AngleAxis(rider.AimHeading, val2.up) * val2.right; (HumanBodyBones, float)[] twistChain2 = TwistChain; for (int j = 0; j < twistChain2.Length; j++) { (HumanBodyBones, float) tuple2 = twistChain2[j]; HumanBodyBones item = tuple2.Item1; float item2 = tuple2.Item2; Transform boneTransform3 = animator.GetBoneTransform(item); if (!((Object)(object)boneTransform3 == (Object)null)) { float num13 = item2 / num11; boneTransform3.rotation = Quaternion.AngleAxis((0f - num10) * num13, val7) * Quaternion.AngleAxis(num9 * num13, val2.up) * boneTransform3.rotation; } } float Approach(float current, float target) { return (local && BodyTurnSpeed.Value > 0f) ? Mathf.MoveTowards(current, target, BodyTurnSpeed.Value * deltaTime) : Mathf.Lerp(current, target, blend); } } } [HarmonyPatch(typeof(CharacterAnimEvent), "UpdateLookat")] private static class UpdateLookatPatch { private static void Postfix(CharacterAnimEvent __instance) { Character character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && s_riders.TryGetValue(val, out Rider value) && value.Mounted && !(value.AimWeight <= 0f)) { __instance.m_animator.SetLookAtWeight(__instance.m_lookAtWeight * (1f - value.AimWeight), 0f, __instance.m_headLookWeight, __instance.m_eyeLookWeight, __instance.m_lookClamp); } } } [HarmonyPatch(typeof(Player), "AutoPickup")] private static class AutoPickupPatch { [HarmonyPriority(800)] private static void Prefix(Player __instance, out float __state) { __state = __instance.m_autoPickupRange; if (Enabled.Value && IsRidingMount(__instance)) { __instance.m_autoPickupRange += PickupReach.Value + (RiderSeat(__instance)?.PickupReach ?? 0f); } } [HarmonyPriority(800)] private static void Finalizer(Player __instance, float __state) { __instance.m_autoPickupRange = __state; } } [HarmonyPatch(typeof(Attack), "GetProjectileSpawnPoint")] private static class GetProjectileSpawnPointPatch { private static void Postfix(Attack __instance, ref Vector3 spawnPoint, ref Vector3 aimDir) { //IL_0051: 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_0062: 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_0086: Unknown result type (might be due to invalid IL or missing references) //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Unknown result type (might be due to invalid IL or missing references) //IL_00ad: Unknown result type (might be due to invalid IL or missing references) //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00bb: 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_00f1: 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_0101: 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_010b: Unknown result type (might be due to invalid IL or missing references) Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && Enabled.Value && IsRidingMount(val)) { Transform val2 = AimBasis(val); if (__instance.m_attackAnimation == "spear_throw") { ClampAim(val2, ((Character)val).GetLookDir(), out var yaw, out var pitch); aimDir = val2.rotation * (Quaternion.Euler(0f - pitch, yaw * ThrowTurn.Value, 0f) * Vector3.forward); } else { aimDir = ClampAim(val2, __instance.m_useCharacterFacing ? ((Humanoid)val).GetAimDir(spawnPoint) : aimDir, out var _, out var _); } Transform boneTransform = ((Character)val).m_animator.GetBoneTransform((HumanBodyBones)(__instance.m_bowDraw ? 17 : 18)); if (!((Object)(object)boneTransform == (Object)null)) { spawnPoint = boneTransform.position + ((Vector3)(ref aimDir)).normalized * 0.4f; } } } } [HarmonyPatch(typeof(Attack), "GetMeleeAttackDir")] private static class GetMeleeAttackDirPatch { private static void Postfix(Attack __instance, ref Vector3 attackDir) { //IL_003c: 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_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005e: Unknown result type (might be due to invalid IL or missing references) //IL_0064: Unknown result type (might be due to invalid IL or missing references) //IL_006a: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_00a1: Unknown result type (might be due to invalid IL or missing references) //IL_00af: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00be: Unknown result type (might be due to invalid IL or missing references) //IL_00c3: Unknown result type (might be due to invalid IL or missing references) Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val != null && Enabled.Value && IsRidingMount(val)) { Transform val2 = AimBasis(val); ClampAim(val2, ((Character)val).GetLookDir(), out var yaw, out var _); Vector3 val3 = val2.InverseTransformDirection(((Character)val).GetLookDir()); float y = val3.y; Vector2 val4 = new Vector2(val3.x, val3.z); float num = Mathf.Clamp(Mathf.Atan2(y, ((Vector2)(ref val4)).magnitude) * 57.29578f, 0f - MeleeAimDown.Value, MeleeAimUp.Value); attackDir = val2.rotation * (Quaternion.Euler(0f - num, yaw, 0f) * Vector3.forward); } } } [HarmonyPatch(typeof(Attack), "Start")] private static class AttackStartPatch { private static void Postfix(Humanoid character, Rigidbody body) { //IL_0040: 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) Player val = (Player)(object)((character is Player) ? character : null); if (val != null && Enabled.Value && IsRidingMount(val) && !((Object)(object)val.m_attachPoint == (Object)null)) { ((Component)val).transform.rotation = val.m_attachPoint.rotation; if ((Object)(object)body != (Object)null) { body.rotation = val.m_attachPoint.rotation; } } } } [HarmonyPatch(typeof(Character), "RPC_Damage")] private static class RPC_DamagePatch { private static void Prefix(Character __instance, HitData hit) { if (!Enabled.Value) { return; } float num = 1f; Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null) { if (IsRidingMount(val)) { num = PlayerDamageTaken.Value; } } else if (__instance.IsTamed()) { Sadle componentInChildren = ((Component)__instance).GetComponentInChildren<Sadle>(); if (componentInChildren != null && (Object)(object)componentInChildren != (Object)null && componentInChildren.HaveValidUser() && MountInfo(componentInChildren).Combat) { num = MountDamageTaken.Value; } } if (!Mathf.Approximately(num, 1f)) { hit.ApplyModifier(num); } } } [HarmonyPatch(typeof(ZSyncAnimation), "RPC_SetTrigger")] private static class RPC_SetTriggerPatch { [HarmonyPriority(0)] private static void Postfix(ZSyncAnimation __instance, string name) { Player component = ((Component)__instance).GetComponent<Player>(); if (component != null && s_riders.TryGetValue(component, out Rider value) && value.Mounted) { Animator animator = ((Character)component).m_animator; if ((Object)(object)animator != (Object)null && ReclaimController(component, animator, value)) { animator.SetTrigger(name); } } } } [HarmonyPatch(typeof(FejdStartup), "Awake")] private static class CompatPatch { private static bool s_done; private static void Postfix() { //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00ab: Expected O, but got Unknown if (s_done || Harmony == null) { return; } s_done = true; s_windstrideDriver = FindType("QuickMod.BowString.BowDrawDriver"); if (s_windstrideDriver != null) { ManualLogSource? s_logger = MountedAttacks.s_logger; if (s_logger != null) { s_logger.LogInfo((object)"Windstride's Bow Animations found: its bow poses are paused while riding an Odin Horse."); } } MethodInfo methodInfo = FindType("DualWield.DualWield")?.GetMethod("FastReplaceRAC", BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic); if (!(methodInfo == null)) { Harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(AccessTools.Method(typeof(CompatPatch), "SkipWhileMounted", (Type[])null, (Type[])null)), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null); ManualLogSource? s_logger2 = MountedAttacks.s_logger; if (s_logger2 != null) { s_logger2.LogInfo((object)"DualWield found: its animation swaps are paused while riding an Odin Horse."); } } } private static bool SkipWhileMounted(Player player) { return !IsMounted((Character)(object)player); } private static Type? FindType(string fullName) { Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies(); foreach (Assembly assembly in assemblies) { Type type = assembly.GetType(fullName, throwOnError: false); if ((object)type != null) { return type; } } return null; } } [HarmonyPatch(typeof(Attack), "DoMeleeAttack")] private static class DoMeleeAttackPatch { private static void Prefix(Attack __instance, out float __state) { __state = __instance.m_attackRange; Humanoid character = __instance.m_character; Player val = (Player)(object)((character is Player) ? character : null); if (val == null || !Enabled.Value || !IsRidingMount(val)) { return; } float attackRange = __instance.m_attackRange; float num = MeleeReachBonus.Value + (RiderSeat(val)?.MeleeReach ?? 0f); float num2; if (__instance.m_weapon != null) { WeaponFamily weaponFamily = FamilyOf(__instance.m_weapon, __instance); if (weaponFamily != null) { ConfigEntry<float> reach = weaponFamily.Reach; if (reach != null) { num2 = reach.Value; goto IL_0088; } } } num2 = 0f; goto IL_0088; IL_0088: __instance.m_attackRange = attackRange + (num + num2); } private static void Finalizer(Attack __instance, float __state) { __instance.m_attackRange = __state; } } [HarmonyPatch(typeof(Humanoid), "GetAimDir")] private static class GetAimDirPatch { private static void Postfix(Humanoid __instance, ref Vector3 __result) { //IL_002c: 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_003a: Unknown result type (might be due to invalid IL or missing references) Player val = (Player)(object)((__instance is Player) ? __instance : null); if (val != null && Enabled.Value && IsRidingMount(val)) { __result = ClampAim(AimBasis(val), __result, out var _, out var _); } } } [HarmonyPatch(typeof(Character), "CanMove")] private static class CanMovePatch { private static void Postfix(Character __instance, ref bool __result) { if (!__result && !((Object)(object)__instance != (Object)(object)s_seatedAttacker)) { __result = !__instance.IsStaggering() && __instance.GetNextOrCurrentAnimHash() == Character.s_animatorTagSitting; } } } [HarmonyPatch(typeof(Player), "AttachStop")] private static class AttachStopPatch { private static void Prefix(Player __instance) { if (__instance.m_attached && s_riders.TryGetValue(__instance, out Rider value) && (value.HoldingAttach || value.Redirected)) { if (!string.IsNullOrEmpty(__instance.m_attachAnimation)) { ((Character)__instance).m_animator.SetBool(__instance.m_attachAnimation, true); } value.HoldingAttach = false; } } } internal static ConfigEntry<bool> Enabled = null; internal static ConfigEntry<float> BowTurnLeft = null; internal static ConfigEntry<float> BowTurnRight = null; internal static ConfigEntry<float> BowPitch = null; internal static ConfigEntry<float> MeleeTurn = null; internal static ConfigEntry<float> ThrowTurn = null; internal static ConfigEntry<float> LanceTurnRight = null; internal static ConfigEntry<float> LanceTurnLeft = null; internal static ConfigEntry<float> LancePitch = null; internal static ConfigEntry<bool> LanceUnhorse = null; internal static ConfigEntry<float> LanceUnhorsePower = null; internal static ConfigEntry<float> LanceStaminaDrain = null; internal static ConfigEntry<float> LanceHitInterval = null; internal static ConfigEntry<float> LanceMinSpeed = null; internal static ConfigEntry<float> LanceFullSpeed = null; internal static ConfigEntry<float> LanceMaxPower = null; internal static ConfigEntry<float> LanceChargeDamage = null; internal static ConfigEntry<float> LanceChargePush = null; internal static ConfigEntry<float> BodyTurnSpeed = null; internal static ConfigEntry<float> AimBlendTime = null; internal static ConfigEntry<float> MeleeReachBonus = null; internal static ConfigEntry<float> MeleeAimDown = null; internal static ConfigEntry<float> MeleeAimUp = null; internal static ConfigEntry<float> PickupReach = null; internal static ConfigEntry<bool> HideCape = null; internal static ConfigEntry<float> PlayerDamageTaken = null; internal static ConfigEntry<float> MountDamageTaken = null; private static Dictionary<string, MountSeat> s_seats = new Dictionary<string, MountSeat>(); private static int s_mountsVersion; private static Dictionary<string, MountSeat> s_ymlSeats = new Dictionary<string, MountSeat>(); private static readonly Dictionary<string, MountSeat> s_registeredSeats = new Dictionary<string, MountSeat>(); private static readonly ConditionalWeakTable<Sadle, MountOf> s_saddleMounts = new ConditionalWeakTable<Sadle, MountOf>(); private static readonly int s_mountSeatKey = StringExtensionMethods.GetStableHashCode("OdinMountedCombat_MountSeat"); private static readonly int s_mountRideKey = StringExtensionMethods.GetStableHashCode("OdinMountedCombat_MountRide"); private static readonly int s_mountKeepKey = StringExtensionMethods.GetStableHashCode("OdinMountedCombat_MountKeepRide"); private const float ReturnToRideFade = 0.2f; private const int ZSyncSalt = 438569; private static readonly int s_mountedKey = StringExtensionMethods.GetStableHashCode("OdinMountedCombat_MountedAttacks"); private static readonly int s_attachLox = ZSyncAnimation.GetHash("attach_lox"); private static readonly int s_rideLox = Animator.StringToHash("Base Layer.RideLox"); private static readonly int s_movement = Animator.StringToHash("Base Layer.Movement"); private static readonly int s_bowAimState = Animator.StringToHash("Base Layer.bow aim"); private static readonly int s_bowFireState = Animator.StringToHash("Base Layer.bow fire"); private static readonly int s_spearThrowState = Animator.StringToHash("Base Layer.spear_throw"); private static readonly int s_crossbowFireState = Animator.StringToHash("Base Layer.crossbow fire"); private static readonly int s_blocking = ZSyncAnimation.GetHash("blocking"); private static readonly Dictionary<int, int> BlockStates = new Dictionary<int, int> { { 0, Animator.StringToHash("Base Layer.Unarmed Blocking") }, { 1, Animator.StringToHash("Base Layer.One handed Blocking") }, { 2, Animator.StringToHash("Base Layer.Two handed blocking") }, { 3, Animator.StringToHash("Base Layer.Bow blocking") }, { 4, Animator.StringToHash("Base Layer.Shield blocking") }, { 5, Animator.StringToHash("Base Layer.One handed Blocking") }, { 6, Animator.StringToHash("Base Layer.Shield blocking") }, { 7, Animator.StringToHash("Base Layer.Atgeir Blocking") }, { 8, Animator.StringToHash("Base Layer.Battleaxe Blocking") }, { 10, Animator.StringToHash("Base Layer.Crossbow Blocking") }, { 11, Animator.StringToHash("Base Layer.Dual Wield Blocking") }, { 12, Animator.StringToHash("Base Layer.Staff Blocking") }, { 13, Animator.StringToHash("Base Layer.Two handed blocking") }, { 14, Animator.StringToHash("Base Layer.One handed Blocking") }, { 15, Animator.StringToHash("Base Layer.Dual Wield Blocking") } }; private static readonly HashSet<int> BlockStateHashes = new HashSet<int>(BlockStates.Values); private const float AimSmoothing = 12f; private const float ChestYawSmoothing = 10f; private static readonly (HumanBodyBones bone, float share)[] TwistChain = new(HumanBodyBones, float)[3] { ((HumanBodyBones)7, 0.3f), ((HumanBodyBones)8, 0.3f), ((HumanBodyBones)54, 0.4f) }; private static readonly int s_bowAim = ZSyncAnimation.GetHash("bow_aim"); private static readonly int s_attackTag = Animator.StringToHash("attack"); private static readonly Dictionary<string, string> ClipMap = new Dictionary<string, string> { { "Attack1", "Mounted_Attack1_2" }, { "Attack2", "Mounted_Attack2" }, { "Attack3", "Mounted_Attack3" }, { "Sword-Attack-R4", "Mounted_Sword-Attack-R4" }, { "axe_swing", "Mounted_axe_swing" }, { "Axe combo 2", "Mounted_Axe_combo_2" }, { "Axe combo 3", "Mounted_Axe_combo_3" }, { "Axe Secondary Attack", "Mounted_Axe_Secondary_Attack" }, { "MaceAltAttack", "Mounted_MaceAltAttack" }, { "Javelin Stab", "Mounted_Javelin_Stab" }, { "throw_spear", "Mounted_throw_spear" }, { "Bow Aim Idle 01", "Mounted_Bow_Aim_Idle_01" }, { "Bow Aim Walk Forward", "Mounted_Bow_Aim_Idle_01" }, { "Bow Aim Walk Back", "Mounted_Bow_Aim_Idle_01" }, { "Bow Aim Walk Left", "Mounted_Bow_Aim_Idle_01" }, { "Bow Aim Walk Right", "Mounted_Bow_Aim_Idle_01" }, { "Bow Aim Recoil", "Mounted_Bow_Aim_Recoil" }, { "Fire Crossbow", "Mounted_Fire_Crossbow" }, { "Reload Crossbow", "Mounted_Reload_Crossbow" } }; private static readonly (string prefix, string mounted)[] BlockFamilies = new(string, string)[14] { ("Block idle", "Mounted_Block_idle"), ("Block TwoHand ", "Mounted_Block_idle"), ("Block Atgeir ", "Mounted_Block_idle"), ("Sword And Shield Idle", "Mounted_Sword_And_Shield_Idle"), ("Block Shield ", "Mounted_Sword_And_Shield_Idle"), ("fight idle", "Mounted_fight_idle"), ("Block Unarmed ", "Mounted_fight_idle"), ("Block Bow ", "Mounted_Block_Bow_Idle"), ("Crossbow Idle Block", "Mounted_Crossbow_Idle_Block"), ("Block Crossbow ", "Mounted_Crossbow_Idle_Block"), ("Knife Idle Block", "Mounted_Knife_Idle_Block"), ("Block DualWield ", "Mounted_Knife_Idle_Block"), ("Block Idle Staff", "Mounted_Block_Idle_Staff"), ("Block Staff ", "Mounted_Block_Idle_Staff") }; internal static readonly WeaponFamily[] Families = new WeaponFamily[20] { new WeaponFamily("Swords", "one-handed swords", "Attack1_2", "Attack2", "Attack3", "Sword-Attack-R4") { DefaultReach = 0f, Original = true }, new WeaponFamily("Axes", "one-handed axes", "axe_swing", "Axe combo 2", "Axe combo 3", "Axe Secondary Attack") { DefaultReach = 0f, Original = true }, new WeaponFamily("Clubs", "clubs and maces", "Attack1_2", "Attack2", "Attack3", "MaceAltAttack") { DefaultReach = 0f, Original = true }, new WeaponFamily("Spears", "spears (stab and throw)", "Javelin Stab", "throw_spear") { DefaultReach = 0f, Original = true }, new WeaponFamily("Knives", "knives", "knife_slash0", "knife_slash1", "knife_slash2", "Knife JumpAttack") { DefaultReach = 0.75f }, new WeaponFamily("Torches", "torches", "Attack1_2", "Attack2", "Attack3") { DefaultReach = 0.25f, Original = true }, new WeaponFamily("Fists", "bare fists", "Punchstep 1_0", "Punchstep 2_0", "Kickstep") { DefaultReach = 0.75f }, new WeaponFamily("Greatswords", "two-handed swords", "Greatsword BaseAttack (1)", "Greatsword BaseAttack (2)", "Greatsword BaseAttack (3)", "Greatsword Secondary Attack") { DefaultReach = 0f }, new WeaponFamily("Battleaxes", "battleaxes", "BattleAxe1", "BattleAxe2", "BattleAxe_Combo3", "BattleAxeAltAttack") { DefaultReach = 0f }, new WeaponFamily("Sledges", "sledges and two-handed clubs", "Sledge-Attack1") { DefaultReach = 0f }, new WeaponFamily("Atgeirs", "atgeirs", "2Hand-Spear-Attack1", "2Hand-Spear-Attack9", "2Hand-Spear-Attack3", "Atgeir360Attack") { DefaultReach = 0f }, new WeaponFamily("Dual Axes", "dual axes", "DualAxes Attack 1", "DualAxes Attack 2 2", "DualAxes Attack 3 2", "DualAxes Attack 4", "DualAxes Attack Cleave") { DefaultReach = 0.25f }, new WeaponFamily("Dual Knives", "dual knives", "Knife Attack Combo (1)", "Knife Attack Combo (2)", "Knife Attack Combo (3)", "Knife Attack Leap") { DefaultReach = 0.75f }, new WeaponFamily("Bows", "bows", "Bow Aim Idle 01", "Bow Aim Recoil") { Original = true }, new WeaponFamily("Crossbows", "crossbows", "Fire Crossbow", "Reload Crossbow") { Original = true }, new WeaponFamily("Elemental Staffs", "elemental magic staffs (fire, frost, lightning, beam)", "Fireball Staff Attacks (1)", "Fireball Staff Attacks (2)", "FrostShield", "Thunderstruck", "Lightning Staff Attack", "Fire Crossbow", "Beam Staff Attack", "Beam Staff Attack Loop", "Beam Staff Attack 2 FW"), new WeaponFamily("Blood Magic Staffs", "blood magic staffs (shield and summons)", "Ground Staff Attack", "Skeleton Summon", "Troll Summon"), new WeaponFamily("Pickaxes", "pickaxes", "swing_pickaxe") { DefaultReach = 0.25f }, new WeaponFamily("Tools", "scythes and shovels", "Scything", "Attack Shovel 1 Upperbody", "Attack Shovel 2 Upperbody", "Attack Shovel 3", "Attack Shovel Secondary") { DefaultReach = 0.25f }, new WeaponFamily("Bombs", "thrown bombs", "BombThrow") }; private const string BowDrawState = "bow_aim"; private static readonly Dictionary<int, string> RideVariants = new Dictionary<int, string> { { 1, "1H" }, { 4, "Shield" }, { 5, "1H" }, { 6, "Shield" }, { 3, "Bow" }, { 2, "TwoHanded" }, { 7, "Atgeir" }, { 8, "Battleaxe" }, { 10, "Crossbow" }, { 11, "DualWield" }, { 12, "Staff" }, { 13, "Greatsword" }, { 14, "MagicItem" }, { 15, "DualWield" }, { 16, "Feaster" }, { 17, "Scythe" } }; private static readonly string[] RideClips = new string[3] { "Riding_Idle", "Riding_Walk", "Riding_Canter" }; private const string PlainVariant = "Plain"; private static readonly HashSet<string> s_lanceNames = new HashSet<string>(); private static readonly HashSet<int> s_lanceItems = new HashSet<int>(); private static readonly int s_lanceCouchKey = StringExtensionMethods.GetStableHashCode("OdinMountedCombat_LanceCouched"); private const string LanceBlockClip = "Mounted_Lance_Block"; private const string LanceLowerClip = "Mounted_Lance_Lower"; private const string LanceRaiseClip = "Mounted_Lance_Raise"; private const float MountedClothVelocity = 0.25f; private const float MountedClothAcceleration = 0.1f; private const float ClothScanInterval = 1f; private const float MountedProjectileLead = 0.4f; private static readonly int s_statei = ZSyncAnimation.GetHash("statei"); private static readonly HumanBodyBones[] PoseBones; private static readonly Dictionary<string, AnimationClip> s_clips; private static readonly Dictionary<(RuntimeAnimatorController, string?), AnimatorOverrideController> s_overrides; private static readonly ConditionalWeakTable<Player, Rider> s_riders; private static Player? s_seatedAttacker; private static Player? s_drawingRider; internal static Harmony? Harmony; private static ManualLogSource? s_logger; private static readonly HashSet<int> ReadyStates; private static Type? s_windstrideDriver; private static readonly List<Renderer> s_capeRenderers; internal const string ChargeClip = "Lance_Charge"; private const string KnifeLeapClip = "Knife JumpAttack"; private static readonly Dictionary<(RuntimeAnimatorController, string), AnimatorOverrideController> s_footOverrides; private const float LanceHitReach = 0.45f; private const float LanceHitRadius = 0.3f; private static readonly Collider[] s_lanceOverlap; private static int s_lanceMask; private const string UnhorseRpc = "OdinMountedCombat_Unhorse"; private const float UnhorsePush = 12f; private static bool LanceReady => LanceTurnRight != null; internal static void SetSeats(string yml) { s_ymlSeats = MountSeatsFile.Parse(yml); RebuildSeats(); } internal static void RegisterMount(MountSeat seat) { s_registeredSeats[seat.Name] = seat; RebuildSeats(); } private static void RebuildSeats() { Dictionary<string, MountSeat> dictionary = new Dictionary<string, MountSeat>(s_ymlSeats); foreach (KeyValuePair<string, MountSeat> s_registeredSeat in s_registeredSeats) { if (!dictionary.ContainsKey(s_registeredSeat.Key)) { dictionary[s_registeredSeat.Key] = s_registeredSeat.Value; } } s_seats = dictionary; s_mountsVersion++; } private static MountSeat? RiderSeat(Player player) { Rider value; return s_riders.TryGetValue(player, out value) ? value.Seat : null; } private static MountSeat? SeatByHash(int hash) { if (hash == 0) { return null; } foreach (MountSeat value in s_seats.Values) { if (value.Hash == hash) { return value; } } return null; } private static MountOf MountInfo(Sadle sadle) { MountOf orCreateValue = s_saddleMounts.GetOrCreateValue(sadle); if (orCreateValue.Version == s_mountsVersion) { return orCreateValue; } orCreateValue.Version = s_mountsVersion; Character character = sadle.GetCharacter(); string name = (((Object)(object)character != (Object)null) ? ((Object)((Component)character).gameObject).name : ""); MountSeat mountSeat = (from s in s_seats.Values where name.Contains(s.Name) orderby s.Name.Length descending select s).FirstOrDefault(); orCreateValue.Combat = mountSeat != null; orCreateValue.Seat = (orCreateValue.Combat ? mountSeat : null); return orCreateValue; } private static int RideStateFor(string attach) { string text = (attach.StartsWith("attach_") ? attach.Substring(7) : attach); return (text.Length == 0) ? s_rideLox : Animator.StringToHash("Base Layer.Ride" + char.ToUpperInvariant(text[0]) + text.Substring(1)); } private static string? BlockClipFor(string vanillaClip) { (string, string)[] blockFamilies = BlockFamilies; for (int i = 0; i < blockFamilies.Length; i++) { var (value, result) = blockFamilies[i]; if (vanillaClip.StartsWith(value, StringComparison.Ordinal)) { return result; } } return null; } private static WeaponFamily? Family(string name) { return Families.FirstOrDefault((WeaponFamily f) => f.Name == name); } private static string GameClipName(string projectName) { return Regex.Replace(projectName, "_[0-9]+$", ""); } private static string MountedClipName(string projectName) { return "Mounted_" + projectName.Replace(" ", "_"); } private static WeaponFamily? FamilyOf(ItemData weapon, Attack attack) { //IL_0017: Unknown result type (might be due to invalid IL or missing references) //IL_001c: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Invalid comparison between Unknown and I4 //IL_014d: Unknown result type (might be due to invalid IL or missing references) //IL_0150: Invalid comparison between Unknown and I4 //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0215: Invalid comparison between Unknown and I4 //IL_0217: Unknown result type (might be due to invalid IL or missing references) //IL_0219: Invalid comparison between Unknown and I4 //IL_021b: Unknown result type (might be due to invalid IL or missing references) //IL_021d: Invalid comparison between Unknown and I4 //IL_021f: Unknown result type (might be due to invalid IL or missing references) //IL_0221: Invalid comparison between Unknown and I4 string text = attack.m_attackAnimation ?? ""; SkillType skillType = weapon.m_shared.m_skillType; string text2; if (text.StartsWith("dual_knives")) { text2 = "Dual Knives"; } else { string text3; if (text.StartsWith("knife")) { text3 = "Knives"; } else { string text4; if (text.StartsWith("dualaxes")) { text4 = "Dual Axes"; } else { string text5; if (text.StartsWith("greatsword")) { text5 = "Greatswords"; } else { string text6; if (text.StartsWith("battleaxe")) { text6 = "Battleaxes"; } else { string text7; if (text == "swing_sledge") { text7 = "Sledges"; } else { string text8; if (text.StartsWith("atgeir")) { text8 = "Atgeirs"; } else { string text9; if (text.StartsWith("unarmed")) { text9 = "Fists"; } else { string text10; if (text == "swing_pickaxe") { text10 = "Pickaxes"; } else { string text11; if (text == "scything" || text.StartsWith("shovel")) { text11 = "Tools"; } else { string text12; if (text == "throw_bomb") { text12 = "Bombs"; } else { string text13; if ((int)skillType == 10) { text13 = "Blood Magic Staffs"; } else { string text14; if ((int)skillType == 9 || text.StartsWith("staff")) { text14 = "Elemental Staffs"; } else { string text15; if (text == "bow_fire") { text15 = "Bows"; } else { string text16; if (text == "crossbow_fire") { text16 = "Crossbows"; } else { string text17; if (text.StartsWith("spear")) { text17 = "Spears"; } else { bool flag; switch (text) { case "swing_longsword": case "sword_secondary": case "swing_axe": case "axe_secondary": case "mace_secondary": flag = true; break; default: flag = false; break; } text17 = ((!flag) ? null : (((int)weapon.m_shared.m_itemType == 15) ? "Torches" : (((int)skillType == 7) ? "Axes" : (((int)skillType == 3) ? "Clubs" : (((int)skillType == 2) ? "Knives" : "Swords"))))); } text16 = text17; } text15 = text16; } text14 = text15; } text13 = text14; } text12 = text13; } text11 = text12; } text10 = text11; } text9 = text10; } text8 = text9; } text7 = text8; } text6 = text7; } text5 = text6; } text4 = text5; } text3 = text4; } text2 = text3; } string text18 = text2; return (text18 == null) ? null : Family(text18); } private static void UpdateFamilies() { WeaponFamily[] families = Families; foreach (WeaponFamily weaponFamily in families) { string[] clips = weaponFamily.Clips; foreach (string projectName in clips) { ClipMap[GameClipName(projectName)] = MountedClipName(projectName); } weaponFamily.Available = weaponFamily.Clips.All((string c) => s_clips.ContainsKey(MountedClipName(c))); } } internal static void RegisterLance(string prefabName) { s_lanceNames.Add(prefabName); s_lanceItems.Add(StringExtensionMethods.GetStableHashCode(prefabName)); } private static void RestoreAnimatedPose(Animator animator, Rider rider) { //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_00a4: Unknown result type (might be due to invalid IL or missing references) //IL_00aa: 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_006b: 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_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d3: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) for (int i = 0; i < PoseBones.Length; i++) { Transform boneTransform = animator.GetBoneTransform(PoseBones[i]); if (!((Object)(object)boneTransform == (Object)null)) { if (rider.Wrote && boneTransform.localRotation == rider.WrittenLocal[i]) { boneTransform.localRotation = rider.AnimatedLocal[i]; } else { rider.AnimatedLocal[i] = boneTransform.localRotation; } } } Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)0); if ((Object)(object)boneTransform2 != (Object)null) { if (rider.Wrote && boneTransform2.localPosition == rider.WrittenHips) { boneTransform2.localPosition = rider.AnimatedHips; } else { rider.AnimatedHips = boneTransform2.localPosition; } } rider.Wrote = false; } internal static void Init(AssetBundle? bundle, ManualLogSource logger) { s_logger = logger; LoadClips(bundle); } internal static void LoadClips(AssetBundle? bundle) { UpdateFamilies(); if ((Object)(object)bundle != (Object)null) { LoadClipsFrom(bundle); } UpdateFamilies(); string[] array = (from f in Families where !f.Available select f.Name).ToArray(); if (array.Length != 0) { ManualLogSource? obj = s_logger; if (obj != null) { obj.LogInfo((object)("No mounted clips yet for: " + string.Join(", ", array) + ". Attacking with those dismounts, as in vanilla.")); } } } private static void LoadClipsFrom(AssetBundle bundle) { foreach (string item in ClipMap.Values.Concat(BlockFamilies.Select(((string prefix, string mounted) f) => f.mounted)).Distinct()) { if (!s_clips.ContainsKey(item)) { AnimationClip val = bundle.LoadAsset<AnimationClip>(item); if ((Object)(object)val != (Object)null) { s_clips[item] = val; } } } foreach (string item2 in RideVariants.Values.Append("Plain")) { string[] rideClips = RideClips; foreach (string rideClip in rideClips) { string text = RidePoseName(rideClip, item2); if (!s_clips.ContainsKey(text)) { AnimationClip val2 = bundle.LoadAsset<AnimationClip>(text); if ((Object)(object)val2 != (Object)null) { s_clips[text] = val2; } } } } List<string> list = new List<string> { "Mounted_Lance_Block" }; string[] array = new string[2] { "", "Shield" }; foreach (string text2 in array) { string[] rideClips2 = RideClips; foreach (string rideClip2 in rideClips2) { list.Add(RidePoseName(rideClip2, "Lance" + text2)); list.Add(RidePoseName(rideClip2, "LanceCouched" + text2)); } list.Add(LanceTransitionClip("Mounted_Lance_Lower", text2)); list.Add(LanceTransitionClip("Mounted_Lance_Raise", text2)); } foreach (string item3 in list) { if (!s_clips.ContainsKey(item3)) { AnimationClip val3 = bundle.LoadAsset<AnimationClip>(item3); if ((Object)(object)val3 != (Object)null) { s_clips[item3] = val3; } } } string[] array2 = new string[2] { "Lance_Charge", "Lance_Charge_Shield" }; foreach (string text3 in array2) { if (!s_clips.ContainsKey(text3)) { AnimationClip val4 = bundle.LoadAsset<AnimationClip>(text3); if ((Object)(object)val4 != (Object)null) { s_clips[text3] = val4; } } } } private static string LanceTransitionClip(string clip, string shield) { return (shield == "") ? clip : (clip + "_" + shield); } private static string RideClipFor(string rideClip, string variant) { if (1 == 0) { } string result = variant switch { "LanceLower" => "Mounted_Lance_Lower", "LanceLowerShield" => LanceTransitionClip("Mounted_Lance_Lower", "Shield"), "LanceRaise" => "Mounted_Lance_Raise", "LanceRaiseShield" => LanceTransitionClip("Mounted_Lance_Raise", "Shield"), _ => s_clips.ContainsKey(RidePoseName(rideClip, variant)) ? RidePoseName(rideClip, variant) : RidePoseName(rideClip, "Plain"), }; if (1 == 0) { } return result; } private static string? BlockClipFor(string vanillaClip, string? variant) { string text = BlockClipFor(vanillaClip); if (text == null || variant == null || !variant.StartsWith("Lance", StringComparison.Ordinal)) { return text; } return variant.EndsWith("Shield", StringComparison.Ordinal) ? "Mounted_Lance_Block" : RidePoseName(RideClips[0], "Lance"); } private static string RidePoseName(string rideClip, string variant) { return "Mounted_" + rideClip + "_" + variant; } private static Transform AimBasis(Player player) { return ((Object)(object)player.m_attachPoint != (Object)null) ? player.m_attachPoint : ((Component)player).transform; } private static bool IsRidingMount(Player player) { return (Object)(object)RiddenMount(player) != (Object)null; } private static Sadle? RiddenMount(Player player) { if (player.m_attached) { IDoodadController doodadController = player.GetDoodadController(); Sadle val = (Sadle)(object)((doodadController is Sadle) ? doodadController : null); if (val != null && !((Object)(object)val == (Object)null) && !((Object)(object)val.GetCharacter() == (Object)null)) { return MountInfo(val).Combat ? val : null; } } return null; } private static bool HasMountedAttack(Humanoid humanoid, bool secondary) { ItemData currentWeapon = humanoid.GetCurrentWeapon(); if (currentWeapon == null) { return false; } Attack val = (secondary ? currentWeapon.m_shared.m_secondaryAttack : currentWeapon.m_shared.m_attack); if (val != null) { WeaponFamily weaponFamily = FamilyOf(currentWeapon, val); if (weaponFamily != null && weaponFamily.Available) { ConfigEntry<bool> enabled = weaponFamily.Enabled; if (enabled == null || enabled.Value) { return !val.m_bowDraw || val.m_drawAnimationState == "bow_aim"; } } } return false; } private static bool HoldsLance(Humanoid humanoid) { int result; if (LanceReady) { ItemData rightItem = humanoid.GetRightItem(); if (rightItem != null) { GameObject dropPrefab = rightItem.m_dropPrefab; if (dropPrefab != null) { result = (s_lanceNames.Contains(((Object)dropPrefab).name) ? 1 : 0); goto IL_002e; } } } result = 0; goto IL_002e; IL_002e: return (byte)result != 0; } private static bool IsMounted(Character character) { Player val = (Player)(object)((character is Player) ? character : null); Rider value; return val != null && s_riders.TryGetValue(val, out value) && value.Mounted; } private static AimMode AimModeOf(Animator animator) { //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_001a: Unknown result type (might be due to invalid IL or missing references) AnimatorStateInfo val = (animator.IsInTransition(0) ? animator.GetNextAnimatorStateInfo(0) : animator.GetCurrentAnimatorStateInfo(0)); if (((AnimatorStateInfo)(ref val)).fullPathHash == s_bowAimState || ((AnimatorStateInfo)(ref val)).fullPathHash == s_bowFireState) { return AimMode.Bow; } if (((AnimatorStateInfo)(ref val)).fullPathHash == s_spearThrowState) { return AimMode.Throw; } if (((AnimatorStateInfo)(ref val)).fullPathHash == s_crossbowFireState) { return AimMode.Ranged; } if (((AnimatorStateInfo)(ref val)).tagHash == s_attackTag && animator.GetInteger(s_statei) == 12) { return AimMode.Ranged; } if (((AnimatorStateInfo)(ref val)).tagHash == s_attackTag) { return AimMode.Melee; } return ReadyStates.Contains(animator.GetInteger(s_statei)) ? AimMode.Ready : AimMode.None; } private static Vector3 ClampAim(Transform body, Vector3 dir, out float yaw, out float pitch) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0003: Unknown result type (might be due to invalid IL or missing references) //IL_0008: Unknown result type (might be due to invalid IL or missing references) //IL_000a: 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_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_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_0057: Unknown result type (might be due to invalid IL or missing references) //IL_0085: 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_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a3: 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_00ab: Unknown result type (might be due to invalid IL or missing references) Vector3 val = body.InverseTransformDirection(dir); yaw = Mathf.Clamp(Mathf.Atan2(val.x, val.z) * 57.29578f, 0f - BowTurnLeft.Value, BowTurnRight.Value); Vector2 val2 = new Vector2(val.x, val.z); float magnitude = ((Vector2)(ref val2)).magnitude; pitch = Mathf.Clamp(Mathf.Atan2(val.y, magnitude) * 57.29578f, 0f - BowPitch.Value, BowPitch.Value); return body.rotation * (Quaternion.Euler(0f - pitch, yaw, 0f) * Vector3.forward); } private static float ChestYaw(Animator animator, Transform basis) { //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0040: Unknown result type (might be due to invalid IL or missing references) //IL_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_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) Transform boneTransform = animator.GetBoneTransform((HumanBodyBones)13); Transform boneTransform2 = animator.GetBoneTransform((HumanBodyBones)14); if ((Object)(object)boneTransform == (Object)null || (Object)(object)boneTransform2 == (Object)null) { return 0f; } Vector3 val = basis.InverseTransformDirection(boneTransform2.position - boneTransform.position); return Mathf.Atan2(0f - val.z, val.x) * 57.29578f; } private static bool HoldsRide(AnimatorStateInfo state) { return ((AnimatorStateInfo)(ref state)).tagHash == s_attackTag || ((AnimatorStateInfo)(ref state)).fullPathHash == s_bowAimState || BlockStateHashes.Contains(((AnimatorStateInfo)(ref state)).fullPathHash); } private static AnimatorOverrideController GetOverride(RuntimeAnimatorController original, string? variant) { //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_0066: Expected O, but got Unknown if (s_overrides.TryGetValue((original, variant), out AnimatorOverrideController value) && (Object)(object)value != (Object)null) { return value; } AnimatorOverrideController val = (AnimatorOverrideController)(object)((original is AnimatorOverrideController) ? original : null); RuntimeAnimatorController val2 = (RuntimeAnimatorController)((val != null) ? ((object)val.runtimeAnimatorController) : ((object)original)); AnimatorOverrideController val3 = new AnimatorOverrideController(val2) { name = ((Object)original).name + " (OdinHorse mounted " + variant + ")" }; List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(val3.overridesCount); ((AnimatorOverrideController)(((object)((original is AnimatorOverrideController) ? original : null)) ?? ((object)val3))).GetOverrides(list); for (int i = 0; i < list.Count; i++) { AnimationClip key = list[i].Key; if (!((Object)(object)key == (Object)null)) { string value2; string text = (ClipMap.TryGetValue(((Object)key).name, out value2) ? value2 : ((variant != null && RideClips.Contains(((Object)key).name)) ? RideClipFor(((Object)key).name, variant) : BlockClipFor(((Object)key).name, variant))); if (text != null && s_clips.TryGetValue(text, out AnimationClip value3)) { list[i] = new KeyValuePair<AnimationClip, AnimationClip>(key, value3); } } } val3.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list); return s_overrides[(original, variant)] = val3; } private static void SetController(Animator animator, RuntimeAnimatorController controller, Rider? restore = null) { //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_0049: Unknown result type (might be due to invalid IL or missing references) //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0062: Expected I4, but got Unknown //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_011b: Unknown result type (might be due to invalid IL or missing references) //IL_0120: Unknown result type (might be due to invalid IL or missing references) //IL_0122: 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_0126: Unknown result type (might be due to invalid IL or missing references) //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_013f: Expected I4, but got Unknown if ((Object)(object)animator.runtimeAnimatorController == (Object)(object)controller) { return; } AnimatorControllerParameter[] parameters = animator.parameters; float[] array = new float[parameters.Length]; for (int i = 0; i < parameters.Length; i++) { AnimatorControllerParameter val = parameters[i]; float[] array2 = array; int num = i; AnimatorControllerParameterType type = val.type; if (1 == 0) { } float num2 = (type - 1) switch { 3 => animator.GetBool(val.nameHash) ? 1f : 0f, 0 => animator.GetFloat(val.nameHash), 2 => animator.GetInteger(val.nameHash), _ => 0f, }; if (1 == 0) { } array2[num] = num2; } AnimatorStateInfo[] array3 = (AnimatorStateInfo[])(object)new AnimatorStateInfo[animator.layerCount]; for (int j = 0; j < array3.Length; j++) { array3[j] = animator.GetCurrentAnimatorStateInfo(j); } animator.runtimeAnimatorController = controller; for (int k = 0; k < parameters.Length; k++) { AnimatorControllerParameter val2 = parameters[k]; AnimatorControllerParameterType type2 = val2.type; AnimatorControllerParameterType val3 = type2; switch (val3 - 1) { case 3: animator.SetBool(val2.nameHash, array[k] > 0f); break; case 0: animator.SetFloat(val2.nameHash, array[k]); break; case 2: animator.SetInteger(val2.nameHash, (int)array[k]); break; } } for (int l = 0; l < Mathf.Min(array3.Length, animator.layerCount); l++) { if (restore?.GoodStates != null && l < restore.GoodStates.Length) { animator.Play(restore.GoodStates[l], l, restore.GoodTimes[l]); } else { animator.Play(((AnimatorStateInfo)(ref array3[l])).fullPathHash, l, ((AnimatorStateInfo)(ref array3[l])).normalizedTime); } } animator.Update(0f); } private static void PausePoseDriver(Player player, Rider rider) { if (!(s_windstrideDriver == null)) { Component component = ((Component)player).GetComponent(s_windstrideDriver); Behaviour val = (Behaviour)(object)((component is Behaviour) ? component : null); if (val != null && val.enabled) { val.enabled = false; rider.PausedPoseDriver = val; } } } private static void ResumePoseDriver(Rider rider) { if ((Object)(object)rider.PausedPoseDriver != (Object)null) { rider.PausedPoseDriver.enabled = true; } rider.PausedPoseDriver = null; } private static bool IsOurController(RuntimeAnimatorController? controller) { AnimatorOverrideController val = (AnimatorOverrideController)(object)((controller is AnimatorOverrideController) ? controller : null); return val != null && s_overrides.ContainsValue(val); } private static void RememberGoodPose(Animator animator, Rider rider) { //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Unknown result type (might be due to invalid IL or missing references) int layerCount = animator.layerCount; if (rider.GoodStates == null || rider.GoodStates.Length != layerCount) { rider.GoodStates = new int[layerCount]; rider.GoodTimes = new float[layerCount]; } for (int i = 0; i < layerCount; i++) { AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(i); rider.GoodStates[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash; rider.GoodTimes[i] = ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime; } } private static bool ReclaimController(Player player, Animator animator, Rider rider) { if ((Object)(object)rider.Original == (Object)null) { return false; } RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController; if (IsOurController(runtimeAnimatorController) || (Object)(object)runtimeAnimatorController == (Object)(object)rider.Original) { return false; } SetController(animator, (RuntimeAnimatorController)(object)GetOverride(rider.Original, rider.KeepRide ? rider.Variant : (rider.Variant ?? "Plain")), rider); return true; } private static void CalmCloth(Player player, Rider rider, float dt) { rider.ClothScanTimer -= dt; if (rider.ClothScanTimer > 0f) { return; } rider.ClothScanTimer = 1f; Cloth[] componentsInChildren = ((Component)player).GetComponentsInChildren<Cloth>(); foreach (Cloth val in componentsInChildren) { if (!rider.CalmedCloth.ContainsKey(val)) { rider.CalmedCloth[val] = (val.worldVelocityScale, val.worldAccelerationScale); val.worldVelocityScale *= 0.25f; val.worldAccelerationScale *= 0.1f; } } } private static void HideCapeOf(Player player, Rider rider) { List<GameObject> list = (((Object)(object)((Humanoid)player).m_visEquipment != (Object)null) ? ((Humanoid)player).m_visEquipment.m_shoulderItemInstances : null); if (list == null) { return; } foreach (GameObject item in list) { if ((Object)(object)item == (Object)null) { continue; } item.GetComponentsInChildren<Renderer>(s_capeRenderers); foreach (Renderer s_capeRenderer in s_capeRenderers) { if (s_capeRenderer.enabled) { s_capeRenderer.enabled = false; rider.HiddenCape.Add(s_capeRenderer); } } } } private static void ShowCape(Rider rider) { foreach (Renderer item in rider.HiddenCape) { if ((Object)(object)item != (Object)null) { item.enabled = true; } } rider.HiddenCape.Clear(); } private static void RestoreCloth(Rider rider) { foreach (KeyValuePair<Cloth, (float, float)> item in rider.CalmedCloth) { if (!((Object)(object)item.Key == (Object)null)) { item.Key.worldVelocityScale = item.Value.Item1; item.Key.worldAccelerationScale = item.Value.Item2; } } rider.CalmedCloth.Clear(); rider.ClothScanTimer = 0f; } private static void Tick(Player player) { //IL_04ed: Unknown result type (might be due to invalid IL or missing references) //IL_04f2: Unknown result type (might be due to invalid IL or missing references) //IL_050f: Unknown result type (might be due to invalid IL or missing references) //IL_0503: Unknown result type (might be due to invalid IL or missing references) //IL_0509: Unknown result type (might be due to invalid IL or missing references) //IL_0514: Unknown result type (might be due to invalid IL or missing references) //IL_047c: Unknown result type (might be due to invalid IL or missing references) //IL_0481: Unknown result type (might be due to invalid IL or missing references) //IL_05f9: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_05b8: Unknown result type (might be due to invalid IL or missing references) ZNetView nview = ((Character)player).m_nview; Animator animator = ((Character)player).m_animator; if ((Object)(object)nview == (Object)null || !nview.IsValid() || (Object)(object)animator == (Object)null) { return; } ZDO zDO = nview.GetZDO(); Rider orCreateValue = s_riders.GetOrCreateValue(player); bool flag; if (nview.IsOwner()) { Sadle val = (Enabled.Value ? RiddenMount(player) : null); MountSeat mountSeat = (((Object)(object)val != (Object)null) ? MountInfo(val).Seat : null); flag = (Object)(object)val != (Object)null; string text = (((Object)(object)val != (Object)null) ? val.m_attachAnimation : ""); int num = ((flag && !string.IsNullOrEmpty(text) && text != "attach_lox") ? ZSyncAnimation.GetHash(text) : 0); if (zDO.GetBool(s_mountedKey, false) != flag) { zDO.Set(s_mountedKey, flag); } if (zDO.GetInt(s_mountSeatKey, 0) != (mountSeat?.Hash ?? 0)) { zDO.Set(s_mountSeatKey, mountSeat?.Hash ?? 0, false); } if (zDO.GetInt(s_mountRideKey, 0) != num) { zDO.Set(s_mountRideKey, num, false); } int num2 = ((flag && mountSeat != null && mountSeat.KeepRidingAnimation) ? RideStateFor(text) : 0); if (zDO.GetInt(s_mountKeepKey, 0) != num2) { zDO.Set(s_mountKeepKey, num2, false); } } else { flag = zDO.GetBool(s_mountedKey, false); } orCreateValue.Seat = (flag ? SeatByHash(zDO.GetInt(s_mountSeatKey, 0)) : null); if (flag != orCreateValue.Mounted) { if (flag) { RestoreFoot(animator, orCreateValue); orCreateValue.Original = animator.runtimeAnimatorController; orCreateValue.RideParam = zDO.GetInt(s_mountRideKey, 0); int num3 = zDO.GetInt(s_mountKeepKey, 0); orCreateValue.KeepRide = num3 != 0; orCreateValue.RideBool = ((orCreateValue.KeepRide && orCreateValue.RideParam != 0) ? orCreateValue.RideParam : s_attachLox); orCreateValue.RideState = (orCreateValue.KeepRide ? num3 : s_rideLox); } else if ((Object)(object)orCreateValue.Original != (Object)null) { if (orCreateValue.Redirected) { animator.SetBool(s_attachLox, false); } orCreateValue.RideParam = 0; orCreateValue.KeepRide = false; SetController(animator, orCreateValue.Original); RestoreCloth(orCreateValue); ResumePoseDriver(orCreateValue); ShowCape(orCreateValue); orCreateValue.Original = null; } orCreateValue.Mounted = flag; orCreateValue.HoldingAttach = false; orCreateValue.LanceStage = LanceStage.Raised; orCreateValue.LanceTime = 0f; orCreateValue.LanceInput = false; } if (!flag) { FootLance(player, animator, orCreateValue); if (nview.IsOwner()) { FootChargeStrike(player, orCreateValue); } } else { if ((Object)(object)orCreateValue.Original == (Object)null) { return; } CalmCloth(player, orCreateValue, Time.deltaTime); PausePoseDriver(player, orCreateValue); if (HideCape.Value) { HideCapeOf(player, orCreateValue); } else if (orCreateValue.HiddenCape.Count > 0) { ShowCape(orCreateValue); } LanceStage lanceStage = orCreateValue.LanceStage; string value; AnimatorOverrideController val2 = GetOverride(variant: orCreateValue.Variant = LanceVariant(player, animator, orCreateValue, zDO, nview.IsOwner(), Time.deltaTime) ?? (orCreateValue.KeepRide ? null : (RideVariants.TryGetValue(animator.GetInteger(s_statei), out value) ? value : "Plain")), original: orCreateValue.Original); AnimatorStateInfo val3; if ((Object)(object)animator.runtimeAnimatorController != (Object)(object)val2) { RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController; bool flag2 = !IsOurController(runtimeAnimatorController) && (Object)(object)runtimeAnimatorController != (Object)(object)orCreateValue.Original; SetController(animator, (RuntimeAnimatorController)(object)val2, flag2 ? orCreateValue : null); if (orCreateValue.Lance && orCreateValue.LanceStage != lanceStage) { val3 = animator.GetCurrentAnimatorStateInfo(0); if (((AnimatorStateInfo)(ref val3)).fullPathHash == orCreateValue.RideState) { animator.Play(orCreateValue.RideState, 0, LanceRideTime(orCreateValue)); animator.Update(0f); } } } RememberGoodPose(animator, orCreateValue); if (orCreateValue.Lance && nview.IsOwner()) { LanceStrike(player, orCreateValue); } AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0); bool flag3 = animator.IsInTransition(0); AnimatorStateInfo val4; if (!flag3) { val3 = default(AnimatorStateInfo); val4 = val3; } else { val4 = animator.GetNextAnimatorStateInfo(0); } AnimatorStateInfo state = val4; if (!flag3 && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash == orCreateValue.RideState && animator.GetBool(s_bowAim)) { animator.CrossFadeInFixedTime(s_bowAimState, 0.2f, 0); } else if (!flag3 && ((AnimatorStateInfo)(ref currentAnimatorStateInfo)).fullPathHash == orCreateValue.RideState && animator.GetBool(s_blocking)) { animator.CrossFadeInFixedTime(BlockStates.TryGetValue(animator.GetInteger(s_statei), out var value2) ? value2 : BlockStates[0], 0.2f, 0); } else if (flag3 && HoldsRide(currentAnimatorStateInfo) && ((AnimatorStateInfo)(ref state)).fullPathHash == s_movement) { animator.CrossFadeInFixedTime(orCreateValue.RideState, 0.2f, 0); } bool flag4 = (flag3 ? HoldsRide(state) : HoldsRide(currentAnimatorStateInfo)); if (orCreateValue.Redirected) { animator.SetBool(orCreateValue.RideParam, false); } if (flag4) { animator.SetBool(orCreateValue.RideBool, false); orCreateValue.HoldingAttach = true; } else if (orCreateValue.Redirected) { animator.SetBool(s_attachLox, true); orCreateValue.HoldingAttach = false; } else if (orCreateValue.HoldingAttach) { animator.SetBool(orCreateValue.RideBool, zDO.GetInt(438569 + orCreateValue.RideBool, 0) != 0); orCreateValue.HoldingAttach = false; } } } private static void FootLance(Player player, Animator animator, Rider rider) { bool flag = LanceReady && (Object)(object)((Humanoid)player).m_visEquipment != (Object)null && s_lanceItems.Contains(((Humanoid)player).m_visEquipment.m_rightItem); int integer = animator.GetInteger(s_statei); string text = ((integer == 4 || integer == 6) ? "Lance_Charge_Shield" : "Lance_Charge"); if (!flag || !s_clips.ContainsKey(text)) { RestoreFoot(animator, rider); return; } RuntimeAnimatorController runtimeAnimatorController = animator.runtimeAnimatorController; if ((Object)(object)runtimeAnimatorController == (Object)null) { return; } if (!IsFootController(runtimeAnimatorController)) { rider.FootOriginal = runtimeAnimatorController; } if (!((Object)(object)rider.FootOriginal == (Object)null)) { AnimatorOverrideController footOverride = GetFootOverride(rider.FootOriginal, text); if ((Object)(object)runtimeAnimatorController != (Object)(object)footOverride) { SetController(animator, (RuntimeAnimatorController)(object)footOverride); } } } private static bool IsFootController(RuntimeAnimatorController? controller) { AnimatorOverrideController val = (AnimatorOverrideController)(object)((controller is AnimatorOverrideController) ? controller : null); return val != null && s_footOverrides.ContainsValue(val); } private static void RestoreFoot(Animator animator, Rider rider) { if (!((Object)(object)rider.FootOriginal == (Object)null)) { if (IsFootController(animator.runtimeAnimatorController)) { SetController(animator, rider.FootOriginal); } rider.FootOriginal = null; } } private static AnimatorOverrideController GetFootOverride(RuntimeAnimatorController original, string clipName) { //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_0066: Expected O, but got Unknown if (s_footOverrides.TryGetValue((original, clipName), out AnimatorOverrideController value) && (Object)(object)value != (Object)null) { return value; } AnimatorOverrideController val = (AnimatorOverrideController)(object)((original is AnimatorOverrideController) ? original : null); RuntimeAnimatorController val2 = (RuntimeAnimatorController)((val != null) ? ((object)val.runtimeAnimatorController) : ((object)original)); AnimatorOverrideController val3 = new AnimatorOverrideController(val2) { name = ((Object)original).name + " (OdinHorse " + clipName + ")" }; List<KeyValuePair<AnimationClip, AnimationClip>> list = new List<KeyValuePair<AnimationClip, AnimationClip>>(val3.overridesCount); ((AnimatorOverrideController)(((object)((original is AnimatorOverrideController) ? original : null)) ?? ((object)val3))).GetOverrides(list); for (int i = 0; i < list.Count; i++) { if ((Object)(object)list[i].Key != (Object)null && ((Object)list[i].Key).name == "Knife JumpAttack") { list[i] = new KeyValuePair<AnimationClip, AnimationClip>(list[i].Key, s_clips[clipName]); } } val3.ApplyOverrides((IList<KeyValuePair<AnimationClip, AnimationClip>>)list); return s_footOverrides[(original, clipName)] = val3; } private static string? LanceVariant(Player player, Animator animator, Rider rider, ZDO zdo, bool owner, float dt) { rider.Lance = LanceReady && (Object)(object)((Humanoid)player).m_visEquipment != (Object)null && s_lanceItems.Contains(((Humanoid)player).m_visEquipment.m_rightItem); if (!rider.Lance) { rider.LanceStage = LanceStage.Raised; rider.LanceTime = 0f; return null; } bool flag; if (owner) { flag = rider.LanceInput; if (zdo.GetBool(s_lanceCouchKey, false) != flag) { zdo.Set(s_lanceCouchKey, flag); } } else { flag = zdo.GetBool(s_lanceCouchKey, false); } float num = LanceMoveTime(); switch (rider.LanceStage) { case LanceStage.Raised: if (flag) { rider.LanceStage = LanceStage.Lowering; rider.LanceTime = 0f; } break; case LanceStage.Couched: if (!flag) { rider.LanceStage = LanceStage.Raising; rider.LanceTime = 0f; } break; case LanceStage.Lowering: if (!flag) { rider.LanceStage = LanceStage.Raising; rider.LanceTime = Mathf.Max(0f, num - rider.LanceTime); } break; case LanceStage.Raising: if (flag) { rider.LanceStage = LanceStage.Lowering; rider.LanceTime = Mathf.Max(0f, num - rider.LanceTime); } break; } LanceStage lanceStage = rider.LanceStage; if ((lanceStage == LanceStage.Lowering || lanceStage == LanceStage.Raising) ? true : false) { rider.LanceTime += dt; if (rider.LanceTime >= num) { rider.LanceStage = ((rider.LanceStage == LanceStage.Lowering) ? LanceStage.Couched : LanceStage.Raised); } } int integer = animator.GetInteger(s_statei); string text = ((integer == 4 || integer == 6) ? "Shield" : ""); LanceStage lanceStage2 = rider.LanceStage; if (1 == 0) { } string result = lanceStage2 switch { LanceStage.Lowering => "LanceLower" + text, LanceStage.Couched => "LanceCouched" + text, LanceStage.Raising => "LanceRaise" + text, _ => "Lance" + text, }; if (1 == 0) { } return result; } private static void LanceStrike(Player player, Rider rider) { //IL_00d7: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: 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_00e3: Unknown result type (might be due to invalid IL