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
24 public static BadSettings RootSettings =>
26 throw new BadRuntimeException("BadSettingsProvider.RootSettings is not initialized");
27
32 public static void SetRootSettings(BadSettings settings)
33 {
34 s_RootSettings = settings;
35 }
36}
37
41public abstract class BadSettingsProvider<T> where T : BadSettingsProvider<T>, new()
42{
46 private static T? s_Instance;
47
51 private readonly string m_Path;
52
57 protected BadSettingsProvider(string path)
58 {
59 m_Path = path;
60 }
61
66 BadSettingsProvider.HasRootSettings ? BadSettingsProvider.RootSettings.FindOrCreateProperty(m_Path) : null;
67
71 public static T Instance => s_Instance ??= new T();
72}
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.