diff --git a/src/IdAssigner.cs b/src/IdAssigner.cs index 0f11307..5cb4143 100644 --- a/src/IdAssigner.cs +++ b/src/IdAssigner.cs @@ -7,11 +7,9 @@ internal class IdAssigner uint Next; NativeArray AvailableIds = new NativeArray(); - 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; } diff --git a/src/World.cs b/src/World.cs index c7c5d6f..f6a2ee0 100644 --- a/src/World.cs +++ b/src/World.cs @@ -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()); @@ -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()); EntityComponentIndex.Add(entity, new IndexableSet());