using System; using Unity.Collections; using Unity.Mathematics; namespace GameCore.TinyECS { public struct EntityDatabase : IDisposable where TEnum : unmanaged where TData : unmanaged, IEntityDataStruct { public TData dataStruct; public EntityGenerator generator; public EntityCollection collection; public Entity AddEntity() { var entity = generator.Create(); collection.Add(entity); dataStruct.Add(); return entity; } public void RemoveEntity(Entity entity) { generator.Delete(entity); if (collection.Remove(entity, out var index, out var _)) dataStruct.Remove(index); } public void Dispose() { generator.Dispose(); collection.Dispose(); dataStruct.Dispose(); } } }