mirror of
https://github.com/DCFApixels/DragonECS.git
synced 2025-09-18 01:44:35 +08:00
fix IdDispenser
This commit is contained in:
parent
3fed9886fe
commit
37bfe72d7e
@ -405,7 +405,11 @@ namespace DCFApixels.DragonECS
|
|||||||
unchecked { _gens[e]++; }//up gen
|
unchecked { _gens[e]++; }//up gen
|
||||||
_gens[e] |= DEATH_GEN_BIT;
|
_gens[e] |= DEATH_GEN_BIT;
|
||||||
}
|
}
|
||||||
// _entityDispenser.Sort(); //уплотнение свободных айдишников
|
Densify();
|
||||||
|
}
|
||||||
|
private void Densify() //уплотнение свободных айдишников
|
||||||
|
{
|
||||||
|
_entityDispenser.Sort();
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
@ -156,7 +156,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
int usedIndex = 0;
|
int usedIndex = 0;
|
||||||
int freeIndex = _usedCount;
|
int freeIndex = _usedCount;
|
||||||
for (int i = 1; i < _size; i++)
|
for (int i = 0; i < _size; i++)
|
||||||
{
|
{
|
||||||
if (_sparse[i] < _usedCount)
|
if (_sparse[i] < _usedCount)
|
||||||
{
|
{
|
||||||
@ -193,7 +193,7 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
Swap(nullID, _usedCount++);
|
Swap(nullID, _usedCount++);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private bool IsValid()
|
internal bool IsValid()
|
||||||
{
|
{
|
||||||
for (int i = 0; i < _usedCount; i++)
|
for (int i = 0; i < _usedCount; i++)
|
||||||
{
|
{
|
||||||
@ -328,7 +328,12 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
{
|
{
|
||||||
Pair[] result = new Pair[_target.Size];
|
Pair[] result = new Pair[_target.Size];
|
||||||
for (int i = 0; i < result.Length; i++)
|
for (int i = 0; i < result.Length; i++)
|
||||||
result[i] = new Pair(_target._dense[i], _target._sparse[i]);
|
{
|
||||||
|
result[i] = new Pair(
|
||||||
|
_target._dense[i],
|
||||||
|
_target._sparse[i],
|
||||||
|
i < _target.Count);
|
||||||
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -356,12 +361,20 @@ namespace DCFApixels.DragonECS.Internal
|
|||||||
public ID(int id, string state) { this.id = id; this.state = state; }
|
public ID(int id, string state) { this.id = id; this.state = state; }
|
||||||
public override string ToString() => $"{id} - {state}";
|
public override string ToString() => $"{id} - {state}";
|
||||||
}
|
}
|
||||||
|
[DebuggerDisplay("{Separator} -> {sparse} - {dense}")]
|
||||||
internal readonly struct Pair
|
internal readonly struct Pair
|
||||||
{
|
{
|
||||||
public readonly int dense;
|
|
||||||
public readonly int sparse;
|
public readonly int sparse;
|
||||||
public Pair(int dense, int sparse) { this.dense = dense; this.sparse = sparse; }
|
public readonly int dense;
|
||||||
public override string ToString() => $"{dense} - {sparse}";
|
public readonly bool isSeparator;
|
||||||
|
public int Separator => isSeparator ? 1 : 0;
|
||||||
|
public Pair(int dense, int sparse, bool isSeparator)
|
||||||
|
{
|
||||||
|
this.dense = dense;
|
||||||
|
this.sparse = sparse;
|
||||||
|
this.isSeparator = isSeparator;
|
||||||
|
}
|
||||||
|
//public override string ToString() => $"{sparse} - {dense} { (isSeparator ? '>' : ' ') } ";
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user