mirror of
https://github.com/ppy/osu.git
synced 2025-03-22 21:00:33 +08:00
Merge branch 'master' into song-select-loading-reoptimisation
This commit is contained in:
commit
cd30958086
@ -8,11 +8,6 @@ namespace osu.Game.Modes.Osu.Beatmaps
|
||||
{
|
||||
internal class OsuBeatmapProcessor : IBeatmapProcessor<OsuHitObject>
|
||||
{
|
||||
public void SetDefaults(OsuHitObject hitObject, Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
hitObject.SetDefaultsFromBeatmap(beatmap);
|
||||
}
|
||||
|
||||
public void PostProcess(Beatmap<OsuHitObject> beatmap)
|
||||
{
|
||||
if (beatmap.ComboColors.Count == 0)
|
||||
|
@ -3,10 +3,11 @@
|
||||
|
||||
using osu.Game.Modes.Objects;
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Modes.Osu.Objects.Drawables;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using OpenTK.Graphics;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
@ -67,9 +68,11 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
return OsuScoreResult.Miss;
|
||||
}
|
||||
|
||||
public virtual void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||
{
|
||||
Scale = (1.0f - 0.7f * (beatmap.BeatmapInfo.Difficulty.CircleSize - 5) / 5) / 2;
|
||||
base.ApplyDefaults(timing, difficulty);
|
||||
|
||||
Scale = (1.0f - 0.7f * (difficulty.CircleSize - 5) / 5) / 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2,13 +2,13 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using OpenTK;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Modes.Objects.Types;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Osu.Objects
|
||||
{
|
||||
@ -47,19 +47,17 @@ namespace osu.Game.Modes.Osu.Objects
|
||||
public double Velocity;
|
||||
public double TickDistance;
|
||||
|
||||
public override void SetDefaultsFromBeatmap(Beatmap<OsuHitObject> beatmap)
|
||||
public override void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty)
|
||||
{
|
||||
base.SetDefaultsFromBeatmap(beatmap);
|
||||
|
||||
var baseDifficulty = beatmap.BeatmapInfo.Difficulty;
|
||||
base.ApplyDefaults(timing, difficulty);
|
||||
|
||||
ControlPoint overridePoint;
|
||||
ControlPoint timingPoint = beatmap.TimingInfo.TimingPointAt(StartTime, out overridePoint);
|
||||
ControlPoint timingPoint = timing.TimingPointAt(StartTime, out overridePoint);
|
||||
var velocityAdjustment = overridePoint?.VelocityAdjustment ?? 1;
|
||||
var baseVelocity = 100 * baseDifficulty.SliderMultiplier / velocityAdjustment;
|
||||
var baseVelocity = 100 * difficulty.SliderMultiplier / velocityAdjustment;
|
||||
|
||||
Velocity = baseVelocity / timingPoint.BeatLength;
|
||||
TickDistance = baseVelocity / baseDifficulty.SliderTickRate;
|
||||
TickDistance = baseVelocity / difficulty.SliderTickRate;
|
||||
}
|
||||
|
||||
public IEnumerable<SliderTick> Ticks
|
||||
|
@ -197,7 +197,7 @@ namespace osu.Game.Beatmaps.Formats
|
||||
|
||||
if (split.Length > 2)
|
||||
{
|
||||
//int kiaiFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
|
||||
int effectFlags = split.Length > 7 ? Convert.ToInt32(split[7], NumberFormatInfo.InvariantInfo) : 0;
|
||||
double beatLength = double.Parse(split[1].Trim(), NumberFormatInfo.InvariantInfo);
|
||||
cp = new ControlPoint
|
||||
{
|
||||
@ -205,6 +205,8 @@ namespace osu.Game.Beatmaps.Formats
|
||||
BeatLength = beatLength > 0 ? beatLength : 0,
|
||||
VelocityAdjustment = beatLength < 0 ? -beatLength / 100.0 : 1,
|
||||
TimingChange = split.Length <= 6 || split[6][0] == '1',
|
||||
KiaiMode = (effectFlags & 1) > 0,
|
||||
OmitFirstBarLine = (effectFlags & 8) > 0
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -8,17 +8,10 @@ namespace osu.Game.Beatmaps
|
||||
/// <summary>
|
||||
/// Processes a post-converted Beatmap.
|
||||
/// </summary>
|
||||
/// <typeparam name="T">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<T>
|
||||
where T : HitObject
|
||||
/// <typeparam name="TObject">The type of HitObject contained in the Beatmap.</typeparam>
|
||||
public interface IBeatmapProcessor<TObject>
|
||||
where TObject : HitObject
|
||||
{
|
||||
/// <summary>
|
||||
/// Sets default values for a HitObject.
|
||||
/// </summary>
|
||||
/// <param name="hitObject">The HitObject to set default values for.</param>
|
||||
/// <param name="beatmap">The Beatmap to extract the default values from.</param>
|
||||
void SetDefaults(T hitObject, Beatmap<T> beatmap);
|
||||
|
||||
/// <summary>
|
||||
/// Post-processes a Beatmap to add mode-specific components that aren't added during conversion.
|
||||
/// <para>
|
||||
@ -26,6 +19,6 @@ namespace osu.Game.Beatmaps
|
||||
/// </para>
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap to process.</param>
|
||||
void PostProcess(Beatmap<T> beatmap);
|
||||
void PostProcess(Beatmap<TObject> beatmap);
|
||||
}
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ namespace osu.Game.Beatmaps.Timing
|
||||
public double VelocityAdjustment;
|
||||
public bool TimingChange;
|
||||
public bool KiaiMode;
|
||||
public bool OmitFirstBarLine;
|
||||
|
||||
}
|
||||
|
||||
|
@ -39,7 +39,7 @@ namespace osu.Game.Database
|
||||
using (SerializationReader sr = new SerializationReader(s))
|
||||
{
|
||||
var ruleset = Ruleset.GetRuleset((PlayMode)sr.ReadByte());
|
||||
score = ruleset.CreateScoreProcessor().GetScore();
|
||||
score = ruleset.CreateScoreProcessor().CreateScore();
|
||||
|
||||
/* score.Pass = true;*/
|
||||
var version = sr.ReadInt32();
|
||||
|
@ -2,6 +2,8 @@
|
||||
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
|
||||
|
||||
using osu.Game.Beatmaps.Samples;
|
||||
using osu.Game.Beatmaps.Timing;
|
||||
using osu.Game.Database;
|
||||
|
||||
namespace osu.Game.Modes.Objects
|
||||
{
|
||||
@ -22,5 +24,12 @@ namespace osu.Game.Modes.Objects
|
||||
/// The sample to be played when this HitObject is hit.
|
||||
/// </summary>
|
||||
public HitSampleInfo Sample { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Applies default values to this HitObject.
|
||||
/// </summary>
|
||||
/// <param name="difficulty">The difficulty settings to use.</param>
|
||||
/// <param name="timing">The timing settings to use.</param>
|
||||
public virtual void ApplyDefaults(TimingInfo timing, BeatmapDifficulty difficulty) { }
|
||||
}
|
||||
}
|
||||
|
@ -7,13 +7,14 @@ using System.Collections.Generic;
|
||||
using osu.Game.Modes.Judgements;
|
||||
using osu.Game.Modes.UI;
|
||||
using osu.Game.Modes.Objects;
|
||||
using osu.Game.Beatmaps;
|
||||
|
||||
namespace osu.Game.Modes
|
||||
{
|
||||
public abstract class ScoreProcessor
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when the score is in a failing state.
|
||||
/// Invoked when the ScoreProcessor is in a failed state.
|
||||
/// </summary>
|
||||
public event Action Failed;
|
||||
|
||||
@ -42,7 +43,28 @@ namespace osu.Game.Modes
|
||||
/// </summary>
|
||||
public readonly BindableInt HighestCombo = new BindableInt();
|
||||
|
||||
public virtual Score GetScore() => new Score
|
||||
/// <summary>
|
||||
/// Whether the score is in a failed state.
|
||||
/// </summary>
|
||||
public virtual bool HasFailed => false;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ScoreProcessor has already triggered the failed state.
|
||||
/// </summary>
|
||||
private bool alreadyFailed;
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Creates a Score applicable to the game mode in which this ScoreProcessor resides.
|
||||
/// </summary>
|
||||
/// <returns>The Score.</returns>
|
||||
public virtual Score CreateScore() => new Score
|
||||
{
|
||||
TotalScore = TotalScore,
|
||||
Combo = Combo,
|
||||
@ -52,16 +74,31 @@ namespace osu.Game.Modes
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks if the score is in a failing state.
|
||||
/// Resets this ScoreProcessor to a default state.
|
||||
/// </summary>
|
||||
/// <returns>Whether the score is in a failing state.</returns>
|
||||
public abstract bool CheckFailed();
|
||||
protected virtual void Reset()
|
||||
{
|
||||
TotalScore.Value = 0;
|
||||
Accuracy.Value = 0;
|
||||
Health.Value = 0;
|
||||
Combo.Value = 0;
|
||||
HighestCombo.Value = 0;
|
||||
|
||||
alreadyFailed = false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Notifies subscribers that the score is in a failed state.
|
||||
/// Checks if the score is in a failed state and notifies subscribers.
|
||||
/// <para>
|
||||
/// This can only ever notify subscribers once.
|
||||
/// </para>
|
||||
/// </summary>
|
||||
protected void TriggerFailed()
|
||||
protected void UpdateFailed()
|
||||
{
|
||||
if (alreadyFailed || !HasFailed)
|
||||
return;
|
||||
|
||||
alreadyFailed = true;
|
||||
Failed?.Invoke();
|
||||
}
|
||||
}
|
||||
@ -75,29 +112,28 @@ namespace osu.Game.Modes
|
||||
/// </summary>
|
||||
protected readonly List<TJudgement> Judgements = new List<TJudgement>();
|
||||
|
||||
/// <summary>
|
||||
/// Whether the score is in a failable state.
|
||||
/// </summary>
|
||||
protected virtual bool IsFailable => Health.Value == Health.MinValue;
|
||||
|
||||
/// <summary>
|
||||
/// Whether this ScoreProcessor has already failed.
|
||||
/// </summary>
|
||||
private bool hasFailed;
|
||||
public override bool HasFailed => Health.Value == Health.MinValue;
|
||||
|
||||
protected ScoreProcessor()
|
||||
{
|
||||
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
|
||||
}
|
||||
|
||||
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer)
|
||||
{
|
||||
Judgements.Capacity = hitRenderer.Beatmap.HitObjects.Count;
|
||||
|
||||
hitRenderer.OnJudgement += addJudgement;
|
||||
|
||||
ComputeTargets(hitRenderer.Beatmap);
|
||||
|
||||
Reset();
|
||||
}
|
||||
|
||||
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer)
|
||||
: this()
|
||||
{
|
||||
Judgements.Capacity = hitRenderer.Beatmap.HitObjects.Count;
|
||||
hitRenderer.OnJudgement += addJudgement;
|
||||
}
|
||||
/// <summary>
|
||||
/// Computes target scoring values for this ScoreProcessor. This is equivalent to performing an auto-play of the score to find the values.
|
||||
/// </summary>
|
||||
/// <param name="beatmap">The Beatmap containing the objects that will be judged by this ScoreProcessor.</param>
|
||||
protected virtual void ComputeTargets(Beatmap<TObject> beatmap) { }
|
||||
|
||||
/// <summary>
|
||||
/// Adds a judgement to this ScoreProcessor.
|
||||
@ -111,33 +147,12 @@ namespace osu.Game.Modes
|
||||
|
||||
judgement.ComboAtHit = (ulong)Combo.Value;
|
||||
|
||||
CheckFailed();
|
||||
UpdateFailed();
|
||||
}
|
||||
|
||||
public override bool CheckFailed()
|
||||
{
|
||||
if (!hasFailed && IsFailable)
|
||||
{
|
||||
hasFailed = true;
|
||||
TriggerFailed();
|
||||
}
|
||||
|
||||
return hasFailed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resets this ScoreProcessor to a stale state.
|
||||
/// </summary>
|
||||
protected virtual void Reset()
|
||||
protected override void Reset()
|
||||
{
|
||||
Judgements.Clear();
|
||||
|
||||
hasFailed = false;
|
||||
TotalScore.Value = 0;
|
||||
Accuracy.Value = 0;
|
||||
Health.Value = 0;
|
||||
Combo.Value = 0;
|
||||
HighestCombo.Value = 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,4 +161,4 @@ namespace osu.Game.Modes
|
||||
/// <param name="newJudgement">A new JudgementInfo that triggered this calculation. May be null.</param>
|
||||
protected abstract void UpdateCalculations(TJudgement newJudgement);
|
||||
}
|
||||
}
|
||||
}
|
@ -25,6 +25,9 @@ namespace osu.Game.Modes.UI
|
||||
/// </summary>
|
||||
public abstract class HitRenderer : Container
|
||||
{
|
||||
/// <summary>
|
||||
/// Invoked when all the judgeable HitObjects have been judged.
|
||||
/// </summary>
|
||||
public event Action OnAllJudged;
|
||||
|
||||
/// <summary>
|
||||
@ -86,16 +89,26 @@ namespace osu.Game.Modes.UI
|
||||
{
|
||||
Debug.Assert(beatmap != null, "HitRenderer initialized with a null beatmap.");
|
||||
|
||||
// Convert + process the beatmap
|
||||
Beatmap = CreateBeatmapConverter().Convert(beatmap.Beatmap);
|
||||
Beatmap.HitObjects.ForEach(h => CreateBeatmapProcessor().SetDefaults(h, Beatmap));
|
||||
CreateBeatmapProcessor().PostProcess(Beatmap);
|
||||
|
||||
applyMods(beatmap.Mods.Value);
|
||||
|
||||
RelativeSizeAxes = Axes.Both;
|
||||
|
||||
IBeatmapConverter<TObject> converter = CreateBeatmapConverter();
|
||||
IBeatmapProcessor<TObject> processor = CreateBeatmapProcessor();
|
||||
|
||||
// Convert the beatmap
|
||||
Beatmap = converter.Convert(beatmap.Beatmap);
|
||||
|
||||
// Apply defaults
|
||||
foreach (var h in Beatmap.HitObjects)
|
||||
h.ApplyDefaults(Beatmap.TimingInfo, Beatmap.BeatmapInfo.Difficulty);
|
||||
|
||||
// Post-process the beatmap
|
||||
processor.PostProcess(Beatmap);
|
||||
|
||||
// Add mods, should always be the last thing applied to give full control to mods
|
||||
applyMods(beatmap.Mods.Value);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Applies the active mods to this HitRenderer.
|
||||
/// </summary>
|
||||
@ -190,9 +203,10 @@ namespace osu.Game.Modes.UI
|
||||
/// <param name="judgedObject">The object that Judgement has been updated for.</param>
|
||||
private void onJudgement(DrawableHitObject<TObject, TJudgement> judgedObject)
|
||||
{
|
||||
OnJudgement?.Invoke(judgedObject.Judgement);
|
||||
Playfield.OnJudgement(judgedObject);
|
||||
|
||||
OnJudgement?.Invoke(judgedObject.Judgement);
|
||||
|
||||
CheckAllJudged();
|
||||
}
|
||||
|
||||
|
@ -239,14 +239,9 @@ namespace osu.Game.Screens.Play
|
||||
|
||||
private void onCompletion()
|
||||
{
|
||||
// Force a final check to see if the player has failed
|
||||
// Some game modes (e.g. taiko) fail at the end of the map
|
||||
if (scoreProcessor.CheckFailed())
|
||||
{
|
||||
// If failed, onFail will be invoked which will push a new screen.
|
||||
// Let's not push the completion screen in this case
|
||||
// Only show the completion screen if the player hasn't failed
|
||||
if (scoreProcessor.HasFailed)
|
||||
return;
|
||||
}
|
||||
|
||||
Delay(1000);
|
||||
Schedule(delegate
|
||||
@ -254,7 +249,7 @@ namespace osu.Game.Screens.Play
|
||||
ValidForResume = false;
|
||||
Push(new Results
|
||||
{
|
||||
Score = scoreProcessor.GetScore()
|
||||
Score = scoreProcessor.CreateScore()
|
||||
});
|
||||
});
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user