Compare commits

..

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

7 changed files with 38 additions and 73 deletions

View File

@ -10,7 +10,7 @@
<RootNamespace>DCFApixels.DragonECS</RootNamespace>
<Title>DragonECS</Title>
<Version>1.0.1</Version>
<Version>0.9.23</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 актуальная и рабочая версия.
>
> Если есть неясные моменты, вопросы можно задать тут [Обратная связь](#обратная-связь)
## Оглавление
- [Установка](#установка)
@ -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)
// ...
@ -1010,7 +1009,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)。
>
> 如果有不清楚的地方,可以在这里提问 [反馈](#反馈)。
## 目录
- [安装](#安装)
@ -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)
// ...

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)
// ...

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.23",
"repository": {
"type": "git",
"url": "https://github.com/DCFApixels/DragonECS.git"

View File

@ -399,7 +399,7 @@ namespace DCFApixels.DragonECS
{
_entityListeners.InvokeOnNewEntity(entityID);
}
MoveToEmptyEntities(entityID, false);
MoveToEmptyEntities(entityID);
}
@ -446,18 +446,10 @@ namespace DCFApixels.DragonECS
}
}
[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 +461,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 +480,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 +919,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)
{

View File

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