1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-21 15:27:24 +08:00

Rename judgement-related methods/events + commenting

This commit is contained in:
smoogipoo 2018-08-06 10:54:16 +09:00
parent 38263714a1
commit 5fd4ed2f4e
15 changed files with 78 additions and 53 deletions

View File

@ -29,9 +29,9 @@ namespace osu.Game.Rulesets.Catch.Scoring
private const double harshness = 0.01; private const double harshness = 0.01;
protected override void OnNewJudgement(JudgementResult result) protected override void ApplyResult(JudgementResult result)
{ {
base.OnNewJudgement(result); base.ApplyResult(result);
if (result.Type == HitResult.Miss) if (result.Type == HitResult.Miss)
{ {

View File

@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Catch.UI
public override void Add(DrawableHitObject h) public override void Add(DrawableHitObject h)
{ {
h.OnJudgement += onJudgement; h.OnNewResult += onNewResult;
base.Add(h); base.Add(h);
@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Catch.UI
fruit.CheckPosition = CheckIfWeCanCatch; fruit.CheckPosition = CheckIfWeCanCatch;
} }
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result) private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
=> catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, result); => catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, result);
} }
} }

View File

@ -121,9 +121,9 @@ namespace osu.Game.Rulesets.Mania.Scoring
} }
} }
protected override void OnNewJudgement(JudgementResult result) protected override void ApplyResult(JudgementResult result)
{ {
base.OnNewJudgement(result); base.ApplyResult(result);
bool isTick = result.Judgement is HoldNoteTickJudgement; bool isTick = result.Judgement is HoldNoteTickJudgement;

View File

@ -131,12 +131,12 @@ namespace osu.Game.Rulesets.Mania.UI
public override void Add(DrawableHitObject hitObject) public override void Add(DrawableHitObject hitObject)
{ {
hitObject.AccentColour = AccentColour; hitObject.AccentColour = AccentColour;
hitObject.OnJudgement += OnJudgement; hitObject.OnNewResult += OnNewResult;
HitObjects.Add(hitObject); HitObjects.Add(hitObject);
} }
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result) internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
if (!result.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements) if (!result.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements)
return; return;

View File

@ -156,12 +156,12 @@ namespace osu.Game.Rulesets.Mania.UI
var maniaObject = (ManiaHitObject)h.HitObject; var maniaObject = (ManiaHitObject)h.HitObject;
int columnIndex = maniaObject.Column - firstColumnIndex; int columnIndex = maniaObject.Column - firstColumnIndex;
Columns.ElementAt(columnIndex).Add(h); Columns.ElementAt(columnIndex).Add(h);
h.OnJudgement += OnJudgement; h.OnNewResult += OnNewResult;
} }
public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline)); public void Add(BarLine barline) => base.Add(new DrawableBarLine(barline));
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result) internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
if (!judgedObject.DisplayJudgement || !DisplayJudgements) if (!judgedObject.DisplayJudgement || !DisplayJudgements)
return; return;

View File

@ -304,13 +304,13 @@ namespace osu.Game.Rulesets.Osu.Tests
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>()) foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
mod.ApplyToDrawableHitObjects(new[] { drawable }); mod.ApplyToDrawableHitObjects(new[] { drawable });
drawable.OnJudgement += onJudgement; drawable.OnNewResult += onNewResult;
Add(drawable); Add(drawable);
} }
private float judgementOffsetDirection = 1; private float judgementOffsetDirection = 1;
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result) private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
var osuObject = judgedObject as DrawableOsuHitObject; var osuObject = judgedObject as DrawableOsuHitObject;
if (osuObject == null) if (osuObject == null)

View File

@ -51,9 +51,9 @@ namespace osu.Game.Rulesets.Osu.Scoring
private const double harshness = 0.01; private const double harshness = 0.01;
protected override void OnNewJudgement(JudgementResult result) protected override void ApplyResult(JudgementResult result)
{ {
base.OnNewJudgement(result); base.ApplyResult(result);
var osuResult = (OsuJudgementResult)result; var osuResult = (OsuJudgementResult)result;

View File

@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.UI
public override void Add(DrawableHitObject h) public override void Add(DrawableHitObject h)
{ {
h.OnJudgement += onJudgement; h.OnNewResult += onNewResult;
var c = h as IDrawableHitObjectWithProxiedApproach; var c = h as IDrawableHitObjectWithProxiedApproach;
if (c != null) if (c != null)
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.UI
connectionLayer.HitObjects = HitObjects.Objects.Select(d => d.HitObject).OfType<OsuHitObject>(); connectionLayer.HitObjects = HitObjects.Objects.Select(d => d.HitObject).OfType<OsuHitObject>();
} }
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result) private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
if (!judgedObject.DisplayJudgement || !DisplayJudgements) if (!judgedObject.DisplayJudgement || !DisplayJudgements)
return; return;

View File

@ -140,18 +140,18 @@ namespace osu.Game.Rulesets.Taiko.Tests
var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) }; var h = new DrawableTestHit(hit) { X = RNG.NextSingle(hitResult == HitResult.Good ? -0.1f : -0.05f, hitResult == HitResult.Good ? 0.1f : 0.05f) };
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult }); ((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
if (RNG.Next(10) == 0) if (RNG.Next(10) == 0)
{ {
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult }); ((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoJudgement()) { Type = hitResult });
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(h, new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great }); ((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great });
} }
} }
private void addMissJudgement() private void addMissJudgement()
{ {
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(new DrawableTestHit(new Hit()), new JudgementResult(new TaikoJudgement()) { Type = HitResult.Miss }); ((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(new DrawableTestHit(new Hit()), new JudgementResult(new TaikoJudgement()) { Type = HitResult.Miss });
} }
private void addBarLine(bool major, double delay = scroll_time) private void addBarLine(bool major, double delay = scroll_time)

View File

@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>()) foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
{ {
var newTick = new DrawableDrumRollTick(tick); var newTick = new DrawableDrumRollTick(tick);
newTick.OnJudgement += onTickJudgement; newTick.OnNewResult += onNewTickResult;
AddNested(newTick); AddNested(newTick);
tickContainer.Add(newTick); tickContainer.Add(newTick);
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
colourEngaged = colours.YellowDarker; colourEngaged = colours.YellowDarker;
} }
private void onTickJudgement(DrawableHitObject obj, JudgementResult result) private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
{ {
if (result.Type > HitResult.Miss) if (result.Type > HitResult.Miss)
rollingHits++; rollingHits++;

View File

@ -76,9 +76,9 @@ namespace osu.Game.Rulesets.Taiko.Scoring
hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max); hpIncreaseMiss = BeatmapDifficulty.DifficultyRange(beatmap.BeatmapInfo.BaseDifficulty.DrainRate, hp_miss_min, hp_miss_mid, hp_miss_max);
} }
protected override void OnNewJudgement(JudgementResult result) protected override void ApplyResult(JudgementResult result)
{ {
base.OnNewJudgement(result); base.ApplyResult(result);
bool isTick = result.Judgement is TaikoDrumRollTickJudgement; bool isTick = result.Judgement is TaikoDrumRollTickJudgement;

View File

@ -209,7 +209,7 @@ namespace osu.Game.Rulesets.Taiko.UI
public override void Add(DrawableHitObject h) public override void Add(DrawableHitObject h)
{ {
h.OnJudgement += OnJudgement; h.OnNewResult += OnNewResult;
base.Add(h); base.Add(h);
@ -224,7 +224,7 @@ namespace osu.Game.Rulesets.Taiko.UI
} }
} }
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result) internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
{ {
if (!DisplayJudgements) if (!DisplayJudgements)
return; return;

View File

@ -35,8 +35,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
private readonly Lazy<List<DrawableHitObject>> nestedHitObjects = new Lazy<List<DrawableHitObject>>(); private readonly Lazy<List<DrawableHitObject>> nestedHitObjects = new Lazy<List<DrawableHitObject>>();
public IEnumerable<DrawableHitObject> NestedHitObjects => nestedHitObjects.IsValueCreated ? nestedHitObjects.Value : Enumerable.Empty<DrawableHitObject>(); public IEnumerable<DrawableHitObject> NestedHitObjects => nestedHitObjects.IsValueCreated ? nestedHitObjects.Value : Enumerable.Empty<DrawableHitObject>();
public event Action<DrawableHitObject, JudgementResult> OnJudgement; /// <summary>
public event Action<DrawableHitObject, JudgementResult> OnJudgementRemoved; /// Invoked when a <see cref="JudgementResult"/> has been applied by this <see cref="DrawableHitObject"/> or a nested <see cref="DrawableHitObject"/>.
/// </summary>
public event Action<DrawableHitObject, JudgementResult> OnNewResult;
/// <summary>
/// Invoked when a <see cref="JudgementResult"/> has been reset by this <see cref="DrawableHitObject"/> or a nested <see cref="DrawableHitObject"/>.
/// </summary>
public event Action<DrawableHitObject, JudgementResult> OnResultReset;
/// <summary> /// <summary>
/// Whether a visible judgement should be displayed when this representation is hit. /// Whether a visible judgement should be displayed when this representation is hit.
@ -143,7 +150,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
if (Result.TimeOffset + endTime < Time.Current) if (Result.TimeOffset + endTime < Time.Current)
{ {
OnJudgementRemoved?.Invoke(this, Result); OnResultReset?.Invoke(this, Result);
Result.Type = HitResult.None; Result.Type = HitResult.None;
State.Value = ArmedState.Idle; State.Value = ArmedState.Idle;
@ -162,8 +169,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
protected virtual void AddNested(DrawableHitObject h) protected virtual void AddNested(DrawableHitObject h)
{ {
h.OnJudgement += (d, r) => OnJudgement?.Invoke(d, r); h.OnNewResult += (d, r) => OnNewResult?.Invoke(d, r);
h.OnJudgementRemoved += (d, r) => OnJudgementRemoved?.Invoke(d, r); h.OnResultReset += (d, r) => OnResultReset?.Invoke(d, r);
h.ApplyCustomUpdateState += (d, j) => ApplyCustomUpdateState?.Invoke(d, j); h.ApplyCustomUpdateState += (d, j) => ApplyCustomUpdateState?.Invoke(d, j);
nestedHitObjects.Value.Add(h); nestedHitObjects.Value.Add(h);
@ -195,7 +202,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
break; break;
} }
OnJudgement?.Invoke(this, Result); OnNewResult?.Invoke(this, Result);
} }
/// <summary> /// <summary>

View File

@ -195,8 +195,8 @@ namespace osu.Game.Rulesets.Scoring
{ {
Debug.Assert(base_portion + combo_portion == 1.0); Debug.Assert(base_portion + combo_portion == 1.0);
rulesetContainer.OnJudgement += AddJudgement; rulesetContainer.OnNewResult += applyResult;
rulesetContainer.OnJudgementRemoved += RemoveJudgement; rulesetContainer.OnResultReset += resetResult;
SimulateAutoplay(rulesetContainer.Beatmap); SimulateAutoplay(rulesetContainer.Beatmap);
Reset(true); Reset(true);
@ -210,10 +210,19 @@ namespace osu.Game.Rulesets.Scoring
Mode.ValueChanged += _ => updateScore(); Mode.ValueChanged += _ => updateScore();
} }
/// <summary>
/// Applies any properties of the <see cref="Beatmap{TObject}"/> which affect scoring to this <see cref="ScoreProcessor{TObject}"/>.
/// </summary>
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to read properties from.</param>
protected virtual void ApplyBeatmap(Beatmap<TObject> beatmap) protected virtual void ApplyBeatmap(Beatmap<TObject> beatmap)
{ {
} }
/// <summary>
/// Simulates an autoplay of the <see cref="Beatmap{TObject}"/> to determine scoring values.
/// </summary>
/// <remarks>This provided temporarily. DO NOT USE.</remarks>
/// <param name="beatmap">The <see cref="Beatmap{TObject}"/> to simulate.</param>
protected virtual void SimulateAutoplay(Beatmap<TObject> beatmap) protected virtual void SimulateAutoplay(Beatmap<TObject> beatmap)
{ {
foreach (var obj in beatmap.HitObjects) foreach (var obj in beatmap.HitObjects)
@ -230,18 +239,17 @@ namespace osu.Game.Rulesets.Scoring
var result = CreateJudgementResult(obj.Judgement); var result = CreateJudgementResult(obj.Judgement);
result.Type = obj.Judgement.MaxResult; result.Type = obj.Judgement.MaxResult;
AddJudgement(result); applyResult(result);
} }
} }
/// <summary> /// <summary>
/// Adds a judgement to this ScoreProcessor. /// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
/// </summary> /// </summary>
/// <param name="judgement">The judgement to add.</param> /// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
/// <param name="result">The judgement scoring result.</param> private void applyResult(JudgementResult result)
protected void AddJudgement(JudgementResult result)
{ {
OnNewJudgement(result); ApplyResult(result);
updateScore(); updateScore();
UpdateFailed(); UpdateFailed();
@ -249,22 +257,21 @@ namespace osu.Game.Rulesets.Scoring
} }
/// <summary> /// <summary>
/// Removes a judgement from this ScoreProcessor. /// Resets the score change of a <see cref="JudgementResult"/> that was applied to this <see cref="ScoreProcessor"/>.
/// </summary> /// </summary>
/// <param name="judgement">The judgement to remove.</param> /// <param name="judgement">The judgement to remove.</param>
/// <param name="result">The judgement scoring result.</param> /// <param name="result">The judgement scoring result.</param>
protected void RemoveJudgement(JudgementResult result) private void resetResult(JudgementResult result)
{ {
OnJudgementRemoved(result); ResetResult(result);
updateScore(); updateScore();
} }
/// <summary> /// <summary>
/// Applies a judgement. /// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
/// </summary> /// </summary>
/// <param name="judgement">The judgement to apply/</param> /// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
/// <param name="result">The judgement scoring result.</param> protected virtual void ApplyResult(JudgementResult result)
protected virtual void OnNewJudgement(JudgementResult result)
{ {
result.ComboAtJudgement = Combo; result.ComboAtJudgement = Combo;
result.HighestComboAtJudgement = HighestCombo; result.HighestComboAtJudgement = HighestCombo;
@ -299,11 +306,11 @@ namespace osu.Game.Rulesets.Scoring
} }
/// <summary> /// <summary>
/// Removes a judgement. This should reverse everything in <see cref="OnNewJudgement(Judgement)"/>. /// Resets the score change of a <see cref="JudgementResult"/> that was applied to this <see cref="ScoreProcessor"/>.
/// </summary> /// </summary>
/// <param name="judgement">The judgement to remove.</param> /// <param name="judgement">The judgement to remove.</param>
/// <param name="result">The judgement scoring result.</param> /// <param name="result">The judgement scoring result.</param>
protected virtual void OnJudgementRemoved(JudgementResult result) protected virtual void ResetResult(JudgementResult result)
{ {
Combo.Value = result.ComboAtJudgement; Combo.Value = result.ComboAtJudgement;
HighestCombo.Value = result.HighestComboAtJudgement; HighestCombo.Value = result.HighestComboAtJudgement;
@ -356,6 +363,10 @@ namespace osu.Game.Rulesets.Scoring
bonusScore = 0; bonusScore = 0;
} }
/// <summary>
/// Creates the <see cref="JudgementResult"/> that represents the scoring result for a <see cref="HitObject"/>.
/// </summary>
/// <param name="judgement">The <see cref="Judgement"/> that provides the scoring information.</param>
protected virtual JudgementResult CreateJudgementResult(Judgement judgement) => new JudgementResult(judgement); protected virtual JudgementResult CreateJudgementResult(Judgement judgement) => new JudgementResult(judgement);
} }

View File

@ -182,8 +182,15 @@ namespace osu.Game.Rulesets.UI
public abstract class RulesetContainer<TObject> : RulesetContainer public abstract class RulesetContainer<TObject> : RulesetContainer
where TObject : HitObject where TObject : HitObject
{ {
public event Action<JudgementResult> OnJudgement; /// <summary>
public event Action<JudgementResult> OnJudgementRemoved; /// Invoked when a <see cref="JudgementResult"/> has been applied by any <see cref="DrawableHitObject"/>.
/// </summary>
public event Action<JudgementResult> OnNewResult;
/// <summary>
/// Invoked when a <see cref="JudgementResult"/> has been reset by any <see cref="DrawableHitObject"/>.
/// </summary>
public event Action<JudgementResult> OnResultReset;
/// <summary> /// <summary>
/// The Beatmap /// The Beatmap
@ -290,8 +297,8 @@ namespace osu.Game.Rulesets.UI
if (drawableObject == null) if (drawableObject == null)
continue; continue;
drawableObject.OnJudgement += (_, r) => OnJudgement?.Invoke(r); drawableObject.OnNewResult += (_, r) => OnNewResult?.Invoke(r);
drawableObject.OnJudgementRemoved += (_, r) => OnJudgementRemoved?.Invoke(r); drawableObject.OnResultReset += (_, r) => OnResultReset?.Invoke(r);
Playfield.Add(drawableObject); Playfield.Add(drawableObject);
} }