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 Just Vault v1.0.1
JustVault.dll
Decompiled 2 days agousing System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using Jotunn.Utils; using TMPro; using UnityEngine; using UnityEngine.UI; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")] [assembly: AssemblyCompany("JustVault")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("JustVault")] [assembly: AssemblyTitle("JustVault")] [assembly: AssemblyVersion("1.0.0.0")] namespace JustVault; [HarmonyPatch] internal static class PlayerAwakePatch { private static MethodBase TargetMethod() { return AccessTools.Method(typeof(Player), "Awake", (Type[])null, (Type[])null); } private static void Postfix(Player __instance) { if ((Object)(object)((Component)__instance).GetComponent<VaultController>() == (Object)null) { ((Component)__instance).gameObject.AddComponent<VaultController>(); } } } [HarmonyPatch(typeof(Player), "SetControls")] internal static class PlayerControlsPatch { private static void Prefix(Player __instance, ref Vector3 movedir, ref bool attack, ref bool attackHold, ref bool secondaryAttack, ref bool secondaryAttackHold, ref bool block, ref bool blockHold, ref bool jump, ref bool crouch, ref bool run, ref bool autoRun, ref bool dodge) { //IL_001a: Unknown result type (might be due to invalid IL or missing references) //IL_001f: Unknown result type (might be due to invalid IL or missing references) VaultController component = ((Component)__instance).GetComponent<VaultController>(); if (!((Object)(object)component == (Object)null) && component.IsVaulting) { movedir = Vector3.zero; attack = false; attackHold = false; secondaryAttack = false; secondaryAttackHold = false; block = false; blockHold = false; jump = false; crouch = false; run = false; autoRun = false; dodge = false; } } } [HarmonyPatch(typeof(Character), "Jump")] internal static class JumpPatch { private static bool Prefix(Character __instance) { Player val = (Player)(object)((__instance is Player) ? __instance : null); if ((Object)(object)val == (Object)null) { return true; } VaultController component = ((Component)val).GetComponent<VaultController>(); if (!((Object)(object)component == (Object)null)) { return !component.IsVaulting; } return true; } } [HarmonyPatch(typeof(Player), "CanMove")] internal static class CanMovePatch { private static void Postfix(Player __instance, ref bool __result) { VaultController component = ((Component)__instance).GetComponent<VaultController>(); if ((Object)(object)component != (Object)null && component.IsVaulting) { __result = false; } } } [HarmonyPatch(typeof(ZInput), "Save")] internal static class VaultKeybindConfigPatch { private static readonly MethodInfo KeyCodeToPathMethod = AccessTools.Method(typeof(ZInput), "KeyCodeToPath", new Type[2] { typeof(KeyCode), typeof(bool) }, (Type[])null); private static void Postfix() { //IL_0069: Unknown result type (might be due to invalid IL or missing references) //IL_006e: Unknown result type (might be due to invalid IL or missing references) //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0072: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Invalid comparison between Unknown and I4 //IL_0088: 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) try { if (ZInput.instance == null || Plugin.VaultButton == null || Plugin.VaultKey == null || KeyCodeToPathMethod == null) { return; } ButtonDef buttonDef = ZInput.instance.GetButtonDef(Plugin.VaultButton.Name); if (buttonDef == null) { return; } string actionPath = buttonDef.GetActionPath(true); foreach (KeyCode value in Enum.GetValues(typeof(KeyCode))) { if ((int)value != 0 && (int)value < 330 && string.Equals((string)KeyCodeToPathMethod.Invoke(null, new object[2] { (object)value, false }), actionPath, StringComparison.OrdinalIgnoreCase)) { Plugin.SaveVaultKey(value); return; } } Plugin.LogWarning("Could not save vault binding with unsupported input path: " + actionPath); } catch (Exception ex) { Plugin.LogWarning("Could not save vault binding to config: " + ex); } } } [HarmonyPatch] internal static class ControlsSettingsPatch { private static readonly Type SettingsType = AccessTools.TypeByName("Valheim.SettingsGui.KeyboardMouseSettings"); private static readonly Type KeySettingType = AccessTools.TypeByName("Valheim.SettingsGui.KeySetting"); private static MethodBase TargetMethod() { if (!(SettingsType == null)) { return AccessTools.Method(SettingsType, "Initialize", (Type[])null, (Type[])null); } return null; } private static void Prefix(object __instance) { //IL_00e0: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Unknown result type (might be due to invalid IL or missing references) //IL_016b: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Unknown result type (might be due to invalid IL or missing references) //IL_017b: Unknown result type (might be due to invalid IL or missing references) if (Plugin.VaultButton == null || KeySettingType == null) { return; } FieldInfo fieldInfo = AccessTools.Field(SettingsType, "m_keys"); FieldInfo fieldInfo2 = AccessTools.Field(SettingsType, "m_keyRows"); IList list = ((fieldInfo == null) ? null : (fieldInfo.GetValue(__instance) as IList)); if (list == null || list.Count < 2) { return; } string name = Plugin.VaultButton.Name; string text = "Joy!" + Plugin.VaultButton.Name; bool flag = ContainsAction(list, name); bool flag2 = ContainsAction(list, text); if (flag && flag2) { return; } int num = ((fieldInfo2 == null) ? list.Count : ((int)fieldInfo2.GetValue(__instance))); int num2 = Mathf.Clamp(num - 1, 1, list.Count - 1); object template = list[num2]; object previous = list[num2 - 1]; Vector2 rowStep = Vector2.zero; object obj = (flag ? null : CloneSetting(template, previous, name, "$vault_control_keyboard", insertAfterTemplate: true, out rowStep)); if (obj != null) { list.Insert(num2 + 1, obj); } object template2 = list[list.Count - 1]; object previous2 = list[list.Count - 2]; Vector2 rowStep2 = Vector2.zero; object obj2 = (flag2 ? null : CloneSetting(template2, previous2, text, "$vault_control_gamepad", insertAfterTemplate: false, out rowStep2)); if (obj2 != null) { list.Add(obj2); } if (obj != null || obj2 != null) { if (rowStep == Vector2.zero) { rowStep = rowStep2; } if (fieldInfo2 != null) { fieldInfo2.SetValue(__instance, num + 1); } Plugin.LogInfo("Added keyboard and gamepad vault bindings to Controls; actions: " + name + ", " + text); } } private static void Postfix(object __instance) { MonoBehaviour val = (MonoBehaviour)((__instance is MonoBehaviour) ? __instance : null); if ((Object)(object)val != (Object)null && (Object)(object)Plugin.Instance != (Object)null) { ((MonoBehaviour)Plugin.Instance).StartCoroutine(EnableBindingsScrollAfterLayout(val)); } } private static IEnumerator EnableBindingsScrollAfterLayout(MonoBehaviour settings) { while ((Object)(object)settings != (Object)null && !((Component)settings).gameObject.activeInHierarchy) { yield return null; } if (!((Object)(object)settings == (Object)null)) { yield return null; Canvas.ForceUpdateCanvases(); FieldInfo fieldInfo = AccessTools.Field(SettingsType, "m_keys"); FieldInfo columnsField = AccessTools.Field(SettingsType, "m_keyCols"); IList keys = ((fieldInfo == null) ? null : (fieldInfo.GetValue(settings) as IList)); if (keys != null && keys.Count != 0) { MakeBindingsScrollable(keys[0], GetColumnCount(settings, columnsField)); yield return (object)new WaitForEndOfFrame(); MakeBindingsScrollable(keys[0], GetColumnCount(settings, columnsField)); } } } private static int GetColumnCount(object settings, FieldInfo columnsField) { if (!(columnsField == null)) { return Mathf.Max(1, (int)columnsField.GetValue(settings)); } return 2; } private static bool ContainsAction(IList keys, string action) { FieldInfo fieldInfo = AccessTools.Field(KeySettingType, "m_keyName"); for (int i = 0; i < keys.Count; i++) { if ((string)fieldInfo.GetValue(keys[i]) == action) { return true; } } return false; } private static object CloneSetting(object template, object previous, string action, string labelToken, bool insertAfterTemplate, out Vector2 rowStep) { //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0053: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) //IL_005d: 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_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) rowStep = Vector2.zero; FieldInfo fieldInfo = AccessTools.Field(KeySettingType, "m_keyTransform"); object? value = fieldInfo.GetValue(template); RectTransform val = (RectTransform)((value is RectTransform) ? value : null); object? value2 = fieldInfo.GetValue(previous); RectTransform val2 = (RectTransform)((value2 is RectTransform) ? value2 : null); if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null) { return null; } rowStep = val.anchoredPosition - val2.anchoredPosition; GameObject obj = Object.Instantiate<GameObject>(((Component)val).gameObject, ((Transform)val).parent); ((Object)obj).name = "JustVaultControl_" + action; RectTransform component = obj.GetComponent<RectTransform>(); component.anchoredPosition = val.anchoredPosition + rowStep; if (insertAfterTemplate) { ((Transform)component).SetSiblingIndex(((Transform)val).GetSiblingIndex() + 1); } Button componentInChildren = obj.GetComponentInChildren<Button>(true); TMP_Text[] componentsInChildren = obj.GetComponentsInChildren<TMP_Text>(true); for (int i = 0; i < componentsInChildren.Length; i++) { if ((Object)(object)componentInChildren == (Object)null || !componentsInChildren[i].transform.IsChildOf(((Component)componentInChildren).transform)) { componentsInChildren[i].text = Localization.instance.Localize(labelToken); break; } } object obj2 = Activator.CreateInstance(KeySettingType); AccessTools.Field(KeySettingType, "m_keyName").SetValue(obj2, action); fieldInfo.SetValue(obj2, component); AccessTools.Field(KeySettingType, "m_blockedButtons").SetValue(obj2, new KeyCode[0]); return obj2; } private static void MakeBindingsScrollable(object template, int columnCount) { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0084: 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_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_0165: 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_0111: 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) object? value = AccessTools.Field(KeySettingType, "m_keyTransform").GetValue(template); RectTransform val = (RectTransform)((value is RectTransform) ? value : null); if ((Object)(object)val == (Object)null) { return; } ScrollRect componentInParent = ((Component)val).GetComponentInParent<ScrollRect>(); RectTransform val2 = (RectTransform)(((Object)(object)componentInParent == (Object)null) ? ((object)/*isinst with value type is only supported in some contexts*/) : ((object)componentInParent.content)); if ((Object)(object)val2 == (Object)null) { return; } GridLayoutGroup component = ((Component)val2).GetComponent<GridLayoutGroup>(); float num = 1f; Rect rect = val2.rect; float num2 = ((Rect)(ref rect)).height; if ((Object)(object)component != (Object)null) { num = Mathf.Max(1f, component.cellSize.y + component.spacing.y); int num3 = 0; for (int i = 0; i < ((Transform)val2).childCount; i++) { Transform child = ((Transform)val2).GetChild(i); LayoutElement component2 = ((Component)child).GetComponent<LayoutElement>(); if (((Component)child).gameObject.activeSelf && ((Object)(object)component2 == (Object)null || !component2.ignoreLayout)) { num3++; } } int num4 = Mathf.CeilToInt((float)num3 / (float)Mathf.Max(1, columnCount)); num2 = (float)((LayoutGroup)component).padding.vertical + (float)num4 * component.cellSize.y + (float)Mathf.Max(0, num4 - 1) * component.spacing.y; } float height; if (!((Object)(object)componentInParent != (Object)null) || !((Object)(object)componentInParent.viewport != (Object)null)) { rect = val2.rect; height = ((Rect)(ref rect)).height; } else { rect = componentInParent.viewport.rect; height = ((Rect)(ref rect)).height; } float num5 = height; float num6 = Mathf.Max(num2, num5 + num); val2.SetSizeWithCurrentAnchors((Axis)1, num6); if (!((Object)(object)componentInParent == (Object)null)) { ((Behaviour)componentInParent).enabled = true; componentInParent.vertical = true; componentInParent.scrollSensitivity = Mathf.Max(componentInParent.scrollSensitivity, num); componentInParent.verticalScrollbarVisibility = (ScrollbarVisibility)0; if ((Object)(object)componentInParent.verticalScrollbar != (Object)null) { ((Component)componentInParent.verticalScrollbar).transform.SetAsLastSibling(); ((Component)componentInParent.verticalScrollbar).gameObject.SetActive(true); } LayoutRebuilder.ForceRebuildLayoutImmediate(val2); Canvas.ForceUpdateCanvases(); componentInParent.StopMovement(); componentInParent.verticalNormalizedPosition = 1f; } } } [BepInPlugin("com.igentuman.justvault", "Just Vault", "1.0.1")] [BepInDependency(/*Could not decode attribute arguments.*/)] [NetworkCompatibility(/*Could not decode attribute arguments.*/)] public sealed class Plugin : BaseUnityPlugin { public const string PluginGuid = "com.igentuman.justvault"; public const string PluginName = "Just Vault"; public const string PluginVersion = "1.0.1"; internal static ConfigEntry<float> ForwardCheckDistance; internal static ConfigEntry<int> ForwardRayCount; internal static ConfigEntry<float> ForwardRayHeightStep; internal static ConfigEntry<float> MinVaultHeight; internal static ConfigEntry<float> MaxVaultHeight; internal static ConfigEntry<float> StandClearance; internal static ConfigEntry<float> PlayerRadius; internal static ConfigEntry<float> VaultStartDelay; internal static ConfigEntry<float> VaultDuration; internal static ConfigEntry<float> VaultEaseExponent; internal static ConfigEntry<float> EmoteCancelDelay; internal static ConfigEntry<bool> DebugVisuals; internal static ConfigEntry<float> StaminaCost; internal static ConfigEntry<KeyCode> VaultKey; private Harmony _harmony; internal static ButtonConfig VaultButton { get; private set; } internal static Plugin Instance { get; private set; } private void Awake() { //IL_0011: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0043: Expected O, but got Unknown //IL_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown Instance = this; BindConfiguration(); AddLocalization(); VaultButton = new ButtonConfig { Name = "JustVaultVault", Config = VaultKey, GamepadButton = (GamepadButton)7, HintToken = "$vault_action" }; InputManager.Instance.AddButton("com.igentuman.justvault", VaultButton); _harmony = new Harmony("com.igentuman.justvault"); _harmony.PatchAll(); ((BaseUnityPlugin)this).Logger.LogInfo((object)"JustVault loaded"); } internal static void LogInfo(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogInfo((object)message); } } internal static void LogWarning(string message) { if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Logger.LogWarning((object)message); } } internal unsafe static void SaveVaultKey(KeyCode key) { //IL_000d: 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_001d: Unknown result type (might be due to invalid IL or missing references) if (VaultKey != null) { bool num = VaultKey.Value != key; VaultKey.Value = key; if ((Object)(object)Instance != (Object)null) { ((BaseUnityPlugin)Instance).Config.Save(); } if (num) { LogInfo("Saved vault keybind to config: " + ((object)(*(KeyCode*)(&key))/*cast due to .constrained prefix*/).ToString()); } } } private void Update() { Player localPlayer = Player.m_localPlayer; if (!((Object)(object)localPlayer == (Object)null) && VaultButton != null && ZInput.GetButtonDown(VaultButton.Name)) { VaultController component = ((Component)localPlayer).GetComponent<VaultController>(); if ((Object)(object)component != (Object)null) { component.TryVault(); } } } private void OnDestroy() { if (_harmony != null) { _harmony.UnpatchSelf(); } Instance = null; } private void BindConfiguration() { //IL_006c: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected O, but got Unknown VaultKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Controls", "Vault key", (KeyCode)118, "Keyboard or mouse button used to vault. Changes made in Valheim's Controls menu are saved here."); ForwardCheckDistance = Bind("Detection", "Forward check distance", 1.3f, 0.2f, 3f, "Distance in meters to check in front of the player for a vaultable object."); ForwardRayCount = ((BaseUnityPlugin)this).Config.Bind<int>("Detection", "Forward ray count", 6, new ConfigDescription("Number of forward rays scanned from eye height upward (first hit wins).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 6), Array.Empty<object>())); ForwardRayHeightStep = Bind("Detection", "Forward ray height step", 0.15f, 0.05f, 1f, "Vertical spacing in meters between each forward ray, starting at eye level."); MinVaultHeight = Bind("Detection", "Minimum vault height", 0.05f, 0f, 0.5f, "Minimum height difference required between the player's feet and the landing spot."); MaxVaultHeight = Bind("Detection", "Maximum vault height", 2f, 0.1f, 3f, "How far above the player's eye level the landing spot is allowed to be."); StandClearance = Bind("Detection", "Stand clearance", 1.9f, 1f, 3f, "Vertical space required above the landing spot for the player to stand."); PlayerRadius = Bind("Detection", "Player radius", 0.1f, 0.1f, 1f, "Radius used when checking for standing room at the landing spot."); VaultStartDelay = Bind("Vaulting", "Start delay", 0.5f, 0f, 2f, "Seconds to wait after the emote starts (hands raising) before the player begins moving to the landing spot."); VaultDuration = Bind("Vaulting", "Duration", 0.8f, 0.1f, 3f, "Seconds it takes to move the player from the start to the landing spot, once movement begins."); VaultEaseExponent = Bind("Vaulting", "Ease exponent", 3f, 1f, 6f, "Shapes the pull motion: 1 = linear, higher = a sharper initial pull that eases out near the landing spot."); EmoteCancelDelay = Bind("Vaulting", "Emote cancel delay", 0.5f, 0.05f, 3f, "Seconds after the emote starts before it's cancelled so the hands lower again; usually matches the start delay."); DebugVisuals = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Show debug visuals", false, "Draws the vault raycasts/points in-world and logs failure reasons to the BepInEx console."); StaminaCost = Bind("Vaulting", "Stamina cost", 5f, 0f, 100f, "Stamina consumed by a successful vault. Checked before running the vault checks, but only spent once a valid landing spot is found."); } private ConfigEntry<float> Bind(string section, string key, float value, float min, float max, string description) { //IL_0019: Unknown result type (might be due to invalid IL or missing references) //IL_0023: Expected O, but got Unknown return ((BaseUnityPlugin)this).Config.Bind<float>(section, key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>())); } private static void AddLocalization() { CustomLocalization localization = LocalizationManager.Instance.GetLocalization(); string text = "English"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "vault_action", "Vault" }, { "vault_control_keyboard", "Vault (keyboard)" }, { "vault_control_gamepad", "Vault (gamepad)" }, { "vault_fail", "You can't vault here." }, { "vault_no_stamina", "Not enough stamina to vault." } }); text = "Russian"; localization.AddTranslation(ref text, new Dictionary<string, string> { { "vault_action", "Перелезть" }, { "vault_control_keyboard", "Перелезть (клавиатура)" }, { "vault_control_gamepad", "Перелезть (геймпад)" }, { "vault_fail", "Здесь нельзя перелезть." }, { "vault_no_stamina", "Недостаточно выносливости, чтобы перелезть." } }); } } internal sealed class VaultController : MonoBehaviour { private static readonly FieldInfo BodyField = AccessTools.Field(typeof(Character), "m_body"); private static readonly FieldInfo EyeField = AccessTools.Field(typeof(Character), "m_eye"); private static readonly MethodInfo StopEmoteMethod = AccessTools.Method(typeof(Player), "StopEmote", (Type[])null, (Type[])null); private static readonly int VaultLayerMask = LayerMask.GetMask(new string[6] { "Default", "static_solid", "Default_small", "piece", "terrain", "vehicle" }); private const float FallbackEyeHeight = 1.7f; private Player _player; private Rigidbody _body; private bool _vaulting; private bool _emotePending; private bool _wasKinematic; private float _vaultElapsed; private float _emoteTimer; private Vector3 _vaultStart; private Vector3 _vaultTarget; internal bool IsVaulting => _vaulting; private void Awake() { _player = ((Component)this).GetComponent<Player>(); _body = (Rigidbody)((BodyField != null) ? /*isinst with value type is only supported in some contexts*/: null); } private void Update() { if (!((Object)(object)_player == (Object)null) && !((Object)(object)_player != (Object)(object)Player.m_localPlayer) && _vaulting) { UpdateVault(Time.deltaTime); } } private void OnDestroy() { if (_vaulting) { CancelVault(); } } internal void TryVault() { //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00e1: Unknown result type (might be due to invalid IL or missing references) //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00e8: Unknown result type (might be due to invalid IL or missing references) //IL_0136: Unknown result type (might be due to invalid IL or missing references) if (_vaulting) { return; } if (((Character)_player).IsDead() || ((Character)_player).IsTeleporting() || ((Character)_player).InCutscene() || ((Character)_player).InBed() || ((Character)_player).IsAttached() || ((Character)_player).InAttack() || !((Character)_player).CanMove()) { Show("$vault_fail"); return; } if (_player.GetStamina() < Plugin.StaminaCost.Value) { Show("$vault_no_stamina"); return; } if (!TryFindLandingPoint(out var landingPoint)) { Show("$vault_fail"); return; } ((Character)_player).UseStamina(Plugin.StaminaCost.Value); _player.StartEmote("loveyou", true); _vaultStart = ((Component)_player).transform.position; _vaultTarget = landingPoint; _vaultElapsed = 0f; _emoteTimer = 0f; _emotePending = true; _vaulting = true; if ((Object)(object)_body != (Object)null) { _wasKinematic = _body.isKinematic; _body.velocity = Vector3.zero; _body.isKinematic = true; } } private bool TryFindLandingPoint(out Vector3 landingPoint) { //IL_0001: 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_0017: Unknown result type (might be due to invalid IL or missing references) //IL_0046: Unknown result type (might be due to invalid IL or missing references) //IL_004b: 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_0056: Unknown result type (might be due to invalid IL or missing references) //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_008e: 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_009b: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Unknown result type (might be due to invalid IL or missing references) //IL_00a5: Unknown result type (might be due to invalid IL or missing references) //IL_00a7: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00fe: 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_0102: 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) //IL_00c7: Unknown result type (might be due to invalid IL or missing references) //IL_00cc: 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_00e2: Unknown result type (might be due to invalid IL or missing references) //IL_00f6: 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_0192: Unknown result type (might be due to invalid IL or missing references) //IL_0197: 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_01a2: Unknown result type (might be due to invalid IL or missing references) //IL_01a7: Unknown result type (might be due to invalid IL or missing references) //IL_01ab: Unknown result type (might be due to invalid IL or missing references) //IL_01ba: Unknown result type (might be due to invalid IL or missing references) //IL_01ce: Unknown result type (might be due to invalid IL or missing references) //IL_01dd: Unknown result type (might be due to invalid IL or missing references) //IL_01df: Unknown result type (might be due to invalid IL or missing references) //IL_01e6: Unknown result type (might be due to invalid IL or missing references) //IL_01eb: Unknown result type (might be due to invalid IL or missing references) //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f2: Unknown result type (might be due to invalid IL or missing references) //IL_01f4: Unknown result type (might be due to invalid IL or missing references) //IL_026a: Unknown result type (might be due to invalid IL or missing references) //IL_026e: Unknown result type (might be due to invalid IL or missing references) //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0284: Unknown result type (might be due to invalid IL or missing references) //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_029f: Unknown result type (might be due to invalid IL or missing references) //IL_020a: Unknown result type (might be due to invalid IL or missing references) //IL_020c: Unknown result type (might be due to invalid IL or missing references) //IL_020e: Unknown result type (might be due to invalid IL or missing references) //IL_0328: Unknown result type (might be due to invalid IL or missing references) //IL_0332: Unknown result type (might be due to invalid IL or missing references) //IL_02bf: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_039e: Unknown result type (might be due to invalid IL or missing references) //IL_03fb: Unknown result type (might be due to invalid IL or missing references) //IL_03fd: Unknown result type (might be due to invalid IL or missing references) //IL_03ff: Unknown result type (might be due to invalid IL or missing references) //IL_0411: Unknown result type (might be due to invalid IL or missing references) //IL_03b7: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03bb: Unknown result type (might be due to invalid IL or missing references) //IL_044a: Unknown result type (might be due to invalid IL or missing references) //IL_044c: Unknown result type (might be due to invalid IL or missing references) //IL_044e: Unknown result type (might be due to invalid IL or missing references) //IL_045e: Unknown result type (might be due to invalid IL or missing references) //IL_0467: Unknown result type (might be due to invalid IL or missing references) //IL_0471: Unknown result type (might be due to invalid IL or missing references) //IL_0478: Unknown result type (might be due to invalid IL or missing references) //IL_047d: Unknown result type (might be due to invalid IL or missing references) //IL_042b: Unknown result type (might be due to invalid IL or missing references) //IL_042d: Unknown result type (might be due to invalid IL or missing references) //IL_042f: Unknown result type (might be due to invalid IL or missing references) landingPoint = default(Vector3); Vector3 forward = ((Component)_player).transform.forward; forward.y = 0f; if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f) { return false; } ((Vector3)(ref forward)).Normalize(); Vector3 position = ((Component)_player).transform.position; float eyeHeight = GetEyeHeight(position); RaycastHit val = default(RaycastHit); bool flag = false; Vector3 val2 = default(Vector3); RaycastHit val3 = default(RaycastHit); for (int i = 0; i < Plugin.ForwardRayCount.Value; i++) { float num = eyeHeight + (float)i * Plugin.ForwardRayHeightStep.Value; ((Vector3)(ref val2))..ctor(position.x, num, position.z); Vector3 to = val2 + forward * Plugin.ForwardCheckDistance.Value; if (Physics.Raycast(val2, forward, ref val3, Plugin.ForwardCheckDistance.Value, VaultLayerMask, (QueryTriggerInteraction)1)) { DrawDebugLine(val2, ((RaycastHit)(ref val3)).point, Color.green); DrawDebugPoint(((RaycastHit)(ref val3)).point, Color.yellow); val = val3; flag = true; break; } DrawDebugLine(val2, to, Color.red); } if (!flag) { LogFail("forward check missed on all " + Plugin.ForwardRayCount.Value + " rays - no obstacle within " + Plugin.ForwardCheckDistance.Value + "m"); return false; } float num2 = eyeHeight + Plugin.MaxVaultHeight.Value; Vector3 val4 = ((RaycastHit)(ref val)).point + forward * 0.15f; Vector3 val5 = default(Vector3); ((Vector3)(ref val5))..ctor(val4.x, num2 + 0.5f, val4.z); float num3 = num2 + 0.5f - (position.y - 0.5f); Vector3 to2 = val5 + Vector3.down * num3; RaycastHit val6 = default(RaycastHit); if (!Physics.Raycast(val5, Vector3.down, ref val6, num3, VaultLayerMask, (QueryTriggerInteraction)1)) { DrawDebugLine(val5, to2, Color.red); LogFail("no landing surface found above the obstacle (probed from y=" + val5.y.ToString("F2") + " down " + num3.ToString("F2") + "m)"); return false; } DrawDebugLine(val5, ((RaycastHit)(ref val6)).point, Color.cyan); DrawDebugPoint(((RaycastHit)(ref val6)).point, Color.blue); if (((RaycastHit)(ref val6)).point.y > num2) { LogFail("landing spot y=" + ((RaycastHit)(ref val6)).point.y.ToString("F2") + " is above the eye+" + Plugin.MaxVaultHeight.Value.ToString("F2") + " limit (" + num2.ToString("F2") + ")"); return false; } float num4 = ((RaycastHit)(ref val6)).point.y - position.y; if (num4 < Plugin.MinVaultHeight.Value) { LogFail("landing height diff " + num4.ToString("F2") + "m is below the minimum step of " + Plugin.MinVaultHeight.Value.ToString("F2") + "m"); return false; } if (!HasClearance(position, num4 + Plugin.StandClearance.Value, out var capsuleFoot, out var capsuleHead)) { DrawDebugLine(capsuleFoot, capsuleHead, Color.red); LogFail("not enough headroom above current position to pull up (need " + (num4 + Plugin.StandClearance.Value).ToString("F2") + "m)"); return false; } DrawDebugLine(capsuleFoot, capsuleHead, Color.green); if (!HasClearance(((RaycastHit)(ref val6)).point, Plugin.StandClearance.Value, out var capsuleFoot2, out var capsuleHead2)) { DrawDebugLine(capsuleFoot2, capsuleHead2, Color.red); LogFail("landing spot blocked - not enough clearance to stand"); return false; } DrawDebugLine(capsuleFoot2, capsuleHead2, Color.green); landingPoint = new Vector3(val4.x, ((RaycastHit)(ref val6)).point.y, val4.z); return true; } private bool HasClearance(Vector3 basePoint, float requiredHeight, out Vector3 capsuleFoot, out Vector3 capsuleHead) { //IL_0024: Unknown result type (might be due to invalid IL or missing references) //IL_002a: Unknown result type (might be due to invalid IL or missing references) //IL_0032: 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_0044: 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_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references) //IL_0063: 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) float value = Plugin.PlayerRadius.Value; float num = value + 0.02f; float num2 = Mathf.Max(requiredHeight - value, num + 0.05f); capsuleFoot = new Vector3(basePoint.x, basePoint.y + num, basePoint.z); capsuleHead = new Vector3(basePoint.x, basePoint.y + num2, basePoint.z); return !Physics.CheckCapsule(capsuleFoot, capsuleHead, value, VaultLayerMask, (QueryTriggerInteraction)1); } private float GetEyeHeight(Vector3 feet) { //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_002f: Unknown result type (might be due to invalid IL or missing references) Transform val = (Transform)((EyeField != null) ? /*isinst with value type is only supported in some contexts*/: null); if (!((Object)(object)val != (Object)null)) { return feet.y + 1.7f; } return val.position.y; } private static void LogFail(string reason) { if (Plugin.DebugVisuals.Value) { Plugin.LogInfo("[Vault] " + reason); } } private static void DrawDebugLine(Vector3 from, Vector3 to, Color color, float duration = 4f) { //IL_0012: Unknown result type (might be due to invalid IL or missing references) //IL_0017: 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_0056: Expected O, but got Unknown //IL_0057: 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_0066: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown if (Plugin.DebugVisuals.Value) { GameObject val = new GameObject("VaultDebugLine"); LineRenderer obj = val.AddComponent<LineRenderer>(); obj.positionCount = 2; obj.useWorldSpace = true; obj.startWidth = 0.03f; obj.endWidth = 0.03f; ((Renderer)obj).material = new Material(Shader.Find("Sprites/Default")); obj.startColor = color; obj.endColor = color; obj.SetPosition(0, from); obj.SetPosition(1, to); Object.Destroy((Object)val, duration); } } private static void DrawDebugPoint(Vector3 position, Color color, float radius = 0.08f, float duration = 4f) { //IL_002f: 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_0041: 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_0070: Expected O, but got Unknown //IL_0076: Unknown result type (might be due to invalid IL or missing references) if (Plugin.DebugVisuals.Value) { GameObject obj = GameObject.CreatePrimitive((PrimitiveType)0); ((Object)obj).name = "VaultDebugPoint"; Object.Destroy((Object)(object)obj.GetComponent<Collider>()); obj.transform.position = position; obj.transform.localScale = Vector3.one * radius; Renderer component = obj.GetComponent<Renderer>(); if ((Object)(object)component != (Object)null) { component.material = new Material(Shader.Find("Sprites/Default")); component.material.color = color; } Object.Destroy((Object)(object)obj, duration); } } private void UpdateVault(float deltaTime) { //IL_00ce: Unknown result type (might be due to invalid IL or missing references) //IL_00d4: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) if (((Character)_player).IsDead() || ((Character)_player).IsTeleporting()) { CancelVault(); return; } _vaultElapsed += deltaTime; if (_emotePending) { _emoteTimer += deltaTime; if (_emoteTimer >= Plugin.EmoteCancelDelay.Value) { StopEmote(); } } float num = _vaultElapsed - Plugin.VaultStartDelay.Value; if (num <= 0f) { ((Component)_player).transform.position = _vaultStart; Physics.SyncTransforms(); return; } float num2 = Mathf.Clamp01(num / Plugin.VaultDuration.Value); float num3 = 1f - Mathf.Pow(1f - num2, Plugin.VaultEaseExponent.Value); ((Component)_player).transform.position = Vector3.LerpUnclamped(_vaultStart, _vaultTarget, num3); Physics.SyncTransforms(); if (num2 >= 1f) { FinishVault(); } } private void FinishVault() { _vaulting = false; if ((Object)(object)_body != (Object)null) { _body.isKinematic = _wasKinematic; } } private void CancelVault() { if (_emotePending) { StopEmote(); } FinishVault(); } private void StopEmote() { _emotePending = false; if (StopEmoteMethod != null) { StopEmoteMethod.Invoke(_player, null); } } private void Show(string token) { ((Character)_player).Message((MessageType)2, token, 0, (Sprite)null, false); } }