mirror of
https://github.com/ppy/osu.git
synced 2025-01-12 19:42:55 +08:00
Remove replay logic from DrawableRuleset
(and implement in DrawableEditorRulesetWrapper
)
This commit is contained in:
parent
f14c0eae99
commit
8a76d97b63
@ -1,9 +1,11 @@
|
|||||||
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
|
||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
|
using System.Linq;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
|
using osu.Game.Rulesets.Mods;
|
||||||
using osu.Game.Rulesets.Objects;
|
using osu.Game.Rulesets.Objects;
|
||||||
using osu.Game.Rulesets.UI;
|
using osu.Game.Rulesets.UI;
|
||||||
using osu.Game.Screens.Edit;
|
using osu.Game.Screens.Edit;
|
||||||
@ -52,15 +54,21 @@ namespace osu.Game.Rulesets.Edit
|
|||||||
if (changeHandler != null)
|
if (changeHandler != null)
|
||||||
{
|
{
|
||||||
// for now only regenerate replay on a finalised state change, not HitObjectUpdated.
|
// for now only regenerate replay on a finalised state change, not HitObjectUpdated.
|
||||||
changeHandler.OnStateChange += updateReplay;
|
changeHandler.OnStateChange += () => Scheduler.AddOnce(regenerateAutoplay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
beatmap.HitObjectUpdated += _ => updateReplay();
|
beatmap.HitObjectUpdated += _ => Scheduler.AddOnce(regenerateAutoplay);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateReplay() => Scheduler.AddOnce(drawableRuleset.RegenerateAutoplay);
|
Scheduler.AddOnce(regenerateAutoplay);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenerateAutoplay()
|
||||||
|
{
|
||||||
|
var autoplayMod = drawableRuleset.Mods.OfType<ModAutoplay>().Single();
|
||||||
|
drawableRuleset.SetReplayScore(autoplayMod.CreateReplayScore(drawableRuleset.Beatmap, drawableRuleset.Mods));
|
||||||
|
}
|
||||||
|
|
||||||
private void addHitObject(HitObject hitObject)
|
private void addHitObject(HitObject hitObject)
|
||||||
{
|
{
|
||||||
|
@ -182,18 +182,11 @@ namespace osu.Game.Rulesets.UI
|
|||||||
.WithChild(ResumeOverlay)));
|
.WithChild(ResumeOverlay)));
|
||||||
}
|
}
|
||||||
|
|
||||||
RegenerateAutoplay();
|
applyRulesetMods(Mods, config);
|
||||||
|
|
||||||
loadObjects(cancellationToken ?? default);
|
loadObjects(cancellationToken ?? default);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RegenerateAutoplay()
|
|
||||||
{
|
|
||||||
// for now this is applying mods which aren't just autoplay.
|
|
||||||
// we'll need to reconsider this flow in the future.
|
|
||||||
applyRulesetMods(Mods, config);
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Creates and adds drawable representations of hit objects to the play field.
|
/// Creates and adds drawable representations of hit objects to the play field.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -349,9 +342,6 @@ namespace osu.Game.Rulesets.UI
|
|||||||
foreach (var mod in mods.OfType<IApplicableToDrawableRuleset<TObject>>())
|
foreach (var mod in mods.OfType<IApplicableToDrawableRuleset<TObject>>())
|
||||||
mod.ApplyToDrawableRuleset(this);
|
mod.ApplyToDrawableRuleset(this);
|
||||||
|
|
||||||
foreach (var mod in mods.OfType<ICreateReplay>())
|
|
||||||
SetReplayScore(mod.CreateReplayScore(Beatmap, mods));
|
|
||||||
|
|
||||||
foreach (var mod in mods.OfType<IReadFromConfig>())
|
foreach (var mod in mods.OfType<IReadFromConfig>())
|
||||||
mod.ReadFromConfig(config);
|
mod.ReadFromConfig(config);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user