Mirror of Svelto.ECS because we're a fan of it
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
704B

  1. using Svelto.ECS.DataStructures;
  2. namespace Svelto.ECS
  3. {
  4. public readonly ref struct NativeEntityInitializer
  5. {
  6. readonly NativeBag _unsafeBuffer;
  7. readonly UnsafeArrayIndex _index;
  8. public NativeEntityInitializer(in NativeBag unsafeBuffer, UnsafeArrayIndex index)
  9. {
  10. _unsafeBuffer = unsafeBuffer;
  11. _index = index;
  12. }
  13. public void Init<T>(in T component) where T : unmanaged, IEntityComponent
  14. {
  15. uint id = EntityComponentID<T>.ID.Data;
  16. _unsafeBuffer.AccessReserved<uint>(_index)++;
  17. _unsafeBuffer.Enqueue(id);
  18. _unsafeBuffer.Enqueue(component);
  19. }
  20. }
  21. }