1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-06 09:07:25 +08:00

Remove unnecessary lists

This commit is contained in:
Bartłomiej Dach 2020-04-28 23:22:50 +02:00
parent 0d285ac0f4
commit 24216b6600

View File

@ -39,9 +39,8 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
private Bindable<WorkingBeatmap> workingBeatmap; private Bindable<WorkingBeatmap> workingBeatmap;
private readonly List<DrawableTaikoMascot> mascots = new List<DrawableTaikoMascot>(); private IEnumerable<TestDrawableTaikoMascot> mascots => this.ChildrenOfType<TestDrawableTaikoMascot>();
private readonly List<TaikoPlayfield> playfields = new List<TaikoPlayfield>(); private IEnumerable<TaikoPlayfield> playfields => this.ChildrenOfType<TaikoPlayfield>();
private readonly List<DrawableTaikoRuleset> rulesets = new List<DrawableTaikoRuleset>();
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(Bindable<WorkingBeatmap> beatmap) private void load(Bindable<WorkingBeatmap> beatmap)
@ -56,14 +55,7 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
AddStep("Create mascot (idle)", () => AddStep("Create mascot (idle)", () =>
{ {
mascots.Clear(); SetContents(() => new TestDrawableTaikoMascot());
SetContents(() =>
{
var mascot = new TestDrawableTaikoMascot();
mascots.Add(mascot);
return mascot;
});
}); });
AddStep("Clear state", () => setState(TaikoMascotAnimationState.Clear)); AddStep("Clear state", () => setState(TaikoMascotAnimationState.Clear));
@ -80,19 +72,13 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
AddStep("Create ruleset", () => AddStep("Create ruleset", () =>
{ {
rulesets.Clear();
SetContents(() => SetContents(() =>
{ {
var ruleset = new TaikoRuleset(); var ruleset = new TaikoRuleset();
var drawableRuleset = new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo)); return new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
rulesets.Add(drawableRuleset);
return drawableRuleset;
}); });
}); });
AddStep("Collect playfields", collectPlayfields);
AddStep("Collect mascots", collectMascots);
AddStep("Create hit (miss)", () => AddStep("Create hit (miss)", () =>
{ {
foreach (var playfield in playfields) foreach (var playfield in playfields)
@ -121,19 +107,13 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
{ {
workingBeatmap.Value.Track.Start(); workingBeatmap.Value.Track.Start();
rulesets.Clear();
SetContents(() => SetContents(() =>
{ {
var ruleset = new TaikoRuleset(); var ruleset = new TaikoRuleset();
var drawableRuleset = new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo)); return new DrawableTaikoRuleset(ruleset, workingBeatmap.Value.GetPlayableBeatmap(ruleset.RulesetInfo));
rulesets.Add(drawableRuleset);
return drawableRuleset;
}); });
}); });
AddStep("Collect playfields", collectPlayfields);
AddStep("Collect mascots", collectMascots);
AddUntilStep("Wait for fail state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Fail)); AddUntilStep("Wait for fail state", () => mascots.Where(d => d != null).All(d => d.State == TaikoMascotAnimationState.Fail));
AddStep("Create hit (great)", () => AddStep("Create hit (great)", () =>
@ -177,26 +157,6 @@ namespace osu.Game.Rulesets.Taiko.Tests.Skinning
mascot?.ShowState(state); mascot?.ShowState(state);
} }
private void collectPlayfields()
{
playfields.Clear();
foreach (var ruleset in rulesets)
playfields.Add(ruleset.ChildrenOfType<TaikoPlayfield>().Single());
}
private void collectMascots()
{
mascots.Clear();
foreach (var playfield in playfields)
{
var mascot = playfield.ChildrenOfType<DrawableTaikoMascot>()
.SingleOrDefault();
if (mascot != null) mascots.Add(mascot);
}
}
private void addJudgement(TaikoPlayfield playfield, HitResult result) private void addJudgement(TaikoPlayfield playfield, HitResult result)
{ {
playfield.OnNewResult(new DrawableHit(new Hit()), new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = result }); playfield.OnNewResult(new DrawableHit(new Hit()), new JudgementResult(new HitObject(), new TaikoJudgement()) { Type = result });