mirror of
https://github.com/osukey/osukey.git
synced 2025-07-03 01:09:57 +09:00
Add action support to taiko
This commit is contained in:
@ -6,7 +6,6 @@ using System.Linq;
|
||||
using osu.Framework.Input;
|
||||
using osu.Game.Rulesets.Objects.Drawables;
|
||||
using osu.Game.Rulesets.Taiko.Judgements;
|
||||
using OpenTK.Input;
|
||||
|
||||
namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
{
|
||||
@ -20,7 +19,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
|
||||
private double firstHitTime;
|
||||
private bool firstKeyHeld;
|
||||
private Key firstHitKey;
|
||||
private TaikoAction firstHitAction;
|
||||
|
||||
protected DrawableHitStrong(Hit hit)
|
||||
: base(hit)
|
||||
@ -46,18 +45,26 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
Judgement.SecondHit = true;
|
||||
}
|
||||
|
||||
protected override bool HandleKeyPress(Key key)
|
||||
public override bool OnReleased(TaikoAction action)
|
||||
{
|
||||
if (action == firstHitAction)
|
||||
firstKeyHeld = false;
|
||||
return base.OnReleased(action);
|
||||
}
|
||||
|
||||
public override bool OnPressed(TaikoAction action)
|
||||
{
|
||||
// Check if we've handled the first key
|
||||
if (Judgement.Result == HitResult.None)
|
||||
{
|
||||
// First key hasn't been handled yet, attempt to handle it
|
||||
bool handled = base.HandleKeyPress(key);
|
||||
bool handled = base.OnPressed(action);
|
||||
|
||||
if (handled)
|
||||
{
|
||||
firstHitTime = Time.Current;
|
||||
firstHitKey = key;
|
||||
firstHitAction = action;
|
||||
firstKeyHeld = true;
|
||||
}
|
||||
|
||||
return handled;
|
||||
@ -68,22 +75,15 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
return false;
|
||||
|
||||
// Don't handle represses of the first key
|
||||
if (firstHitKey == key)
|
||||
if (firstHitAction == action)
|
||||
return false;
|
||||
|
||||
// Don't handle invalid hit key presses
|
||||
if (!HitKeys.Contains(key))
|
||||
// Don't handle invalid hit action presses
|
||||
if (!HitActions.Contains(action))
|
||||
return false;
|
||||
|
||||
// Assume the intention was to hit the strong hit with both keys only if the first key is still being held down
|
||||
return firstKeyHeld && UpdateJudgement(true);
|
||||
}
|
||||
|
||||
protected override bool OnKeyDown(InputState state, KeyDownEventArgs args)
|
||||
{
|
||||
firstKeyHeld = state.Keyboard.Keys.Contains(firstHitKey);
|
||||
|
||||
return base.OnKeyDown(state, args);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user