mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2026-04-22 01:45:55 +08:00
Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4f28618277 | ||
|
|
2cca65e37e |
@ -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>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
"displayName": "DragonECS",
|
"displayName": "DragonECS",
|
||||||
"description": "C# Entity Component System Framework",
|
"description": "C# Entity Component System Framework",
|
||||||
"unity": "2021.2",
|
"unity": "2021.2",
|
||||||
"version": "1.0.0",
|
"version": "1.0.1",
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
"url": "https://github.com/DCFApixels/DragonECS.git"
|
"url": "https://github.com/DCFApixels/DragonECS.git"
|
||||||
|
|||||||
@ -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)
|
||||||
{
|
{
|
||||||
|
|||||||
@ -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)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user