1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-23 16:07:24 +08:00
osu-lazer/osu.Game/Screens/Play/HUD/KeyCounterActionTrigger.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

37 lines
953 B
C#
Raw Normal View History

// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.
2018-04-13 17:19:50 +08:00
2019-11-13 22:35:50 +08:00
using System.Collections.Generic;
namespace osu.Game.Screens.Play.HUD
{
public partial class KeyCounterActionTrigger<T> : InputTrigger
where T : struct
{
public T Action { get; }
2018-04-13 17:19:50 +08:00
public KeyCounterActionTrigger(T action)
2019-02-28 12:31:40 +08:00
: base($"B{(int)(object)action + 1}")
{
Action = action;
}
2018-04-13 17:19:50 +08:00
public bool OnPressed(T action, bool forwards)
{
2019-11-13 22:35:50 +08:00
if (!EqualityComparer<T>.Default.Equals(action, Action))
return false;
Activate(forwards);
return false;
}
2018-04-13 17:19:50 +08:00
public void OnReleased(T action, bool forwards)
{
2019-11-13 22:35:50 +08:00
if (!EqualityComparer<T>.Default.Equals(action, Action))
return;
Deactivate(forwards);
}
}
2018-01-05 19:21:19 +08:00
}