From 29e9d9edbb2af01661bf2a05e8e7f7e4440d7c30 Mon Sep 17 00:00:00 2001 From: Mikhail <99481254+DCFApixels@users.noreply.github.com> Date: Mon, 10 Jun 2024 18:04:33 +0800 Subject: [PATCH] move DragonDocs to Unity integration --- src/Debug/DragonDocs/DragonDocs.cs | 101 ------------------ src/Debug/DragonDocs/DragonDocsMeta.cs | 64 ----------- .../MetaAttributes/MetaGroupAttribute.cs | 2 +- src/Debug/MetaAttributes/MetaTagsAttribute.cs | 2 +- src/Debug/TypeMeta.cs.meta | 11 ++ 5 files changed, 13 insertions(+), 167 deletions(-) delete mode 100644 src/Debug/DragonDocs/DragonDocs.cs delete mode 100644 src/Debug/DragonDocs/DragonDocsMeta.cs create mode 100644 src/Debug/TypeMeta.cs.meta diff --git a/src/Debug/DragonDocs/DragonDocs.cs b/src/Debug/DragonDocs/DragonDocs.cs deleted file mode 100644 index 6ff1040..0000000 --- a/src/Debug/DragonDocs/DragonDocs.cs +++ /dev/null @@ -1,101 +0,0 @@ -using DCFApixels.DragonECS.PoolsCore; -using System; -using System.Collections.Generic; -using System.Runtime.Serialization; - -namespace DCFApixels.DragonECS.Docs -{ - [Serializable] - [DataContract] - public class DragonDocs - { - [DataMember] - private readonly DragonDocsMeta[] _metas; - [NonSerialized] - private DragonDocsMetaGroup[] _mapping = null; - - public ReadOnlySpan Meta - { - get { return new ReadOnlySpan(_metas); } - } - public ReadOnlySpan Mapping - { - get - { - Init(); - return new ReadOnlySpan(_mapping); ; - } - } - private bool _isInit = false; - private void Init() - { - if (_isInit) { return; } - - if (_metas.Length < 0) - { - _mapping = Array.Empty(); - } - List groups = new List(); - string name = _metas[0].Name; - int startIndex = 0; - for (int i = 1; i < _metas.Length; i++) - { - var meta = _metas[i]; - if (name != meta.Name) - { - groups.Add(new DragonDocsMetaGroup(name, startIndex, i - startIndex)); - name = meta.Name; - startIndex = i; - } - } - groups.Add(new DragonDocsMetaGroup(name, startIndex, _metas.Length - startIndex)); - _mapping = groups.ToArray(); - } - private DragonDocs(DragonDocsMeta[] metas) - { - _metas = metas; - } - - public static DragonDocs Generate() - { - List metas = new List(256); - foreach (var type in GetTypes()) - { - metas.Add(new DragonDocsMeta(type.ToMeta())); - } - DragonDocsMeta[] array = metas.ToArray(); - Array.Sort(array); - return new DragonDocs(array); - } - private static List GetTypes() - { - Type metaAttributeType = typeof(EcsMetaAttribute); - Type memberType = typeof(IEcsMember); - List result = new List(512); - foreach (var assembly in AppDomain.CurrentDomain.GetAssemblies()) - { - foreach (var type in assembly.GetTypes()) - { - if (memberType.IsAssignableFrom(type) || Attribute.GetCustomAttributes(type, metaAttributeType, false).Length > 1) - { - result.Add(type); - } - } - } - return result; - } - } - public struct DragonDocsMetaGroup - { - public readonly string Name; - public readonly int StartIndex; - public readonly int Length; - public DragonDocsMetaGroup(string name, int startIndex, int length) - { - Name = name; - StartIndex = startIndex; - Length = length; - } - } - -} \ No newline at end of file diff --git a/src/Debug/DragonDocs/DragonDocsMeta.cs b/src/Debug/DragonDocs/DragonDocsMeta.cs deleted file mode 100644 index 1764a70..0000000 --- a/src/Debug/DragonDocs/DragonDocsMeta.cs +++ /dev/null @@ -1,64 +0,0 @@ -using System; -using System.Runtime.Serialization; - -namespace DCFApixels.DragonECS.Docs -{ - [Serializable] - [DataContract] - public class DragonDocsMeta : IComparable - { - [NonSerialized] private Type _sourceType; - [NonSerialized] private bool _isInitSourceType = false; - - [DataMember] public readonly string AssemblyQualifiedName = string.Empty; - - [DataMember] public readonly string Name = string.Empty; - [DataMember] public readonly bool IsCustomName = false; - [DataMember] public readonly MetaColor Color = MetaColor.BlackColor; - [DataMember] public readonly bool IsCustomColor = false; - [DataMember] public readonly string Autor = string.Empty; - [DataMember] public readonly string Description = string.Empty; - - [DataMember] public readonly string Group = string.Empty; - [DataMember] public readonly string[] Tags = Array.Empty(); - - public DragonDocsMeta(TypeMeta meta) - { - _sourceType = meta.Type; - AssemblyQualifiedName = meta.Type.AssemblyQualifiedName; - - Name = meta.Name; - IsCustomName = meta.IsCustomName; - Color = meta.Color; - IsCustomColor = meta.IsCustomColor; - Autor = meta.Description.Author; - Description = meta.Description.Text; - - Group = meta.Group.Name; - Tags = new string[meta.Tags.Count]; - for (int i = 0, n = meta.Tags.Count; i < n; i++) - { - Tags[i] = meta.Tags[i]; - } - } - - public bool TryGetSourceType(out Type type) - { - type = GetSourceType(); - return type != null; - } - private Type GetSourceType() - { - if (_isInitSourceType) { return _sourceType; } - _isInitSourceType = true; - _sourceType = Type.GetType(AssemblyQualifiedName); - return _sourceType; - } - - int IComparable.CompareTo(DragonDocsMeta other) - { - int c = string.Compare(Group, other.Group); - return c == 0 ? c : string.Compare(Name, other.Name); - } - } -} \ No newline at end of file diff --git a/src/Debug/MetaAttributes/MetaGroupAttribute.cs b/src/Debug/MetaAttributes/MetaGroupAttribute.cs index 609525b..4d8385b 100644 --- a/src/Debug/MetaAttributes/MetaGroupAttribute.cs +++ b/src/Debug/MetaAttributes/MetaGroupAttribute.cs @@ -34,7 +34,7 @@ namespace DCFApixels.DragonECS { if (_path == null) { - _path = Name.Split(_separatpor, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + _path = Name.Split(_separatpor, StringSplitOptions.RemoveEmptyEntries); //TODO добавить ручное StringSplitOptions.TrimEntries } return _path; } diff --git a/src/Debug/MetaAttributes/MetaTagsAttribute.cs b/src/Debug/MetaAttributes/MetaTagsAttribute.cs index c33486a..35b9031 100644 --- a/src/Debug/MetaAttributes/MetaTagsAttribute.cs +++ b/src/Debug/MetaAttributes/MetaTagsAttribute.cs @@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS public MetaTagsAttribute() { } public MetaTagsAttribute(string tags) { - _tags = tags.Split(_separatpor, StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries); + _tags = tags.Split(_separatpor, StringSplitOptions.RemoveEmptyEntries); //TODO добавить ручное StringSplitOptions.TrimEntries for (int i = 0; i < _tags.Length; i++) { _tags[i] = string.Intern(_tags[i]); diff --git a/src/Debug/TypeMeta.cs.meta b/src/Debug/TypeMeta.cs.meta new file mode 100644 index 0000000..780cc1d --- /dev/null +++ b/src/Debug/TypeMeta.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4f969a5755aec72419e45d175d1d46b9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: