Skip to content

Commit

Permalink
Update ApplyResult usages
Browse files Browse the repository at this point in the history
  • Loading branch information
LumpBloom7 committed Feb 19, 2024
1 parent a08a766 commit d3a9f2f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,5 @@ public SentakkiJudgementResult(HitObject hitObject, Judgement judgement) : base(
}
}

public bool Critical { get; private set; }
public bool Critical { get; set; }
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,12 @@ public DrawableScoreBonusObject(ScoreBonusObject? hitObject)

public void TriggerResult()
{
double timeOffset = Math.Abs(Time.Current - HitObject.StartTime);

ApplyResult(r =>
ApplyResult((r, dho) =>
{
double timeOffset = Math.Abs(Time.Current - HitObject.StartTime);
bool isCrit = r.HitObject.HitWindows.ResultFor(timeOffset) == HitResult.Perfect;
r.Type = isCrit ? r.Judgement.MaxResult : r.Judgement.MinResult;
});
}

public new void ApplyResult(Action<JudgementResult> application)
{
if (!Result.HasResult)
base.ApplyResult(application);
}
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Judgements;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
Expand All @@ -19,10 +20,20 @@ public DrawableScorePaddingObject(ScorePaddingObject? hitObject)

protected override JudgementResult CreateResult(Judgement judgement) => new SentakkiJudgementResult(HitObject, judgement);

public new void ApplyResult(Action<JudgementResult> application)
public new void ApplyResult(HitResult result)
{
if (!Result.HasResult)
base.ApplyResult(application);
var SentakkiJudgementResult = (SentakkiJudgementResult)Result;
if (result == HitResult.Perfect)
{
SentakkiJudgementResult.Critical = true;
result = Result.Judgement.MaxResult;
}
else
{
SentakkiJudgementResult.Critical = false;
}

base.ApplyResult(result);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -57,11 +57,21 @@ protected override void OnApply()

protected override JudgementResult CreateResult(Judgement judgement) => new SentakkiJudgementResult(HitObject, judgement);

protected void ApplyResult(HitResult result)
protected new void ApplyResult(HitResult result)
{
void resultApplication(JudgementResult r) => ((SentakkiJudgementResult)r).Type = result;

ApplyResult(resultApplication);
var SentakkiJudgementResult = (SentakkiJudgementResult)Result;
if (result == HitResult.Perfect)
{
SentakkiJudgementResult.Critical = true;
result = Result.Judgement.MaxResult;
}
else
{
SentakkiJudgementResult.Critical = false;
}


Check notice on line 73 in osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs

View check run for this annotation

codefactor.io / CodeFactor

osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSentakkiHitObject.cs#L73

The code must not contain multiple blank lines in a row. (SA1507)
base.ApplyResult(result);
}

protected override void OnFree()
Expand Down Expand Up @@ -95,12 +105,5 @@ protected override void UpdateInitialTransforms()
}

private bool transformResetQueued;

protected new virtual void ApplyResult(Action<JudgementResult> application)
{
// Apply judgement to this object
if (!Result.HasResult)
base.ApplyResult(application);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;
using osu.Game.Rulesets.Sentakki.Configuration;
using osu.Game.Rulesets.Sentakki.UI;
using osu.Game.Skinning;
Expand Down Expand Up @@ -105,17 +106,17 @@ protected override void OnFree()
breakSample.ClearSamples();
}

protected override void ApplyResult(Action<JudgementResult> application)
protected new void ApplyResult(HitResult hitResult)
{
// Judge the scoreBonus
foreach (var bonusObject in scoreBonusObjects)
bonusObject.TriggerResult();

// Also give Break note score padding a judgement
for (int i = 0; i < scorePaddingObjects.Count; ++i)
scorePaddingObjects[^(i + 1)].ApplyResult(application);
scorePaddingObjects[^(i + 1)].ApplyResult(hitResult);

base.ApplyResult(application);
base.ApplyResult(hitResult);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Scoring;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
{
Expand Down Expand Up @@ -78,16 +79,18 @@ protected override void CheckForResult(bool userTriggered, double timeOffset)
ApplyResult(Result.Judgement.MaxResult);
}

protected override void ApplyResult(Action<JudgementResult> application)

Check notice on line 82 in osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs

View check run for this annotation

codefactor.io / CodeFactor

osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs#L82

The code must not contain multiple blank lines in a row. (SA1507)

Check notice on line 83 in osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs

View check run for this annotation

codefactor.io / CodeFactor

osu.Game.Rulesets.Sentakki/Objects/Drawables/DrawableSlideCheckpoint.cs#L83

The code must not contain multiple blank lines in a row. (SA1507)
protected new void ApplyResult(HitResult result)
{
if (Judged)
return;

// Make sure remaining nodes are judged
foreach (var node in nodes)
node.ApplyResult(application);
node.ApplyResult(result);

base.ApplyResult(application);
base.ApplyResult(result);
}

// Forcefully miss this node, used when players fail to complete the slide on time.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using osu.Framework.Graphics;
using osu.Framework.Input;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Scoring;
using osuTK;

namespace osu.Game.Rulesets.Sentakki.Objects.Drawables
Expand Down Expand Up @@ -82,6 +83,12 @@ private bool checkForTouchInput()
return false;
}

public new void ApplyResult(Action<JudgementResult> application) => base.ApplyResult(application);
public new void ApplyResult(HitResult result)
{
if (Judged)
return;

base.ApplyResult(result);
}
}
}

0 comments on commit d3a9f2f

Please sign in to comment.