This commit is contained in:
JohnCorby 2022-03-29 17:34:44 -07:00
parent 8a51fe74a3
commit 256e058462
3 changed files with 19 additions and 2 deletions

8
QSB/QSBApi.cs Normal file
View File

@ -0,0 +1,8 @@
using OWML.Common;
namespace QSB;
public class QSBApi
{
public void RegisterAddon(IModBehaviour addon) => QSBCore.Addons.Add(addon);
}

View File

@ -8,6 +8,7 @@ using QSB.QuantumSync;
using QSB.Utility;
using QSB.WorldSync;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
@ -163,6 +164,9 @@ public class QSBCore : ModBehaviour
DebugLog.ToConsole($"DEBUG MODE = {DebugSettings.DebugMode}");
}
}
public static readonly List<IModBehaviour> Addons = new();
public override object GetApi() => new QSBApi();
}
/*

View File

@ -175,8 +175,13 @@ public static class Extensions
multiDelegate.GetInvocationList().ForEach(dl => dl.DynamicInvoke(args));
}
public static IEnumerable<Type> GetDerivedTypes(this Type type) => type.Assembly.GetTypes()
.Where(x => !x.IsInterface && !x.IsAbstract && type.IsAssignableFrom(x));
public static IEnumerable<Type> GetDerivedTypes(this Type type) =>
QSBCore.Addons
.Select(x => x.GetType().Assembly)
.Append(type.Assembly)
.SelectMany(x => x.GetTypes())
.Where(x => !x.IsInterface && !x.IsAbstract && type.IsAssignableFrom(x))
.OrderBy(x => x.AssemblyQualifiedName);
public static Guid ToGuid(this int value)
{