Compare commits

...

2 Commits
1.0.0 ... 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
4 changed files with 55 additions and 17 deletions

View File

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

View File

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

View File

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