1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-16 02:37:19 +08:00

Make processors and break overlay frame-stable

This commit is contained in:
smoogipoo 2019-12-25 14:35:32 +09:00
parent 85c44b5a5a
commit 977fb3d1bf
4 changed files with 34 additions and 36 deletions

View File

@ -49,7 +49,12 @@ namespace osu.Game.Rulesets.Scoring
healthIncreases = null;
}
public override void ApplyElapsedTime(double elapsedTime) => Health.Value -= drainRate * elapsedTime;
protected override void Update()
{
base.Update();
Health.Value -= drainRate * Time.Elapsed;
}
protected override void ApplyResultInternal(JudgementResult result)
{

View File

@ -3,13 +3,14 @@
using System;
using osu.Framework.Extensions.TypeExtensions;
using osu.Framework.Graphics;
using osu.Game.Beatmaps;
using osu.Game.Rulesets.Judgements;
using osu.Game.Rulesets.Objects;
namespace osu.Game.Rulesets.Scoring
{
public abstract class JudgementProcessor
public abstract class JudgementProcessor : Component
{
/// <summary>
/// Invoked when all <see cref="HitObject"/>s have been judged by this <see cref="JudgementProcessor"/>.
@ -47,10 +48,6 @@ namespace osu.Game.Rulesets.Scoring
Reset(true);
}
public virtual void ApplyElapsedTime(double elapsedTime)
{
}
/// <summary>
/// Applies the score change of a <see cref="JudgementResult"/> to this <see cref="ScoreProcessor"/>.
/// </summary>
@ -119,8 +116,6 @@ namespace osu.Game.Rulesets.Scoring
/// <param name="beatmap">The <see cref="IBeatmap"/> to simulate.</param>
protected virtual void SimulateAutoplay(IBeatmap beatmap)
{
HitObject lastObject = null;
foreach (var obj in beatmap.HitObjects)
simulate(obj);
@ -129,9 +124,6 @@ namespace osu.Game.Rulesets.Scoring
foreach (var nested in obj.NestedHitObjects)
simulate(nested);
if (lastObject != null)
ApplyElapsedTime(lastObject.GetEndTime() - obj.StartTime);
var judgement = obj.CreateJudgement();
if (judgement == null)
return;
@ -142,8 +134,6 @@ namespace osu.Game.Rulesets.Scoring
result.Type = judgement.MaxResult;
ApplyResult(result);
lastObject = obj;
}
}
}

View File

@ -72,10 +72,9 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public override Playfield Playfield => playfield.Value;
/// <summary>
/// Place to put drawables above hit objects but below UI.
/// </summary>
public Container Overlays { get; private set; }
private Container overlays;
public override Container Overlays => overlays;
public override GameplayClock FrameStableClock => frameStabilityContainer.GameplayClock;
@ -185,12 +184,15 @@ namespace osu.Game.Rulesets.UI
frameStabilityContainer = new FrameStabilityContainer(GameplayStartTime)
{
FrameStablePlayback = FrameStablePlayback,
Child = KeyBindingInputManager
.WithChild(CreatePlayfieldAdjustmentContainer()
.WithChild(Playfield)
)
Children = new Drawable[]
{
KeyBindingInputManager
.WithChild(CreatePlayfieldAdjustmentContainer()
.WithChild(Playfield)
),
overlays = new Container { RelativeSizeAxes = Axes.Both }
}
},
Overlays = new Container { RelativeSizeAxes = Axes.Both }
};
if ((ResumeOverlay = CreateResumeOverlay()) != null)
@ -385,6 +387,11 @@ namespace osu.Game.Rulesets.UI
/// </summary>
public abstract Playfield Playfield { get; }
/// <summary>
/// Place to put drawables above hit objects but below UI.
/// </summary>
public abstract Container Overlays { get; }
/// <summary>
/// The frame-stable clock which is being used for playfield display.
/// </summary>

View File

@ -208,12 +208,6 @@ namespace osu.Game.Screens.Play
{
target.AddRange(new[]
{
BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Breaks = working.Beatmap.Breaks
},
// display the cursor above some HUD elements.
DrawableRuleset.Cursor?.CreateProxy() ?? new Container(),
DrawableRuleset.ResumeOverlay?.CreateProxy() ?? new Container(),
@ -268,6 +262,16 @@ namespace osu.Game.Screens.Play
},
failAnimation = new FailAnimation(DrawableRuleset) { OnComplete = onFailComplete, }
});
DrawableRuleset.Overlays.Add(BreakOverlay = new BreakOverlay(working.Beatmap.BeatmapInfo.LetterboxInBreaks, DrawableRuleset.GameplayStartTime, ScoreProcessor)
{
Anchor = Anchor.Centre,
Origin = Anchor.Centre,
Breaks = working.Beatmap.Breaks
});
DrawableRuleset.Overlays.Add(ScoreProcessor);
DrawableRuleset.Overlays.Add(HealthProcessor);
}
private void updatePauseOnFocusLostState() =>
@ -342,14 +346,6 @@ namespace osu.Game.Screens.Play
this.Exit();
}
protected override void Update()
{
base.Update();
if (!GameplayClockContainer.IsPaused.Value)
HealthProcessor.ApplyElapsedTime(GameplayClockContainer.GameplayClock.ElapsedFrameTime);
}
/// <summary>
/// Restart gameplay via a parent <see cref="PlayerLoader"/>.
/// <remarks>This can be called from a child screen in order to trigger the restart process.</remarks>