fix crash on post-snapshot entity ID recycle
parent
f849db955c
commit
2d333d0651
|
@ -7,11 +7,9 @@ internal class IdAssigner
|
|||
uint Next;
|
||||
NativeArray<uint> AvailableIds = new NativeArray<uint>();
|
||||
|
||||
public uint Assign(out bool recycled)
|
||||
public uint Assign()
|
||||
{
|
||||
recycled = AvailableIds.TryPop(out var id);
|
||||
|
||||
if (recycled)
|
||||
if (AvailableIds.TryPop(out var id))
|
||||
{
|
||||
return id;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ namespace MoonTools.ECS
|
|||
return TypeToId[typeof(T)];
|
||||
}
|
||||
|
||||
var typeId = new TypeId(TypeIdAssigner.Assign(out var _));
|
||||
var typeId = new TypeId(TypeIdAssigner.Assign());
|
||||
TypeToId.Add(typeof(T), typeId);
|
||||
ElementSizes.Add(typeId, Unsafe.SizeOf<T>());
|
||||
|
||||
|
@ -116,9 +116,9 @@ namespace MoonTools.ECS
|
|||
|
||||
public Entity CreateEntity(string tag = "")
|
||||
{
|
||||
var entity = new Entity(EntityIdAssigner.Assign(out var recycled));
|
||||
var entity = new Entity(EntityIdAssigner.Assign());
|
||||
|
||||
if (!recycled)
|
||||
if (!EntityComponentIndex.ContainsKey(entity))
|
||||
{
|
||||
EntityRelationIndex.Add(entity, new IndexableSet<TypeId>());
|
||||
EntityComponentIndex.Add(entity, new IndexableSet<TypeId>());
|
||||
|
|
Loading…
Reference in New Issue