Skip to content

Commit 1d3e682

Browse files
author
Bartłomiej Dach
authored
Add score multiplier calculator API (ppy#37822)
- Part of ppy#37818 - Continued from ppy#37355 (comment) ## Overview This PR introduces an alternative API, `ScoreMultiplierCalculator`, to be used going forward for calculating mod multipliers. The reason for introducing this new API is that it has been requested that: - For any two given mods, it should be possible to have the combined mod multipliers of them in combination be *different* than the product of the individual mods' multipliers in isolation, i.e. $mult( \\{ A, B \\} ) \neq mult( \\{ A \\} ) \cdot mult( \\{ B \\} )$. - For an individual mod, it should be possible to have the mod multipliers depend on a quantity that is *not* the presence of another mod or the direct value of a setting on the mod. This capability is being demonstrated in this PR via the `osu.Game.Tests.Rulesets.Scoring.ScoreMultiplierCalculatorTest` test fixture. ## Parity with `Mod.ScoreMultiplier` This PR contains a `ScoreMultiplierCalculator` implementation for each of the built-in four rulesets. The abstract `osu.Game.Tests.Rulesets.RulesetScoreMultiplierTest` and its four derived ruleset-specific test fixtures were written to ensure that the new implementations do not diverge from the current state of affairs. `Mod.ScoreMultiplier` is not removed in this diff to keep size low. It will be removed as a follow-up. ## Performance This PR contains a benchmark comparing the current implementation via `Mod.ScoreMultiplier` and the new `ScoreMultiplierCalculator` API. Results below. <details> | Method | Times | Mods | Mean | Error | StdDev | Gen0 | Allocated | |---------------------- |------ |--------------------- |--------------:|------------:|------------:|--------:|----------:| | ViaModScoreMultiplier | 1 | mods (...)tings [27] | 121.171 ns | 1.5284 ns | 1.4297 ns | 0.0782 | 656 B | | ViaCalculator | 1 | mods (...)tings [27] | 248.509 ns | 1.9313 ns | 1.6127 ns | 0.1364 | 1144 B | | ViaModScoreMultiplier | 1 | multiple mods | 128.357 ns | 0.4282 ns | 0.4006 ns | 0.0782 | 656 B | | ViaCalculator | 1 | multiple mods | 252.953 ns | 1.2860 ns | 1.2029 ns | 0.1364 | 1144 B | | ViaModScoreMultiplier | 1 | no mods | 3.007 ns | 0.0345 ns | 0.0288 ns | - | - | | ViaCalculator | 1 | no mods | 14.802 ns | 0.0616 ns | 0.0576 ns | 0.0134 | 112 B | | ViaModScoreMultiplier | 1 | single mod | 40.271 ns | 0.1238 ns | 0.1098 ns | 0.0258 | 216 B | | ViaCalculator | 1 | single mod | 113.033 ns | 0.3140 ns | 0.2937 ns | 0.0842 | 704 B | | ViaModScoreMultiplier | 1 | single mod 2 | 3.653 ns | 0.0384 ns | 0.0359 ns | 0.0038 | 32 B | | ViaCalculator | 1 | single mod 2 | 78.172 ns | 0.0680 ns | 0.0603 ns | 0.0621 | 520 B | | ViaModScoreMultiplier | 10 | mods (...)tings [27] | 1,169.609 ns | 4.3058 ns | 4.0276 ns | 0.7839 | 6560 B | | ViaCalculator | 10 | mods (...)tings [27] | 2,575.264 ns | 21.2705 ns | 19.8964 ns | 1.3657 | 11440 B | | ViaModScoreMultiplier | 10 | multiple mods | 1,171.775 ns | 6.2332 ns | 5.2050 ns | 0.7839 | 6560 B | | ViaCalculator | 10 | multiple mods | 2,579.593 ns | 22.1010 ns | 20.6733 ns | 1.3657 | 11440 B | | ViaModScoreMultiplier | 10 | no mods | 35.943 ns | 0.1665 ns | 0.1476 ns | - | - | | ViaCalculator | 10 | no mods | 154.980 ns | 0.2381 ns | 0.1988 ns | 0.1338 | 1120 B | | ViaModScoreMultiplier | 10 | single mod | 404.185 ns | 1.3190 ns | 1.2338 ns | 0.2580 | 2160 B | | ViaCalculator | 10 | single mod | 1,167.279 ns | 6.1641 ns | 5.7659 ns | 0.8411 | 7040 B | | ViaModScoreMultiplier | 10 | single mod 2 | 42.128 ns | 0.2878 ns | 0.2692 ns | 0.0382 | 320 B | | ViaCalculator | 10 | single mod 2 | 775.435 ns | 2.3318 ns | 2.1811 ns | 0.6208 | 5200 B | | ViaModScoreMultiplier | 100 | mods (...)tings [27] | 11,623.346 ns | 51.7174 ns | 43.1863 ns | 7.8430 | 65600 B | | ViaCalculator | 100 | mods (...)tings [27] | 25,252.987 ns | 44.4352 ns | 39.3906 ns | 13.6719 | 114400 B | | ViaModScoreMultiplier | 100 | multiple mods | 11,928.536 ns | 35.2079 ns | 32.9334 ns | 7.8430 | 65600 B | | ViaCalculator | 100 | multiple mods | 25,399.378 ns | 152.4597 ns | 127.3108 ns | 13.6719 | 114400 B | | ViaModScoreMultiplier | 100 | no mods | 328.158 ns | 0.5827 ns | 0.5165 ns | - | - | | ViaCalculator | 100 | no mods | 1,517.485 ns | 10.2304 ns | 9.5695 ns | 1.3390 | 11200 B | | ViaModScoreMultiplier | 100 | single mod | 3,986.251 ns | 24.2523 ns | 21.4991 ns | 2.5787 | 21600 B | | ViaCalculator | 100 | single mod | 11,479.514 ns | 23.3738 ns | 20.7203 ns | 8.4076 | 70400 B | | ViaModScoreMultiplier | 100 | single mod 2 | 385.679 ns | 3.5190 ns | 3.2917 ns | 0.3824 | 3200 B | | ViaCalculator | 100 | single mod 2 | 7,658.646 ns | 21.8274 ns | 19.3494 ns | 6.2103 | 52000 B | </details> While the calculator is obviously slower, in my view it is not egregiously so. The main overheads both time- and memory-wise are collection allocations for the dictionary and the set which I consider to be directly caused by the requested additional complexity and as such I don't really consider them eliminable. I have tried and applied some micro-optimisations (e2469ce, cb33abe), albeit with negligible effect. I have also tried to key the mods by `Acronym` instead of by `Type` and the difference was basically nil. <details> <summary>patch for keying by acronym</summary> ```diff diff --git a/osu.Game/Rulesets/Scoring/ScoreMultiplierCalculator.cs b/osu.Game/Rulesets/Scoring/ScoreMultiplierCalculator.cs index 772f9d1..7f5907cbda 100644 --- a/osu.Game/Rulesets/Scoring/ScoreMultiplierCalculator.cs +++ b/osu.Game/Rulesets/Scoring/ScoreMultiplierCalculator.cs @@ -13,26 +13,26 @@ namespace osu.Game.Rulesets.Scoring /// </summary> public class ScoreMultiplierCalculator { - private static readonly List<(Type[] mods, Func<Mod[], double> multiplier)> combination_multipliers = []; - private static readonly Dictionary<Type, Func<Mod, ScoreMultiplierCalculator, double>> single_multipliers_with_context = []; - private static readonly Dictionary<Type, Func<Mod, double>> single_multipliers = []; + private static readonly List<(string[] modAcronyms, Func<Mod[], double> multiplier)> combination_multipliers = []; + private static readonly Dictionary<string, Func<Mod, ScoreMultiplierCalculator, double>> single_multipliers_with_context = []; + private static readonly Dictionary<string, Func<Mod, double>> single_multipliers = []; /// <summary> /// Defines a flat, setting-independent score multiplier for the given <typeparamref name="TMod"/>. /// </summary> public static void Single<TMod>(double hasMultiplier) - where TMod : Mod + where TMod : Mod, new() { - single_multipliers[typeof(TMod)] = _ => hasMultiplier; + single_multipliers[new TMod().Acronym] = _ => hasMultiplier; } /// <summary> /// Defines a setting-dependent score multiplier for the given <typeparamref name="TMod"/>. /// </summary> public static void Single<TMod>(Func<TMod, double> hasMultiplier) - where TMod : Mod + where TMod : Mod, new() { - single_multipliers[typeof(TMod)] = mod => hasMultiplier.Invoke((TMod)mod); + single_multipliers[new TMod().Acronym] = mod => hasMultiplier.Invoke((TMod)mod); } /// <summary> @@ -40,20 +40,20 @@ public static void Single<TMod>(Func<TMod, double> hasMultiplier) /// The multiplier calculation is given additional context to calculate the multiplier via the <typeparamref name="TContext"/> type instance. /// </summary> public static void Single<TMod, TContext>(Func<TMod, TContext, double> hasMultiplier) - where TMod : Mod + where TMod : Mod, new() where TContext : ScoreMultiplierCalculator { - single_multipliers_with_context[typeof(TMod)] = (mod, context) => hasMultiplier.Invoke((TMod)mod, (TContext)context); + single_multipliers_with_context[new TMod().Acronym] = (mod, context) => hasMultiplier.Invoke((TMod)mod, (TContext)context); } /// <summary> /// Defines a score multiplier specific to when both <typeparamref name="T1"/> and <typeparamref name="T2"/> mods are present. /// </summary> public static void Combination<T1, T2>(Func<T1, T2, double> hasMultiplier) - where T1 : Mod - where T2 : Mod + where T1 : Mod, new() + where T2 : Mod, new() { - combination_multipliers.Add(([typeof(T1), typeof(T2)], mods => hasMultiplier((T1)mods[0], (T2)mods[1]))); + combination_multipliers.Add(([new T1().Acronym, new T2().Acronym], mods => hasMultiplier((T1)mods[0], (T2)mods[1]))); } /// <summary> @@ -61,7 +61,7 @@ public static void Combination<T1, T2>(Func<T1, T2, double> hasMultiplier) /// </summary> public double CalculateFor(IEnumerable<Mod> mods) { - var allModsByType = mods.ToDictionary(m => m.GetType()); + var allModsByType = mods.ToDictionary(m => m.Acronym); if (allModsByType.Count == 0) return 1; @@ -83,7 +83,7 @@ public double CalculateFor(IEnumerable<Mod> mods) } } - foreach (var modType in remainingModTypes) + foreach (string modType in remainingModTypes) { if (single_multipliers.TryGetValue(modType, out var multiplier)) result *= multiplier(allModsByType[modType]); ``` </details> One particular parallel thread that may warrant follow-up is that `Mod.UsesDefaultConfiguration` is disproportionately expensive due to calling into regexes via Humanizer internals. <img width="1517" height="517" alt="Screenshot_2026-05-19_at_10 58 30" src="https://github.com/user-attachments/assets/68309a8c-74e7-4f96-8ef9-62868eeca337" />
1 parent 732b2a7 commit 1d3e682

17 files changed

Lines changed: 869 additions & 0 deletions

File tree

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using System.Collections.Generic;
5+
using BenchmarkDotNet.Attributes;
6+
using NUnit.Framework;
7+
using osu.Game.Rulesets.Mods;
8+
using osu.Game.Rulesets.Osu;
9+
using osu.Game.Rulesets.Osu.Mods;
10+
using osu.Game.Rulesets.Scoring;
11+
12+
namespace osu.Game.Benchmarks
13+
{
14+
public class BenchmarkScoreMultiplierCalculator : BenchmarkTest
15+
{
16+
private ScoreMultiplierCalculator calculator = null!;
17+
18+
[Params(1, 10, 100)]
19+
public int Times { get; set; }
20+
21+
public record ModTestCase(string Description, IEnumerable<Mod> Mods)
22+
{
23+
public override string ToString() => Description;
24+
}
25+
26+
public static IEnumerable<ModTestCase> ValuesForMods =>
27+
[
28+
new ModTestCase("no mods", []),
29+
new ModTestCase("single mod", [new OsuModHardRock()]),
30+
new ModTestCase("single mod 2", [new OsuModEasy()]),
31+
new ModTestCase("multiple mods", [new OsuModHidden(), new OsuModHardRock(), new OsuModDoubleTime()]),
32+
new ModTestCase("mods with adjusted settings", [
33+
new OsuModDoubleTime { SpeedChange = { Value = 2 } },
34+
new OsuModHidden { OnlyFadeApproachCircles = { Value = true } },
35+
new OsuModHardRock()
36+
]),
37+
];
38+
39+
[ParamsSource(nameof(ValuesForMods))]
40+
public ModTestCase Mods { get; set; } = null!;
41+
42+
public override void SetUp()
43+
{
44+
base.SetUp();
45+
calculator = new OsuRuleset().CreateScoreMultiplierCalculator();
46+
}
47+
48+
[Benchmark]
49+
public double ViaModScoreMultiplier() => viaModScoreMultiplier(Times, Mods);
50+
51+
[Test]
52+
public void ViaModScoreMultiplier([Values(100)] int times, [ValueSource(nameof(ValuesForMods))] ModTestCase mods)
53+
=> viaModScoreMultiplier(times, mods);
54+
55+
private double viaModScoreMultiplier(int times, ModTestCase mods)
56+
{
57+
double scoreMultiplier = 1;
58+
59+
for (int i = 0; i < times; ++i)
60+
{
61+
scoreMultiplier = 1;
62+
63+
foreach (var mod in mods.Mods)
64+
scoreMultiplier *= mod.ScoreMultiplier;
65+
}
66+
67+
return scoreMultiplier;
68+
}
69+
70+
[Benchmark]
71+
public double ViaCalculator()
72+
=> viaCalculator(Times, Mods);
73+
74+
[Test]
75+
public void ViaCalculator([Values(100)] int times, [ValueSource(nameof(ValuesForMods))] ModTestCase mods)
76+
=> viaCalculator(times, mods);
77+
78+
private double viaCalculator(int times, ModTestCase mods)
79+
{
80+
double scoreMultiplier = 1;
81+
82+
for (int i = 0; i < times; ++i)
83+
scoreMultiplier = calculator.CalculateFor(mods.Mods);
84+
85+
return scoreMultiplier;
86+
}
87+
}
88+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using NUnit.Framework;
5+
using osu.Game.Rulesets.Catch.Mods;
6+
using osu.Game.Tests.Rulesets;
7+
8+
namespace osu.Game.Rulesets.Catch.Tests
9+
{
10+
public class CatchScoreMultiplierTest : RulesetScoreMultiplierTest
11+
{
12+
public CatchScoreMultiplierTest()
13+
: base(new CatchRuleset())
14+
{
15+
}
16+
17+
[Test]
18+
public void TestFlashlightOnNonDefaultSettings()
19+
=> TestModCombination([new CatchModFlashlight { ComboBasedSize = { Value = false } }]);
20+
21+
[Test]
22+
public void TestHalfTimeSpeeds([Values(0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99)] double speedChange)
23+
=> TestModCombination([new CatchModHalfTime { SpeedChange = { Value = speedChange } }]);
24+
25+
[Test]
26+
public void TestDaycoreSpeeds([Values(0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99)] double speedChange)
27+
=> TestModCombination([new CatchModDaycore { SpeedChange = { Value = speedChange } }]);
28+
29+
[Test]
30+
public void TestDoubleTimeSpeeds([Values(1.01, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2)] double speedChange)
31+
=> TestModCombination([new CatchModDoubleTime { SpeedChange = { Value = speedChange } }]);
32+
33+
[Test]
34+
public void TestNightcoreSpeeds([Values(1.01, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2)] double speedChange)
35+
=> TestModCombination([new CatchModNightcore { SpeedChange = { Value = speedChange } }]);
36+
37+
[Test]
38+
public void TestMultiplicativeCombination()
39+
=> TestModCombination([new CatchModHidden(), new CatchModHardRock()]);
40+
}
41+
}

osu.Game.Rulesets.Catch/CatchRuleset.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
169169
}
170170
}
171171

172+
public override ScoreMultiplierCalculator CreateScoreMultiplierCalculator() => new CatchScoreMultiplierCalculator();
173+
172174
public override string Description => "osu!catch";
173175

174176
public override string ShortName => SHORT_NAME;
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using osu.Game.Rulesets.Catch.Mods;
5+
using osu.Game.Rulesets.Mods;
6+
using osu.Game.Rulesets.Scoring;
7+
8+
namespace osu.Game.Rulesets.Catch.Scoring
9+
{
10+
public class CatchScoreMultiplierCalculator : ScoreMultiplierCalculator
11+
{
12+
static CatchScoreMultiplierCalculator()
13+
{
14+
#region Difficulty Reduction
15+
16+
Single<CatchModEasy>(hasMultiplier: 0.5);
17+
Single<CatchModNoFail>(hasMultiplier: 0.5);
18+
Single<CatchModHalfTime>(hasMultiplier: halfTime => rateAdjustMultiplier(halfTime.SpeedChange.Value));
19+
Single<CatchModDaycore>(hasMultiplier: daycore => rateAdjustMultiplier(daycore.SpeedChange.Value));
20+
21+
#endregion
22+
23+
#region Difficulty Increase
24+
25+
Single<CatchModHardRock>(hasMultiplier: hardRock => hardRock.UsesDefaultConfiguration ? 1.12 : 1);
26+
// Sudden Death
27+
// Perfect
28+
Single<CatchModDoubleTime>(hasMultiplier: doubleTime => rateAdjustMultiplier(doubleTime.SpeedChange.Value));
29+
Single<CatchModNightcore>(hasMultiplier: nightcore => rateAdjustMultiplier(nightcore.SpeedChange.Value));
30+
Single<CatchModHidden>(hasMultiplier: hidden => hidden.UsesDefaultConfiguration ? 1.06 : 1);
31+
Single<CatchModFlashlight>(hasMultiplier: flashlight => flashlight.UsesDefaultConfiguration ? 1.12 : 1);
32+
// Accuracy Challenge
33+
34+
#endregion
35+
36+
#region Conversion
37+
38+
Single<CatchModDifficultyAdjust>(hasMultiplier: 0.5);
39+
Single<CatchModClassic>(hasMultiplier: 0.96);
40+
// Mirror
41+
42+
#endregion
43+
44+
#region Automation
45+
46+
// Autoplay
47+
// Cinema
48+
Single<CatchModRelax>(hasMultiplier: 0.1);
49+
50+
#endregion
51+
52+
#region Fun
53+
54+
Single<ModWindUp>(hasMultiplier: 0.5);
55+
Single<ModWindDown>(hasMultiplier: 0.5);
56+
// Floating Fruits
57+
// Muted
58+
// No Scope
59+
// Moving Fast
60+
Single<CatchModSynesthesia>(hasMultiplier: 0.8);
61+
62+
#endregion
63+
64+
#region System
65+
66+
// Score V2
67+
68+
#endregion
69+
}
70+
71+
private static double rateAdjustMultiplier(double speedChange)
72+
{
73+
// Round to the nearest multiple of 0.1.
74+
double value = (int)(speedChange * 10) / 10.0;
75+
76+
// Offset back to 0.
77+
value -= 1;
78+
79+
if (speedChange >= 1)
80+
return 1 + value / 5;
81+
else
82+
return 0.6 + value;
83+
}
84+
}
85+
}
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using NUnit.Framework;
5+
using osu.Game.Rulesets.Mania.Mods;
6+
using osu.Game.Tests.Rulesets;
7+
8+
namespace osu.Game.Rulesets.Mania.Tests
9+
{
10+
public class ManiaScoreMultiplierTest : RulesetScoreMultiplierTest
11+
{
12+
public ManiaScoreMultiplierTest()
13+
: base(new ManiaRuleset())
14+
{
15+
}
16+
17+
[Test]
18+
public void TestHalfTimeSpeeds([Values(0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99)] double speedChange)
19+
=> TestModCombination([new ManiaModHalfTime { SpeedChange = { Value = speedChange } }]);
20+
21+
[Test]
22+
public void TestDaycoreSpeeds([Values(0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95, 0.99)] double speedChange)
23+
=> TestModCombination([new ManiaModDaycore { SpeedChange = { Value = speedChange } }]);
24+
25+
[Test]
26+
public void TestDoubleTimeSpeeds([Values(1.01, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2)] double speedChange)
27+
=> TestModCombination([new ManiaModDoubleTime { SpeedChange = { Value = speedChange } }]);
28+
29+
[Test]
30+
public void TestNightcoreSpeeds([Values(1.01, 1.05, 1.1, 1.15, 1.2, 1.25, 1.3, 1.35, 1.4, 1.45, 1.5, 1.55, 1.6, 1.65, 1.7, 1.75, 1.8, 1.85, 1.9, 1.95, 2)] double speedChange)
31+
=> TestModCombination([new ManiaModNightcore { SpeedChange = { Value = speedChange } }]);
32+
33+
[Test]
34+
public void TestMultiplicativeCombination()
35+
=> TestModCombination([new ManiaModEasy(), new ManiaModKey4()]);
36+
}
37+
}

osu.Game.Rulesets.Mania/ManiaRuleset.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,8 @@ public override IEnumerable<Mod> GetModsFor(ModType type)
307307
}
308308
}
309309

310+
public override ScoreMultiplierCalculator CreateScoreMultiplierCalculator() => new ManiaScoreMultiplierCalculator();
311+
310312
public override string Description => "osu!mania";
311313

312314
public override string ShortName => SHORT_NAME;
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
2+
// See the LICENCE file in the repository root for full licence text.
3+
4+
using osu.Game.Rulesets.Mania.Mods;
5+
using osu.Game.Rulesets.Mods;
6+
using osu.Game.Rulesets.Scoring;
7+
8+
namespace osu.Game.Rulesets.Mania.Scoring
9+
{
10+
public class ManiaScoreMultiplierCalculator : ScoreMultiplierCalculator
11+
{
12+
static ManiaScoreMultiplierCalculator()
13+
{
14+
#region Difficulty Reduction
15+
16+
Single<ManiaModEasy>(hasMultiplier: 0.5);
17+
Single<ManiaModNoFail>(hasMultiplier: 0.5);
18+
Single<ManiaModHalfTime>(hasMultiplier: halfTime => rateAdjustMultiplier(halfTime.SpeedChange.Value));
19+
Single<ManiaModDaycore>(hasMultiplier: daycore => rateAdjustMultiplier(daycore.SpeedChange.Value));
20+
Single<ManiaModNoRelease>(hasMultiplier: 0.9);
21+
22+
#endregion
23+
24+
#region Difficulty Increase
25+
26+
// Hard Rock
27+
// Sudden Death
28+
// Perfect
29+
// Double Time
30+
// Nightcore
31+
// Fade In
32+
// Hidden
33+
// Cover
34+
// Flashlight
35+
// Accuracy Challenge
36+
37+
#endregion
38+
39+
#region Conversion
40+
41+
// Random
42+
// Dual Stages
43+
// Mirror
44+
Single<ManiaModDifficultyAdjust>(hasMultiplier: 0.5);
45+
Single<ManiaModClassic>(hasMultiplier: 0.96);
46+
// Invert
47+
Single<ManiaModConstantSpeed>(hasMultiplier: 0.9);
48+
Single<ManiaModHoldOff>(hasMultiplier: 0.9);
49+
Single<ManiaModKey1>(hasMultiplier: 0.9);
50+
Single<ManiaModKey2>(hasMultiplier: 0.9);
51+
Single<ManiaModKey3>(hasMultiplier: 0.9);
52+
Single<ManiaModKey4>(hasMultiplier: 0.9);
53+
Single<ManiaModKey5>(hasMultiplier: 0.9);
54+
Single<ManiaModKey6>(hasMultiplier: 0.9);
55+
Single<ManiaModKey7>(hasMultiplier: 0.9);
56+
Single<ManiaModKey8>(hasMultiplier: 0.9);
57+
Single<ManiaModKey9>(hasMultiplier: 0.9);
58+
Single<ManiaModKey10>(hasMultiplier: 0.9);
59+
60+
#endregion
61+
62+
#region Automation
63+
64+
// Autoplay
65+
// Cinema
66+
67+
#endregion
68+
69+
#region Fun
70+
71+
Single<ModWindUp>(hasMultiplier: 0.5);
72+
Single<ModWindDown>(hasMultiplier: 0.5);
73+
// Muted
74+
Single<ModAdaptiveSpeed>(hasMultiplier: 0.5);
75+
76+
#endregion
77+
78+
#region System
79+
80+
// Score V2
81+
82+
#endregion
83+
}
84+
85+
private static double rateAdjustMultiplier(double speedChange)
86+
{
87+
// Round to the nearest multiple of 0.1.
88+
double value = (int)(speedChange * 10) / 10.0;
89+
90+
// Offset back to 0.
91+
value -= 1;
92+
93+
if (speedChange >= 1)
94+
return 1 + value / 5;
95+
else
96+
return 0.6 + value;
97+
}
98+
}
99+
}

0 commit comments

Comments
 (0)