mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 04:53:29 +01:00
Added GetDownTime, GetUpTime and GetTimeSincePress to Keybind and Combination
This commit is contained in:
parent
cc749103e0
commit
8469185297
2 changed files with 67 additions and 0 deletions
|
@ -15,6 +15,7 @@ Jump to version:
|
|||
Additions
|
||||
- Added TokenizedString.Realign
|
||||
- Added GetFlags and GetUniqueFlags to EnumHelper
|
||||
- Added GetDownTime, GetUpTime and GetTimeSincePress to Keybind and Combination
|
||||
- **Added the ability to find paths to one of multiple goals using AStar**
|
||||
|
||||
Improvements
|
||||
|
|
|
@ -183,6 +183,39 @@ namespace MLEM.Input {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that this keybind has been held down for.
|
||||
/// If this input isn't currently down, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting down time, or <see cref="TimeSpan.Zero"/> if the input is not being held.</returns>
|
||||
public TimeSpan GetDownTime(InputHandler handler, int gamepadIndex = -1) {
|
||||
return this.combinations.Max(c => c.GetDownTime(handler, gamepadIndex));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that this keybind has been up for since the last time it was down.
|
||||
/// If this input isn't currently up, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting up time, or <see cref="TimeSpan.Zero"/> if the input is being held.</returns>
|
||||
public TimeSpan GetUpTime(InputHandler handler, int gamepadIndex = -1) {
|
||||
return this.combinations.Min(c => c.GetUpTime(handler, gamepadIndex));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that has passed since this keybind last counted as pressed.
|
||||
/// If this input hasn't been pressed previously, or is currently pressed, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting up time, or <see cref="TimeSpan.Zero"/> if the input has never been pressed, or is currently pressed.</returns>
|
||||
public TimeSpan GetTimeSincePress(InputHandler handler, int gamepadIndex = -1) {
|
||||
return this.combinations.Min(c => c.GetTimeSincePress(handler, gamepadIndex));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns an enumerable of all of the combinations that this keybind currently contains
|
||||
/// </summary>
|
||||
|
@ -347,6 +380,39 @@ namespace MLEM.Input {
|
|||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that this combination has been held down for.
|
||||
/// If this input isn't currently down, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting down time, or <see cref="TimeSpan.Zero"/> if the input is not being held.</returns>
|
||||
public TimeSpan GetDownTime(InputHandler handler, int gamepadIndex = -1) {
|
||||
return handler.GetDownTime(this.Key, gamepadIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that this combination has been up for since the last time it was down.
|
||||
/// If this input isn't currently up, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting up time, or <see cref="TimeSpan.Zero"/> if the input is being held.</returns>
|
||||
public TimeSpan GetUpTime(InputHandler handler, int gamepadIndex = -1) {
|
||||
return handler.GetUpTime(this.Key, gamepadIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the amount of time that has passed since this combination last counted as pressed.
|
||||
/// If this input hasn't been pressed previously, or is currently pressed, this method returns <see cref="TimeSpan.Zero"/>.
|
||||
/// </summary>
|
||||
/// <param name="handler">The input handler to query the keys with</param>
|
||||
/// <param name="gamepadIndex">The index of the gamepad to query, or -1 to query all gamepads</param>
|
||||
/// <returns>The resulting up time, or <see cref="TimeSpan.Zero"/> if the input has never been pressed, or is currently pressed.</returns>
|
||||
public TimeSpan GetTimeSincePress(InputHandler handler, int gamepadIndex = -1) {
|
||||
return handler.GetTimeSincePress(this.Key, gamepadIndex);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts this combination into an easily human-readable string.
|
||||
/// When using <see cref="ToString()"/>, this method is used with <paramref name="joiner"/> set to " + ".
|
||||
|
|
Loading…
Reference in a new issue