2021-10-01 13:34:11 +08:00
|
|
|
// 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 System;
|
2021-10-01 15:31:11 +08:00
|
|
|
using osu.Game.Database;
|
2021-10-01 13:34:11 +08:00
|
|
|
|
|
|
|
#nullable enable
|
|
|
|
|
2021-10-01 15:31:11 +08:00
|
|
|
namespace osu.Game.Rulesets
|
2021-10-01 13:34:11 +08:00
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// A representation of a ruleset's metadata.
|
|
|
|
/// </summary>
|
|
|
|
public interface IRulesetInfo : IHasOnlineID
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// The user-exposed name of this ruleset.
|
|
|
|
/// </summary>
|
|
|
|
string Name { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// An acronym defined by the ruleset that can be used as a permanent identifier.
|
|
|
|
/// </summary>
|
|
|
|
string ShortName { get; }
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// A string representation of this ruleset, to be used with reflection to instantiate the ruleset represented by this metadata.
|
|
|
|
/// </summary>
|
|
|
|
string InstantiationInfo { get; }
|
|
|
|
|
2021-10-06 04:52:28 +08:00
|
|
|
Ruleset? CreateInstance()
|
2021-10-01 13:34:11 +08:00
|
|
|
{
|
|
|
|
var type = Type.GetType(InstantiationInfo);
|
|
|
|
|
|
|
|
if (type == null)
|
|
|
|
return null;
|
|
|
|
|
|
|
|
var ruleset = Activator.CreateInstance(type) as Ruleset;
|
|
|
|
|
|
|
|
// overwrite the pre-populated RulesetInfo with a potentially database attached copy.
|
2021-10-04 15:55:16 +08:00
|
|
|
// TODO: figure if we still want/need this after switching to realm.
|
2021-10-01 13:34:11 +08:00
|
|
|
// ruleset.RulesetInfo = this;
|
|
|
|
|
|
|
|
return ruleset;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|