Files
MiraAPI/MiraAPI/GameOptions/ModdedGroupSingleton.cs
T

21 lines
524 B
C#

using System;
using System.Linq;
namespace MiraAPI.GameOptions
{
public class ModdedGroupSingleton<T> where T : ModdedOptionGroup
{
private static T _instance;
public static T Instance
{
get => _instance ??= ModdedOptionsManager.Groups.OfType<T>().Single();
set
{
if (_instance != null) throw new InvalidOperationException($"Instance for {typeof(T)} is already set");
_instance = value;
}
}
}
}