1
0
mirror of https://github.com/ppy/osu.git synced 2025-01-13 17:13:06 +08:00

Add back CreateScoreProcessor to Ruleset to instantiate a non-generic ScoreProcessor for ScoreDatabase.

This commit is contained in:
smoogipooo 2017-03-16 13:13:45 +09:00
parent 7b66faab9e
commit 5cafec3b6a
11 changed files with 47 additions and 4 deletions

View File

@ -88,5 +88,7 @@ namespace osu.Game.Modes.Catch
};
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new CatchDifficultyCalculator(beatmap);
public override ScoreProcessor CreateScoreProcessor() => new CatchScoreProcessor();
}
}

View File

@ -9,6 +9,10 @@ namespace osu.Game.Modes.Catch
{
internal class CatchScoreProcessor : ScoreProcessor<CatchBaseHit, CatchJudgementInfo>
{
public CatchScoreProcessor()
{
}
public CatchScoreProcessor(HitRenderer<CatchBaseHit, CatchJudgementInfo> hitRenderer)
: base(hitRenderer)
{

View File

@ -103,5 +103,7 @@ namespace osu.Game.Modes.Mania
public override IEnumerable<KeyCounter> CreateGameplayKeys() => new KeyCounter[] { /* Todo: Should be keymod specific */ };
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new ManiaDifficultyCalculator(beatmap);
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
}
}

View File

@ -9,6 +9,10 @@ namespace osu.Game.Modes.Mania
{
internal class ManiaScoreProcessor : ScoreProcessor<ManiaBaseHit, ManiaJudgementInfo>
{
public ManiaScoreProcessor()
{
}
public ManiaScoreProcessor(HitRenderer<ManiaBaseHit, ManiaJudgementInfo> hitRenderer)
: base(hitRenderer)
{

View File

@ -108,5 +108,7 @@ namespace osu.Game.Modes.Osu
new KeyCounterMouse(MouseButton.Left),
new KeyCounterMouse(MouseButton.Right)
};
public override ScoreProcessor CreateScoreProcessor() => new OsuScoreProcessor();
}
}

View File

@ -10,9 +10,19 @@ namespace osu.Game.Modes.Osu
{
internal class OsuScoreProcessor : ScoreProcessor<OsuHitObject, OsuJudgementInfo>
{
public OsuScoreProcessor()
{
}
public OsuScoreProcessor(HitRenderer<OsuHitObject, OsuJudgementInfo> hitRenderer)
: base(hitRenderer)
{
}
protected override void Reset()
{
base.Reset();
Health.Value = 1;
Accuracy.Value = 1;
}

View File

@ -89,5 +89,7 @@ namespace osu.Game.Modes.Taiko
};
public override DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap) => new TaikoDifficultyCalculator(beatmap);
public override ScoreProcessor CreateScoreProcessor() => new TaikoScoreProcessor();
}
}

View File

@ -9,6 +9,10 @@ namespace osu.Game.Modes.Taiko
{
internal class TaikoScoreProcessor : ScoreProcessor<TaikoBaseHit, TaikoJudgementInfo>
{
public TaikoScoreProcessor()
{
}
public TaikoScoreProcessor(HitRenderer<TaikoBaseHit, TaikoJudgementInfo> hitRenderer)
: base(hitRenderer)
{

View File

@ -38,8 +38,8 @@ namespace osu.Game.Database
using (Stream s = storage.GetStream(Path.Combine(replay_folder, replayFilename)))
using (SerializationReader sr = new SerializationReader(s))
{
Ruleset.GetRuleset((PlayMode)sr.ReadByte());
score = new Score();
var ruleset = Ruleset.GetRuleset((PlayMode)sr.ReadByte());
score = ruleset.CreateScoreProcessor().GetScore();
/* score.Pass = true;*/
var version = sr.ReadInt32();

View File

@ -33,6 +33,8 @@ namespace osu.Game.Modes
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
public abstract ScoreProcessor CreateScoreProcessor();
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
protected abstract PlayMode PlayMode { get; }

View File

@ -68,11 +68,17 @@ namespace osu.Game.Modes
/// </summary>
protected bool HasFailed { get; private set; }
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer)
protected ScoreProcessor()
{
Combo.ValueChanged += delegate { HighestCombo.Value = Math.Max(HighestCombo.Value, Combo.Value); };
Judgements = new List<TJudgement>(hitRenderer.Beatmap.HitObjects.Count);
Reset();
}
protected ScoreProcessor(HitRenderer<TObject, TJudgement> hitRenderer)
: this()
{
Judgements = new List<TJudgement>(hitRenderer.Beatmap.HitObjects.Count);
hitRenderer.OnJudgement += addJudgement;
}
@ -90,6 +96,11 @@ namespace osu.Game.Modes
}
}
/// <summary>
/// Resets this ScoreProcessor to a stale state.
/// </summary>
protected virtual void Reset() { }
/// <summary>
/// Update any values that potentially need post-processing on a judgement change.
/// </summary>