Check nested hitobjects while asserting accent colour

This commit is contained in:
Salman Ahmed 2021-07-22 16:15:23 +03:00
parent 399c3b0be8
commit cd7b90363a

View File

@ -9,6 +9,8 @@ using osu.Framework.Allocation;
using osu.Framework.Audio; using osu.Framework.Audio;
using osu.Game.Beatmaps; using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Rulesets.Objects;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.Osu.Objects; using osu.Game.Rulesets.Osu.Objects;
using osu.Game.Skinning; using osu.Game.Skinning;
using osu.Game.Tests.Beatmaps; using osu.Game.Tests.Beatmaps;
@ -113,31 +115,43 @@ namespace osu.Game.Rulesets.Osu.Tests
{ {
int index = 0; int index = 0;
foreach (var drawable in TestPlayer.DrawableRuleset.Playfield.AllHitObjects) return TestPlayer.DrawableRuleset.Playfield.AllHitObjects.All(d =>
{ {
index = nextExpectedComboIndex(index, (OsuHitObject)drawable.HitObject); index = nextExpectedComboIndex(index, (OsuHitObject)d.HitObject);
return checkComboColour(d, expectedColours[index % expectedColours.Length]);
if (drawable.AccentColour.Value != expectedColours[index % expectedColours.Length]) });
return false;
}
return true;
}); });
static bool checkComboColour(DrawableHitObject drawableHitObject, Color4 expectedColour)
{
return drawableHitObject.AccentColour.Value == expectedColour &&
drawableHitObject.NestedHitObjects.All(n => checkComboColour(n, expectedColour));
}
} }
private static IEnumerable<OsuHitObject> getHitCirclesWithLegacyOffsets() private static IEnumerable<OsuHitObject> getHitCirclesWithLegacyOffsets()
{ {
var hitObjects = new List<OsuHitObject>(); var hitObjects = new List<OsuHitObject>();
for (int i = 0; i < 5; i++) for (int i = 0; i < 10; i++)
{ {
hitObjects.Add(new HitCircle var hitObject = i % 2 == 0
{ ? (OsuHitObject)new HitCircle()
StartTime = i, : new Slider()
Position = new Vector2(256, 192), {
NewCombo = true, Path = new SliderPath(new[]
ComboOffset = i, {
}); new PathControlPoint(new Vector2(0, 0)),
new PathControlPoint(new Vector2(100, 0)),
})
};
hitObject.StartTime = i;
hitObject.Position = new Vector2(256, 192);
hitObject.NewCombo = true;
hitObject.ComboOffset = i;
hitObjects.Add(hitObject);
} }
return hitObjects; return hitObjects;