mirror of
https://github.com/ppy/osu.git
synced 2024-09-22 03:27:24 +08:00
Avoid constructor overhead for realm BeatmapInfo
parameterless constructor
This commit is contained in:
parent
64fe7d8dd3
commit
3faf980fed
@ -26,37 +26,35 @@ namespace osu.Game.Beatmaps
|
|||||||
public class BeatmapInfo : RealmObject, IHasGuidPrimaryKey, IBeatmapInfo, IEquatable<BeatmapInfo>
|
public class BeatmapInfo : RealmObject, IHasGuidPrimaryKey, IBeatmapInfo, IEquatable<BeatmapInfo>
|
||||||
{
|
{
|
||||||
[PrimaryKey]
|
[PrimaryKey]
|
||||||
public Guid ID { get; set; } = Guid.NewGuid();
|
public Guid ID { get; set; }
|
||||||
|
|
||||||
public string DifficultyName { get; set; } = string.Empty;
|
public string DifficultyName { get; set; } = string.Empty;
|
||||||
|
|
||||||
public RulesetInfo Ruleset { get; set; }
|
public RulesetInfo Ruleset { get; set; } = null!;
|
||||||
|
|
||||||
public BeatmapDifficulty Difficulty { get; set; }
|
public BeatmapDifficulty Difficulty { get; set; } = null!;
|
||||||
|
|
||||||
public BeatmapMetadata Metadata { get; set; }
|
public BeatmapMetadata Metadata { get; set; } = null!;
|
||||||
|
|
||||||
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
[Backlink(nameof(ScoreInfo.BeatmapInfo))]
|
||||||
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
public IQueryable<ScoreInfo> Scores { get; } = null!;
|
||||||
|
|
||||||
public BeatmapInfo(RulesetInfo ruleset, BeatmapDifficulty difficulty, BeatmapMetadata metadata)
|
public BeatmapInfo(RulesetInfo? ruleset = null, BeatmapDifficulty? difficulty = null, BeatmapMetadata? metadata = null)
|
||||||
{
|
{
|
||||||
Ruleset = ruleset;
|
ID = Guid.NewGuid();
|
||||||
Difficulty = difficulty;
|
Ruleset = ruleset ?? new RulesetInfo
|
||||||
Metadata = metadata;
|
|
||||||
}
|
|
||||||
|
|
||||||
[UsedImplicitly]
|
|
||||||
public BeatmapInfo() // TODO: consider removing this and migrating all usages to ctor with parameters.
|
|
||||||
{
|
|
||||||
Ruleset = new RulesetInfo
|
|
||||||
{
|
{
|
||||||
OnlineID = 0,
|
OnlineID = 0,
|
||||||
ShortName = @"osu",
|
ShortName = @"osu",
|
||||||
Name = @"null placeholder ruleset"
|
Name = @"null placeholder ruleset"
|
||||||
};
|
};
|
||||||
Difficulty = new BeatmapDifficulty();
|
Difficulty = difficulty ?? new BeatmapDifficulty();
|
||||||
Metadata = new BeatmapMetadata();
|
Metadata = metadata ?? new BeatmapMetadata();
|
||||||
|
}
|
||||||
|
|
||||||
|
[UsedImplicitly]
|
||||||
|
private BeatmapInfo()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public BeatmapSetInfo? BeatmapSet { get; set; }
|
public BeatmapSetInfo? BeatmapSet { get; set; }
|
||||||
|
Loading…
Reference in New Issue
Block a user