osu/osu.Game/Beatmaps/EFBeatmapDifficulty.cs

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

79 lines
2.4 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 09:19:50 +00:00
using System;
using System.ComponentModel.DataAnnotations.Schema;
using osu.Game.Database;
2018-04-13 09:19:50 +00:00
2017-07-26 04:22:46 +00:00
namespace osu.Game.Beatmaps
{
[Table(@"BeatmapDifficulty")]
public class EFBeatmapDifficulty : IHasPrimaryKey, IBeatmapDifficultyInfo
{
2017-05-15 03:54:56 +00: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;
2018-04-13 09:19:50 +00:00
2017-10-14 05:28:25 +00:00
public int ID { get; set; }
2018-04-13 09:19:50 +00:00
public bool IsManaged => ID > 0;
2017-05-15 03:54:56 +00:00
public float DrainRate { get; set; } = DEFAULT_DIFFICULTY;
public float CircleSize { get; set; } = DEFAULT_DIFFICULTY;
public float OverallDifficulty { get; set; } = DEFAULT_DIFFICULTY;
2018-04-13 09:19:50 +00:00
private float? approachRate;
2018-04-13 09:19:50 +00:00
public EFBeatmapDifficulty()
{
}
public EFBeatmapDifficulty(IBeatmapDifficultyInfo source)
{
CopyFrom(source);
}
public float ApproachRate
{
2018-02-13 11:23:51 +00:00
get => approachRate ?? OverallDifficulty;
set => approachRate = value;
}
2018-04-13 09:19:50 +00:00
public double SliderMultiplier { get; set; } = 1;
public double SliderTickRate { get; set; } = 1;
2018-04-13 09:19:50 +00:00
/// <summary>
/// Returns a shallow-clone of this <see cref="EFBeatmapDifficulty"/>.
/// </summary>
public EFBeatmapDifficulty Clone()
{
var diff = (EFBeatmapDifficulty)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(EFBeatmapDifficulty other)
{
other.ApproachRate = ApproachRate;
other.DrainRate = DrainRate;
other.CircleSize = CircleSize;
other.OverallDifficulty = OverallDifficulty;
other.SliderMultiplier = SliderMultiplier;
other.SliderTickRate = SliderTickRate;
}
}
}