1
0
mirror of https://github.com/ppy/osu.git synced 2025-03-06 20:27:46 +08:00
osu-lazer/osu.Game/Modes/Ruleset.cs

60 lines
1.9 KiB
C#
Raw Normal View History

// Copyright (c) 2007-2017 ppy Pty Ltd <contact@ppy.sh>.
// Licensed under the MIT Licence - https://raw.githubusercontent.com/ppy/osu/master/LICENCE
using System.Collections.Generic;
2016-11-14 18:03:20 +09:00
using osu.Game.Modes.Objects;
2016-11-14 18:54:24 +09:00
using osu.Game.Modes.UI;
2016-11-14 19:20:27 +09:00
using System;
using System.Collections.Concurrent;
2017-02-28 20:14:48 +09:00
using osu.Framework.Input;
using osu.Game.Beatmaps;
using osu.Game.Graphics;
2016-11-14 18:03:20 +09:00
namespace osu.Game.Modes
{
public class BeatmapStatistic
{
public FontAwesome Icon;
public string Content;
public string Name;
}
public abstract class Ruleset
{
private static ConcurrentDictionary<PlayMode, Type> availableRulesets = new ConcurrentDictionary<PlayMode, Type>();
public abstract ScoreOverlay CreateScoreOverlay();
public virtual IEnumerable<BeatmapStatistic> GetBeatmapStatistics(WorkingBeatmap beatmap) => new BeatmapStatistic[] { };
public abstract IEnumerable<Mod> GetModsFor(ModType type);
public abstract ScoreProcessor CreateScoreProcessor(int hitObjectCount = 0);
2016-11-29 15:41:48 +09:00
2017-02-28 20:14:48 +09:00
public abstract HitRenderer CreateHitRendererWith(Beatmap beatmap, InputManager input = null);
public abstract HitObjectParser CreateHitObjectParser();
public abstract DifficultyCalculator CreateDifficultyCalculator(Beatmap beatmap);
public static void Register(Ruleset ruleset) => availableRulesets.TryAdd(ruleset.PlayMode, ruleset.GetType());
2016-11-14 23:18:21 +09:00
protected abstract PlayMode PlayMode { get; }
2017-01-30 13:35:40 +09:00
public virtual FontAwesome Icon => FontAwesome.fa_question_circle;
public virtual Score CreateAutoplayScore(Beatmap beatmap) => null;
public static Ruleset GetRuleset(PlayMode mode)
{
Type type;
2016-11-14 18:54:24 +09:00
if (!availableRulesets.TryGetValue(mode, out type))
2016-11-14 19:20:27 +09:00
return null;
return Activator.CreateInstance(type) as Ruleset;
}
}
}