From 2f07b3f0169d5f63d1503e1abe12fef4de96ca7a Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 24 Dec 2023 18:17:43 +0800 Subject: [PATCH] update --- src/Aspect/EcsAspectAuto.cs | 2 +- src/AutoInjectSystem.cs | 5 +- src/AutoProcesses/AutoProcesses.cs | 107 +++++++------------------ src/Utils/Exceptions.cs | 2 +- src/Utils/ReflectionExtensions.cs | 14 ---- src/Utils/ReflectionExtensions.cs.meta | 11 --- 6 files changed, 32 insertions(+), 109 deletions(-) delete mode 100644 src/Utils/ReflectionExtensions.cs delete mode 100644 src/Utils/ReflectionExtensions.cs.meta diff --git a/src/Aspect/EcsAspectAuto.cs b/src/Aspect/EcsAspectAuto.cs index 21e666f..80d7091 100644 --- a/src/Aspect/EcsAspectAuto.cs +++ b/src/Aspect/EcsAspectAuto.cs @@ -73,7 +73,7 @@ namespace DCFApixels.DragonECS } }//TODO КОНЕЦ убрать дублирование кода - вынести в отедльный метод - if (!fieldInfo.TryGetAttribute(out InjectAttribute injectAttribute)) + if (!fieldInfo.TryGetCustomAttribute(out InjectAttribute injectAttribute)) continue; if (injectAttribute is IncAttribute) diff --git a/src/AutoInjectSystem.cs b/src/AutoInjectSystem.cs index dc6b0cf..ea6c137 100644 --- a/src/AutoInjectSystem.cs +++ b/src/AutoInjectSystem.cs @@ -1,4 +1,4 @@ -using DCFApixels.DragonECS.AutoInjectionsInternal; +using DCFApixels.DragonECS.AutoInjections.Internal; using System; using System.Collections.Generic; using System.Linq; @@ -150,7 +150,8 @@ namespace DCFApixels.DragonECS } } - [DebugHide, DebugColor(DebugColor.Gray)] + [MetaTags(MetaTags.HIDDEN)] + [MetaColor(MetaColor.Gray)] public class AutoInjectSystem : IEcsPreInject, IEcsInject, IEcsPreInitInjectProcess { private EcsPipeline _pipeline; diff --git a/src/AutoProcesses/AutoProcesses.cs b/src/AutoProcesses/AutoProcesses.cs index dd9e35d..c548af0 100644 --- a/src/AutoProcesses/AutoProcesses.cs +++ b/src/AutoProcesses/AutoProcesses.cs @@ -72,141 +72,87 @@ namespace DCFApixels.DragonECS } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// - internal class IEcsProcessWrapperBase + internal class EcsProcessWrapperBase { [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static bool CheckParameters(MethodInfo method, out bool isHasParam) + public static bool CheckParameters(MethodInfo method) { - var parametres = method.GetParameters(); - isHasParam = false; - if (parametres.Length != 0 && (parametres[0].ParameterType != typeof(EcsPipeline))) - return false; - isHasParam = parametres.Length > 0; - return true; + return method.GetParameters().Length <= 0; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Action CreateEmptyAction(object target, MethodInfo method) + public static Action CreateAction(object target, MethodInfo method) { return EcsAutoProcessUtility.CreateDelegate(target, method); } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static Action CreateAction(object target, MethodInfo method) - { - return EcsAutoProcessUtility.CreateDelegate>(target, method); - } } - internal class IEcsProcessEmptyWrapper : IEcsProcessWrapperBase, IEcsDebugMetaProvider + internal class IEcsProcessWrapper : EcsProcessWrapperBase, IEcsMetaProvider { public object system; public Action a; - public object DebugMetaSource => system; - } - internal class IEcsProcessWrapper : IEcsProcessWrapperBase, IEcsDebugMetaProvider - { - public object system; - public Action a; - public object DebugMetaSource => system; + public object MetaSource => system; } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// [EcsProcessWrapperBuilder(nameof(PreInit), nameof(Builder))] - internal class EcsPreInitProcessEmptyWrapper : IEcsProcessEmptyWrapper, IEcsPreInitProcess + internal class EcsPreInitProcessWrapper : IEcsProcessWrapper, IEcsPreInitProcess { - public EcsPreInitProcessEmptyWrapper(object target, Action a) { system = target; this.a = a; } + public EcsPreInitProcessWrapper(object target, Action a) { system = target; this.a = a; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void PreInit(EcsPipeline pipeline) => a(); + public void PreInit() => a(); public static IEcsProcess Builder(object target, MethodInfo method) { if (target is IEcsPreInitProcess) return null; - if (CheckParameters(method, out bool isHasParam)) - if (isHasParam) - return new EcsPreInitProcessWrapper(target, CreateAction(target, method)); - else - return new EcsPreInitProcessEmptyWrapper(target, CreateEmptyAction(target, method)); + if (CheckParameters(method)) + return new EcsPreInitProcessWrapper(target, CreateAction(target, method)); return null; } } - internal class EcsPreInitProcessWrapper : IEcsProcessWrapper, IEcsPreInitProcess - { - public EcsPreInitProcessWrapper(object target, Action a) { system = target; this.a = a; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void PreInit(EcsPipeline pipeline) => a(pipeline); - } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// [EcsProcessWrapperBuilder(nameof(Init), nameof(Builder))] - internal class EcsInitProcessEmptyWrapper : IEcsProcessEmptyWrapper, IEcsInitProcess + internal class EcsInitProcessWrapper : IEcsProcessWrapper, IEcsInitProcess { - public EcsInitProcessEmptyWrapper(object target, Action a) { system = target; this.a = a; } + public EcsInitProcessWrapper(object target, Action a) { system = target; this.a = a; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Init(EcsPipeline pipeline) => a(); + public void Init() => a(); public static IEcsProcess Builder(object target, MethodInfo method) { if (target is IEcsInitProcess) return null; - if (CheckParameters(method, out bool isHasParam)) - if (isHasParam) - return new EcsInitProcessWrapper(target, CreateAction(target, method)); - else - return new EcsInitProcessEmptyWrapper(target, CreateEmptyAction(target, method)); + if (CheckParameters(method)) + return new EcsInitProcessWrapper(target, CreateAction(target, method)); return null; } } - internal class EcsInitProcessWrapper : IEcsProcessWrapper, IEcsInitProcess - { - public EcsInitProcessWrapper(object target, Action a) { system = target; this.a = a; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Init(EcsPipeline pipeline) => a(pipeline); - } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// [EcsProcessWrapperBuilder(nameof(Run), nameof(Builder))] - internal class EcsRunProcessEmptyWrapper : IEcsProcessEmptyWrapper, IEcsRunProcess + internal class EcsRunProcessEmptyWrapper : IEcsProcessWrapper, IEcsRunProcess { public EcsRunProcessEmptyWrapper(object target, Action a) { system = target; this.a = a; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Run(EcsPipeline pipeline) => a(); + public void Run() => a(); public static IEcsProcess Builder(object target, MethodInfo method) { if (target is IEcsRunProcess) return null; - if (CheckParameters(method, out bool isHasParam)) - if (isHasParam) - return new EcsRunProcessWrapper(target, CreateAction(target, method)); - else - return new EcsRunProcessEmptyWrapper(target, CreateEmptyAction(target, method)); + if (CheckParameters(method)) + return new EcsRunProcessEmptyWrapper(target, CreateAction(target, method)); return null; } } - internal class EcsRunProcessWrapper : IEcsProcessWrapper, IEcsRunProcess - { - public EcsRunProcessWrapper(object target, Action a) { system = target; this.a = a; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Run(EcsPipeline pipeline) => a(pipeline); - } /////////////////////////////////////////////////////////////////////////////////////////////////////////////// [EcsProcessWrapperBuilder(nameof(Destroy), nameof(Builder))] - internal class EcsDestroyProcessEmptyWrapper : IEcsProcessEmptyWrapper, IEcsDestroyProcess + internal class EcsDestroyProcessEmptyWrapper : IEcsProcessWrapper, IEcsDestroyProcess { public EcsDestroyProcessEmptyWrapper(object target, Action a) { system = target; this.a = a; } [MethodImpl(MethodImplOptions.AggressiveInlining)] - public void Destroy(EcsPipeline pipeline) => a(); + public void Destroy() => a(); public static IEcsProcess Builder(object target, MethodInfo method) { - if (target is IEcsDestroyProcess) return null; - if (CheckParameters(method, out bool isHasParam)) - if (isHasParam) - return new EcsDestroyProcessWrapper(target, CreateAction(target, method)); - else - return new EcsDestroyProcessEmptyWrapper(target, CreateEmptyAction(target, method)); + if (target is IEcsRunProcess) return null; + if (CheckParameters(method)) + return new EcsDestroyProcessEmptyWrapper(target, CreateAction(target, method)); return null; } } - internal class EcsDestroyProcessWrapper : IEcsProcessWrapper, IEcsDestroyProcess - { - public EcsDestroyProcessWrapper(object target, Action a) { system = target; this.a = a; } - [MethodImpl(MethodImplOptions.AggressiveInlining)] public void Destroy(EcsPipeline pipeline) => a(pipeline); - } - - - - + /* public interface ISomeCustomeProcess : IEcsProcess { void DoSomething(); @@ -228,4 +174,5 @@ namespace DCFApixels.DragonECS return new SomeCustomeProcessWrapper(system, EcsAutoProcessUtility.CreateDelegate(system, method)); } } + */ } diff --git a/src/Utils/Exceptions.cs b/src/Utils/Exceptions.cs index cb1eadc..edff6fc 100644 --- a/src/Utils/Exceptions.cs +++ b/src/Utils/Exceptions.cs @@ -5,7 +5,7 @@ using System.Runtime.Serialization; namespace DCFApixels.DragonECS { - namespace AutoInjectionsInternal + namespace AutoInjections.Internal { internal static class Throw { diff --git a/src/Utils/ReflectionExtensions.cs b/src/Utils/ReflectionExtensions.cs deleted file mode 100644 index e4ffc49..0000000 --- a/src/Utils/ReflectionExtensions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Reflection; - -namespace DCFApixels.DragonECS -{ - internal static class ReflectionExtensions - { - public static bool TryGetAttribute(this MemberInfo self, out T attribute) where T : Attribute - { - attribute = self.GetCustomAttribute(); - return attribute != null; - } - } -} diff --git a/src/Utils/ReflectionExtensions.cs.meta b/src/Utils/ReflectionExtensions.cs.meta deleted file mode 100644 index afd1984..0000000 --- a/src/Utils/ReflectionExtensions.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1f6eaf9c4ba7e4b4996a1600ff39f19f -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: