From b14adb01ca497e368519c14d720f11e8d00bf952 Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 17 Mar 2025 20:00:27 +0800 Subject: [PATCH] update TypeMeta --- .../MetaDescriptionAttribute.cs | 1 + src/DebugUtils/TypeMeta.cs | 44 ++++++++++++++++++- src/EcsPipeline.cs | 1 + 3 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/DebugUtils/MetaAttributes/MetaDescriptionAttribute.cs b/src/DebugUtils/MetaAttributes/MetaDescriptionAttribute.cs index 4119212..6b5352a 100644 --- a/src/DebugUtils/MetaAttributes/MetaDescriptionAttribute.cs +++ b/src/DebugUtils/MetaAttributes/MetaDescriptionAttribute.cs @@ -28,6 +28,7 @@ namespace DCFApixels.DragonECS { get { return string.IsNullOrEmpty(Author) == false; } } + public MetaDescription(string text) : this(null, text) { } public MetaDescription(string author, string text) { if (author == null) { author = string.Empty; } diff --git a/src/DebugUtils/TypeMeta.cs b/src/DebugUtils/TypeMeta.cs index 1a822ba..78c7577 100644 --- a/src/DebugUtils/TypeMeta.cs +++ b/src/DebugUtils/TypeMeta.cs @@ -65,6 +65,9 @@ namespace DCFApixels.DragonECS private string _metaID; private EcsTypeCode _typeCode; + private bool _isProcess; + private bool _isComponent; + private InitFlag _initFlags = InitFlag.None; #region Constructors @@ -287,6 +290,33 @@ namespace DCFApixels.DragonECS } #endregion + #region ReflectionInfo + public bool IsComponent + { + get + { + if (_initFlags.HasFlag(InitFlag.ReflectionInfo) == false) + { + MetaGenerator.GetReflectionInfo(this); + _initFlags |= InitFlag.ReflectionInfo; + } + return _isComponent; + } + } + public bool IsProcess + { + get + { + if (_initFlags.HasFlag(InitFlag.ReflectionInfo) == false) + { + MetaGenerator.GetReflectionInfo(this); + _initFlags |= InitFlag.ReflectionInfo; + } + return _isProcess; + } + } + #endregion + #region InitializeAll public TypeMeta InitializeAll() { @@ -316,9 +346,10 @@ namespace DCFApixels.DragonECS Tags = 1 << 4, MetaID = 1 << 5, TypeCode = 1 << 6, - //MemberType = 1 << 7, + ReflectionInfo = 1 << 7, + //MemberType = 1 << 8, - All = Name | Group | Color | Description | Tags | TypeCode | MetaID //| MemberType + All = Name | Group | Color | Description | Tags | TypeCode | MetaID | ReflectionInfo //| MemberType } #endregion @@ -548,6 +579,15 @@ namespace DCFApixels.DragonECS #endif } #endregion + + #region GetReflectionInfo + public static void GetReflectionInfo(TypeMeta meta) + { + var interfaces = meta.Type.GetInterfaces(); + meta._isComponent = Array.IndexOf(interfaces, typeof(IEcsComponentMember)) >= 0; + meta._isProcess = Array.IndexOf(interfaces, typeof(IEcsProcess)) >= 0; + } + #endregion } #endregion } diff --git a/src/EcsPipeline.cs b/src/EcsPipeline.cs index 6ad2331..45a6527 100644 --- a/src/EcsPipeline.cs +++ b/src/EcsPipeline.cs @@ -14,6 +14,7 @@ using static DCFApixels.DragonECS.EcsConsts; namespace DCFApixels.DragonECS { public interface IEcsMember { } + public interface IEcsComponentMember : IEcsMember { } public interface INamedMember { string Name { get; }