mirror of
https://github.com/ppy/osu
synced 2024-12-26 00:32:52 +00:00
Restore catcher state on revert judgement result
This commit is contained in:
parent
0213f77b4b
commit
cb76a2d7b5
@ -56,6 +56,24 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public void TestCatcherStateRevert()
|
||||||
|
{
|
||||||
|
DrawableCatchHitObject drawableObject = null;
|
||||||
|
JudgementResult result = null;
|
||||||
|
AddStep("catch kiai fruit", () =>
|
||||||
|
{
|
||||||
|
drawableObject = createDrawableObject(new TestKiaiFruit());
|
||||||
|
result = attemptCatch(drawableObject);
|
||||||
|
});
|
||||||
|
checkState(CatcherAnimationState.Kiai);
|
||||||
|
AddStep("revert result", () =>
|
||||||
|
{
|
||||||
|
catcher.OnRevertResult(drawableObject, result);
|
||||||
|
});
|
||||||
|
checkState(CatcherAnimationState.Idle);
|
||||||
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestCatcherCatchWidth()
|
public void TestCatcherCatchWidth()
|
||||||
{
|
{
|
||||||
@ -170,17 +188,19 @@ namespace osu.Game.Rulesets.Catch.Tests
|
|||||||
|
|
||||||
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
private void attemptCatch(CatchHitObject hitObject, int count = 1)
|
||||||
{
|
{
|
||||||
hitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
|
||||||
|
|
||||||
for (var i = 0; i < count; i++)
|
for (var i = 0; i < count; i++)
|
||||||
|
attemptCatch(createDrawableObject(hitObject));
|
||||||
|
}
|
||||||
|
|
||||||
|
private JudgementResult attemptCatch(DrawableCatchHitObject drawableObject)
|
||||||
|
{
|
||||||
|
drawableObject.HitObject.ApplyDefaults(new ControlPointInfo(), new BeatmapDifficulty());
|
||||||
|
var result = new CatchJudgementResult(drawableObject.HitObject, drawableObject.HitObject.CreateJudgement())
|
||||||
{
|
{
|
||||||
var drawableObject = createDrawableObject(hitObject);
|
Type = catcher.CanCatch(drawableObject.HitObject) ? HitResult.Great : HitResult.Miss
|
||||||
var result = new JudgementResult(hitObject, new CatchJudgement())
|
};
|
||||||
{
|
catcher.OnNewResult(drawableObject, result);
|
||||||
Type = catcher.CanCatch(hitObject) ? HitResult.Great : HitResult.Miss
|
return result;
|
||||||
};
|
|
||||||
catcher.OnNewResult(drawableObject, result);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private DrawableCatchHitObject createDrawableObject(CatchHitObject hitObject)
|
private DrawableCatchHitObject createDrawableObject(CatchHitObject hitObject)
|
||||||
|
23
osu.Game.Rulesets.Catch/Judgements/CatchJudgementResult.cs
Normal file
23
osu.Game.Rulesets.Catch/Judgements/CatchJudgementResult.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// 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.
|
||||||
|
|
||||||
|
using JetBrains.Annotations;
|
||||||
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
|
using osu.Game.Rulesets.Objects;
|
||||||
|
|
||||||
|
namespace osu.Game.Rulesets.Catch.Judgements
|
||||||
|
{
|
||||||
|
public class CatchJudgementResult : JudgementResult
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// The catcher animation state prior to this judgement.
|
||||||
|
/// </summary>
|
||||||
|
public CatcherAnimationState CatcherAnimationState;
|
||||||
|
|
||||||
|
public CatchJudgementResult([NotNull] HitObject hitObject, [NotNull] Judgement judgement)
|
||||||
|
: base(hitObject, judgement)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -5,7 +5,9 @@ using System;
|
|||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Rulesets.Catch.Judgements;
|
||||||
using osu.Game.Rulesets.Catch.UI;
|
using osu.Game.Rulesets.Catch.UI;
|
||||||
|
using osu.Game.Rulesets.Judgements;
|
||||||
using osu.Game.Rulesets.Objects.Drawables;
|
using osu.Game.Rulesets.Objects.Drawables;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
@ -52,6 +54,8 @@ namespace osu.Game.Rulesets.Catch.Objects.Drawables
|
|||||||
|
|
||||||
public override bool RemoveWhenNotAlive => IsOnPlate;
|
public override bool RemoveWhenNotAlive => IsOnPlate;
|
||||||
|
|
||||||
|
protected override JudgementResult CreateResult(Judgement judgement) => new CatchJudgementResult(HitObject, judgement);
|
||||||
|
|
||||||
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
protected override void CheckForResult(bool userTriggered, double timeOffset)
|
||||||
{
|
{
|
||||||
if (CheckPosition == null) return;
|
if (CheckPosition == null) return;
|
||||||
|
@ -14,6 +14,7 @@ using osu.Framework.Input.Bindings;
|
|||||||
using osu.Framework.Utils;
|
using osu.Framework.Utils;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Rulesets.Catch.Judgements;
|
||||||
using osu.Game.Rulesets.Catch.Objects;
|
using osu.Game.Rulesets.Catch.Objects;
|
||||||
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
using osu.Game.Rulesets.Catch.Objects.Drawables;
|
||||||
using osu.Game.Rulesets.Catch.Skinning;
|
using osu.Game.Rulesets.Catch.Skinning;
|
||||||
@ -210,6 +211,9 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult result)
|
public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult result)
|
||||||
{
|
{
|
||||||
|
var catchResult = (CatchJudgementResult)result;
|
||||||
|
catchResult.CatcherAnimationState = CurrentState;
|
||||||
|
|
||||||
if (!(drawableObject.HitObject is PalpableCatchHitObject hitObject)) return;
|
if (!(drawableObject.HitObject is PalpableCatchHitObject hitObject)) return;
|
||||||
|
|
||||||
if (result.IsHit)
|
if (result.IsHit)
|
||||||
@ -238,6 +242,8 @@ namespace osu.Game.Rulesets.Catch.UI
|
|||||||
|
|
||||||
public void OnRevertResult(DrawableCatchHitObject fruit, JudgementResult result)
|
public void OnRevertResult(DrawableCatchHitObject fruit, JudgementResult result)
|
||||||
{
|
{
|
||||||
|
var catchResult = (CatchJudgementResult)result;
|
||||||
|
updateState(catchResult.CatcherAnimationState);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user