1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 11:20:04 +08:00

make HP and OD generic and instantiate CS and AR to modes that need it

This commit is contained in:
unknown 2019-12-22 16:45:32 +08:00
parent 0eef218945
commit fe73b9f8d3
5 changed files with 68 additions and 103 deletions

View File

@ -2,6 +2,7 @@
// 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;
@ -9,18 +10,8 @@ namespace osu.Game.Rulesets.Catch.Mods
{
public class CatchModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
[SettingSource("Fruit Size", "Override a beatmap's set CS.")]
public override BindableNumber<float> CircleSize { get; } = new BindableFloat()
public BindableNumber<float> CircleSize { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
@ -30,7 +21,7 @@ namespace osu.Game.Rulesets.Catch.Mods
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.")]
public override BindableNumber<float> ApproachRate { get; } = new BindableFloat()
public BindableNumber<float> ApproachRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
@ -39,14 +30,20 @@ namespace osu.Game.Rulesets.Catch.Mods
Value = 5,
};
[SettingSource("Overall Difficulty", "Override a beatmap's set OD.")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat()
protected override void UpdateSettings(BeatmapDifficulty difficulty)
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
base.UpdateSettings(difficulty);
CircleSize.Value = CircleSize.Default = difficulty.CircleSize;
ApproachRate.Value = ApproachRate.Default = difficulty.ApproachRate;
}
protected override void ApplySettings(BeatmapDifficulty difficulty)
{
base.ApplySettings(difficulty);
difficulty.CircleSize = CircleSize.Value;
difficulty.ApproachRate = ApproachRate.Value;
}
}
}

View File

@ -9,24 +9,5 @@ namespace osu.Game.Rulesets.Mania.Mods
{
public class ManiaModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
[SettingSource("Overall Difficulty", "Override a beatmap's set OD.")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
}
}

View File

@ -2,6 +2,7 @@
// 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;
@ -9,18 +10,8 @@ namespace osu.Game.Rulesets.Osu.Mods
{
public class OsuModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
[SettingSource("Circle Size", "Override a beatmap's set CS.")]
public override BindableNumber<float> CircleSize { get; } = new BindableFloat()
public BindableNumber<float> CircleSize { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
@ -30,7 +21,7 @@ namespace osu.Game.Rulesets.Osu.Mods
};
[SettingSource("Approach Rate", "Override a beatmap's set AR.")]
public override BindableNumber<float> ApproachRate { get; } = new BindableFloat()
public BindableNumber<float> ApproachRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
@ -39,14 +30,20 @@ namespace osu.Game.Rulesets.Osu.Mods
Value = 5,
};
[SettingSource("Overall Difficulty", "Override a beatmap's set OD.")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat()
protected override void UpdateSettings(BeatmapDifficulty difficulty)
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
base.UpdateSettings(difficulty);
CircleSize.Value = CircleSize.Default = difficulty.CircleSize;
ApproachRate.Value = ApproachRate.Default = difficulty.ApproachRate;
}
protected override void ApplySettings(BeatmapDifficulty difficulty)
{
base.ApplySettings(difficulty);
difficulty.CircleSize = CircleSize.Value;
difficulty.ApproachRate = ApproachRate.Value;
}
}
}

View File

@ -9,24 +9,5 @@ namespace osu.Game.Rulesets.Taiko.Mods
{
public class TaikoModDifficultyAdjust : ModDifficultyAdjust
{
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]
public override BindableNumber<float> DrainRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
[SettingSource("Overall Difficulty", "Override a beatmap's set OD.")]
public override BindableNumber<float> OverallDifficulty { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
}
}

View File

@ -5,6 +5,7 @@ using osu.Game.Beatmaps;
using osu.Framework.Bindables;
using osu.Framework.Graphics.Sprites;
using System;
using osu.Game.Configuration;
namespace osu.Game.Rulesets.Mods
{
@ -24,41 +25,49 @@ namespace osu.Game.Rulesets.Mods
public override Type[] IncompatibleMods => new[] { typeof(ModEasy), typeof(ModHardRock) };
public virtual BindableNumber<float> DrainRate { get; }
[SettingSource("Drain Rate", "Override a beatmap's set HP.")]
public BindableNumber<float> DrainRate { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
public virtual BindableNumber<float> CircleSize { get; }
public virtual BindableNumber<float> ApproachRate { get; }
public virtual BindableNumber<float> OverallDifficulty { get; }
[SettingSource("Overall Difficulty", "Override a beatmap's set OD.")]
public BindableNumber<float> OverallDifficulty { get; } = new BindableFloat()
{
Precision = 0.1f,
MinValue = 1,
MaxValue = 10,
Default = 5,
Value = 5,
};
private BeatmapDifficulty difficulty;
public virtual void ApplyToDifficulty(BeatmapDifficulty difficulty)
public void ApplyToDifficulty(BeatmapDifficulty difficulty)
{
if (this.difficulty == null || this.difficulty.ID != difficulty.ID)
{
this.difficulty = difficulty;
if (DrainRate != null)
DrainRate.Value = DrainRate.Default = difficulty.DrainRate;
if (CircleSize != null)
CircleSize.Value = CircleSize.Default = difficulty.CircleSize;
if (ApproachRate != null)
ApproachRate.Value = ApproachRate.Default = difficulty.ApproachRate;
if (OverallDifficulty != null)
OverallDifficulty.Value = OverallDifficulty.Default = difficulty.OverallDifficulty;
UpdateSettings(difficulty);
}
else
{
difficulty.DrainRate = DrainRate?.Value ?? difficulty.DrainRate;
difficulty.CircleSize = CircleSize?.Value ?? difficulty.CircleSize;
difficulty.ApproachRate = ApproachRate?.Value ?? difficulty.ApproachRate;
difficulty.OverallDifficulty = OverallDifficulty?.Value ?? difficulty.OverallDifficulty;
}
ApplySettings(difficulty);
}
protected virtual void UpdateSettings(BeatmapDifficulty difficulty)
{
DrainRate.Value = DrainRate.Default = difficulty.DrainRate;
OverallDifficulty.Value = OverallDifficulty.Default = difficulty.OverallDifficulty;
}
protected virtual void ApplySettings(BeatmapDifficulty difficulty)
{
difficulty.DrainRate = DrainRate.Value;
difficulty.OverallDifficulty = OverallDifficulty.Value;
}
}
}