2019-01-24 16:43:03 +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.
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
using System;
|
2018-11-28 12:12:29 +08:00
|
|
|
|
using Newtonsoft.Json;
|
2019-03-27 18:29:27 +08:00
|
|
|
|
using osu.Framework.Graphics.Sprites;
|
2018-11-28 12:12:29 +08:00
|
|
|
|
using osu.Game.IO.Serialization;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
namespace osu.Game.Rulesets.Mods
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The base class for gameplay modifiers.
|
|
|
|
|
/// </summary>
|
2018-11-30 16:16:00 +08:00
|
|
|
|
public abstract class Mod : IMod, IJsonSerializable
|
2018-04-13 17:19:50 +08:00
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The name of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public abstract string Name { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The shortened name of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-30 16:16:00 +08:00
|
|
|
|
public abstract string Acronym { get; }
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The icon of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2019-04-02 18:55:24 +08:00
|
|
|
|
public virtual IconUsage Icon => FontAwesome.Solid.Question;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The type of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-07-31 17:00:42 +08:00
|
|
|
|
public virtual ModType Type => ModType.Fun;
|
2018-04-13 17:19:50 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The user readable description of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public virtual string Description => string.Empty;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The score multiplier of this mod.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public abstract double ScoreMultiplier { get; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns true if this mod is implemented (and playable).
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public virtual bool HasImplementation => this is IApplicableMod;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Returns if this mod is ranked.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public virtual bool Ranked => false;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// The mods this mod cannot be enabled with.
|
|
|
|
|
/// </summary>
|
2018-11-28 12:12:29 +08:00
|
|
|
|
[JsonIgnore]
|
2018-04-13 17:19:50 +08:00
|
|
|
|
public virtual Type[] IncompatibleMods => new Type[] { };
|
2019-03-14 22:39:45 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Creates a copy of this <see cref="Mod"/> initialised to a default state.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public virtual Mod CreateCopy() => (Mod)Activator.CreateInstance(GetType());
|
2019-05-03 09:05:45 +08:00
|
|
|
|
|
|
|
|
|
public bool Equals(IMod other) => GetType() == other?.GetType();
|
2018-04-13 17:19:50 +08:00
|
|
|
|
}
|
|
|
|
|
}
|