New settings handling

This commit is contained in:
amevarashi 2023-03-24 20:22:54 +05:00
parent fed4b54915
commit 8d49addd63
24 changed files with 309 additions and 233 deletions

View file

@ -0,0 +1,35 @@
using Verse;
namespace RJWSexperience.Settings
{
public class SettingHandle<T> : ISettingHandle
{
public T Value { get; set; }
public readonly string XmlLabel;
public readonly T DefaultValue;
public SettingHandle(string xmlLabel, T defaultValue)
{
XmlLabel = xmlLabel;
DefaultValue = defaultValue;
Value = defaultValue;
}
public void Reset()
{
Value = DefaultValue;
}
public void Scribe()
{
T value = Value;
Scribe_Values.Look(ref value, XmlLabel, DefaultValue);
Value = value;
}
public static implicit operator T(SettingHandle<T> settingHandle)
{
return settingHandle.Value;
}
}
}