Compare commits

..

No commits in common. "main" and "0.9.22" have entirely different histories.
main ... 0.9.22

43 changed files with 400 additions and 460 deletions

View File

@ -10,7 +10,7 @@
<RootNamespace>DCFApixels.DragonECS</RootNamespace>
<Title>DragonECS</Title>
<Version>1.0.1</Version>
<Version>0.9.22</Version>
<Authors>DCFApixels</Authors>
<Description>ECS Framework for Game Engines with C# and .Net Platform</Description>
<Copyright>DCFApixels</Copyright>

View File

@ -41,8 +41,10 @@
DragonECS - это [ECS](https://en.wikipedia.org/wiki/Entity_component_system) фреймворк, нацеленный на максимальную удобность, модульность, расширяемость и производительность динамического изменения сущностей. Разработан на чистом C#, без зависимостей и генерации кода. Вдохновлен [LeoEcs Lite](https://github.com/Leopotam/ecslite).
> [!Note]
> Есть вопросы или хотите быть в курсе разработки? Присоединяйтесь к нашему комьюнити! -> [Обратная связь](#обратная-связь)
> [!WARNING]
> Проект предрелизной версии, поэтому API может меняться. В ветке main актуальная и рабочая версия.
>
> Если есть неясные моменты, вопросы можно задать тут [Обратная связь](#обратная-связь)
## Оглавление
- [Установка](#установка)
@ -73,7 +75,7 @@ DragonECS - это [ECS](https://en.wikipedia.org/wiki/Entity_component_system)
- [Расширение фреймворка](#расширение-фреймворка)
- [Компоненты мира](#компоненты-мира)
- [Конфиги](#конфиги)
- [Проекты на DragonECS](#проекты-на-dragonecs)
- [Проекты на DragonECS](#Проекты-на-DragonECS)
- [FAQ](#faq)
- [Обратная связь](#обратная-связь)
- [Лицензия](#лицензия)
@ -348,13 +350,10 @@ EcsPipeline pipeline = EcsPipeline.New()
Слой определяет место в пайплайне для вставки систем. Например, если необходимо чтобы система была вставлена в конце пайплайна, эту систему можно добавить в слой `EcsConsts.END_LAYER`.
```c#
const string SOME_LAYER = nameof(SOME_LAYER);
const string SOME_LAYER_2 = nameof(SOME_LAYER_2);
EcsPipeline pipeline = EcsPipeline.New()
// ...
// Вставляет новый слой перед конечным слоем EcsConsts.END_LAYER
.Layers.Add(SOME_LAYER).Before(EcsConsts.END_LAYER)
// Вставляет SOME_LAYER_2 слой в позицию после EcsConsts.BASIC_LAYER
.Layers.Add(SOME_LAYER).After(EcsConsts.BASIC_LAYER)
.Layers.Insert(EcsConsts.END_LAYER, SOME_LAYER)
// Система SomeSystem будет вставлена в слой SOME_LAYER
.Add(New SomeSystem(), SOME_LAYER)
// ...
@ -913,40 +912,6 @@ var tags = typeMeta.Tags; // [MetaTags]
```
> Для автоматической генерации уникальных идентификаторов MetaID есть метод `MetaID.GenerateNewUniqueID()` и [Браузерный генератор](https://dcfapixels.github.io/DragonECS-MetaID_Generator_Online/)
<details>
<summary>[MetaProxy]</summary>
`[MetaProxy(typeof(MetaProxyType))]` атрибут для гибкой настройки метаданных. Он позволяет обходить ограничения обычных атрибутов (например, невозможность передавать в них неконстантные данные) и задавать метаданные программно. Кроме того, метаданные, полученные через `MetaProxy`, наследуются.
API напоминает `[DebuggerTypeProxy]`, но вместо экземпляра объекта принимает тип `Type`. А класс для `MetaProxy` должен наследовать `MetaProxyBase`.
Пример использования:
``` c#
// Применение атрибута
[MetaProxy(typeof(UnityComponent<>.MetaProxy))]
// В данном примере UnityComponent оборачивает компонент Unity
public struct UnityComponent<T> where T : Component
{
// ...
// Реализация MetaProxyBase. MetaProxy копирует метаданные оборачиваемого типа,
// чтобы в инспекторе Unity отображалась его мета.
private class MetaProxy : MetaProxyBase
{
protected TypeMeta Meta = typeof(T).GetMeta();
public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta != null && Meta.IsCustomColor ? Meta.Color : null; } }
public override MetaGroup Group { get { return Meta?.Group; } }
public override MetaDescription Description { get { return Meta?.Description; } }
public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public MetaProxy(Type type) : base(type) { }
}
}
```
</details>
## EcsDebug
Вспомогательный тип с набором методов для отладки и логирования. Реализован как статический класс вызывающий методы Debug-сервисов. Debug-сервисы - это посредники между EcsDebug и инструментами отладки среды. Такая реализация позволяет не изменяя отладочный код, менять его поведение или переносить проект в другие среды, достаточно только реализовать соответствующий Debug-сервис.
@ -1010,7 +975,7 @@ using (_marker.Auto())
var configs = new ConfigContainer()
.Set(new EcsWorldConfig(entitiesCapacity: 2000, poolsCapacity: 2000)
.Set(new SomeDataA(/* ... */))
.Set(new SomeDataB(/* ... */));
.Set(new SomeDataB(/* ... */)));
EcsDefaultWorld _world = new EcsDefaultWorld(configs);
// ...
var _someDataA = _world.Configs.Get<SomeDataA>();

View File

@ -43,8 +43,12 @@
DragonECS 是一个[实体组件系统](https://www.imooc.com/article/331544)框架。专注于提升便利性、模块性、可扩展性和动态实体修改性能。 用纯C#开发的,没有依赖和代码生成。灵感来自于[LeoEcs Lite](https://github.com/Leopotam/ecslite)。
> [!Note]
> 有疑问或想了解开发进度?欢迎加入我们的社区! -> [Feedback](#Feedback)
> [!WARNING]
> 该框架是预发布版本,因此 API 可能会有变化。在 `main` 分支中是当前的工作版本。
>
> 最新版本的 README 是[俄文版](https://github.com/DCFApixels/DragonECS/blob/main/README-RU.md)。
>
> 如果有不清楚的地方,可以在这里提问 [反馈](#反馈)。
## 目录
- [安装](#安装)
@ -68,7 +72,7 @@ DragonECS 是一个[实体组件系统](https://www.imooc.com/article/331544)框
- [集合](#集合)
- [ECS入口](#ECS入口)
- [Debug](#debug)
- [Meta Attributes](#meta-attributes)
- [元属性](#元属性)
- [EcsDebug](#ecsdebug)
- [性能分析](#性能分析)
- [Define Symbols](#define-symbols)
@ -308,9 +312,7 @@ const string SOME_LAYER = nameof(SOME_LAYER);
EcsPipeline pipeline = EcsPipeline.New()
// ...
// 在最终的 EcsConsts.END_LAYER 层前面插入一个新 SOME_LAYER 层。
.Layers.Add(SOME_LAYER).Before(EcsConsts.END_LAYER)
// 将 SOME_LAYER_2 层级入到 EcsConsts.BASIC_LAYER 之后的位置
.Layers.Add(SOME_LAYER).After(EcsConsts.BASIC_LAYER)
.Layers.Insert(EcsConsts.END_LAYER, SOME_LAYER)
// SomeSystem 系统将插入 SAME_LAYER 层。
.Add(New SomeSystem(), SOME_LAYER)
// ...
@ -796,7 +798,7 @@ public class EcsRoot
# Debug
该框架提供了额外的调试和日志记录工具,不依赖于环境此外,许多类型都有自己的 DebuggerProxy以便在 IDE 中更详细地显示信息。
## Meta Attributes
## 元属性
默认情况下,元属性没有用处,在与引擎集成时用于指定在调试工具和编辑器中的显示方式。还可以用于生成自动文档。
``` c#
using DCFApixels.DragonECS;
@ -835,40 +837,6 @@ var tags = typeMeta.Tags; // [MetaTags]
```
> 为了自动生成唯一的标识符 MetaID可以使用 `MetaID.GenerateNewUniqueID()` 方法和 [浏览器生成器](https://dcfapixels.github.io/DragonECS-MetaID_Generator_Online/)。
<details>
<summary>MetaProxy</summary>
`[MetaProxy(typeof(MetaProxyType))]` 特性用于灵活配置元数据。它允许绕过常规特性的限制(例如无法向其传递非常量数据),并以编程方式设置元数据。此外,通过 `MetaProxy` 获得的元数据是可继承的。
该 API 类似于 `[DebuggerTypeProxy]`,但不同之处在于它接受的是 `Type` 类型,而不是对象实例。`MetaProxy` 的类必须继承自 `MetaProxyBase`
使用示例:
``` c#
// 应用特性
[MetaProxy(typeof(UnityComponent<>.MetaProxy))]
// 在此示例中UnityComponent 包装了一个 Unity 组件
public struct UnityComponent<T> where T : Component
{
// ...
// MetaProxyBase 的实现。MetaProxy 复制被包装类型的元数据,
// 以便在 Unity 检查器中显示其元数据。
private class MetaProxy : MetaProxyBase
{
protected TypeMeta Meta = typeof(T).GetMeta();
public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta != null && Meta.IsCustomColor ? Meta.Color : null; } }
public override MetaGroup Group { get { return Meta?.Group; } }
public override MetaDescription Description { get { return Meta?.Description; } }
public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public MetaProxy(Type type) : base(type) { }
}
}
```
</details>
## EcsDebug
具有调试和日志记录方法集. 实现为一个静态类,调用 DebugService 的方法. DebugService 是环境调试系统与 EcsDebug 之间的中介. 这使得可以将项目移植到其他引擎上,而无需修改项目的调试代码,只需要实现特定的 DebugService 即可。

View File

@ -43,8 +43,12 @@
The [ECS](https://en.wikipedia.org/wiki/Entity_component_system) Framework aims to maximize usability, modularity, extensibility and performance for dynamic entity changes, without code generation or external dependencies. Inspired by [LeoEcs Lite](https://github.com/Leopotam/ecslite).
> [!Note]
> Have questions or want to stay updated on development? Join our community! -> [Feedback](#Feedback)
> [!WARNING]
> The project is a work in progress; the API may change.
>
> The most current version of the README is in [Russian version](https://github.com/DCFApixels/DragonECS/blob/main/README-RU.md).
>
> If there are unclear points, you can ask questions here [Feedback](#Feedback)
## Table of Contents
- [Installation](#installation)
@ -305,9 +309,7 @@ const string SOME_LAYER = nameof(SOME_LAYER);
EcsPipeline pipeline = EcsPipeline.New()
// ...
// Inserts a new layer before the end layer EcsConsts.END_LAYER
.Layers.Add(SOME_LAYER).Before(EcsConsts.END_LAYER)
// Inserts SOME_LAYER_2 layer at the position after EcsConsts.BASIC_LAYER
.Layers.Add(SOME_LAYER).After(EcsConsts.BASIC_LAYER)
.Layers.Insert(EcsConsts.END_LAYER, SOME_LAYER)
// System SomeSystem will be added to the SOME_LAYER layer
.Add(new SomeSystem(), SOME_LAYER)
// ...
@ -869,41 +871,6 @@ var tags = typeMeta.Tags; // [MetaTags]
```
> To simplify generate unique MetaID values, use `MetaID.GenerateNewUniqueID()` or the [Browser Generator](https://dcfapixels.github.io/DragonECS-MetaID_Generator_Online/).
<details>
<summary>[MetaProxy]</summary>
The `[MetaProxy(typeof(MetaProxyType))]` attribute enables flexible metadata configuration. It allows bypassing the limitations of regular attributes (for example, the inability to pass non-constant data into them) and setting metadata programmatically. Furthermore, metadata obtained via `MetaProxy` is inherited.
The API resembles `[DebuggerTypeProxy]`, but instead of an object instance, it accepts a Type. The class for `MetaProxy` must inherit from `MetaProxyBase`.
Usage example:
``` c#
// Applying the attribute
[MetaProxy(typeof(UnityComponent<>.MetaProxy))]
// In this example, UnityComponent wraps a Unity component
public struct UnityComponent<T> where T : Component
{
// ...
// Implementation of MetaProxyBase. MetaProxy copies the metadata of the wrapped type
// so that its metadata is displayed in the Unity inspector.
private class MetaProxy : MetaProxyBase
{
protected TypeMeta Meta = typeof(T).GetMeta();
public override string Name { get { return Meta?.Name; } }
public override MetaColor? Color { get { return Meta != null && Meta.IsCustomColor ? Meta.Color : null; } }
public override MetaGroup Group { get { return Meta?.Group; } }
public override MetaDescription Description { get { return Meta?.Description; } }
public override IEnumerable<string> Tags { get { return Meta?.Tags; } }
public MetaProxy(Type type) : base(type) { }
}
}
```
</details>
## EcsDebug
Provides methods for debugging and logging. Implemented as a static class that forwards calls to a Debug service. Debug services act as intermediaries between environment-specific debugging systems and EcsDebug, enabling portability.

View File

@ -7,8 +7,8 @@
},
"displayName": "DragonECS",
"description": "C# Entity Component System Framework",
"unity": "2021.2",
"version": "1.0.1",
"unity": "2020.3",
"version": "0.9.22",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"

View File

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

View File

@ -1,6 +1,7 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
using DCFApixels.DragonECS.RunnersCore;
using System;
namespace DCFApixels.DragonECS
@ -59,6 +60,7 @@ namespace DCFApixels.DragonECS.Core.Internal
#endif
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_3273527C9201285BAA0A463F700A50FB")]
internal sealed class EcsPreInitRunner : EcsRunner<IEcsPreInit>, IEcsPreInit
@ -79,6 +81,7 @@ namespace DCFApixels.DragonECS.Core.Internal
#endif
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_ED85527C9201A391AB8EC0B734917859")]
internal sealed class EcsInitRunner : EcsRunner<IEcsInit>, IEcsInit
@ -99,6 +102,7 @@ namespace DCFApixels.DragonECS.Core.Internal
#endif
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_2098527C9201F260C840BFD50BC7E0BA")]
internal sealed class EcsRunRunner : EcsRunner<IEcsRun>, IEcsRun
@ -179,6 +183,7 @@ namespace DCFApixels.DragonECS.Core.Internal
#endif
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_06A6527C92010430ACEB3DA520F272CC")]
internal sealed class EcsDestroyRunner : EcsRunner<IEcsDestroy>, IEcsDestroy

View File

@ -1,4 +1,6 @@
namespace DCFApixels.DragonECS
using System;
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(obj));
return TypeMeta.Get(Type.GetTypeHandle(GetTypeMetaSource(obj)));
}
public static TypeMeta GetTypeMeta<T>()
{
@ -300,6 +300,17 @@ 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

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

View File

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

View File

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

View File

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

View File

@ -1,5 +1,5 @@
fileFormatVersion: 2
guid: 2ce533d3befbc0f4fb16b68a1bcce552
guid: eb8cc656a6e80f843b8794af9f63faa8
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 : DragonMetaAttribute, IMetaColor
public sealed class MetaColorAttribute : EcsMetaAttribute, 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 : DragonMetaAttribute
public sealed class MetaDescriptionAttribute : EcsMetaAttribute
{
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 : DragonMetaAttribute
public sealed class MetaGroupAttribute : EcsMetaAttribute
{
public const char SEPARATOR = MetaGroup.SEPARATOR;
public readonly string Name = string.Empty;
@ -73,10 +73,6 @@ namespace DCFApixels.DragonECS
}
return new MetaGroup(name);
}
public static MetaGroup FromName(params string[] path)
{
return FromName(string.Join(SEPARATOR, path));
}
public static MetaGroup FromNameSpace(Type type)
{
if (string.IsNullOrWhiteSpace(type.Namespace))

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 : DragonMetaAttribute
public sealed class MetaIDAttribute : EcsMetaAttribute
{
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 : DragonMetaAttribute
public sealed class MetaNameAttribute : EcsMetaAttribute
{
public readonly string name;
public readonly bool isHideGeneric;

View File

@ -1,31 +0,0 @@
#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 = false)]
public sealed class MetaProxyAttribute : DragonMetaAttribute
{
public Type Type;
public bool ForDeclaringType;
public MetaProxyAttribute(Type type, bool forDeclaringType = false)
{
Type = type;
ForDeclaringType = forDeclaringType;
}
}
public class MetaProxyBase
{
public static readonly MetaProxyBase EmptyProxy = new MetaProxyBase(typeof(void));
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 MetaProxyBase(Type type) { }
}
}

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 : DragonMetaAttribute
public sealed class MetaTagsAttribute : EcsMetaAttribute
{
public const char SEPARATOR = ',';
private readonly string[] _tags = Array.Empty<string>();

View File

@ -1,17 +1,15 @@
#if DISABLE_DEBUG
#undef DEBUG
#endif
#if DEBUG || !REFLECTION_DISABLED
#define REFLECTION_ENABLED
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
#if REFLECTION_ENABLED
#if DEBUG || !REFLECTION_DISABLED
using System.Reflection;
#endif
@ -53,8 +51,6 @@ namespace DCFApixels.DragonECS
private readonly int _uniqueID;
internal readonly Type _type;
private readonly MetaProxyBase _proxy;
private readonly bool _isSelfProxy;
private bool _isCustomName;
private bool _isCustomColor;
@ -97,7 +93,6 @@ namespace DCFApixels.DragonECS
_initFlags = InitFlag.All,
};
_metaCache.Add(typeof(void).TypeHandle, NullTypeMeta);
}
public static TypeMeta Get(Type type) { return Get(type.TypeHandle); }
@ -113,54 +108,12 @@ namespace DCFApixels.DragonECS
return result;
}
}
private static Type FindDeclaringType(Type targetPureType, Type currentType)
{
if (currentType == typeof(object)) { return null; }
var pure = currentType.GetPureType();
if (pure == targetPureType)
{
return currentType;
}
return FindDeclaringType(targetPureType, currentType.BaseType);
}
private TypeMeta(Type type)
{
_uniqueID = _increment++;
_type = type;
_proxy = MetaProxyBase.EmptyProxy;
if (type.TryGetAttributeInherited<MetaProxyAttribute>(out var proxyAtr, out var declaringAtrType))
{
#if REFLECTION_ENABLED
#pragma warning disable IL3050 // Calling members annotated with 'RequiresDynamicCodeAttribute' may break functionality when AOT compiling.
#pragma warning disable IL2055 // Either the type on which the MakeGenericType is called can't be statically determined, or the type parameters to be used for generic arguments can't be statically determined.
#pragma warning disable IL2077 // Target parameter argument does not satisfy 'DynamicallyAccessedMembersAttribute' in call to target method. The source field does not have matching annotations.
Type proxyType = proxyAtr.Type;
if (proxyType.ContainsGenericParameters && proxyType.IsNested)
{
if (declaringAtrType != null && declaringAtrType.ContainsGenericParameters == false)
{
var args = declaringAtrType.GetGenericArguments();
proxyType = proxyType.MakeGenericType(args);
}
}
if (proxyType.ContainsGenericParameters == false)
{
var proxy = Activator.CreateInstance(proxyType, proxyAtr.ForDeclaringType ? declaringAtrType : type) as MetaProxyBase;
if (proxy != null)
{
_proxy = proxy;
_isSelfProxy = declaringAtrType == type;
}
}
#pragma warning restore IL2055
#pragma warning restore IL3050
#pragma warning restore IL2077
#endif
}
}
#endregion
#endregion
#region Type
public Type Type
@ -174,7 +127,7 @@ namespace DCFApixels.DragonECS
{
if (_initFlags.HasFlag(InitFlag.Name) == false)
{
(_name, _isCustomName) = MetaGenerator.GetMetaName(this);
(_name, _isCustomName) = MetaGenerator.GetMetaName(_type);
_typeName = _isCustomName ? MetaGenerator.GetTypeName(_type) : _name;
_initFlags |= InitFlag.Name;
}
@ -239,7 +192,7 @@ namespace DCFApixels.DragonECS
{
if (_initFlags.HasFlag(InitFlag.Description) == false)
{
_description = MetaGenerator.GetDescription(this);
_description = MetaGenerator.GetDescription(_type);
_initFlags |= InitFlag.Description;
}
return _description;
@ -254,7 +207,7 @@ namespace DCFApixels.DragonECS
{
if (_initFlags.HasFlag(InitFlag.Group) == false)
{
_group = MetaGenerator.GetGroup(this);
_group = MetaGenerator.GetGroup(_type);
_initFlags |= InitFlag.Group;
}
return _group;
@ -267,7 +220,7 @@ namespace DCFApixels.DragonECS
{
if (_initFlags.HasFlag(InitFlag.Tags) == false)
{
_tags = MetaGenerator.GetTags(this);
_tags = MetaGenerator.GetTags(_type);
_initFlags |= InitFlag.Tags;
_isHidden = _tags.Contains(MetaTags.HIDDEN);
_isObsolete = _tags.Contains(MetaTags.OBSOLETE);
@ -432,7 +385,7 @@ namespace DCFApixels.DragonECS
}
private static bool CheckEcsMemener(Type checkedType)
{
#if REFLECTION_ENABLED
#if DEBUG || !REFLECTION_DISABLED
return checkedType.IsInterface == false && checkedType.IsAbstract == false && typeof(IEcsMember).IsAssignableFrom(checkedType);
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(CheckEcsMemener)} method does not work.");
@ -451,16 +404,16 @@ namespace DCFApixels.DragonECS
}
public static bool IsHasCustomMeta(Type type)
{
#if REFLECTION_ENABLED
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(DragonMetaAttribute), false).Length > 0;
#if DEBUG || !REFLECTION_DISABLED
return CheckEcsMemener(type) || Attribute.GetCustomAttributes(type, typeof(EcsMetaAttribute), false).Length > 0;
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasCustomMeta)} method does not work.");
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMeta)} method does not work.");
return false;
#endif
}
public static bool IsHasMetaID(Type type)
{
#if REFLECTION_ENABLED
#if DEBUG || !REFLECTION_DISABLED
return TryGetCustomMeta(type, out TypeMeta meta) && meta.IsHasMetaID();
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(TypeMeta)}.{nameof(IsHasMetaID)} method does not work.");
@ -527,20 +480,15 @@ namespace DCFApixels.DragonECS
{
return EcsDebugUtility.GetGenericTypeName(type, GENERIC_NAME_DEPTH);
}
public static (string, bool) GetMetaName(TypeMeta meta)
public static (string, bool) GetMetaName(Type type)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (meta._isSelfProxy && meta._proxy.Name != null)
{
return (meta._proxy.Name, true);
}
var type = meta.Type;
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = type.TryGetAttribute(out MetaNameAttribute atr) && string.IsNullOrEmpty(atr.name) == false;
if (isCustom)
{
if ((type.IsGenericType && atr.isHideGeneric == false) == false)
{
return (atr.name, true);
return (atr.name, isCustom);
}
string genericParams = "";
Type[] typeParameters = type.GetGenericArguments();
@ -549,16 +497,12 @@ namespace DCFApixels.DragonECS
string paramTypeName = EcsDebugUtility.GetGenericTypeName(typeParameters[i], GENERIC_NAME_DEPTH);
genericParams += (i == 0 ? paramTypeName : $", {paramTypeName}");
}
return ($"{atr.name}<{genericParams}>", true);
return ($"{atr.name}<{genericParams}>", isCustom);
}
if (meta._proxy.Name != null)
{
return (meta._proxy.Name, true);
}
return (EcsDebugUtility.GetGenericTypeName(type, GENERIC_NAME_DEPTH), false);
return (EcsDebugUtility.GetGenericTypeName(type, GENERIC_NAME_DEPTH), isCustom);
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetMetaName)} method does not work.");
return (meta.Type.Name, false);
return (type.Name, false);
#endif
}
#endregion
@ -579,21 +523,9 @@ namespace DCFApixels.DragonECS
}
public static (MetaColor, bool) GetColor(TypeMeta meta)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (meta._isSelfProxy && meta._proxy.Color != null)
{
return (meta._proxy.Color.Value, true);
}
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = meta.Type.TryGetAttribute(out MetaColorAttribute atr);
if (isCustom)
{
return (atr.color, true);
}
if (meta._proxy.Color != null)
{
return (meta._proxy.Color.Value, true);
}
return (AutoColor(meta), false);
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);
@ -602,22 +534,17 @@ namespace DCFApixels.DragonECS
#endregion
#region GetGroup
public static MetaGroup GetGroup(TypeMeta meta)
public static MetaGroup GetGroup(Type type)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (meta._isSelfProxy && meta._proxy.Group != null)
{
return meta._proxy.Group;
}
if (meta.Type.TryGetAttribute(out MetaGroupAttribute atr))
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (type.TryGetAttribute(out MetaGroupAttribute atr))
{
return MetaGroup.FromName(atr.Name);
}
if (meta._proxy.Group != null)
else
{
return meta._proxy.Group;
return MetaGroup.FromNameSpace(type);
}
return MetaGroup.FromNameSpace(meta.Type);
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetGroup)} method does not work.");
return MetaGroup.Empty;
@ -626,22 +553,11 @@ namespace DCFApixels.DragonECS
#endregion
#region GetDescription
public static MetaDescription GetDescription(TypeMeta meta)
public static MetaDescription GetDescription(Type type)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (meta._isSelfProxy && meta._proxy.Description != null)
{
return meta._proxy.Description;
}
if (meta.Type.TryGetAttribute(out MetaDescriptionAttribute atr))
{
return atr.Data;
}
if (meta._proxy.Description != null)
{
return meta._proxy.Description;
}
return MetaDescription.Empty;
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
bool isCustom = type.TryGetAttribute(out MetaDescriptionAttribute atr);
return isCustom ? atr.Data : MetaDescription.Empty;
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetDescription)} method does not work.");
return MetaDescription.Empty;
@ -650,22 +566,11 @@ namespace DCFApixels.DragonECS
#endregion
#region GetTags
public static IReadOnlyList<string> GetTags(TypeMeta meta)
public static IReadOnlyList<string> GetTags(Type type)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
if (meta._isSelfProxy && meta._proxy.Tags != null)
{
return meta._proxy.Tags.ToArray();
}
if (meta.Type.TryGetAttribute(out MetaTagsAttribute atr))
{
return atr.Tags;
}
if (meta._proxy.Tags != null)
{
return meta._proxy.Tags.ToArray();
}
return Array.Empty<string>();
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
var atr = type.GetCustomAttribute<MetaTagsAttribute>();
return atr != null ? atr.Tags : Array.Empty<string>();
#else
EcsDebug.PrintWarning($"Reflection is not available, the {nameof(MetaGenerator)}.{nameof(GetTags)} method does not work.");
return Array.Empty<string>();
@ -676,7 +581,7 @@ namespace DCFApixels.DragonECS
#region GetMetaID
public static string GetMetaID(Type type)
{
#if REFLECTION_ENABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
#if DEBUG || !REFLECTION_DISABLED //в дебажных утилитах REFLECTION_DISABLED только в релизном билде работает
var atr = type.GetCustomAttribute<MetaIDAttribute>();
if (atr == null)

View File

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

View File

@ -3,6 +3,7 @@
#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 Core
namespace RunnersCore
{
//добавить инъекцию в раннеры
public abstract class EcsRunner
@ -63,23 +63,6 @@ namespace DCFApixels.DragonECS
#endregion
public delegate void ActionWithData<in TProcess, T>(TProcess process, ref T Data);
#region MetaProxy
protected class RunnerMetaProxy : MetaProxyBase
{
private TypeMeta _processMeta;
public override MetaColor? Color => MetaColor.DragonRose;
public override MetaDescription Description => new MetaDescription(EcsConsts.AUTHOR, $"Runner for {_processMeta.TypeName} process.");
public override MetaGroup Group => MetaGroup.FromName(EcsConsts.PACK_GROUP, EcsConsts.PROCESSES_GROUP);
public RunnerMetaProxy(Type type) : base(type)
{
if (type.IsGenericType)
{
_processMeta = type.GetGenericArguments()[0].GetMeta();
}
}
}
#endregion
}
[MetaColor(MetaColor.DragonRose)]
@ -97,9 +80,9 @@ namespace DCFApixels.DragonECS
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[MetaDescription(EcsConsts.AUTHOR, "...")]
[MetaTags(MetaTags.HIDDEN)]
[MetaID("DragonECS_7DB3557C9201F85E0E1C17D7B19D9CEE")]
[MetaProxy(typeof(RunnerMetaProxy), true)]
public abstract class EcsRunner<TProcess> : EcsRunner, IEcsRunner, IEcsProcess
where TProcess : IEcsProcess
{
@ -493,6 +476,8 @@ namespace DCFApixels.DragonECS
#endregion
}
#endregion
//----
}
}

View File

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

View File

@ -4,6 +4,7 @@
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;
@ -86,7 +87,6 @@ namespace DCFApixels.DragonECS
private StructList<IEcsWorldEventListener> _listeners = new StructList<IEcsWorldEventListener>(2);
private StructList<IEcsEntityEventListener> _entityListeners = new StructList<IEcsEntityEventListener>(2);
private bool _hasAnyEntityListener = false;
#region Properties
EcsWorld IEntityStorage.World
@ -395,11 +395,8 @@ namespace DCFApixels.DragonECS
{
slot.gen |= GEN_SLEEP_MASK;
}
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnNewEntity(entityID);
}
MoveToEmptyEntities(entityID, false);
_entityListeners.InvokeOnNewEntity(entityID);
MoveToEmptyEntities(entityID);
}
@ -440,24 +437,13 @@ namespace DCFApixels.DragonECS
_delEntBuffer[_delEntBufferCount++] = entityID;
_entities[entityID].isUsed = false;
_entitiesCount--;
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnDelEntity(entityID);
}
_entityListeners.InvokeOnDelEntity(entityID);
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void MoveToEmptyEntities(int entityID, bool readyToRemove)
private void MoveToEmptyEntities(int entityID)
{
if (readyToRemove)
{
entityID |= int.MinValue;
}
_emptyEntities[_emptyEntitiesLength++] = entityID;
_emptyEntitiesCount++;
if (_emptyEntitiesLength == _emptyEntities.Length)
{
ReleaseEmptyEntitiesBuffer_OnlyReadyToRemove();
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void RemoveFromEmptyEntities(int entityID)
@ -469,7 +455,7 @@ namespace DCFApixels.DragonECS
{
for (int i = _emptyEntitiesLength - 1; i >= 0; i--)
{
if ((_emptyEntities[i] & int.MaxValue) == entityID)
if (_emptyEntities[i] == entityID)
{
_emptyEntities[i] = _emptyEntities[--_emptyEntitiesLength];
}
@ -488,45 +474,6 @@ namespace DCFApixels.DragonECS
_emptyEntitiesLength = 0;
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ReleaseEmptyEntitiesBuffer()
{
for (int i = 0; i < _emptyEntitiesLength; i++)
{
var entityID = _emptyEntities[i] & int.MaxValue;
if (IsUsed(entityID) && _entities[entityID].componentsCount == 0)
{
DelEntity(entityID);
}
}
_emptyEntitiesCount = 0;
_emptyEntitiesLength = 0;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void ReleaseEmptyEntitiesBuffer_OnlyReadyToRemove()
{
var newCount = 0;
for (int i = 0; i < _emptyEntitiesLength; i++)
{
var entityID = _emptyEntities[i];
bool isReady = entityID < 0;
entityID &= int.MaxValue;
if (IsUsed(entityID) && _entities[entityID].componentsCount == 0)
{
if (isReady)
{
DelEntity(entityID);
}
else
{
_emptyEntities[newCount++] = entityID;
}
}
}
_emptyEntitiesCount = newCount;
_emptyEntitiesLength = newCount;
}
#endregion
#region Other
@ -966,7 +913,16 @@ namespace DCFApixels.DragonECS
if (_emptyEntitiesLength <= 0 && _delEntBufferCount <= 0) { return; }
unchecked { _version++; }
ReleaseEmptyEntitiesBuffer();
for (int i = 0; i < _emptyEntitiesLength; i++)
{
var entityID = _emptyEntities[i];
if (IsUsed(entityID) && _entities[entityID].componentsCount == 0)
{
DelEntity(entityID);
}
}
_emptyEntitiesCount = 0;
_emptyEntitiesLength = 0;
if (count < 0)
{
@ -1090,12 +1046,10 @@ namespace DCFApixels.DragonECS
public void AddListener(IEcsEntityEventListener entityEventListener)
{
_entityListeners.Add(entityEventListener);
_hasAnyEntityListener = _entityListeners.Count > 0;
}
public void RemoveListener(IEcsEntityEventListener entityEventListener)
{
_entityListeners.Remove(entityEventListener);
_hasAnyEntityListener = _entityListeners.Count > 0;
}
#endregion
@ -1421,7 +1375,6 @@ namespace DCFApixels.DragonECS
public interface IEcsEntityEventListener
{
void OnNewEntity(int entityID);
void OnMigrateEntity(int entityID);
void OnDelEntity(int entityID);
}
internal static class WorldEventListExtensions
@ -1459,14 +1412,6 @@ namespace DCFApixels.DragonECS
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeOnMigrateEntity(this ref StructList<IEcsEntityEventListener> self, int entityID)
{
for (int i = 0, iMax = self.Count; i < iMax; i++)
{
self[i].OnMigrateEntity(entityID);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void InvokeOnDelEntity(this ref StructList<IEcsEntityEventListener> self, int entityID)
{
for (int i = 0, iMax = self.Count; i < iMax; i++)

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;
@ -286,10 +286,6 @@ namespace DCFApixels.DragonECS
RemoveFromEmptyEntities(entityID);
}
_entityComponentMasks[(entityID << _entityComponentMaskLengthBitShift) + maskBit.chunkIndex] |= maskBit.mask;
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnMigrateEntity(entityID);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private void UnregisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
@ -300,15 +296,12 @@ namespace DCFApixels.DragonECS
slot.version++;
var count = --_entities[entityID].componentsCount;
_entityComponentMasks[(entityID << _entityComponentMaskLengthBitShift) + maskBit.chunkIndex] &= ~maskBit.mask;
if (count == 0 && IsUsed(entityID))
{
MoveToEmptyEntities(entityID, true);
MoveToEmptyEntities(entityID);
}
CheckUnregisterValid(count, entityID);
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnMigrateEntity(entityID);
}
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private bool TryRegisterEntityComponent(int entityID, int componentTypeID, EcsMaskChunck maskBit)
@ -327,10 +320,6 @@ namespace DCFApixels.DragonECS
{
RemoveFromEmptyEntities(entityID);
}
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnMigrateEntity(entityID);
}
return true;
}
return false;
@ -351,13 +340,9 @@ namespace DCFApixels.DragonECS
if (count == 0 && IsUsed(entityID))
{
MoveToEmptyEntities(entityID, true);
MoveToEmptyEntities(entityID);
}
CheckUnregisterValid(count, entityID);
if (_hasAnyEntityListener)
{
_entityListeners.InvokeOnMigrateEntity(entityID);
}
return true;
}
return false;

View File

@ -294,8 +294,6 @@ namespace DCFApixels.DragonECS
#endregion
#region NullWorld
[MetaTags(MetaTags.HIDDEN)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
private sealed class NullWorld : EcsWorld
{
internal NullWorld() : base(new EcsWorldConfig(4, 4, 4, 4, 4), null, 0) { }

View File

@ -160,7 +160,6 @@ namespace DCFApixels.DragonECS.Core.Internal
SortHalper.Sort(_filteredEntities.AsSpan(_filteredEntitiesCount), comparison);
return new EcsUnsafeSpan(World.ID, _filteredEntities.Ptr, _filteredEntitiesCount);
}
public override EcsSpan Snapshot() { return Execute(); }
#endregion
}
}

View File

@ -117,7 +117,6 @@ namespace DCFApixels.DragonECS.Core.Internal
ExecuteFor_Iternal(span);
return _filteredGroup;
}
public override EcsSpan Snapshot() { return Execute(); }
#endregion
}
}

View File

@ -105,7 +105,6 @@ namespace DCFApixels.DragonECS.Core
}
protected abstract void OnInitialize();
protected abstract void OnDestroy();
public abstract EcsSpan Snapshot();
}
#if ENABLE_IL2CPP

View File

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

View File

@ -9,33 +9,6 @@ namespace DCFApixels.DragonECS.Core.Internal
{
internal static class ReflectionUtility
{
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static Type GetPureType(this Type type)
{
if (type.IsGenericType)
{
return type.GetGenericTypeDefinition();
}
return type;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetAttributeInherited<T>(this Type self, out T attribute, out Type declaringAtrType) where T : Attribute
{
if (self == null || self == typeof(object))
{
attribute = null;
declaringAtrType = null;
return false;
}
attribute = self.GetCustomAttribute<T>();
if (attribute == null)
{
return self.BaseType.TryGetAttributeInherited<T>(out attribute, out declaringAtrType);
}
declaringAtrType = self;
return true;
}
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static bool TryGetAttribute<T>(this MemberInfo self, out T attribute) where T : Attribute
{

View File

@ -389,4 +389,253 @@ 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,6 +3,7 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;
@ -400,9 +401,6 @@ namespace DCFApixels.DragonECS
#if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)]
#endif
[MetaTags(MetaTags.HIDDEN)]
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[EditorBrowsable(EditorBrowsableState.Never)]
public readonly struct ReadonlyEcsPool<T> : IEcsReadonlyPool //IEnumerable<T> - IntelliSense hack
where T : struct, IEcsComponent

View File

@ -8,12 +8,13 @@
#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.Core
namespace DCFApixels.DragonECS.PoolsCore
{
/// <summary> Only used to implement a custom pool. In other contexts use IEcsPool or IEcsPool<T>. </summary>
public interface IEcsPoolImplementation : IEcsPool

View File

@ -3,6 +3,7 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;
@ -343,9 +344,6 @@ namespace DCFApixels.DragonECS
#if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)]
#endif
[MetaTags(MetaTags.HIDDEN)]
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[EditorBrowsable(EditorBrowsableState.Never)]
public readonly struct ReadonlyEcsTagPool<T> : IEcsReadonlyPool //IEnumerable<T> - IntelliSense hack
where T : struct, IEcsTagComponent

View File

@ -3,6 +3,7 @@
#endif
using DCFApixels.DragonECS.Core;
using DCFApixels.DragonECS.Core.Internal;
using DCFApixels.DragonECS.PoolsCore;
using System;
using System.Collections;
using System.Collections.Generic;
@ -36,8 +37,8 @@ namespace DCFApixels.DragonECS
public sealed unsafe class EcsValuePool<T> : IEcsPoolImplementation<T>, IEcsStructPool<T>, IEnumerable<T> //IEnumerable<T> - IntelliSense hack
where T : unmanaged, IEcsValueComponent
{
private EcsWorld _world;
private short _worldID;
private EcsWorld _world;
private int _componentTypeID;
private EcsMaskChunck _maskBit;
@ -125,7 +126,6 @@ namespace DCFApixels.DragonECS
void IEcsPoolImplementation.OnInit(EcsWorld world, EcsWorld.PoolsMediator mediator, int componentTypeID)
{
_world = world;
_worldID = world.ID;
_mediator = mediator;
_componentTypeID = componentTypeID;
_maskBit = EcsMaskChunck.FromID(componentTypeID);
@ -408,9 +408,6 @@ namespace DCFApixels.DragonECS
#if ENABLE_IL2CPP
[Il2CppSetOption(Option.NullChecks, false)]
#endif
[MetaTags(MetaTags.HIDDEN)]
[MetaColor(MetaColor.DragonRose)]
[MetaGroup(EcsConsts.PACK_GROUP, EcsConsts.OTHER_GROUP)]
[EditorBrowsable(EditorBrowsableState.Never)]
public readonly struct ReadonlyEcsValuePool<T> : IEcsReadonlyPool //IEnumerable<T> - IntelliSense hack
where T : unmanaged, IEcsValueComponent

View File

@ -2,7 +2,7 @@
#undef DEBUG
#endif
namespace DCFApixels.DragonECS.Core.Unchecked
namespace DCFApixels.DragonECS.UncheckedCore
{
public readonly struct EntitiesMatrix
{