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.

40 lines
935B

  1. using Svelto.ECS.Internal;
  2. namespace Svelto.ECS
  3. {
  4. public struct EGID
  5. {
  6. long _GID;
  7. public long GID
  8. {
  9. get { return _GID; }
  10. }
  11. public int entityID
  12. {
  13. get { return (int) (_GID & 0xFFFFFFFF); }
  14. }
  15. public int groupID
  16. {
  17. get { return (int) (_GID >> 32); }
  18. }
  19. public EGID(int entityID, int groupID) : this()
  20. {
  21. DBC.Check.Require(groupID != ExclusiveGroups.StandardEntity, "can't use an exclusive group ID");
  22. _GID = MAKE_GLOBAL_ID(entityID, groupID);
  23. }
  24. public EGID(int entityID) : this()
  25. {
  26. _GID = MAKE_GLOBAL_ID(entityID, ExclusiveGroups.StandardEntity);
  27. }
  28. static long MAKE_GLOBAL_ID(int entityId, int groupId)
  29. {
  30. return (long)groupId << 32 | (uint)entityId;
  31. }
  32. }
  33. }