BadScript 2
Loading...
Searching...
No Matches
BadSettingsProvider.cs
Go to the documentation of this file.
2
3namespace BadScript2.Settings;
4
8public static class BadSettingsProvider
9{
13 private static BadSettings? s_RootSettings;
14
18 public static bool HasRootSettings => s_RootSettings != null;
19
25 throw new
26 BadRuntimeException("BadSettingsProvider.RootSettings is not initialized"
27 );
28
33 public static void SetRootSettings(BadSettings settings)
34 {
35 s_RootSettings = settings;
36 }
37}
38
42public abstract class BadSettingsProvider<T> where T : BadSettingsProvider<T>, new()
43{
47 private static T? s_Instance;
48
52 private readonly string m_Path;
53
58 protected BadSettingsProvider(string path)
59 {
60 m_Path = path;
61 }
62
66 public BadSettings? Settings => BadSettingsProvider.HasRootSettings
68 : null;
69
73 public static T Instance => s_Instance ??= new T();
74}
Public Api for the Settings System.
BadSettings FindOrCreateProperty(string propertyPath)
Finds a property based on the property path relative to this object.
Helper class that can be used to automatically load a settings object from a file.
static void SetRootSettings(BadSettings settings)
Sets the Root Settings Object.
static ? BadSettings s_RootSettings
The Root Settings Object.
readonly string m_Path
The Settings Path Name('.' separated)
BadSettings? Settings
Returns the Instance of the Settings Provider.
BadSettingsProvider(string path)
Creates a new Settings Provider.
static T Instance
Returns the Instance of the Settings Provider.
static bool HasRootSettings
Returns true if the root setting has been set.
static BadSettings RootSettings
Returns the Root Settings Object.
static ? T s_Instance
The Instance of the Settings Provider.
Contains the Error Objects for the BadScript2 Language.
Contains the Settings Implementation.