diff --git a/OWML.ModHelper.Input/ModInputHandler.cs b/OWML.ModHelper.Input/ModInputHandler.cs index d18b0279f..e187c9ef7 100644 --- a/OWML.ModHelper.Input/ModInputHandler.cs +++ b/OWML.ModHelper.Input/ModInputHandler.cs @@ -21,7 +21,7 @@ public class ModInputHandler : IModInputHandler private readonly HashSet _singlesPressed = new HashSet(); private readonly Dictionary> _comboRegistry = new Dictionary>(); private readonly HashSet _toResetOnNextFrame = new HashSet(); - private readonly float[] _timeout = new float[ModInputLibrary.MaxUsefulKey]; + private readonly int[] _blockedFrame = new int[ModInputLibrary.MaxUsefulKey]; private readonly int[] _gameBindingCounter = new int[ModInputLibrary.MaxUsefulKey]; private HashSet _currentCombinations = new HashSet(); private int _lastSingleUpdate; @@ -56,7 +56,7 @@ internal bool IsPressedAndIgnored(KeyCode key) var cleanKey = ModInputLibrary.NormalizeKeyCode(key); return UnityEngine.Input.GetKey(cleanKey) && _currentCombinations.Count > 0 && - Time.realtimeSinceStartup - _timeout[(int)cleanKey] < Cooldown; + (Time.frameCount - _blockedFrame[(int)cleanKey]) * Time.deltaTime < Cooldown; } private long? GetHashFromKeyboard() @@ -76,7 +76,7 @@ internal bool IsPressedAndIgnored(KeyCode key) return null; } hash = hash * ModInputLibrary.MaxUsefulKey + code; - if (Time.realtimeSinceStartup - _timeout[code] > Cooldown) + if ((Time.frameCount - _blockedFrame[code]) * Time.deltaTime > Cooldown) { countdownTrigger = false; } @@ -115,7 +115,7 @@ private HashSet GetCombinationsFromKeyboard() while (hash > 0) { - _timeout[hash % ModInputLibrary.MaxUsefulKey] = Time.realtimeSinceStartup; + _blockedFrame[hash % ModInputLibrary.MaxUsefulKey] = Time.frameCount; hash /= ModInputLibrary.MaxUsefulKey; } return combinations;