Compare commits

...

6 Commits
0.9.23 ... main

Author SHA1 Message Date
Mikhail
4f28618277 up version 1.0.1 2026-04-21 22:18:02 +08:00
Mikhail
2cca65e37e fix 2026-04-21 21:51:05 +08:00
Mikhail
b45e9ea608 Update package.json 2026-04-21 15:15:30 +08:00
Mikhail
c3ff8b0b58 update readme 2026-04-21 14:21:15 +08:00
Mikhail
a37939a620 update readme 2026-04-21 13:59:12 +08:00
Mikhail
2b50fbdb55 Update README-RU.md 2026-04-19 18:36:33 +08:00
7 changed files with 73 additions and 38 deletions

View File

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

View File

@ -41,10 +41,8 @@
DragonECS - это [ECS](https://en.wikipedia.org/wiki/Entity_component_system) фреймворк, нацеленный на максимальную удобность, модульность, расширяемость и производительность динамического изменения сущностей. Разработан на чистом C#, без зависимостей и генерации кода. Вдохновлен [LeoEcs Lite](https://github.com/Leopotam/ecslite). DragonECS - это [ECS](https://en.wikipedia.org/wiki/Entity_component_system) фреймворк, нацеленный на максимальную удобность, модульность, расширяемость и производительность динамического изменения сущностей. Разработан на чистом C#, без зависимостей и генерации кода. Вдохновлен [LeoEcs Lite](https://github.com/Leopotam/ecslite).
> [!WARNING] > [!Note]
> Проект предрелизной версии, поэтому API может меняться. В ветке main актуальная и рабочая версия. > Есть вопросы или хотите быть в курсе разработки? Присоединяйтесь к нашему комьюнити! -> [Обратная связь](#обратная-связь)
>
> Если есть неясные моменты, вопросы можно задать тут [Обратная связь](#обратная-связь)
## Оглавление ## Оглавление
- [Установка](#установка) - [Установка](#установка)
@ -350,10 +348,13 @@ EcsPipeline pipeline = EcsPipeline.New()
Слой определяет место в пайплайне для вставки систем. Например, если необходимо чтобы система была вставлена в конце пайплайна, эту систему можно добавить в слой `EcsConsts.END_LAYER`. Слой определяет место в пайплайне для вставки систем. Например, если необходимо чтобы система была вставлена в конце пайплайна, эту систему можно добавить в слой `EcsConsts.END_LAYER`.
```c# ```c#
const string SOME_LAYER = nameof(SOME_LAYER); const string SOME_LAYER = nameof(SOME_LAYER);
const string SOME_LAYER_2 = nameof(SOME_LAYER_2);
EcsPipeline pipeline = EcsPipeline.New() EcsPipeline pipeline = EcsPipeline.New()
// ... // ...
// Вставляет новый слой перед конечным слоем EcsConsts.END_LAYER // Вставляет новый слой перед конечным слоем EcsConsts.END_LAYER
.Layers.Insert(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)
// Система SomeSystem будет вставлена в слой SOME_LAYER // Система SomeSystem будет вставлена в слой SOME_LAYER
.Add(New SomeSystem(), SOME_LAYER) .Add(New SomeSystem(), SOME_LAYER)
// ... // ...
@ -1009,7 +1010,7 @@ using (_marker.Auto())
var configs = new ConfigContainer() var configs = new ConfigContainer()
.Set(new EcsWorldConfig(entitiesCapacity: 2000, poolsCapacity: 2000) .Set(new EcsWorldConfig(entitiesCapacity: 2000, poolsCapacity: 2000)
.Set(new SomeDataA(/* ... */)) .Set(new SomeDataA(/* ... */))
.Set(new SomeDataB(/* ... */))); .Set(new SomeDataB(/* ... */));
EcsDefaultWorld _world = new EcsDefaultWorld(configs); EcsDefaultWorld _world = new EcsDefaultWorld(configs);
// ... // ...
var _someDataA = _world.Configs.Get<SomeDataA>(); var _someDataA = _world.Configs.Get<SomeDataA>();

View File

@ -43,12 +43,8 @@
DragonECS 是一个[实体组件系统](https://www.imooc.com/article/331544)框架。专注于提升便利性、模块性、可扩展性和动态实体修改性能。 用纯C#开发的,没有依赖和代码生成。灵感来自于[LeoEcs Lite](https://github.com/Leopotam/ecslite)。 DragonECS 是一个[实体组件系统](https://www.imooc.com/article/331544)框架。专注于提升便利性、模块性、可扩展性和动态实体修改性能。 用纯C#开发的,没有依赖和代码生成。灵感来自于[LeoEcs Lite](https://github.com/Leopotam/ecslite)。
> [!WARNING] > [!Note]
> 该框架是预发布版本,因此 API 可能会有变化。在 `main` 分支中是当前的工作版本。 > 有疑问或想了解开发进度?欢迎加入我们的社区! -> [Feedback](#Feedback)
>
> 最新版本的 README 是[俄文版](https://github.com/DCFApixels/DragonECS/blob/main/README-RU.md)。
>
> 如果有不清楚的地方,可以在这里提问 [反馈](#反馈)。
## 目录 ## 目录
- [安装](#安装) - [安装](#安装)
@ -312,7 +308,9 @@ const string SOME_LAYER = nameof(SOME_LAYER);
EcsPipeline pipeline = EcsPipeline.New() EcsPipeline pipeline = EcsPipeline.New()
// ... // ...
// 在最终的 EcsConsts.END_LAYER 层前面插入一个新 SOME_LAYER 层。 // 在最终的 EcsConsts.END_LAYER 层前面插入一个新 SOME_LAYER 层。
.Layers.Insert(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)
// SomeSystem 系统将插入 SAME_LAYER 层。 // SomeSystem 系统将插入 SAME_LAYER 层。
.Add(New SomeSystem(), SOME_LAYER) .Add(New SomeSystem(), SOME_LAYER)
// ... // ...

View File

@ -43,12 +43,8 @@
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). 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).
> [!WARNING] > [!Note]
> The project is a work in progress; the API may change. > Have questions or want to stay updated on development? Join our community! -> [Feedback](#Feedback)
>
> 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 ## Table of Contents
- [Installation](#installation) - [Installation](#installation)
@ -309,7 +305,9 @@ const string SOME_LAYER = nameof(SOME_LAYER);
EcsPipeline pipeline = EcsPipeline.New() EcsPipeline pipeline = EcsPipeline.New()
// ... // ...
// Inserts a new layer before the end layer EcsConsts.END_LAYER // Inserts a new layer before the end layer EcsConsts.END_LAYER
.Layers.Insert(EcsConsts.END_LAYER, SOME_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)
// System SomeSystem will be added to the SOME_LAYER layer // System SomeSystem will be added to the SOME_LAYER layer
.Add(new SomeSystem(), SOME_LAYER) .Add(new SomeSystem(), SOME_LAYER)
// ... // ...

View File

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

View File

@ -399,7 +399,7 @@ namespace DCFApixels.DragonECS
{ {
_entityListeners.InvokeOnNewEntity(entityID); _entityListeners.InvokeOnNewEntity(entityID);
} }
MoveToEmptyEntities(entityID); MoveToEmptyEntities(entityID, false);
} }
@ -446,10 +446,18 @@ namespace DCFApixels.DragonECS
} }
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void MoveToEmptyEntities(int entityID) private void MoveToEmptyEntities(int entityID, bool readyToRemove)
{ {
if (readyToRemove)
{
entityID |= int.MinValue;
}
_emptyEntities[_emptyEntitiesLength++] = entityID; _emptyEntities[_emptyEntitiesLength++] = entityID;
_emptyEntitiesCount++; _emptyEntitiesCount++;
if (_emptyEntitiesLength == _emptyEntities.Length)
{
ReleaseEmptyEntitiesBuffer_OnlyReadyToRemove();
}
} }
[MethodImpl(MethodImplOptions.AggressiveInlining)] [MethodImpl(MethodImplOptions.AggressiveInlining)]
private void RemoveFromEmptyEntities(int entityID) private void RemoveFromEmptyEntities(int entityID)
@ -461,7 +469,7 @@ namespace DCFApixels.DragonECS
{ {
for (int i = _emptyEntitiesLength - 1; i >= 0; i--) for (int i = _emptyEntitiesLength - 1; i >= 0; i--)
{ {
if (_emptyEntities[i] == entityID) if ((_emptyEntities[i] & int.MaxValue) == entityID)
{ {
_emptyEntities[i] = _emptyEntities[--_emptyEntitiesLength]; _emptyEntities[i] = _emptyEntities[--_emptyEntitiesLength];
} }
@ -480,6 +488,45 @@ namespace DCFApixels.DragonECS
_emptyEntitiesLength = 0; _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 #endregion
#region Other #region Other
@ -919,16 +966,7 @@ namespace DCFApixels.DragonECS
if (_emptyEntitiesLength <= 0 && _delEntBufferCount <= 0) { return; } if (_emptyEntitiesLength <= 0 && _delEntBufferCount <= 0) { return; }
unchecked { _version++; } unchecked { _version++; }
for (int i = 0; i < _emptyEntitiesLength; i++) ReleaseEmptyEntitiesBuffer();
{
var entityID = _emptyEntities[i];
if (IsUsed(entityID) && _entities[entityID].componentsCount == 0)
{
DelEntity(entityID);
}
}
_emptyEntitiesCount = 0;
_emptyEntitiesLength = 0;
if (count < 0) if (count < 0)
{ {

View File

@ -302,7 +302,7 @@ namespace DCFApixels.DragonECS
_entityComponentMasks[(entityID << _entityComponentMaskLengthBitShift) + maskBit.chunkIndex] &= ~maskBit.mask; _entityComponentMasks[(entityID << _entityComponentMaskLengthBitShift) + maskBit.chunkIndex] &= ~maskBit.mask;
if (count == 0 && IsUsed(entityID)) if (count == 0 && IsUsed(entityID))
{ {
MoveToEmptyEntities(entityID); MoveToEmptyEntities(entityID, true);
} }
CheckUnregisterValid(count, entityID); CheckUnregisterValid(count, entityID);
if (_hasAnyEntityListener) if (_hasAnyEntityListener)
@ -351,7 +351,7 @@ namespace DCFApixels.DragonECS
if (count == 0 && IsUsed(entityID)) if (count == 0 && IsUsed(entityID))
{ {
MoveToEmptyEntities(entityID); MoveToEmptyEntities(entityID, true);
} }
CheckUnregisterValid(count, entityID); CheckUnregisterValid(count, entityID);
if (_hasAnyEntityListener) if (_hasAnyEntityListener)