Restore hyper dash state on revert judgement result

This commit is contained in:
ekrctb 2020-12-08 15:21:47 +09:00
parent cb76a2d7b5
commit 100b365c98
3 changed files with 47 additions and 2 deletions

View File

@ -57,7 +57,36 @@ public void SetUp() => Schedule(() =>
});
[Test]
public void TestCatcherStateRevert()
public void TestCatcherHyperStateReverted()
{
DrawableCatchHitObject drawableObject1 = null;
DrawableCatchHitObject drawableObject2 = null;
JudgementResult result1 = null;
JudgementResult result2 = null;
AddStep("catch hyper fruit", () =>
{
drawableObject1 = createDrawableObject(new Fruit { HyperDashTarget = new Fruit { X = 100 } });
result1 = attemptCatch(drawableObject1);
});
AddStep("catch normal fruit", () =>
{
drawableObject2 = createDrawableObject(new Fruit());
result2 = attemptCatch(drawableObject2);
});
AddStep("revert second result", () =>
{
catcher.OnRevertResult(drawableObject2, result2);
});
checkHyperDash(true);
AddStep("revert first result", () =>
{
catcher.OnRevertResult(drawableObject1, result1);
});
checkHyperDash(false);
}
[Test]
public void TestCatcherAnimationStateReverted()
{
DrawableCatchHitObject drawableObject = null;
JudgementResult result = null;

View File

@ -15,6 +15,11 @@ public class CatchJudgementResult : JudgementResult
/// </summary>
public CatcherAnimationState CatcherAnimationState;
/// <summary>
/// Whether the catcher was hyper dashing prior to this judgement.
/// </summary>
public bool CatcherHyperDash;
public CatchJudgementResult([NotNull] HitObject hitObject, [NotNull] Judgement judgement)
: base(hitObject, judgement)
{

View File

@ -213,6 +213,7 @@ public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult r
{
var catchResult = (CatchJudgementResult)result;
catchResult.CatcherAnimationState = CurrentState;
catchResult.CatcherHyperDash = HyperDashing;
if (!(drawableObject.HitObject is PalpableCatchHitObject hitObject)) return;
@ -243,7 +244,17 @@ public void OnNewResult(DrawableCatchHitObject drawableObject, JudgementResult r
public void OnRevertResult(DrawableCatchHitObject fruit, JudgementResult result)
{
var catchResult = (CatchJudgementResult)result;
updateState(catchResult.CatcherAnimationState);
if (CurrentState != catchResult.CatcherAnimationState)
updateState(catchResult.CatcherAnimationState);
if (HyperDashing != catchResult.CatcherHyperDash)
{
if (catchResult.CatcherHyperDash)
SetHyperDashState(2);
else
SetHyperDashState();
}
}
/// <summary>