using System; using JetBrains.Annotations; namespace Robust.Shared.Configuration { /// /// Abstract base class for . You shouldn't inherit this yourself and may be looking for /// /// public abstract class CVarDef { /// /// The default value of this CVar when no override is specified by configuration or the user. /// public object DefaultValue { get; } /// /// Flags for this CVar. /// public CVar Flags { get; } /// /// The name of this CVar. This needs to contain only printable characters. /// Periods '.' are reserved. Everything before the last period is a nested table identifier, /// everything after is the CVar name in the TOML document. /// public string Name { get; } /// /// The description of this CVar. /// public string? Desc { get; } private protected CVarDef(string name, object defaultValue, CVar flags, string? desc) { Name = name; DefaultValue = defaultValue; Flags = flags; Desc = desc; } /// /// Creates a new CVar definition, for use in -annotated classes. /// /// See . /// See . /// See . /// See . /// The type of the CVar, which can be any of: bool, int, long, float, string, any enum, and ushort. public static CVarDef Create( string name, T defaultValue, CVar flag = CVar.NONE, string? desc = null) where T : notnull { return new(name, defaultValue, flag, desc); } } /// /// Contains information defining a CVar for /// /// The type of the CVar, which can be any of: bool, int, long, float, string, any enum, and ushort. /// /// public sealed class CVarDef : CVarDef where T : notnull { public new T DefaultValue { get; } internal CVarDef(string name, T defaultValue, CVar flags, string? desc) : base(name, defaultValue, flags, desc) { DefaultValue = defaultValue; } } /// /// Marks a static class as containing CVar definitions. /// /// /// /// There is no limit on the number of CVarDefs classes you can have, and all CVars will ultimately share the /// same namespace regardless of which class they're in. /// /// /// CVar definitions can be in any assembly, but should never be marked or /// if not in a shared assembly. /// /// /// /// /// public static class MyCVars /// { /// public static readonly CVarDef<bool> MyEnabled = /// CVarDef.Create("mycvars.enabled", true, CVar.SERVER, "Enables the thing."); /// } /// /// [AttributeUsage(AttributeTargets.Class)] [MeansImplicitUse] public sealed class CVarDefsAttribute : Attribute { } }