Mirror of Svelto.ECS because we're a fan of it
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

47 řádky
1.2KB

  1. using System.Runtime.CompilerServices;
  2. using System.Threading;
  3. using Svelto.DataStructures;
  4. namespace Svelto.ECS
  5. {
  6. public struct EntityFilterIndices
  7. {
  8. public EntityFilterIndices(NB<uint> indices, uint count)
  9. {
  10. _indices = indices;
  11. _count = count;
  12. _index = 0;
  13. }
  14. public uint count
  15. {
  16. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  17. get => _count;
  18. }
  19. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  20. public uint Get(uint index) => _indices[index];
  21. public uint this[uint index]
  22. {
  23. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  24. get => _indices[index];
  25. }
  26. public uint this[int index]
  27. {
  28. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  29. get => _indices[index];
  30. }
  31. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  32. public uint Next()
  33. {
  34. return _indices[Interlocked.Increment(ref _index) - 1];
  35. }
  36. readonly NB<uint> _indices;
  37. readonly uint _count;
  38. int _index;
  39. }
  40. }