make ModDifficultyAdjust generic

This commit is contained in:
unknown 2019-12-12 21:14:26 +08:00
parent 472fa9822c
commit 002a125b4a
9 changed files with 46 additions and 170 deletions

View File

@ -101,7 +101,7 @@ namespace osu.Game.Rulesets.Catch
case ModType.Conversion:
return new Mod[]
{
new CatchModDifficultyAdjust(),
new ModDifficultyAdjust(),
};
case ModType.Automation:

View File

@ -1,51 +0,0 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Beatmaps;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override the beatmap's set HP")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 1F,
};
[SettingSource("Fruit Size", "Override the beatmap's set CS")]
public override BindableNumber<float> CircleSize { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
[SettingSource("Approach Rate", "Override the beatmap's set AR")]
public override BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
public override void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
difficulty.DrainRate = DrainRate.Value;
difficulty.CircleSize = CircleSize.Value;
difficulty.ApproachRate = ApproachRate.Value;
difficulty.OverallDifficulty = ApproachRate.Value;
}
}
}

View File

@ -143,7 +143,7 @@ namespace osu.Game.Rulesets.Mania
new ManiaModRandom(),
new ManiaModDualStages(),
new ManiaModMirror(),
new ManiaModDifficultyAdjust(),
new ModDifficultyAdjust(),
};
case ModType.Automation:

View File

@ -1,22 +0,0 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Mania.Mods
{
public class ManiaModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Overall Difficulty", "Override the beatmap's set OD")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
}
}

View File

@ -1,52 +0,0 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override the beatmap's set HP")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
[SettingSource("Circle Size", "Override the beatmap's set CS")]
public override BindableNumber<float> CircleSize { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
[SettingSource("Approach Rate", "Override the beatmap's set AR")]
public override BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
[SettingSource("Overall Difficulty", "Override the beatmap's set OD")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
}
}

View File

@ -121,7 +121,7 @@ namespace osu.Game.Rulesets.Osu
return new Mod[]
{
new OsuModTarget(),
new OsuModDifficultyAdjust(),
new ModDifficultyAdjust(),
};
case ModType.Automation:

View File

@ -1,32 +0,0 @@
// 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.
using osu.Framework.Bindables;
using osu.Game.Configuration;
using osu.Game.Rulesets.Mods;
namespace osu.Game.Rulesets.Taiko.Mods
{
public class TaikoModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override the beatmap's set HP")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
[SettingSource("Overall Difficulty", "Override the beatmap's set OD")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
}
}

View File

@ -100,7 +100,7 @@ namespace osu.Game.Rulesets.Taiko
case ModType.Conversion:
return new Mod[]
{
new TaikoModDifficultyAdjust(),
new ModDifficultyAdjust(),
};
case ModType.Automation:

View File

@ -5,10 +5,11 @@ using osu.Game.Beatmaps;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using System;
using osu.Game.Configuration;
namespace osu.Game.Rulesets.Mods
{
public abstract class ModDifficultyAdjust : Mod, IApplicableToDifficulty
public class ModDifficultyAdjust : Mod, IApplicableToDifficulty
{
public override string Name => @"Difficulty Adjust";
@ -24,20 +25,52 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
public virtual BindableNumber<float> DrainRate { get; }
[SettingSource("Drain Rate", "Override the beatmap's set HP")]
public BindableNumber<float> DrainRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
public virtual BindableNumber<float> CircleSize { get; }
[SettingSource("Circle Size", "Override the beatmap's set CS")]
public BindableNumber<float> CircleSize { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
public virtual BindableNumber<float> ApproachRate { get; }
[SettingSource("Approach Rate", "Override the beatmap's set AR")]
public BindableNumber<float> ApproachRate { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
public virtual BindableNumber<float> OverallDifficulty { get; }
[SettingSource("Overall Difficulty", "Override the beatmap's set OD")]
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat
{
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
Precision = 0.1F,
};
public virtual void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
difficulty.DrainRate = DrainRate != null ? DrainRate.Value : difficulty.DrainRate;
difficulty.CircleSize = CircleSize != null ? CircleSize.Value : difficulty.CircleSize;
difficulty.ApproachRate = ApproachRate != null ? ApproachRate.Value : difficulty.ApproachRate;
difficulty.OverallDifficulty = OverallDifficulty != null ? OverallDifficulty.Value : difficulty.OverallDifficulty;
difficulty.DrainRate = DrainRate.Value;
difficulty.CircleSize = CircleSize.Value;
difficulty.ApproachRate = ApproachRate.Value;
difficulty.OverallDifficulty = OverallDifficulty.Value;
}
}
}