From 3e59e7a5bd0b4946e41922791f8314a429a07506 Mon Sep 17 00:00:00 2001 From: DCFApixels <99481254+DCFApixels@users.noreply.github.com> Date: Sun, 23 Mar 2025 21:12:43 +0800 Subject: [PATCH] remove inheriting meta --- .../MetaAttributes/MetaColorAttribute.cs | 5 -- .../MetaAttributes/MetaGroupAttribute.cs | 46 ++++--------------- src/DebugUtils/TypeMeta.cs | 19 ++++---- 3 files changed, 18 insertions(+), 52 deletions(-) diff --git a/src/DebugUtils/MetaAttributes/MetaColorAttribute.cs b/src/DebugUtils/MetaAttributes/MetaColorAttribute.cs index 94f3431..7d5e930 100644 --- a/src/DebugUtils/MetaAttributes/MetaColorAttribute.cs +++ b/src/DebugUtils/MetaAttributes/MetaColorAttribute.cs @@ -26,7 +26,6 @@ namespace DCFApixels.DragonECS public sealed class MetaColorAttribute : EcsMetaAttribute, IMetaColor { public readonly MetaColor color; - public readonly Type InheritingColorType; #region Properties public byte R @@ -72,10 +71,6 @@ namespace DCFApixels.DragonECS { color = new MetaColor(colorCode, true); } - public MetaColorAttribute(Type inheritingColorType) - { - InheritingColorType = inheritingColorType; - } #endregion } [Serializable] diff --git a/src/DebugUtils/MetaAttributes/MetaGroupAttribute.cs b/src/DebugUtils/MetaAttributes/MetaGroupAttribute.cs index f94546c..832c3da 100644 --- a/src/DebugUtils/MetaAttributes/MetaGroupAttribute.cs +++ b/src/DebugUtils/MetaAttributes/MetaGroupAttribute.cs @@ -13,24 +13,12 @@ namespace DCFApixels.DragonECS public sealed class MetaGroupAttribute : EcsMetaAttribute { public const char SEPARATOR = MetaGroup.SEPARATOR; - public readonly Type InheritingGroupType = null; - public readonly string RelativeName = string.Empty; + public readonly string Name = string.Empty; [Obsolete(EcsMetaAttributeHalper.EMPTY_NO_SENSE_MESSAGE)] public MetaGroupAttribute() { } - public MetaGroupAttribute(string name) { RelativeName = name; } - public MetaGroupAttribute(params string[] path) { RelativeName = string.Join(SEPARATOR, path); } - public MetaGroupAttribute(Type inheritingGroupType) { InheritingGroupType = inheritingGroupType; } - public MetaGroupAttribute(Type inheritingGroupType, string relativeName) - { - InheritingGroupType = inheritingGroupType; - RelativeName = relativeName; - } - public MetaGroupAttribute(Type inheritingGroupType, params string[] relativePath) - { - InheritingGroupType = inheritingGroupType; - RelativeName = string.Join(SEPARATOR, relativePath); - } + public MetaGroupAttribute(string name) { Name = name; } + public MetaGroupAttribute(params string[] path) { Name = string.Join(SEPARATOR, path); } } [DebuggerDisplay("{Name}")] public class MetaGroup @@ -39,9 +27,8 @@ namespace DCFApixels.DragonECS private const string SEPARATOR_STR = "/"; public const string UNGROUPED = ""; private const string PATTERN = @"Module(?=/)"; - public static readonly MetaGroup Empty = new MetaGroup(null, UNGROUPED); + public static readonly MetaGroup Empty = new MetaGroup(UNGROUPED); - public readonly MetaGroup ParentGroup; public readonly string Name; private string[] _splited = null; public IReadOnlyCollection Splited @@ -59,7 +46,7 @@ namespace DCFApixels.DragonECS { get { return this == Empty; } } - private MetaGroup(MetaGroup parentGroup, string name) + private MetaGroup(string name) { if (string.IsNullOrEmpty(name)) { @@ -80,26 +67,11 @@ namespace DCFApixels.DragonECS } public static MetaGroup FromName(string name) { - return FromName(null, name); - } - public static MetaGroup FromName(MetaGroup parentGroup, string name) - { - if(parentGroup == null || parentGroup == Empty) + if (string.IsNullOrWhiteSpace(name)) { - if (string.IsNullOrWhiteSpace(name)) - { - return Empty; - } - return new MetaGroup(null, name); - } - else - { - if (string.IsNullOrWhiteSpace(name)) - { - return new MetaGroup(parentGroup, parentGroup.Name); - } - return new MetaGroup(parentGroup, parentGroup.Name + name); + return Empty; } + return new MetaGroup(name); } public static MetaGroup FromNameSpace(Type type) { @@ -107,7 +79,7 @@ namespace DCFApixels.DragonECS { return Empty; } - return new MetaGroup(null, type.Namespace.Replace('.', SEPARATOR)); + return new MetaGroup(type.Namespace.Replace('.', SEPARATOR)); } public override string ToString() { return Name; } } diff --git a/src/DebugUtils/TypeMeta.cs b/src/DebugUtils/TypeMeta.cs index 373482a..ca26c08 100644 --- a/src/DebugUtils/TypeMeta.cs +++ b/src/DebugUtils/TypeMeta.cs @@ -521,19 +521,11 @@ namespace DCFApixels.DragonECS } return MetaColor.FromHashCode(hash).UpContrast(); } - private static MetaColor GetColorFromAttribute(MetaColorAttribute atr) - { - if(atr.InheritingColorType == null) - { - return atr.color; - } - return atr.InheritingColorType.ToMeta().Color; - } public static (MetaColor, bool) GetColor(TypeMeta meta) { #if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает bool isCustom = meta.Type.TryGetAttribute(out MetaColorAttribute atr); - return (isCustom ? GetColorFromAttribute(atr) : AutoColor(meta), isCustom); + return (isCustom ? atr.color : AutoColor(meta), isCustom); #else EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetColor)} method does not work."); return (MetaColor.White, false); @@ -545,7 +537,14 @@ namespace DCFApixels.DragonECS public static MetaGroup GetGroup(Type type) { #if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает - return type.TryGetAttribute(out MetaGroupAttribute atr) ? MetaGroup.FromName(atr.InheritingGroupType.GetMeta().Group, atr.RelativeName) : MetaGroup.FromNameSpace(type); + if (type.TryGetAttribute(out MetaGroupAttribute atr)) + { + return MetaGroup.FromName(atr.Name); + } + else + { + return MetaGroup.FromNameSpace(type); + } #else EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetGroup)} method does not work."); return MetaGroup.Empty;