2019-01-24 16:43:03 +08:00
|
|
|
|
// 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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
|
|
|
|
using osu.Game.Beatmaps;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Mods;
|
|
|
|
|
using osu.Game.Rulesets.Mania.UI;
|
|
|
|
|
using osu.Game.Rulesets.Mods;
|
|
|
|
|
using osu.Game.Rulesets.UI;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using osu.Framework.Graphics;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Framework.Input.Bindings;
|
2020-07-10 13:49:44 +08:00
|
|
|
|
using osu.Framework.Testing;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
using osu.Game.Graphics;
|
|
|
|
|
using osu.Game.Rulesets.Mania.Replays;
|
|
|
|
|
using osu.Game.Rulesets.Replays.Types;
|
2018-04-13 21:41:35 +08:00
|
|
|
|
using osu.Game.Beatmaps.Legacy;
|
2018-06-11 12:17:08 +08:00
|
|
|
|
using osu.Game.Configuration;
|
2018-06-11 13:36:19 +08:00
|
|
|
|
using osu.Game.Overlays.Settings;
|
2018-06-11 12:17:08 +08:00
|
|
|
|
using osu.Game.Rulesets.Configuration;
|
2018-05-15 16:38:04 +08:00
|
|
|
|
using osu.Game.Rulesets.Difficulty;
|
2018-06-07 15:08:37 +08:00
|
|
|
|
using osu.Game.Rulesets.Edit;
|
2018-04-19 21:04:12 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Beatmaps;
|
2018-06-11 12:17:08 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Configuration;
|
2018-05-15 16:40:19 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Difficulty;
|
2018-06-07 15:08:37 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Edit;
|
2019-12-17 19:08:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Scoring;
|
2019-12-26 21:03:21 +08:00
|
|
|
|
using osu.Game.Rulesets.Mania.Skinning;
|
2019-12-17 19:08:13 +08:00
|
|
|
|
using osu.Game.Rulesets.Scoring;
|
2019-12-26 21:03:21 +08:00
|
|
|
|
using osu.Game.Skinning;
|
2018-11-28 15:12:57 +08:00
|
|
|
|
using osu.Game.Scoring;
|
2020-06-19 20:18:58 +08:00
|
|
|
|
using osu.Game.Screens.Ranking.Statistics;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mania
|
|
|
|
|
{
|
2020-07-10 13:49:44 +08:00
|
|
|
|
[ExcludeFromDynamicCompile]
|
2019-12-24 12:48:27 +08:00
|
|
|
|
public class ManiaRuleset : Ruleset, ILegacyRuleset
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
2020-04-21 09:56:04 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// The maximum number of supported keys in a single stage.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public const int MAX_STAGE_KEYS = 10;
|
|
|
|
|
|
2019-12-12 14:58:11 +08:00
|
|
|
|
public override DrawableRuleset CreateDrawableRulesetWith(IBeatmap beatmap, IReadOnlyList<Mod> mods = null) => new DrawableManiaRuleset(this, beatmap, mods);
|
2019-12-17 19:08:13 +08:00
|
|
|
|
|
2019-12-24 16:01:17 +08:00
|
|
|
|
public override ScoreProcessor CreateScoreProcessor() => new ManiaScoreProcessor();
|
2019-12-17 19:08:13 +08:00
|
|
|
|
|
2020-06-21 17:05:26 +08:00
|
|
|
|
public override HealthProcessor CreateHealthProcessor(double drainStartTime) => new DrainingHealthProcessor(drainStartTime, 0.2);
|
2019-12-17 19:08:13 +08:00
|
|
|
|
|
2019-12-24 15:02:16 +08:00
|
|
|
|
public override IBeatmapConverter CreateBeatmapConverter(IBeatmap beatmap) => new ManiaBeatmapConverter(beatmap, this);
|
2019-12-17 19:08:13 +08:00
|
|
|
|
|
2018-11-30 14:18:52 +08:00
|
|
|
|
public override PerformanceCalculator CreatePerformanceCalculator(WorkingBeatmap beatmap, ScoreInfo score) => new ManiaPerformanceCalculator(this, beatmap, score);
|
2018-06-07 15:08:37 +08:00
|
|
|
|
|
2019-08-30 13:39:02 +08:00
|
|
|
|
public const string SHORT_NAME = "mania";
|
|
|
|
|
|
2018-06-07 15:08:37 +08:00
|
|
|
|
public override HitObjectComposer CreateHitObjectComposer() => new ManiaHitObjectComposer(this);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-04-02 17:39:49 +08:00
|
|
|
|
public override ISkin CreateLegacySkinProvider(ISkinSource source, IBeatmap beatmap) => new ManiaLegacySkinTransformer(source, beatmap);
|
2019-12-26 21:03:21 +08:00
|
|
|
|
|
2020-03-24 11:06:24 +08:00
|
|
|
|
public override IEnumerable<Mod> ConvertFromLegacyMods(LegacyMods mods)
|
2018-04-13 21:41:35 +08:00
|
|
|
|
{
|
2018-04-16 20:14:40 +08:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Nightcore))
|
2018-04-13 21:41:35 +08:00
|
|
|
|
yield return new ManiaModNightcore();
|
|
|
|
|
else if (mods.HasFlag(LegacyMods.DoubleTime))
|
|
|
|
|
yield return new ManiaModDoubleTime();
|
|
|
|
|
|
2019-09-16 04:55:25 +08:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Perfect))
|
|
|
|
|
yield return new ManiaModPerfect();
|
|
|
|
|
else if (mods.HasFlag(LegacyMods.SuddenDeath))
|
|
|
|
|
yield return new ManiaModSuddenDeath();
|
|
|
|
|
|
2019-11-24 01:32:16 +08:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Cinema))
|
|
|
|
|
yield return new ManiaModCinema();
|
|
|
|
|
else if (mods.HasFlag(LegacyMods.Autoplay))
|
2018-04-13 21:41:35 +08:00
|
|
|
|
yield return new ManiaModAutoplay();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Easy))
|
|
|
|
|
yield return new ManiaModEasy();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.FadeIn))
|
|
|
|
|
yield return new ManiaModFadeIn();
|
|
|
|
|
|
2018-04-16 20:14:40 +08:00
|
|
|
|
if (mods.HasFlag(LegacyMods.Flashlight))
|
2018-04-13 21:41:35 +08:00
|
|
|
|
yield return new ManiaModFlashlight();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.HalfTime))
|
|
|
|
|
yield return new ManiaModHalfTime();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.HardRock))
|
|
|
|
|
yield return new ManiaModHardRock();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Hidden))
|
|
|
|
|
yield return new ManiaModHidden();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key1))
|
|
|
|
|
yield return new ManiaModKey1();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key2))
|
|
|
|
|
yield return new ManiaModKey2();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key3))
|
|
|
|
|
yield return new ManiaModKey3();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key4))
|
|
|
|
|
yield return new ManiaModKey4();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key5))
|
|
|
|
|
yield return new ManiaModKey5();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key6))
|
|
|
|
|
yield return new ManiaModKey6();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key7))
|
|
|
|
|
yield return new ManiaModKey7();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key8))
|
|
|
|
|
yield return new ManiaModKey8();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Key9))
|
|
|
|
|
yield return new ManiaModKey9();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.NoFail))
|
|
|
|
|
yield return new ManiaModNoFail();
|
|
|
|
|
|
|
|
|
|
if (mods.HasFlag(LegacyMods.Random))
|
|
|
|
|
yield return new ManiaModRandom();
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-24 11:06:24 +08:00
|
|
|
|
public override LegacyMods ConvertToLegacyMods(Mod[] mods)
|
|
|
|
|
{
|
|
|
|
|
var value = base.ConvertToLegacyMods(mods);
|
|
|
|
|
|
|
|
|
|
foreach (var mod in mods)
|
|
|
|
|
{
|
|
|
|
|
switch (mod)
|
|
|
|
|
{
|
|
|
|
|
case ManiaModKey1 _:
|
|
|
|
|
value |= LegacyMods.Key1;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey2 _:
|
|
|
|
|
value |= LegacyMods.Key2;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey3 _:
|
|
|
|
|
value |= LegacyMods.Key3;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey4 _:
|
|
|
|
|
value |= LegacyMods.Key4;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey5 _:
|
|
|
|
|
value |= LegacyMods.Key5;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey6 _:
|
|
|
|
|
value |= LegacyMods.Key6;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey7 _:
|
|
|
|
|
value |= LegacyMods.Key7;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey8 _:
|
|
|
|
|
value |= LegacyMods.Key8;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModKey9 _:
|
|
|
|
|
value |= LegacyMods.Key9;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case ManiaModFadeIn _:
|
|
|
|
|
value |= LegacyMods.FadeIn;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return value;
|
|
|
|
|
}
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public override IEnumerable<Mod> GetModsFor(ModType type)
|
|
|
|
|
{
|
|
|
|
|
switch (type)
|
|
|
|
|
{
|
|
|
|
|
case ModType.DifficultyReduction:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModEasy(),
|
|
|
|
|
new ManiaModNoFail(),
|
2018-06-06 13:07:50 +08:00
|
|
|
|
new MultiMod(new ManiaModHalfTime(), new ManiaModDaycore()),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case ModType.DifficultyIncrease:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
|
|
|
|
new ManiaModHardRock(),
|
2018-06-06 13:07:50 +08:00
|
|
|
|
new MultiMod(new ManiaModSuddenDeath(), new ManiaModPerfect()),
|
|
|
|
|
new MultiMod(new ManiaModDoubleTime(), new ManiaModNightcore()),
|
|
|
|
|
new MultiMod(new ManiaModFadeIn(), new ManiaModHidden()),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new ManiaModFlashlight(),
|
|
|
|
|
};
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-07-31 17:00:42 +08:00
|
|
|
|
case ModType.Conversion:
|
2018-04-13 17:19:50 +08:00
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
2018-06-06 13:07:50 +08:00
|
|
|
|
new MultiMod(new ManiaModKey4(),
|
|
|
|
|
new ManiaModKey5(),
|
|
|
|
|
new ManiaModKey6(),
|
|
|
|
|
new ManiaModKey7(),
|
|
|
|
|
new ManiaModKey8(),
|
|
|
|
|
new ManiaModKey9(),
|
2020-04-20 20:28:36 +08:00
|
|
|
|
new ManiaModKey10(),
|
2018-06-06 13:07:50 +08:00
|
|
|
|
new ManiaModKey1(),
|
|
|
|
|
new ManiaModKey2(),
|
|
|
|
|
new ManiaModKey3()),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
new ManiaModRandom(),
|
|
|
|
|
new ManiaModDualStages(),
|
|
|
|
|
new ManiaModMirror(),
|
2019-12-20 18:30:23 +08:00
|
|
|
|
new ManiaModDifficultyAdjust(),
|
2018-07-31 17:00:42 +08:00
|
|
|
|
};
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-07-31 17:00:42 +08:00
|
|
|
|
case ModType.Automation:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
2019-11-24 01:32:16 +08:00
|
|
|
|
new MultiMod(new ManiaModAutoplay(), new ManiaModCinema()),
|
2018-04-13 17:19:50 +08:00
|
|
|
|
};
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2019-01-26 12:15:45 +08:00
|
|
|
|
case ModType.Fun:
|
|
|
|
|
return new Mod[]
|
|
|
|
|
{
|
2019-08-01 11:35:17 +08:00
|
|
|
|
new MultiMod(new ModWindUp(), new ModWindDown())
|
2019-01-26 12:15:45 +08:00
|
|
|
|
};
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
default:
|
2019-11-28 21:41:29 +08:00
|
|
|
|
return Array.Empty<Mod>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string Description => "osu!mania";
|
|
|
|
|
|
2019-08-30 13:39:02 +08:00
|
|
|
|
public override string ShortName => SHORT_NAME;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2020-01-03 19:39:15 +08:00
|
|
|
|
public override string PlayingVerb => "Smashing keys";
|
|
|
|
|
|
2019-03-27 18:29:27 +08:00
|
|
|
|
public override Drawable CreateIcon() => new SpriteIcon { Icon = OsuIcon.RulesetMania };
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2018-06-14 14:54:05 +08:00
|
|
|
|
public override DifficultyCalculator CreateDifficultyCalculator(WorkingBeatmap beatmap) => new ManiaDifficultyCalculator(this, beatmap);
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
2019-12-24 12:48:27 +08:00
|
|
|
|
public int LegacyID => 3;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
public override IConvertibleReplayFrame CreateConvertibleReplayFrame() => new ManiaReplayFrame();
|
|
|
|
|
|
2019-01-25 18:14:37 +08:00
|
|
|
|
public override IRulesetConfigManager CreateConfig(SettingsStore settings) => new ManiaRulesetConfigManager(settings, RulesetInfo);
|
2018-06-11 12:17:08 +08:00
|
|
|
|
|
2018-06-11 13:36:19 +08:00
|
|
|
|
public override RulesetSettingsSubsection CreateSettings() => new ManiaSettingsSubsection(this);
|
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public override IEnumerable<int> AvailableVariants
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2020-04-21 09:56:04 +08:00
|
|
|
|
for (int i = 1; i <= MAX_STAGE_KEYS; i++)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
yield return (int)PlayfieldType.Single + i;
|
2020-04-21 09:56:04 +08:00
|
|
|
|
for (int i = 2; i <= MAX_STAGE_KEYS * 2; i += 2)
|
2018-04-13 17:19:50 +08:00
|
|
|
|
yield return (int)PlayfieldType.Dual + i;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override IEnumerable<KeyBinding> GetDefaultKeyBindings(int variant = 0)
|
|
|
|
|
{
|
|
|
|
|
switch (getPlayfieldType(variant))
|
|
|
|
|
{
|
|
|
|
|
case PlayfieldType.Single:
|
2020-04-20 20:28:36 +08:00
|
|
|
|
return new SingleStageVariantGenerator(variant).GenerateMappings();
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case PlayfieldType.Dual:
|
2020-04-20 20:28:36 +08:00
|
|
|
|
return new DualStageVariantGenerator(getDualStageKeyCount(variant)).GenerateMappings();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
2019-11-28 21:41:29 +08:00
|
|
|
|
return Array.Empty<KeyBinding>();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override string GetVariantName(int variant)
|
|
|
|
|
{
|
|
|
|
|
switch (getPlayfieldType(variant))
|
|
|
|
|
{
|
|
|
|
|
default:
|
|
|
|
|
return $"{variant}K";
|
2019-04-01 11:16:05 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
case PlayfieldType.Dual:
|
|
|
|
|
{
|
|
|
|
|
var keys = getDualStageKeyCount(variant);
|
|
|
|
|
return $"{keys}K + {keys}K";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the number of keys for each stage in a <see cref="PlayfieldType.Dual"/> variant.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant.</param>
|
|
|
|
|
private int getDualStageKeyCount(int variant) => (variant - (int)PlayfieldType.Dual) / 2;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Finds the <see cref="PlayfieldType"/> that corresponds to a variant value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="variant">The variant value.</param>
|
|
|
|
|
/// <returns>The <see cref="PlayfieldType"/> that corresponds to <paramref name="variant"/>.</returns>
|
|
|
|
|
private PlayfieldType getPlayfieldType(int variant)
|
|
|
|
|
{
|
|
|
|
|
return (PlayfieldType)Enum.GetValues(typeof(PlayfieldType)).Cast<int>().OrderByDescending(i => i).First(v => variant >= v);
|
|
|
|
|
}
|
2020-06-19 20:18:58 +08:00
|
|
|
|
|
2020-06-22 17:38:41 +08:00
|
|
|
|
public override StatisticRow[] CreateStatisticsForScore(ScoreInfo score, IBeatmap playableBeatmap) => new[]
|
2020-06-19 20:18:58 +08:00
|
|
|
|
{
|
|
|
|
|
new StatisticRow
|
|
|
|
|
{
|
|
|
|
|
Columns = new[]
|
|
|
|
|
{
|
|
|
|
|
new StatisticItem("Timing Distribution", new HitEventTimingDistributionGraph(score.HitEvents)
|
|
|
|
|
{
|
|
|
|
|
RelativeSizeAxes = Axes.X,
|
2020-06-22 18:20:43 +08:00
|
|
|
|
Height = 250
|
2020-06-19 20:18:58 +08:00
|
|
|
|
}),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public enum PlayfieldType
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Columns are grouped into a single stage.
|
|
|
|
|
/// Number of columns in this stage lies at (item - Single).
|
|
|
|
|
/// </summary>
|
|
|
|
|
Single = 0,
|
2019-02-27 20:07:17 +08:00
|
|
|
|
|
2018-04-13 17:19:50 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// Columns are grouped into two stages.
|
|
|
|
|
/// Overall number of columns lies at (item - Dual), further computation is required for
|
|
|
|
|
/// number of columns in each individual stage.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Dual = 1000,
|
|
|
|
|
}
|
|
|
|
|
}
|