Fix dash hotkey causing player freezes in the IL.
This commit is contained in:
1 parent
1159ddd0dd
commit
0ff2d1b9b0
3 files changed
+19
-42
No files matched your search
@@ -116,11 +116,11 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
VerticalGodslayerDashTimer++;
|
||||
if (VerticalGodslayerDashTimer >= 25)
|
||||
{
|
||||
{
|
||||
Player.dashDelay = dashDelayToApply;
|
||||
// Stop the player from going flying
|
||||
Player.velocity *= 0.2f;
|
||||
}
|
||||
// Stop the player from going flying
|
||||
Player.velocity *= 0.2f;
|
||||
}
|
||||
}
|
||||
|
||||
if (HasCustomDash)
|
||||
@@ -205,11 +205,20 @@ namespace CalamityMod.CalPlayer
|
||||
{
|
||||
direction = DashDirection.Directionless;
|
||||
bool justDashed = false;
|
||||
bool pressedManualHotkey = CalamityKeybinds.DashHotkey.JustPressed;
|
||||
bool left = (Player.controlRight && Player.releaseRight && !CalamityKeybinds.DashHotkey.HasValidBinding()) || (pressedManualHotkey && Player.direction == 1);
|
||||
bool right = (Player.controlLeft && Player.releaseLeft && !CalamityKeybinds.DashHotkey.HasValidBinding()) || (pressedManualHotkey && Player.direction == -1);
|
||||
|
||||
if (left)
|
||||
// If the manual hotkey is bound, standard Terraria dashes cannot be triggered by double tapping.
|
||||
bool manualHotkeyBound = CalamityKeybinds.DashHotkey.GetAssignedKeys().Count > 0;
|
||||
bool pressedManualHotkey = CalamityKeybinds.DashHotkey.JustPressed;
|
||||
|
||||
bool vanillaRightDashInput = Player.controlRight && Player.releaseRight && !manualHotkeyBound;
|
||||
bool manualRightDashInput = pressedManualHotkey && Player.direction == 1;
|
||||
bool executeRightDash = vanillaRightDashInput || manualRightDashInput;
|
||||
|
||||
bool vanillaLeftDashInput = Player.controlLeft && Player.releaseLeft && !manualHotkeyBound;
|
||||
bool manualLeftDashInput = pressedManualHotkey && Player.direction == -1;
|
||||
bool executeLeftDash = vanillaLeftDashInput || manualLeftDashInput;
|
||||
|
||||
if (executeRightDash)
|
||||
{
|
||||
if (dashTimeMod > 0 || pressedManualHotkey)
|
||||
{
|
||||
@@ -220,7 +229,7 @@ namespace CalamityMod.CalPlayer
|
||||
else
|
||||
dashTimeMod = 15;
|
||||
}
|
||||
else if (right)
|
||||
else if (executeLeftDash)
|
||||
{
|
||||
if (dashTimeMod < 0 || pressedManualHotkey)
|
||||
{
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace CalamityMod.ILEditing
|
||||
return;
|
||||
}
|
||||
|
||||
if (!CalamityKeybinds.DashHotkey.HasValidBinding())
|
||||
if (CalamityKeybinds.DashHotkey.GetAssignedKeys().Count == 0)
|
||||
orig(self, out dir, out dashing, dashStartAction);
|
||||
else
|
||||
{
|
||||
|
||||
@@ -1,32 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Reflection;
|
||||
using Terraria.GameInput;
|
||||
using Terraria.ModLoader;
|
||||
|
||||
namespace CalamityMod
|
||||
{
|
||||
public static partial class CalamityUtils
|
||||
{
|
||||
internal static readonly FieldInfo KeybindName = typeof(ModKeybind).GetField("uniqueName", BindingFlags.Instance | BindingFlags.NonPublic);
|
||||
|
||||
public static bool HasValidBinding(this ModKeybind key)
|
||||
{
|
||||
// Copypasted stuff from vanilla. This should not be as complicated as it is.
|
||||
static string genInput(List<string> list)
|
||||
{
|
||||
if (list.Count == 0)
|
||||
return "";
|
||||
|
||||
string text = list[0];
|
||||
for (int j = 1; j < list.Count; j++)
|
||||
text = text + "/" + list[j];
|
||||
return text;
|
||||
}
|
||||
|
||||
List<string> list = PlayerInput.CurrentProfile.InputModes[InputMode.Keyboard].KeyStatus[(string)KeybindName.GetValue(key)];
|
||||
string text = genInput(list);
|
||||
return !string.IsNullOrEmpty(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user