mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Rename judgement-related methods/events + commenting
This commit is contained in:
parent
38263714a1
commit
5fd4ed2f4e
@ -29,9 +29,9 @@ namespace osu.Game.Rulesets.Catch.Scoring
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -59,7 +59,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
h.OnJudgement += onJudgement;
|
||||
h.OnNewResult += onNewResult;
|
||||
|
||||
base.Add(h);
|
||||
|
||||
@ -67,7 +67,7 @@ namespace osu.Game.Rulesets.Catch.UI
|
||||
fruit.CheckPosition = CheckIfWeCanCatch;
|
||||
}
|
||||
|
||||
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result)
|
||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
=> catcherArea.OnJudgement((DrawableCatchHitObject)judgedObject, result);
|
||||
}
|
||||
}
|
||||
|
@ -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;
|
||||
|
||||
|
@ -131,12 +131,12 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
public override void Add(DrawableHitObject hitObject)
|
||||
{
|
||||
hitObject.AccentColour = AccentColour;
|
||||
hitObject.OnJudgement += OnJudgement;
|
||||
hitObject.OnNewResult += OnNewResult;
|
||||
|
||||
HitObjects.Add(hitObject);
|
||||
}
|
||||
|
||||
internal void OnJudgement(DrawableHitObject judgedObject, JudgementResult result)
|
||||
internal void OnNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
{
|
||||
if (!result.IsHit || !judgedObject.DisplayJudgement || !DisplayJudgements)
|
||||
return;
|
||||
|
@ -156,12 +156,12 @@ namespace osu.Game.Rulesets.Mania.UI
|
||||
var maniaObject = (ManiaHitObject)h.HitObject;
|
||||
int columnIndex = maniaObject.Column - firstColumnIndex;
|
||||
Columns.ElementAt(columnIndex).Add(h);
|
||||
h.OnJudgement += OnJudgement;
|
||||
h.OnNewResult += OnNewResult;
|
||||
}
|
||||
|
||||
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)
|
||||
return;
|
||||
|
@ -304,13 +304,13 @@ namespace osu.Game.Rulesets.Osu.Tests
|
||||
foreach (var mod in Mods.OfType<IApplicableToDrawableHitObjects>())
|
||||
mod.ApplyToDrawableHitObjects(new[] { drawable });
|
||||
|
||||
drawable.OnJudgement += onJudgement;
|
||||
drawable.OnNewResult += onNewResult;
|
||||
|
||||
Add(drawable);
|
||||
}
|
||||
|
||||
private float judgementOffsetDirection = 1;
|
||||
private void onJudgement(DrawableHitObject judgedObject, JudgementResult result)
|
||||
private void onNewResult(DrawableHitObject judgedObject, JudgementResult result)
|
||||
{
|
||||
var osuObject = judgedObject as DrawableOsuHitObject;
|
||||
if (osuObject == null)
|
||||
|
@ -51,9 +51,9 @@ namespace osu.Game.Rulesets.Osu.Scoring
|
||||
|
||||
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;
|
||||
|
||||
|
@ -50,7 +50,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
h.OnJudgement += onJudgement;
|
||||
h.OnNewResult += onNewResult;
|
||||
|
||||
var c = h as IDrawableHitObjectWithProxiedApproach;
|
||||
if (c != null)
|
||||
@ -64,7 +64,7 @@ namespace osu.Game.Rulesets.Osu.UI
|
||||
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)
|
||||
return;
|
||||
|
@ -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) };
|
||||
|
||||
((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)
|
||||
{
|
||||
((TaikoPlayfield)rulesetContainer.Playfield).OnJudgement(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 TaikoJudgement()) { Type = hitResult });
|
||||
((TaikoPlayfield)rulesetContainer.Playfield).OnNewResult(h, new JudgementResult(new TaikoStrongJudgement()) { Type = HitResult.Great });
|
||||
}
|
||||
}
|
||||
|
||||
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)
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
foreach (var tick in drumRoll.NestedHitObjects.OfType<DrumRollTick>())
|
||||
{
|
||||
var newTick = new DrawableDrumRollTick(tick);
|
||||
newTick.OnJudgement += onTickJudgement;
|
||||
newTick.OnNewResult += onNewTickResult;
|
||||
|
||||
AddNested(newTick);
|
||||
tickContainer.Add(newTick);
|
||||
@ -60,7 +60,7 @@ namespace osu.Game.Rulesets.Taiko.Objects.Drawables
|
||||
colourEngaged = colours.YellowDarker;
|
||||
}
|
||||
|
||||
private void onTickJudgement(DrawableHitObject obj, JudgementResult result)
|
||||
private void onNewTickResult(DrawableHitObject obj, JudgementResult result)
|
||||
{
|
||||
if (result.Type > HitResult.Miss)
|
||||
rollingHits++;
|
||||
|
@ -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);
|
||||
}
|
||||
|
||||
protected override void OnNewJudgement(JudgementResult result)
|
||||
protected override void ApplyResult(JudgementResult result)
|
||||
{
|
||||
base.OnNewJudgement(result);
|
||||
base.ApplyResult(result);
|
||||
|
||||
bool isTick = result.Judgement is TaikoDrumRollTickJudgement;
|
||||
|
||||
|
@ -209,7 +209,7 @@ namespace osu.Game.Rulesets.Taiko.UI
|
||||
|
||||
public override void Add(DrawableHitObject h)
|
||||
{
|
||||
h.OnJudgement += OnJudgement;
|
||||
h.OnNewResult += OnNewResult;
|
||||
|
||||
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)
|
||||
return;
|
||||
|
@ -35,8 +35,15 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
private readonly Lazy<List<DrawableHitObject>> nestedHitObjects = new Lazy<List<DrawableHitObject>>();
|
||||
public IEnumerable<DrawableHitObject> NestedHitObjects => nestedHitObjects.IsValueCreated ? nestedHitObjects.Value : Enumerable.Empty<DrawableHitObject>();
|
||||
|
||||
public event Action<DrawableHitObject, JudgementResult> OnJudgement;
|
||||
public event Action<DrawableHitObject, JudgementResult> OnJudgementRemoved;
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// 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)
|
||||
{
|
||||
OnJudgementRemoved?.Invoke(this, Result);
|
||||
OnResultReset?.Invoke(this, Result);
|
||||
|
||||
Result.Type = HitResult.None;
|
||||
State.Value = ArmedState.Idle;
|
||||
@ -162,8 +169,8 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
|
||||
protected virtual void AddNested(DrawableHitObject h)
|
||||
{
|
||||
h.OnJudgement += (d, r) => OnJudgement?.Invoke(d, r);
|
||||
h.OnJudgementRemoved += (d, r) => OnJudgementRemoved?.Invoke(d, r);
|
||||
h.OnNewResult += (d, r) => OnNewResult?.Invoke(d, r);
|
||||
h.OnResultReset += (d, r) => OnResultReset?.Invoke(d, r);
|
||||
h.ApplyCustomUpdateState += (d, j) => ApplyCustomUpdateState?.Invoke(d, j);
|
||||
|
||||
nestedHitObjects.Value.Add(h);
|
||||
@ -195,7 +202,7 @@ namespace osu.Game.Rulesets.Objects.Drawables
|
||||
break;
|
||||
}
|
||||
|
||||
OnJudgement?.Invoke(this, Result);
|
||||
OnNewResult?.Invoke(this, Result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -195,8 +195,8 @@ namespace osu.Game.Rulesets.Scoring
|
||||
{
|
||||
Debug.Assert(base_portion + combo_portion == 1.0);
|
||||
|
||||
rulesetContainer.OnJudgement += AddJudgement;
|
||||
rulesetContainer.OnJudgementRemoved += RemoveJudgement;
|
||||
rulesetContainer.OnNewResult += applyResult;
|
||||
rulesetContainer.OnResultReset += resetResult;
|
||||
|
||||
SimulateAutoplay(rulesetContainer.Beatmap);
|
||||
Reset(true);
|
||||
@ -210,10 +210,19 @@ namespace osu.Game.Rulesets.Scoring
|
||||
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)
|
||||
{
|
||||
}
|
||||
|
||||
/// <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)
|
||||
{
|
||||
foreach (var obj in beatmap.HitObjects)
|
||||
@ -230,18 +239,17 @@ namespace osu.Game.Rulesets.Scoring
|
||||
var result = CreateJudgementResult(obj.Judgement);
|
||||
result.Type = obj.Judgement.MaxResult;
|
||||
|
||||
AddJudgement(result);
|
||||
applyResult(result);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Adds a judgement to this ScoreProcessor.
|
||||
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="judgement">The judgement to add.</param>
|
||||
/// <param name="result">The judgement scoring result.</param>
|
||||
protected void AddJudgement(JudgementResult result)
|
||||
/// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
|
||||
private void applyResult(JudgementResult result)
|
||||
{
|
||||
OnNewJudgement(result);
|
||||
ApplyResult(result);
|
||||
updateScore();
|
||||
|
||||
UpdateFailed();
|
||||
@ -249,22 +257,21 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="judgement">The judgement to remove.</param>
|
||||
/// <param name="result">The judgement scoring result.</param>
|
||||
protected void RemoveJudgement(JudgementResult result)
|
||||
private void resetResult(JudgementResult result)
|
||||
{
|
||||
OnJudgementRemoved(result);
|
||||
ResetResult(result);
|
||||
updateScore();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Applies a judgement.
|
||||
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
|
||||
/// </summary>
|
||||
/// <param name="judgement">The judgement to apply/</param>
|
||||
/// <param name="result">The judgement scoring result.</param>
|
||||
protected virtual void OnNewJudgement(JudgementResult result)
|
||||
/// <param name="result">The <see cref="JudgementResult"/> to apply.</param>
|
||||
protected virtual void ApplyResult(JudgementResult result)
|
||||
{
|
||||
result.ComboAtJudgement = Combo;
|
||||
result.HighestComboAtJudgement = HighestCombo;
|
||||
@ -299,11 +306,11 @@ namespace osu.Game.Rulesets.Scoring
|
||||
}
|
||||
|
||||
/// <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>
|
||||
/// <param name="judgement">The judgement to remove.</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;
|
||||
HighestCombo.Value = result.HighestComboAtJudgement;
|
||||
@ -356,6 +363,10 @@ namespace osu.Game.Rulesets.Scoring
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -182,8 +182,15 @@ namespace osu.Game.Rulesets.UI
|
||||
public abstract class RulesetContainer<TObject> : RulesetContainer
|
||||
where TObject : HitObject
|
||||
{
|
||||
public event Action<JudgementResult> OnJudgement;
|
||||
public event Action<JudgementResult> OnJudgementRemoved;
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// The Beatmap
|
||||
@ -290,8 +297,8 @@ namespace osu.Game.Rulesets.UI
|
||||
if (drawableObject == null)
|
||||
continue;
|
||||
|
||||
drawableObject.OnJudgement += (_, r) => OnJudgement?.Invoke(r);
|
||||
drawableObject.OnJudgementRemoved += (_, r) => OnJudgementRemoved?.Invoke(r);
|
||||
drawableObject.OnNewResult += (_, r) => OnNewResult?.Invoke(r);
|
||||
drawableObject.OnResultReset += (_, r) => OnResultReset?.Invoke(r);
|
||||
|
||||
Playfield.Add(drawableObject);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user