mirror of
https://github.com/ppy/osu.git
synced 2024-12-13 08:32:57 +08:00
Change CreateInstance
to use Activator.CreateInstance
instead of clone
This commit is contained in:
parent
9cf79a80c2
commit
719392de39
@ -27,6 +27,6 @@ namespace osu.Game.Rulesets.Mods
|
||||
/// <summary>
|
||||
/// Create a fresh <see cref="Mod"/> instance based on this mod.
|
||||
/// </summary>
|
||||
Mod CreateInstance() => ((Mod)this).DeepClone();
|
||||
Mod CreateInstance() => (Mod)Activator.CreateInstance(GetType());
|
||||
}
|
||||
}
|
||||
|
@ -80,12 +80,7 @@ namespace osu.Game.Rulesets
|
||||
/// <param name="acronym">The acronym to query for .</param>
|
||||
public Mod CreateModFromAcronym(string acronym)
|
||||
{
|
||||
var type = AllMods.FirstOrDefault(m => m.Acronym == acronym)?.GetType();
|
||||
|
||||
if (type != null)
|
||||
return (Mod)Activator.CreateInstance(type);
|
||||
|
||||
return null;
|
||||
return AllMods.FirstOrDefault(m => m.Acronym == acronym)?.CreateInstance();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -94,12 +89,7 @@ namespace osu.Game.Rulesets
|
||||
public T CreateMod<T>()
|
||||
where T : Mod
|
||||
{
|
||||
var type = AllMods.FirstOrDefault(m => m is T)?.GetType();
|
||||
|
||||
if (type != null)
|
||||
return (T)Activator.CreateInstance(type);
|
||||
|
||||
return null;
|
||||
return AllMods.FirstOrDefault(m => m is T)?.CreateInstance() as T;
|
||||
}
|
||||
|
||||
public abstract IEnumerable<Mod> GetModsFor(ModType type);
|
||||
|
Loading…
Reference in New Issue
Block a user