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.

33 lines
993B

  1. #if UNITY_NATIVE
  2. using Svelto.DataStructures;
  3. namespace Svelto.ECS.Native
  4. {
  5. public readonly struct NativeEntitySwap
  6. {
  7. readonly AtomicNativeBags _swapQueue;
  8. readonly int _indexSwap;
  9. internal NativeEntitySwap(AtomicNativeBags EGIDsToSwap, int indexSwap)
  10. {
  11. _swapQueue = EGIDsToSwap;
  12. _indexSwap = indexSwap;
  13. }
  14. public void SwapEntity(EGID from, EGID to, int threadIndex)
  15. {
  16. var simpleNativeBag = _swapQueue.GetBag(threadIndex);
  17. simpleNativeBag.Enqueue(_indexSwap);
  18. simpleNativeBag.Enqueue(new DoubleEGID(from, to));
  19. }
  20. public void SwapEntity(EGID from, ExclusiveBuildGroup to, int threadIndex)
  21. {
  22. var simpleNativeBag = _swapQueue.GetBag(threadIndex);
  23. simpleNativeBag.Enqueue(_indexSwap);
  24. simpleNativeBag.Enqueue(new DoubleEGID(from, new EGID(from.entityID, to)));
  25. }
  26. }
  27. }
  28. #endif