1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-24 04:07:26 +08:00
osu-lazer/osu.Game/Beatmaps/BeatmapDifficulty.cs

77 lines
2.3 KiB
C#
Raw Normal View History

// 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.Database;
2018-04-13 17:19:50 +08:00
namespace osu.Game.Beatmaps
{
public class BeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
2018-04-13 17:19:50 +08:00
{
/// <summary>
/// The default value used for all difficulty settings except <see cref="SliderMultiplier"/> and <see cref="SliderTickRate"/>.
/// </summary>
public const float DEFAULT_DIFFICULTY = 5;
public int ID { get; set; }
public bool IsManaged => ID > 0;
2018-04-13 17:19:50 +08:00
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
private float? approachRate;
public BeatmapDifficulty()
{
}
public BeatmapDifficulty(IBeatmapDifficultyInfo source)
{
CopyFrom(source);
}
2018-04-13 17:19:50 +08:00
public float ApproachRate
{
get => approachRate ?? OverallDifficulty;
set => approachRate = value;
}
public double SliderMultiplier { get; set; } = 1;
public double SliderTickRate { get; set; } = 1;
/// <summary>
/// Returns a shallow-clone of this <see cref="BeatmapDifficulty"/>.
/// </summary>
public BeatmapDifficulty Clone()
{
var diff = (BeatmapDifficulty)Activator.CreateInstance(GetType());
CopyTo(diff);
return diff;
}
public virtual void CopyFrom(IBeatmapDifficultyInfo other)
{
ApproachRate = other.ApproachRate;
DrainRate = other.DrainRate;
CircleSize = other.CircleSize;
OverallDifficulty = other.OverallDifficulty;
SliderMultiplier = other.SliderMultiplier;
SliderTickRate = other.SliderTickRate;
}
public virtual void CopyTo(BeatmapDifficulty other)
{
other.ApproachRate = ApproachRate;
other.DrainRate = DrainRate;
other.CircleSize = CircleSize;
other.OverallDifficulty = OverallDifficulty;
other.SliderMultiplier = SliderMultiplier;
other.SliderTickRate = SliderTickRate;
}
2018-04-13 17:19:50 +08:00
}
}