mirror of
https://github.com/osukey/osukey.git
synced 2025-08-07 00:23:59 +09:00
Use reflection to load Rulesets.
This commit is contained in:
@ -4,6 +4,10 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Game.Modes.Objects;
|
using osu.Game.Modes.Objects;
|
||||||
using osu.Game.Modes.UI;
|
using osu.Game.Modes.UI;
|
||||||
|
using System.Reflection;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
|
using System;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
namespace osu.Game.Modes
|
namespace osu.Game.Modes
|
||||||
{
|
{
|
||||||
@ -15,19 +19,16 @@ namespace osu.Game.Modes
|
|||||||
|
|
||||||
public static Ruleset GetRuleset(PlayMode mode)
|
public static Ruleset GetRuleset(PlayMode mode)
|
||||||
{
|
{
|
||||||
switch (mode)
|
Type type = AppDomain.CurrentDomain.GetAssemblies()
|
||||||
{
|
.Where(a => a.FullName.Contains($@"osu.Game.Modes.{mode}"))
|
||||||
default:
|
.SelectMany(a => a.GetTypes())
|
||||||
return null;
|
.Where(t => t.Name == $@"{mode}Ruleset")
|
||||||
|
.FirstOrDefault();
|
||||||
|
|
||||||
// return new OsuRuleset();
|
if (type == null)
|
||||||
//case PlayMode.Catch:
|
return null;
|
||||||
// return new CatchRuleset();
|
|
||||||
//case PlayMode.Mania:
|
return Activator.CreateInstance(type) as Ruleset;
|
||||||
// return new ManiaRuleset();
|
|
||||||
//case PlayMode.Taiko:
|
|
||||||
// return new TaikoRuleset();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user