mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2026-04-21 17:35:56 +08:00
rework namespaces/remove IEcsTypeMetaProvider
This commit is contained in:
parent
371472e851
commit
23cee3e4c7
@ -1,7 +1,7 @@
|
|||||||
#if DISABLE_DEBUG
|
#if DISABLE_DEBUG
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
using DCFApixels.DragonECS.Core;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
|||||||
@ -1,7 +1,6 @@
|
|||||||
#if DISABLE_DEBUG
|
#if DISABLE_DEBUG
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.RunnersCore;
|
|
||||||
using System;
|
using System;
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
|
|||||||
@ -1,6 +1,4 @@
|
|||||||
using System;
|
namespace DCFApixels.DragonECS
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
{
|
||||||
public static class EcsConsts
|
public static class EcsConsts
|
||||||
{
|
{
|
||||||
|
|||||||
@ -285,7 +285,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static TypeMeta GetTypeMeta(object obj)
|
public static TypeMeta GetTypeMeta(object obj)
|
||||||
{
|
{
|
||||||
if (obj == null) { return TypeMeta.NullTypeMeta; }
|
if (obj == null) { return TypeMeta.NullTypeMeta; }
|
||||||
return TypeMeta.Get(Type.GetTypeHandle(GetTypeMetaSource(obj)));
|
return TypeMeta.Get(Type.GetTypeHandle(obj));
|
||||||
}
|
}
|
||||||
public static TypeMeta GetTypeMeta<T>()
|
public static TypeMeta GetTypeMeta<T>()
|
||||||
{
|
{
|
||||||
@ -300,17 +300,6 @@ namespace DCFApixels.DragonECS
|
|||||||
return TypeMeta.Get(typeHandle);
|
return TypeMeta.Get(typeHandle);
|
||||||
}
|
}
|
||||||
#endregion
|
#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
|
public static class TypeMetaDataCachedExtensions
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 50bc53c3762bf6b4ea127004a89a894e
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -1,7 +0,0 @@
|
|||||||
namespace DCFApixels.DragonECS
|
|
||||||
{
|
|
||||||
public interface IEcsTypeMetaProvider
|
|
||||||
{
|
|
||||||
object MetaSource { get; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -5,7 +5,7 @@ using System;
|
|||||||
|
|
||||||
namespace DCFApixels.DragonECS.Core
|
namespace DCFApixels.DragonECS.Core
|
||||||
{
|
{
|
||||||
public abstract class EcsMetaAttribute : Attribute { }
|
public abstract class DragonMetaAttribute : Attribute { }
|
||||||
|
|
||||||
internal static class EcsMetaAttributeHalper
|
internal static class EcsMetaAttributeHalper
|
||||||
{
|
{
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: eb8cc656a6e80f843b8794af9f63faa8
|
guid: fd6afd87df377e5408428ccec3c02685
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -23,7 +23,7 @@ namespace DCFApixels.DragonECS
|
|||||||
#endregion
|
#endregion
|
||||||
}
|
}
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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;
|
public readonly MetaColor color;
|
||||||
|
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using System;
|
|||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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 readonly MetaDescription Data;
|
||||||
public MetaDescriptionAttribute(string text)
|
public MetaDescriptionAttribute(string text)
|
||||||
|
|||||||
@ -10,7 +10,7 @@ using System.Text.RegularExpressions;
|
|||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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 const char SEPARATOR = MetaGroup.SEPARATOR;
|
||||||
public readonly string Name = string.Empty;
|
public readonly string Name = string.Empty;
|
||||||
|
|||||||
@ -14,7 +14,7 @@ using System.Text.RegularExpressions;
|
|||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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 readonly string ID;
|
||||||
public MetaIDAttribute(string id)
|
public MetaIDAttribute(string id)
|
||||||
|
|||||||
@ -7,7 +7,7 @@ using System;
|
|||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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 string name;
|
||||||
public readonly bool isHideGeneric;
|
public readonly bool isHideGeneric;
|
||||||
|
|||||||
34
src/DebugUtils/MetaAttributes/MetaProxyAttribute.cs
Normal file
34
src/DebugUtils/MetaAttributes/MetaProxyAttribute.cs
Normal 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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -1,5 +1,5 @@
|
|||||||
fileFormatVersion: 2
|
fileFormatVersion: 2
|
||||||
guid: 4a642dc8905124247bf83c9d13d8fb13
|
guid: 2ce533d3befbc0f4fb16b68a1bcce552
|
||||||
MonoImporter:
|
MonoImporter:
|
||||||
externalObjects: {}
|
externalObjects: {}
|
||||||
serializedVersion: 2
|
serializedVersion: 2
|
||||||
@ -8,7 +8,7 @@ using System.Collections.Generic;
|
|||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
[AttributeUsage(AttributeTargets.Struct | AttributeTargets.Class | AttributeTargets.Interface, Inherited = false, AllowMultiple = false)]
|
[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 = ',';
|
public const char SEPARATOR = ',';
|
||||||
private readonly string[] _tags = Array.Empty<string>();
|
private readonly string[] _tags = Array.Empty<string>();
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
@ -441,7 +440,7 @@ namespace DCFApixels.DragonECS
|
|||||||
public static bool IsHasCustomMeta(Type type)
|
public static bool IsHasCustomMeta(Type type)
|
||||||
{
|
{
|
||||||
#if DEBUG || !REFLECTION_DISABLED
|
#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
|
#else
|
||||||
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMeta)} method does not work.");
|
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMeta)} method does not work.");
|
||||||
return false;
|
return false;
|
||||||
@ -681,28 +680,4 @@ namespace DCFApixels.DragonECS
|
|||||||
}
|
}
|
||||||
#endregion
|
#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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.RunnersCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#if DISABLE_DEBUG
|
#if DISABLE_DEBUG
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.RunnersCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#if DISABLE_DEBUG
|
#if DISABLE_DEBUG
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.RunnersCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
@ -17,7 +17,7 @@ namespace DCFApixels.DragonECS
|
|||||||
[MetaID("DragonECS_EF8A557C9201E6F04D4A76DC670BDE19")]
|
[MetaID("DragonECS_EF8A557C9201E6F04D4A76DC670BDE19")]
|
||||||
public interface IEcsProcess : IEcsMember { }
|
public interface IEcsProcess : IEcsMember { }
|
||||||
|
|
||||||
namespace RunnersCore
|
namespace Core
|
||||||
{
|
{
|
||||||
//добавить инъекцию в раннеры
|
//добавить инъекцию в раннеры
|
||||||
public abstract class EcsRunner
|
public abstract class EcsRunner
|
||||||
|
|||||||
@ -2,7 +2,6 @@
|
|||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
|
|
||||||
namespace DCFApixels.DragonECS
|
namespace DCFApixels.DragonECS
|
||||||
{
|
{
|
||||||
|
|||||||
@ -4,7 +4,6 @@
|
|||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.Core.Unchecked;
|
using DCFApixels.DragonECS.Core.Unchecked;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
#if DISABLE_DEBUG
|
#if DISABLE_DEBUG
|
||||||
#undef DEBUG
|
#undef DEBUG
|
||||||
#endif
|
#endif
|
||||||
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.CompilerServices;
|
using System.Runtime.CompilerServices;
|
||||||
|
|||||||
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: f5d8c72b3decc2b488a616932366ff0f
|
|
||||||
folderAsset: yes
|
|
||||||
DefaultImporter:
|
|
||||||
externalObjects: {}
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
||||||
@ -389,253 +389,4 @@ namespace DCFApixels.DragonECS.Core.Internal
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#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);
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@ -8,13 +8,12 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Runtime.CompilerServices;
|
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>
|
/// <summary> Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>. </summary>
|
||||||
public interface IEcsPoolImplementation : IEcsPool
|
public interface IEcsPoolImplementation : IEcsPool
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
@ -3,7 +3,6 @@
|
|||||||
#endif
|
#endif
|
||||||
using DCFApixels.DragonECS.Core;
|
using DCFApixels.DragonECS.Core;
|
||||||
using DCFApixels.DragonECS.Core.Internal;
|
using DCFApixels.DragonECS.Core.Internal;
|
||||||
using DCFApixels.DragonECS.PoolsCore;
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user