rework namespaces/remove IEcsTypeMetaProvider

This commit is contained in:
Mikhail 2026-04-14 12:52:18 +08:00
parent 371472e851
commit 23cee3e4c7
32 changed files with 53 additions and 338 deletions

View File

@ -1,7 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.PoolsCore;
using DCFApixels.DragonECS.Core;
namespace DCFApixels.DragonECS
{

View File

@ -1,7 +1,6 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.RunnersCore;
using System;
namespace DCFApixels.DragonECS

View File

@ -1,6 +1,4 @@
using System;
namespace DCFApixels.DragonECS
namespace DCFApixels.DragonECS
{
public static class EcsConsts
{

View File

@ -285,7 +285,7 @@ namespace DCFApixels.DragonECS
public static TypeMeta GetTypeMeta(object obj)
{
if (obj == null) { return TypeMeta.NullTypeMeta; }
return TypeMeta.Get(Type.GetTypeHandle(GetTypeMetaSource(obj)));
return TypeMeta.Get(Type.GetTypeHandle(obj));
}
public static TypeMeta GetTypeMeta<T>()
{
@ -300,17 +300,6 @@ namespace DCFApixels.DragonECS
return TypeMeta.Get(typeHandle);
}
#endregion
#region TypeMetaProvider
public static bool IsTypeMetaProvided(object obj)
{
return obj is IEcsTypeMetaProvider;
}
public static object GetTypeMetaSource(object obj)
{
return obj is IEcsTypeMetaProvider intr ? intr.MetaSource : obj;
}
#endregion
}
public static class TypeMetaDataCachedExtensions

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: 50bc53c3762bf6b4ea127004a89a894e
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -1,7 +0,0 @@
namespace DCFApixels.DragonECS
{
public interface IEcsTypeMetaProvider
{
object MetaSource { get; }
}
}

View File

@ -5,7 +5,7 @@ using System;
namespace DCFApixels.DragonECS.Core
{
public abstract class EcsMetaAttribute : Attribute { }
public abstract class DragonMetaAttribute : Attribute { }
internal static class EcsMetaAttributeHalper
{

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: eb8cc656a6e80f843b8794af9f63faa8
guid: fd6afd87df377e5408428ccec3c02685
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -23,7 +23,7 @@ namespace DCFApixels.DragonECS
#endregion
}
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaColorAttribute : EcsMetaAttribute, IMetaColor
public sealed class MetaColorAttribute : DragonMetaAttribute, IMetaColor
{
public readonly MetaColor color;

View File

@ -7,7 +7,7 @@ using System;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaDescriptionAttribute : EcsMetaAttribute
public sealed class MetaDescriptionAttribute : DragonMetaAttribute
{
public readonly MetaDescription Data;
public MetaDescriptionAttribute(string text)

View File

@ -10,7 +10,7 @@ using System.Text.RegularExpressions;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaGroupAttribute : EcsMetaAttribute
public sealed class MetaGroupAttribute : DragonMetaAttribute
{
public const char SEPARATOR = MetaGroup.SEPARATOR;
public readonly string Name = string.Empty;

View File

@ -14,7 +14,7 @@ using System.Text.RegularExpressions;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaIDAttribute : EcsMetaAttribute
public sealed class MetaIDAttribute : DragonMetaAttribute
{
public readonly string ID;
public MetaIDAttribute(string id)

View File

@ -7,7 +7,7 @@ using System;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaNameAttribute : EcsMetaAttribute
public sealed class MetaNameAttribute : DragonMetaAttribute
{
public readonly string name;
public readonly bool isHideGeneric;

View File

@ -0,0 +1,34 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using System;
using System.Collections.Generic;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class MetaProxyAttribute : DragonMetaAttribute
{
public Type Type;
public MetaProxyAttribute(Type type)
{
Type = type;
}
}
public class MetaProxy
{
public static readonly MetaProxy EmptyProxy = new MetaProxy(typeof(void));
public static TypeMeta EmptyMeta => TypeMeta.NullTypeMeta;
public readonly Type Type;
public virtual string Name { get { return null; } }
public virtual MetaColor? Color { get { return null; } }
public virtual MetaDescription Description { get { return null; } }
public virtual MetaGroup Group { get { return null; } }
public virtual IEnumerable<string> Tags { get { return null; } }
public MetaProxy(Type type)
{
Type = type;
}
}
}

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 4a642dc8905124247bf83c9d13d8fb13
guid: 2ce533d3befbc0f4fb16b68a1bcce552
MonoImporter:
externalObjects: {}
serializedVersion: 2

View File

@ -8,7 +8,7 @@ using System.Collections.Generic;
namespace DCFApixels.DragonECS
{
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
public sealed class MetaTagsAttribute : EcsMetaAttribute
public sealed class MetaTagsAttribute : DragonMetaAttribute
{
public const char SEPARATOR = ',';
private readonly string[] _tags = Array.Empty<string>();

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
@ -441,7 +440,7 @@ namespace DCFApixels.DragonECS
public static bool IsHasCustomMeta(Type type)
{
#if DEBUG || !REFLECTION_DISABLED
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(EcsMetaAttribute), false).Length > 0;
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(DragonMetaAttribute), false).Length > 0;
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMeta)} method does not work.");
return false;
@ -681,28 +680,4 @@ namespace DCFApixels.DragonECS
}
#endregion
}
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct, AllowMultiple = false, Inherited = true)]
public sealed class MetaProxyAttribute : EcsMetaAttribute
{
public Type Type;
public MetaProxyAttribute(Type type)
{
Type = type;
}
}
public class MetaProxy
{
public static readonly MetaProxy EmptyProxy = new MetaProxy(typeof(void));
public static TypeMeta EmptyMeta => TypeMeta.NullTypeMeta;
public readonly Type Type;
public virtual string Name { get { return null; } }
public virtual MetaColor? Color { get { return null; } }
public virtual MetaDescription Description { get { return null; } }
public virtual MetaGroup Group { get { return null; } }
public virtual IEnumerable<string> Tags { get { return null; } }
public MetaProxy(Type type)
{
Type = type;
}
}
}

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Collections.Generic;
using System.Runtime.CompilerServices;

View File

@ -1,8 +1,8 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Collections;
using System.Collections.Generic;

View File

@ -1,8 +1,8 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.RunnersCore;
using System;
using System.Linq;
using System.Runtime.CompilerServices;
@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS
[MetaID("DragonECS_EF8A557C9201E6F04D4A76DC670BDE19")]
public interface IEcsProcess : IEcsMember { }
namespace RunnersCore
namespace Core
{
//добавить инъекцию в раннеры
public abstract class EcsRunner

View File

@ -2,7 +2,6 @@
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.PoolsCore;
namespace DCFApixels.DragonECS
{

View File

@ -4,7 +4,6 @@
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.Core.Unchecked;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;

View File

@ -1,8 +1,8 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Linq;
using System.Runtime.CompilerServices;

View File

@ -1,8 +0,0 @@
fileFormatVersion: 2
guid: f5d8c72b3decc2b488a616932366ff0f
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -390,252 +390,3 @@ namespace DCFApixels.DragonECS.Core.Internal
}
#endregion
}
//namespace DCFApixels.DragonECS.Core.Internal
//{
// internal interface IStructComparer<T> : IComparer<T>
// {
// // a > b = return > 0
// // int Compare(T a, T b);
// }
//
//#if ENABLE_IL2CPP
// [Il2CppSetOption(Option.NullChecks, false)]
// [Il2CppSetOption(Option.ArrayBoundsChecks, false)]
//#endif
// internal static class ArraySortHalperX<T>
// {
// private const int IntrosortSizeThreshold = 16;
//
// #region IStructComparer
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void SwapIfGreater<TComparer>(T[] items, ref TComparer comparer, int i, int j) where TComparer : IStructComparer<T>
// {
// if (comparer.Compare(items[i], items[j]) > 0)
// {
// T key = items[i];
// items[i] = items[j];
// items[j] = key;
// }
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void InsertionSort<TComparer>(T[] items, ref TComparer comparer) where TComparer : IStructComparer<T>
// {
// for (int i = 0; i < items.Length - 1; i++)
// {
// T t = items[i + 1];
//
// int j = i;
// while (j >= 0 && comparer.Compare(t, items[j]) < 0)
// {
// items[j + 1] = items[j];
// j--;
// }
//
// items[j + 1] = t;
// }
// }
//
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void Sort<TComparer>(T[] items, ref TComparer comparer) where TComparer : IStructComparer<T>
// {
// int length = items.Length;
// if (length == 1)
// {
// return;
// }
//
// if (length <= IntrosortSizeThreshold)
// {
//
// if (length == 2)
// {
// SwapIfGreater(items, ref comparer, 0, 1);
// return;
// }
//
// if (length == 3)
// {
// SwapIfGreater(items, ref comparer, 0, 1);
// SwapIfGreater(items, ref comparer, 0, 2);
// SwapIfGreater(items, ref comparer, 1, 2);
// return;
// }
//
// InsertionSort(items, ref comparer);
// return;
// }
//
// IStructComparer<T> packed = comparer;
// Array.Sort(items, 0, items.Length, packed);
// comparer = (TComparer)packed;
// }
// #endregion
//
// #region Comparison
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void SwapIfGreater(T[] items, Comparison<T> comparison, int i, int j)
// {
// if (comparison(items[i], items[j]) > 0)
// {
// T key = items[i];
// items[i] = items[j];
// items[j] = key;
// }
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void InsertionSort(T[] items, int length, Comparison<T> comparison)
// {
// for (int i = 0; i < length - 1; i++)
// {
// T t = items[i + 1];
//
// int j = i;
// while (j >= 0 && comparison(t, items[j]) < 0)
// {
// items[j + 1] = items[j];
// j--;
// }
//
// items[j + 1] = t;
// }
// }
//
//#if ENABLE_IL2CPP
// [Il2CppSetOption(Option.NullChecks, false)]
// [Il2CppSetOption(Option.ArrayBoundsChecks, false)]
//#endif
// private class ComparisonHach : IComparer<T>
// {
// public static readonly ComparisonHach Instance = new ComparisonHach();
// public Comparison<T> comparison;
// private ComparisonHach() { }
// public int Compare(T x, T y) { return comparison(x, y); }
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void Sort(T[] items, Comparison<T> comparison)
// {
// Sort(items, comparison, items.Length);
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void Sort(T[] items, Comparison<T> comparison, int length)
// {
// if (length <= IntrosortSizeThreshold)
// {
// if (length == 1)
// {
// return;
// }
// if (length == 2)
// {
// SwapIfGreater(items, comparison, 0, 1);
// return;
// }
// if (length == 3)
// {
// SwapIfGreater(items, comparison, 0, 1);
// SwapIfGreater(items, comparison, 0, 2);
// SwapIfGreater(items, comparison, 1, 2);
// return;
// }
// InsertionSort(items, length, comparison);
// return;
// }
// ComparisonHach.Instance.comparison = comparison;
// Array.Sort(items, 0, length, ComparisonHach.Instance);
// }
// #endregion
// }
//
//#if ENABLE_IL2CPP
// [Il2CppSetOption(Option.NullChecks, false)]
// [Il2CppSetOption(Option.ArrayBoundsChecks, false)]
//#endif
// internal static unsafe class UnsafeArraySortHalperX<T> where T : unmanaged
// {
// private const int IntrosortSizeThreshold = 16;
//
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void SwapIfGreater<TComparer>(T* items, ref TComparer comparer, int i, int j) where TComparer : IStructComparer<T>
// {
// if (comparer.Compare(items[i], items[j]) > 0)
// {
// T key = items[i];
// items[i] = items[j];
// items[j] = key;
// }
// }
// [MethodImpl(MethodImplOptions.AggressiveInlining)]
// public static void InsertionSort_Unchecked<TComparer>(T* items, int length, ref TComparer comparer) where TComparer : IStructComparer<T>
// {
// for (int i = 0; i < length - 1; i++)
// {
// T t = items[i + 1];
//
// int j = i;
// while (j >= 0 && comparer.Compare(t, items[j]) < 0)
// {
// items[j + 1] = items[j];
// j--;
// }
//
// items[j + 1] = t;
// }
// }
// public static void InsertionSort<TComparer>(T* items, int length, ref TComparer comparer) where TComparer : IStructComparer<T>
// {
// if (length == 1)
// {
// return;
// }
//
// if (length == 2)
// {
// SwapIfGreater(items, ref comparer, 0, 1);
// return;
// }
//
// if (length == 3)
// {
// SwapIfGreater(items, ref comparer, 0, 1);
// SwapIfGreater(items, ref comparer, 0, 2);
// SwapIfGreater(items, ref comparer, 1, 2);
// return;
// }
//
// InsertionSort_Unchecked(items, length, ref comparer);
// }
// }
//}

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;

View File

@ -8,13 +8,12 @@
#endif
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Runtime.CompilerServices;
namespace DCFApixels.DragonECS.PoolsCore
namespace DCFApixels.DragonECS.Core
{
/// <summary> Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>. </summary>
public interface IEcsPoolImplementation : IEcsPool

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;

View File

@ -3,7 +3,6 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;