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.

57 lines
1.2KB

  1. using System;
  2. using System.Diagnostics;
  3. namespace Svelto.ECS
  4. {
  5. sealed class ComponentIDDebugProxy
  6. {
  7. public ComponentIDDebugProxy(ComponentID id)
  8. {
  9. this._id = id;
  10. }
  11. public Type type => ComponentTypeMap.FetchType(_id);
  12. readonly ComponentID _id;
  13. }
  14. [DebuggerTypeProxy(typeof(ComponentIDDebugProxy))]
  15. public struct ComponentID: IEquatable<ComponentID>, IComparable<ComponentID>
  16. {
  17. public static implicit operator int(ComponentID id)
  18. {
  19. return id._id;
  20. }
  21. public static implicit operator uint(ComponentID id)
  22. {
  23. return (uint)id._id;
  24. }
  25. public static implicit operator ComponentID(int id)
  26. {
  27. return new ComponentID()
  28. {
  29. _id = id
  30. };
  31. }
  32. public bool Equals(ComponentID other)
  33. {
  34. return _id == other._id;
  35. }
  36. public override int GetHashCode()
  37. {
  38. return _id;
  39. }
  40. public int CompareTo(ComponentID other)
  41. {
  42. return _id.CompareTo(other._id);
  43. }
  44. int _id;
  45. }
  46. }