mirror of
https://github.com/soarqin/DSP_Mods.git
synced 2026-08-05 10:20:13 +08:00
docs(UXAssist): update ModFeature docs for non-static feature classes
This commit is contained in:
@@ -3,7 +3,7 @@ using System;
|
|||||||
namespace UXAssist.Common.ModFeatures;
|
namespace UXAssist.Common.ModFeatures;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Marks a static class as a mod feature so that <see cref="ModFeatureRegistry"/> can discover it.
|
/// Marks a class as a mod feature so that <see cref="ModFeatureRegistry"/> can discover it.
|
||||||
/// Lifecycle methods (<c>Init</c>, <c>Start</c>, <c>Uninit</c>, <c>OnInputUpdate</c>, <c>OnUpdate</c>) are optional.
|
/// Lifecycle methods (<c>Init</c>, <c>Start</c>, <c>Uninit</c>, <c>OnInputUpdate</c>, <c>OnUpdate</c>) are optional.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
[AttributeUsage(AttributeTargets.Class, Inherited = false)]
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ using System.Reflection;
|
|||||||
namespace UXAssist.Common.ModFeatures;
|
namespace UXAssist.Common.ModFeatures;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Registry that discovers static mod features from assemblies and holds registered instance mod features.
|
/// Registry that discovers mod feature classes marked with <see cref="ModFeatureAttribute"/> from assemblies
|
||||||
/// Static lifecycle methods are optional; if a method is missing it is simply skipped.
|
/// and holds registered instance mod features. Discovered features invoke static lifecycle methods;
|
||||||
|
/// static lifecycle methods are optional and are skipped if missing.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class ModFeatureRegistry
|
public static class ModFeatureRegistry
|
||||||
{
|
{
|
||||||
@@ -46,7 +47,7 @@ public static class ModFeatureRegistry
|
|||||||
private static readonly HashSet<Assembly> _discoveredAssemblies = [];
|
private static readonly HashSet<Assembly> _discoveredAssemblies = [];
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Discovers static mod feature classes marked with <see cref="ModFeatureAttribute"/> in the given assembly.
|
/// Discovers mod feature classes marked with <see cref="ModFeatureAttribute"/> in the given assembly.
|
||||||
/// Each assembly is only discovered once.
|
/// Each assembly is only discovered once.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="assembly">The assembly to scan.</param>
|
/// <param name="assembly">The assembly to scan.</param>
|
||||||
@@ -55,7 +56,7 @@ public static class ModFeatureRegistry
|
|||||||
if (!_discoveredAssemblies.Add(assembly)) return;
|
if (!_discoveredAssemblies.Add(assembly)) return;
|
||||||
|
|
||||||
var staticTypes = Util.GetTypesFiltered(assembly, t =>
|
var staticTypes = Util.GetTypesFiltered(assembly, t =>
|
||||||
t.IsClass && !t.IsInterface &&
|
t.IsClass &&
|
||||||
Attribute.IsDefined(t, typeof(ModFeatureAttribute)) &&
|
Attribute.IsDefined(t, typeof(ModFeatureAttribute)) &&
|
||||||
!typeof(IModFeature).IsAssignableFrom(t));
|
!typeof(IModFeature).IsAssignableFrom(t));
|
||||||
|
|
||||||
@@ -81,7 +82,7 @@ public static class ModFeatureRegistry
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls <see cref="IModFeature.Init"/> on all registered instance features
|
/// Calls <see cref="IModFeature.Init"/> on all registered instance features
|
||||||
/// and invokes the cached static <c>Init</c> methods on all discovered static features.
|
/// and invokes the cached static <c>Init</c> methods on all discovered mod feature classes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void InitAll()
|
public static void InitAll()
|
||||||
{
|
{
|
||||||
@@ -91,7 +92,7 @@ public static class ModFeatureRegistry
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls <see cref="IModFeature.Start"/> on all registered instance features
|
/// Calls <see cref="IModFeature.Start"/> on all registered instance features
|
||||||
/// and invokes the cached static <c>Start</c> methods on all discovered static features.
|
/// and invokes the cached static <c>Start</c> methods on all discovered mod feature classes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void StartAll()
|
public static void StartAll()
|
||||||
{
|
{
|
||||||
@@ -101,7 +102,7 @@ public static class ModFeatureRegistry
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls <see cref="IModFeature.Uninit"/> on all registered instance features
|
/// Calls <see cref="IModFeature.Uninit"/> on all registered instance features
|
||||||
/// and invokes the cached static <c>Uninit</c> methods on all discovered static features.
|
/// and invokes the cached static <c>Uninit</c> methods on all discovered mod feature classes.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void UninitAll()
|
public static void UninitAll()
|
||||||
{
|
{
|
||||||
@@ -111,7 +112,7 @@ public static class ModFeatureRegistry
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls <see cref="IModFeature.OnInputUpdate"/> on all registered instance features
|
/// Calls <see cref="IModFeature.OnInputUpdate"/> on all registered instance features
|
||||||
/// and invokes the cached static <c>OnInputUpdate</c> delegates on all discovered static features.
|
/// and invokes the cached static <c>OnInputUpdate</c> delegates on all discovered mod feature classes.
|
||||||
/// This method is meant to be called every frame; no reflection is performed here.
|
/// This method is meant to be called every frame; no reflection is performed here.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void OnInputUpdateAll()
|
public static void OnInputUpdateAll()
|
||||||
@@ -122,7 +123,7 @@ public static class ModFeatureRegistry
|
|||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Calls <see cref="IModFeature.OnUpdate"/> on all registered instance features
|
/// Calls <see cref="IModFeature.OnUpdate"/> on all registered instance features
|
||||||
/// and invokes the cached static <c>OnUpdate</c> delegates on all discovered static features.
|
/// and invokes the cached static <c>OnUpdate</c> delegates on all discovered mod feature classes.
|
||||||
/// This method is meant to be called every frame; no reflection is performed here.
|
/// This method is meant to be called every frame; no reflection is performed here.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static void OnUpdateAll()
|
public static void OnUpdateAll()
|
||||||
|
|||||||
Reference in New Issue
Block a user