XFE Git
XFE Studio Git
Git 首页 全局搜索
XFE 主站 文档 NuGet

XFEWarframe

【WinUI】基于Warframe游戏本体的公开服务器以及安装器

公开
关注 0 Fork 0 Star 0
UTF-8
namespace XFEWarframe.Client;

/// <summary>Game-time tap/hold recognizer. Repeated key-down events never restart a hold.</summary>
public sealed class AbilityBankGesture
{
    public const double HoldSeconds = .35;
    private bool down, cast;
    private double elapsed;
    public double HoldProgress => down ? Math.Clamp(elapsed / HoldSeconds, 0, 1) : 0;
    public void Press() { if (!down) { down = true; cast = false; elapsed = 0; } }
    public bool Tick(double seconds)
    {
        if (!down || cast || !double.IsFinite(seconds) || seconds <= 0) return false;
        elapsed += seconds;
        if (elapsed < HoldSeconds) return false;
        cast = true; return true;
    }
    public bool Release()
    {
        var cycle = down && !cast;
        Cancel(); return cycle;
    }
    public void Cancel() { down = cast = false; elapsed = 0; }
}