mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-21 13:37:54 +00:00
24 lines
698 B
C#
24 lines
698 B
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Reflection;
|
|
|
|
namespace MiraAPI.Hud;
|
|
|
|
public static class CustomButtonManager
|
|
{
|
|
public static readonly List<CustomActionButton> CustomButtons = [];
|
|
|
|
internal static void RegisterButton(Type buttonType)
|
|
{
|
|
if (!typeof(CustomActionButton).IsAssignableFrom(buttonType))
|
|
{
|
|
return;
|
|
}
|
|
|
|
var button = (CustomActionButton)Activator.CreateInstance(buttonType);
|
|
CustomButtons.Add(button);
|
|
typeof(CustomButtonSingleton<>).MakeGenericType(buttonType)
|
|
.GetField("_instance", BindingFlags.Static | BindingFlags.NonPublic)!
|
|
.SetValue(null, button);
|
|
}
|
|
} |