mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-11-19 13:17:10 +00:00
21 lines
524 B
C#
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;
|
|
}
|
|
}
|
|
}
|
|
}
|