diff --git a/src/Builtin/BaseProcesses.cs b/src/Builtin/BaseProcesses.cs index 6d6dc52..b500448 100644 --- a/src/Builtin/BaseProcesses.cs +++ b/src/Builtin/BaseProcesses.cs @@ -5,28 +5,28 @@ using System; namespace DCFApixels.DragonECS { [MetaName(nameof(PreInit))] - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] public interface IEcsPreInit : IEcsProcess { void PreInit(); } [MetaName(nameof(Init))] - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] public interface IEcsInit : IEcsProcess { void Init(); } [MetaName(nameof(Run))] - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] public interface IEcsRun : IEcsProcess { void Run(); } [MetaName(nameof(Destroy))] - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] public interface IEcsDestroy : IEcsProcess { @@ -41,7 +41,7 @@ namespace DCFApixels.DragonECS.Internal [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] #endif - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] internal sealed class EcsPreInitRunner : EcsRunner, IEcsPreInit { @@ -97,7 +97,7 @@ namespace DCFApixels.DragonECS.Internal [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] #endif - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] internal sealed class EcsInitRunner : EcsRunner, IEcsInit { @@ -150,7 +150,7 @@ namespace DCFApixels.DragonECS.Internal [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] #endif - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] internal sealed class EcsRunRunner : EcsRunner, IEcsRun { @@ -203,7 +203,7 @@ namespace DCFApixels.DragonECS.Internal [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] #endif - [MetaColor(MetaColor.Orange)] + [MetaColor(MetaColor.DragonRose)] [MetaGroup(EcsConsts.FRAMEWORK_NAME)] internal sealed class EcsDestroyRunner : EcsRunner, IEcsDestroy { diff --git a/src/Builtin/Worlds.cs b/src/Builtin/Worlds.cs index 9b059d1..a511ccd 100644 --- a/src/Builtin/Worlds.cs +++ b/src/Builtin/Worlds.cs @@ -2,6 +2,8 @@ namespace DCFApixels.DragonECS { + [MetaColor(MetaColor.DragonRose)] + [MetaGroup(EcsConsts.FRAMEWORK_NAME)] [DebuggerTypeProxy(typeof(DebuggerProxy))] public sealed class EcsDefaultWorld : EcsWorld, IInjectionUnit { @@ -12,6 +14,8 @@ namespace DCFApixels.DragonECS initer.AddNode(); } } + [MetaColor(MetaColor.DragonRose)] + [MetaGroup(EcsConsts.FRAMEWORK_NAME)] [DebuggerTypeProxy(typeof(DebuggerProxy))] public sealed class EcsEventWorld : EcsWorld, IInjectionUnit { diff --git a/src/Debug/EcsDebugUtility.cs b/src/Debug/EcsDebugUtility.cs index 8a6d87c..fc3e0b3 100644 --- a/src/Debug/EcsDebugUtility.cs +++ b/src/Debug/EcsDebugUtility.cs @@ -156,36 +156,36 @@ namespace DCFApixels.DragonECS #endregion #region GetDescription - public static string GetDescription(object obj) + public static MetaDescription GetDescription(object obj) { return GetTypeMeta(obj).Description; } - public static string GetDescription() + public static MetaDescription GetDescription() { return GetTypeMeta().Description; } - public static string GetDescription(Type type) + public static MetaDescription GetDescription(Type type) { return GetTypeMeta(type).Description; } - public static bool TryGetDescription(object obj, out string description) + public static bool TryGetDescription(object obj, out MetaDescription description) { TypeMeta meta = GetTypeMeta(obj); description = meta.Description; - return string.IsNullOrEmpty(description); + return description != MetaDescription.Empty; } - public static bool TryGetDescription(out string description) + public static bool TryGetDescription(out MetaDescription description) { TypeMeta meta = GetTypeMeta(); description = meta.Description; - return string.IsNullOrEmpty(description); + return description != MetaDescription.Empty; } - public static bool TryGetDescription(Type type, out string description) + public static bool TryGetDescription(Type type, out MetaDescription description) { TypeMeta meta = GetTypeMeta(type); description = meta.Description; - return string.IsNullOrEmpty(description); + return description != MetaDescription.Empty; } #endregion @@ -207,19 +207,19 @@ namespace DCFApixels.DragonECS { TypeMeta meta = GetTypeMeta(obj); group = meta.Group; - return group.IsNull; + return group != MetaGroup.Empty; } public static bool TryGetGroup(out MetaGroup group) { TypeMeta meta = GetTypeMeta(); group = meta.Group; - return group.IsNull; + return group != MetaGroup.Empty; } public static bool TryGetGroup(Type type, out MetaGroup group) { TypeMeta meta = GetTypeMeta(type); group = meta.Group; - return group.IsNull; + return group != MetaGroup.Empty; } #endregion @@ -308,7 +308,7 @@ namespace DCFApixels.DragonECS { string Name { get; } MetaColor Color { get; } - string Description { get; } + MetaDescription Description { get; } MetaGroup Group { get; } IReadOnlyCollection Tags { get; } } @@ -324,7 +324,7 @@ namespace DCFApixels.DragonECS private string _name; private MetaColor _color; - private string _description; + private MetaDescription _description; private MetaGroup _group; private IReadOnlyCollection _tags; private int _typeCode; @@ -400,7 +400,7 @@ namespace DCFApixels.DragonECS #endregion #region Description - public string Description + public MetaDescription Description { get { @@ -520,7 +520,7 @@ namespace DCFApixels.DragonECS { get { return _meta.Color; } } - public string Description + public MetaDescription Description { get { return _meta.Description; } } @@ -587,10 +587,10 @@ namespace DCFApixels.DragonECS #endregion #region GetDescription - public static string GetDescription(Type type) + public static MetaDescription GetDescription(Type type) { bool isCustom = type.TryGetCustomAttribute(out MetaDescriptionAttribute atr); - return isCustom ? atr.description : string.Empty; + return isCustom ? atr.Data : MetaDescription.Empty; } #endregion diff --git a/src/Debug/MetaAttributes/MetaColorAttribute.cs b/src/Debug/MetaAttributes/MetaColorAttribute.cs index c570468..f9c81bf 100644 --- a/src/Debug/MetaAttributes/MetaColorAttribute.cs +++ b/src/Debug/MetaAttributes/MetaColorAttribute.cs @@ -1,6 +1,8 @@ using DCFApixels.DragonECS.Internal; using System; +using System.Diagnostics; using System.Runtime.InteropServices; +using System.Xml.Linq; namespace DCFApixels.DragonECS { @@ -117,6 +119,12 @@ namespace DCFApixels.DragonECS public const int White = -1; /// color code Black. RGB is (0, 0, 0) public const int Black = 0; + + + /// RGB is (255, 78, 133) color code + public const int DragonRose = (255 << 24) | (78 << 16) | (133 << 8) | 255; + /// RGB is (0, 255, 156) color code + public const int DragonCyan = (0 << 24) | (255 << 16) | (156 << 8) | 255; #endregion [FieldOffset(0)] public readonly int colorCode; @@ -329,5 +337,7 @@ namespace DCFApixels.DragonECS (byte)(a.b - b.b)); } #endregion + + public override string ToString() { return $"({r}, {g}, {b})"; } } } \ No newline at end of file diff --git a/src/Debug/MetaAttributes/MetaDescriptionAttribute.cs b/src/Debug/MetaAttributes/MetaDescriptionAttribute.cs index 3260cc8..1a03581 100644 --- a/src/Debug/MetaAttributes/MetaDescriptionAttribute.cs +++ b/src/Debug/MetaAttributes/MetaDescriptionAttribute.cs @@ -1,14 +1,44 @@ using System; +using System.Diagnostics; namespace DCFApixels.DragonECS { [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)] public sealed class MetaDescriptionAttribute : EcsMetaAttribute { - public readonly string description; - public MetaDescriptionAttribute(string description) + public readonly MetaDescription Data; + public MetaDescriptionAttribute(string text) { - this.description = description; + Data = new MetaDescription(null, text); + } + public MetaDescriptionAttribute(string author, string text) + { + Data = new MetaDescription(author, text); } } + public class MetaDescription + { + public static readonly MetaDescription Empty = new MetaDescription(null, null); + public readonly string Author; + public readonly string Text; + public MetaDescription(string author, string text) + { + if (author == null) { author = string.Empty; } + if (text == null) { text = string.Empty; } + Author = author; + Text = text; + } + public override string ToString() + { + if (string.IsNullOrEmpty(Author)) + { + return Text; + } + else + { + return $"[{Author}] Text"; + } + } + + } } diff --git a/src/Debug/MetaAttributes/MetaGroupAttribute.cs b/src/Debug/MetaAttributes/MetaGroupAttribute.cs index f494656..f4efc47 100644 --- a/src/Debug/MetaAttributes/MetaGroupAttribute.cs +++ b/src/Debug/MetaAttributes/MetaGroupAttribute.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using System.Diagnostics; using System.Text.RegularExpressions; namespace DCFApixels.DragonECS @@ -7,27 +8,27 @@ namespace DCFApixels.DragonECS [AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)] public sealed class MetaGroupAttribute : EcsMetaAttribute { - public readonly MetaGroupRef Data; + public readonly MetaGroup Data; [Obsolete("With empty parameters, this attribute makes no sense.")] public MetaGroupAttribute() { } public MetaGroupAttribute(string name) { - Data = new MetaGroupRef(name); + Data = new MetaGroup(name); } public MetaGroupAttribute(params string[] path) { - Data = new MetaGroupRef(string.Join("/", path)); + Data = new MetaGroup(string.Join("/", path)); } } - public class MetaGroupRef + public class MetaGroup { - public static readonly MetaGroupRef Empty = new MetaGroupRef(""); + public static readonly MetaGroup Empty = new MetaGroup(""); + private static string pattern = @"Module(?=/)"; + private static char[] separatpor = new char[] { '/' }; public readonly string Name; private string[] path = null; - private static string pattern = @"Module(?=/)"; - private static char[] separatpor = new char[] { '/' }; public IReadOnlyCollection Splited { get @@ -39,7 +40,7 @@ namespace DCFApixels.DragonECS return path; } } - public MetaGroupRef(string name) + public MetaGroup(string name) { if (string.IsNullOrEmpty(name)) { @@ -53,32 +54,6 @@ namespace DCFApixels.DragonECS } Name = Regex.Replace(name, pattern, ""); ; } - } - - public readonly struct MetaGroup - { - public static readonly MetaGroup Empty = new MetaGroup(MetaGroupRef.Empty); - private readonly MetaGroupRef _source; - public string Name - { - get { return _source.Name; } - } - public IReadOnlyCollection Splited - { - get { return _source.Splited; } - } - public bool IsNull - { - get { return _source == null; } - } - public MetaGroup(MetaGroupRef source) - { - _source = source; - } - - public static implicit operator MetaGroup(MetaGroupRef group) - { - return new MetaGroup(group); - } + public override string ToString() { return Name; } } } diff --git a/src/EcsPipeline.cs b/src/EcsPipeline.cs index 5b06af9..91e0068 100644 --- a/src/EcsPipeline.cs +++ b/src/EcsPipeline.cs @@ -550,11 +550,11 @@ namespace DCFApixels.DragonECS internal class DebuggerProxy { private EcsProcessRaw _process; - public IEnumerable Systems + public IEnumerable Systems { get { - return _process._systems.Cast().Select(o => o.GetMeta()).ToArray(); + return _process._systems.Cast().ToArray(); } } public int Count @@ -652,37 +652,22 @@ namespace DCFApixels.DragonECS internal class DebuggerProxy { private EcsProcess _process; - public IEnumerable Systems + public IEnumerable Systems { get { - return _process._systems.Select(o => new SystemInfoWrapper(o)).ToArray(); + return _process._systems.Cast().ToArray(); } } public int Count { get { return _process.Length; } } - public TypeMeta __META { get { return typeof(TProcess).ToMeta(); } } public DebuggerProxy(EcsProcess process) { _process = process; } - public readonly struct SystemInfoWrapper - { - public readonly TProcess System; - public SystemInfoWrapper(TProcess system) - { - System = system; - } - public TypeMeta __META { get { return System.GetMeta(); } } - public override string ToString() - { - return System.GetMeta().Name; - } - } - } #endregion } diff --git a/src/EcsWorld.cs b/src/EcsWorld.cs index 39baf86..a4ec473 100644 --- a/src/EcsWorld.cs +++ b/src/EcsWorld.cs @@ -28,6 +28,9 @@ namespace DCFApixels.DragonECS PoolRecycledComponentsCapacity = poolRecycledComponentsCapacity; } } + + [MetaColor(MetaColor.DragonRose)] + [MetaGroup(EcsConsts.FRAMEWORK_NAME)] #if ENABLE_IL2CPP [Il2CppSetOption(Option.NullChecks, false)] [Il2CppSetOption(Option.ArrayBoundsChecks, false)] @@ -797,7 +800,6 @@ namespace DCFApixels.DragonECS } public long Version { get { return _world.Version; } } public IEcsPool[] Pools { get { return _world._pools; } } - public TypeMeta __META { get { return _world.GetMeta(); } } public DebuggerProxy(EcsWorld world) { _world = world;