Changed Mods to be a property

This commit is contained in:
MrTheMake
2017-08-17 12:24:22 +02:00
parent 105048500a
commit 586a652b08
2 changed files with 16 additions and 10 deletions

View File

@ -31,22 +31,28 @@ namespace osu.Game.Rulesets.Scoring
[JsonProperty(@"mods")]
private string[] modStrings { get; set; }
private RulesetInfo ruleset;
public RulesetInfo Ruleset
public RulesetInfo Ruleset;
private Mod[] mods;
public Mod[] Mods
{
get { return ruleset; }
get
{
// Evaluate the mod strings
if (mods == null)
mods = Ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
return mods;
}
set
{
ruleset = value;
mods = value;
// Handle the mod strings if they are assigned
if (modStrings != null)
Mods = ruleset.CreateInstance().GetAllMods().Where(mod => modStrings.Contains(mod.ShortenedName)).ToArray();
// Assign the mod strings
modStrings = mods.Select(mod => mod.ShortenedName).ToArray();
}
}
public Mod[] Mods { get; set; }
[JsonProperty(@"user")]
public User User;