Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add mania hidden/fadein combo scaling coverage #22591

Closed
wants to merge 7 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 5 additions & 4 deletions osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModFadeIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public partial class TestSceneManiaModFadeIn : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();

[TestCase(0.5f)]
[TestCase(0.1f)]
[TestCase(0.7f)]
public void TestCoverage(float coverage) => CreateModTest(new ModTestData { Mod = new ManiaModFadeIn { Coverage = { Value = coverage } }, PassCondition = () => true });
[TestCase(0.5f, 0.5f)]
[TestCase(0.1f, 0.1f)]
[TestCase(0.7f, 0.7f)]
[TestCase(0.1f, 0.7f)]
public void TestCoverage(float minCoverage, float maxCoverage) => CreateModTest(new ModTestData { Mod = new ManiaModFadeIn { MinCoverage = { Value = minCoverage }, MaxCoverage = { Value = maxCoverage } }, PassCondition = () => true });
}
}
9 changes: 5 additions & 4 deletions osu.Game.Rulesets.Mania.Tests/Mods/TestSceneManiaModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@ public partial class TestSceneManiaModHidden : ModTestScene
{
protected override Ruleset CreatePlayerRuleset() => new ManiaRuleset();

[TestCase(0.5f)]
[TestCase(0.2f)]
[TestCase(0.8f)]
public void TestCoverage(float coverage) => CreateModTest(new ModTestData { Mod = new ManiaModHidden { Coverage = { Value = coverage } }, PassCondition = () => true });
[TestCase(0.3f, 0.6f)]
[TestCase(0.2f, 0.2f)]
[TestCase(0.8f, 0.8f)]
[TestCase(0.2f, 0.8f)]
public void TestCoverage(float minCoverage, float maxCoverage) => CreateModTest(new ModTestData { Mod = new ManiaModHidden { MinCoverage = { Value = minCoverage }, MaxCoverage = { Value = maxCoverage } }, PassCondition = () => true });
}
}
10 changes: 9 additions & 1 deletion osu.Game.Rulesets.Mania/Mods/ManiaModFadeIn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ public class ManiaModFadeIn : ManiaModPlayfieldCover

protected override CoverExpandDirection ExpandDirection => CoverExpandDirection.AlongScroll;

public override BindableNumber<float> Coverage { get; } = new BindableFloat(0.5f)
public override BindableNumber<float> MinCoverage { get; } = new BindableFloat(0.5f)
{
Precision = 0.1f,
MinValue = 0.1f,
MaxValue = 0.7f,
Default = 0.5f,
};

public override BindableNumber<float> MaxCoverage { get; } = new BindableFloat(0.5f)
{
Precision = 0.1f,
MinValue = 0.1f,
Expand Down
18 changes: 13 additions & 5 deletions osu.Game.Rulesets.Mania/Mods/ManiaModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,24 @@ public class ManiaModHidden : ManiaModPlayfieldCover
public override LocalisableString Description => @"Keys fade out before you hit them!";
public override double ScoreMultiplier => 1;

public override BindableNumber<float> Coverage { get; } = new BindableFloat(0.5f)
public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ManiaModFadeIn)).ToArray();

protected override CoverExpandDirection ExpandDirection => CoverExpandDirection.AgainstScroll;

public override BindableNumber<float> MinCoverage { get; } = new BindableFloat(0.3f)
{
Precision = 0.1f,
MinValue = 0.2f,
MaxValue = 0.8f,
Default = 0.5f,
Default = 0.3f,
};

public override Type[] IncompatibleMods => base.IncompatibleMods.Append(typeof(ManiaModFadeIn)).ToArray();

protected override CoverExpandDirection ExpandDirection => CoverExpandDirection.AgainstScroll;
public override BindableNumber<float> MaxCoverage { get; } = new BindableFloat(0.6f)
{
Precision = 0.1f,
MinValue = 0.2f,
MaxValue = 0.8f,
Default = 0.6f,
};
}
}
66 changes: 61 additions & 5 deletions osu.Game.Rulesets.Mania/Mods/ManiaModPlayfieldCover.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,37 +12,72 @@
using osu.Game.Rulesets.Mods;
using osu.Game.Rulesets.Objects.Drawables;
using osu.Game.Rulesets.UI;
using osu.Game.Rulesets.Scoring;
using System.Collections.Generic;
using osu.Framework.Timing;

namespace osu.Game.Rulesets.Mania.Mods
{
public abstract class ManiaModPlayfieldCover : ModHidden, IApplicableToDrawableRuleset<ManiaHitObject>
{
private const float combo_to_reach_max_coverage = 480;

private float currentCoverage;
private float coverageRange;

private List<PlayfieldCoveringWrapper> coveringWrappers = null!;
private IFrameBasedClock clock = null!;
public override Type[] IncompatibleMods => new[] { typeof(ModFlashlight<ManiaHitObject>) };

/// <summary>
/// The direction in which the cover should expand.
/// </summary>
protected abstract CoverExpandDirection ExpandDirection { get; }

[SettingSource("Coverage", "The proportion of playfield height that notes will be hidden for.")]
public abstract BindableNumber<float> Coverage { get; }
[SettingSource("Minimum Coverage", "The minimum proportion of playfield height that notes will be hidden for.")]
public abstract BindableNumber<float> MinCoverage { get; }

[SettingSource("Maximum Coverage", "The maximum proportion of playfield height that notes will be hidden for.")]
public abstract BindableNumber<float> MaxCoverage { get; }

private readonly BindableInt combo = new BindableInt();

public override void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
combo.BindTo(scoreProcessor.Combo);

base.ApplyToScoreProcessor(scoreProcessor);
}

public virtual void ApplyToDrawableRuleset(DrawableRuleset<ManiaHitObject> drawableRuleset)
{
ManiaPlayfield maniaPlayfield = (ManiaPlayfield)drawableRuleset.Playfield;
coveringWrappers = new List<PlayfieldCoveringWrapper>();
clock = maniaPlayfield.Clock;
currentCoverage = MinCoverage.Value;
coverageRange = Math.Max(0, MaxCoverage.Value - MinCoverage.Value);

if (coverageRange > 0)
{
maniaPlayfield.OnUpdate += _ => updateCoverage();
}

foreach (Column column in maniaPlayfield.Stages.SelectMany(stage => stage.Columns))
{
HitObjectContainer hoc = column.HitObjectArea.HitObjectContainer;
Container hocParent = (Container)hoc.Parent;

hocParent.Remove(hoc, false);
hocParent.Add(new PlayfieldCoveringWrapper(hoc).With(c =>

PlayfieldCoveringWrapper coveringWrapper = new PlayfieldCoveringWrapper(hoc).With(c =>
{
c.RelativeSizeAxes = Axes.Both;
c.Direction = ExpandDirection;
c.Coverage = Coverage.Value;
}));
c.Coverage = MinCoverage.Value;
});

hocParent.Add(coveringWrapper);
coveringWrappers.Add(coveringWrapper);
}
}

Expand All @@ -53,5 +88,26 @@ protected override void ApplyIncreasedVisibilityState(DrawableHitObject hitObjec
protected override void ApplyNormalVisibilityState(DrawableHitObject hitObject, ArmedState state)
{
}

private void updateCoverage()
{
float targetCoverage = getComboBasedCoverageAmount();

if (targetCoverage != currentCoverage)
{
currentCoverage = targetCoverage;
foreach (PlayfieldCoveringWrapper wrapper in coveringWrappers)
wrapper.Coverage = currentCoverage;
}
}

private float getComboBasedCoverageAmount()
{
float targetCoverage = MinCoverage.Value + coverageRange * Math.Min(1.0f, combo.Value / combo_to_reach_max_coverage);
if (currentCoverage > targetCoverage && clock.ElapsedFrameTime > 0)
return currentCoverage - coverageRange * (float)clock.ElapsedFrameTime / 500;
else
return targetCoverage;
}
}
}
2 changes: 1 addition & 1 deletion osu.Game/Rulesets/Mods/ModHidden.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public abstract class ModHidden : ModWithVisibilityAdjustment, IApplicableToScor
public override IconUsage? Icon => OsuIcon.ModHidden;
public override ModType Type => ModType.DifficultyIncrease;

public void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
public virtual void ApplyToScoreProcessor(ScoreProcessor scoreProcessor)
{
// Default value of ScoreProcessor's Rank in Hidden Mod should be SS+
scoreProcessor.Rank.Value = ScoreRank.XH;
Expand Down