From 06015d51d0f804ed50d51459d1369cee1df53096 Mon Sep 17 00:00:00 2001 From: Soar Qin Date: Tue, 23 Jun 2026 03:38:04 +0800 Subject: [PATCH] docs(UXAssist): update ModFeature docs for non-static feature classes --- .../Common/ModFeatures/ModFeatureAttribute.cs | 2 +- .../Common/ModFeatures/ModFeatureRegistry.cs | 19 ++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/UXAssist/Common/ModFeatures/ModFeatureAttribute.cs b/UXAssist/Common/ModFeatures/ModFeatureAttribute.cs index 9530612..ebbee18 100644 --- a/UXAssist/Common/ModFeatures/ModFeatureAttribute.cs +++ b/UXAssist/Common/ModFeatures/ModFeatureAttribute.cs @@ -3,7 +3,7 @@ using System; namespace UXAssist.Common.ModFeatures; /// -/// Marks a static class as a mod feature so that can discover it. +/// Marks a class as a mod feature so that can discover it. /// Lifecycle methods (Init, Start, Uninit, OnInputUpdate, OnUpdate) are optional. /// [AttributeUsage(AttributeTargets.Class, Inherited = false)] diff --git a/UXAssist/Common/ModFeatures/ModFeatureRegistry.cs b/UXAssist/Common/ModFeatures/ModFeatureRegistry.cs index 16ffc77..a29d5d4 100644 --- a/UXAssist/Common/ModFeatures/ModFeatureRegistry.cs +++ b/UXAssist/Common/ModFeatures/ModFeatureRegistry.cs @@ -6,8 +6,9 @@ using System.Reflection; namespace UXAssist.Common.ModFeatures; /// -/// Registry that discovers static mod features from assemblies and holds registered instance mod features. -/// Static lifecycle methods are optional; if a method is missing it is simply skipped. +/// Registry that discovers mod feature classes marked with from assemblies +/// and holds registered instance mod features. Discovered features invoke static lifecycle methods; +/// static lifecycle methods are optional and are skipped if missing. /// public static class ModFeatureRegistry { @@ -46,7 +47,7 @@ public static class ModFeatureRegistry private static readonly HashSet _discoveredAssemblies = []; /// - /// Discovers static mod feature classes marked with in the given assembly. + /// Discovers mod feature classes marked with in the given assembly. /// Each assembly is only discovered once. /// /// The assembly to scan. @@ -55,7 +56,7 @@ public static class ModFeatureRegistry if (!_discoveredAssemblies.Add(assembly)) return; var staticTypes = Util.GetTypesFiltered(assembly, t => - t.IsClass && !t.IsInterface && + t.IsClass && Attribute.IsDefined(t, typeof(ModFeatureAttribute)) && !typeof(IModFeature).IsAssignableFrom(t)); @@ -81,7 +82,7 @@ public static class ModFeatureRegistry /// /// Calls on all registered instance features - /// and invokes the cached static Init methods on all discovered static features. + /// and invokes the cached static Init methods on all discovered mod feature classes. /// public static void InitAll() { @@ -91,7 +92,7 @@ public static class ModFeatureRegistry /// /// Calls on all registered instance features - /// and invokes the cached static Start methods on all discovered static features. + /// and invokes the cached static Start methods on all discovered mod feature classes. /// public static void StartAll() { @@ -101,7 +102,7 @@ public static class ModFeatureRegistry /// /// Calls on all registered instance features - /// and invokes the cached static Uninit methods on all discovered static features. + /// and invokes the cached static Uninit methods on all discovered mod feature classes. /// public static void UninitAll() { @@ -111,7 +112,7 @@ public static class ModFeatureRegistry /// /// Calls on all registered instance features - /// and invokes the cached static OnInputUpdate delegates on all discovered static features. + /// and invokes the cached static OnInputUpdate delegates on all discovered mod feature classes. /// This method is meant to be called every frame; no reflection is performed here. /// public static void OnInputUpdateAll() @@ -122,7 +123,7 @@ public static class ModFeatureRegistry /// /// Calls on all registered instance features - /// and invokes the cached static OnUpdate delegates on all discovered static features. + /// and invokes the cached static OnUpdate delegates on all discovered mod feature classes. /// This method is meant to be called every frame; no reflection is performed here. /// public static void OnUpdateAll()