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.

39 lines
974B

  1. namespace Svelto.ECS
  2. {
  3. /// <summary>
  4. /// Exclusive Groups guarantee that the GroupID is unique.
  5. ///
  6. /// The best way to use it is like:
  7. ///
  8. /// public static class MyExclusiveGroups //(can be as many as you want)
  9. /// {
  10. /// public static MyExclusiveGroup1 = new ExclusiveGroup();
  11. /// }
  12. /// </summary>
  13. public class ExclusiveGroup
  14. {
  15. public ExclusiveGroup()
  16. {
  17. _id = _globalId;
  18. _globalId += 1;
  19. }
  20. /// <summary>
  21. /// Use this constructor to reserve N groups
  22. /// </summary>
  23. public ExclusiveGroup(int range)
  24. {
  25. _id = _globalId;
  26. _globalId += range;
  27. }
  28. public static explicit operator int(ExclusiveGroup group) // explicit byte to digit conversion operator
  29. {
  30. return group._id;
  31. }
  32. readonly int _id;
  33. static int _globalId;
  34. }
  35. }