Added section ordering for systems runtime

This commit is contained in:
Booklordofthedings 2024-11-19 16:27:52 +01:00
parent 34b929c4e7
commit 6cd249dc5b
4 changed files with 117 additions and 8 deletions

View file

@ -11,6 +11,8 @@ class PagedSparseSet
private List<Entity> _packed = new .() ~ delete _;
private UList _packedEntities ~ delete _;
private function void(void* data) _deallocationFunction = null;
public this(int_cosize size)
{
_packedEntities = new .(size);
@ -29,12 +31,15 @@ class PagedSparseSet
_sparse[e.Index/PageSize][e.Index % PageSize] = (.)_packed.Count-1;
}
public bool Remove(Entity e)
public bool Remove(Entity e, bool cleanup = false)
{
EnsurePage(e.Index/PageSize);
if(_sparse[e.Index/PageSize] == null)
return false;
if(_deallocationFunction != null && !cleanup)
_deallocationFunction(_packedEntities[(.)(_sparse[e.Index/PageSize][e.Index % PageSize].Index)]);
let toRm = _packed[_sparse[e.Index/PageSize][e.Index % PageSize].Index];
let b = _packed.Back;
_packed[_sparse[e.Index/PageSize][e.Index % PageSize].Index] = b;