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.

65 lines
1.9KB

  1. using System;
  2. namespace Svelto.ECS
  3. {
  4. #pragma warning disable 660,661
  5. struct EntitySubmitOperation
  6. #pragma warning restore 660,661
  7. : IEquatable<EntitySubmitOperation>
  8. {
  9. public readonly EntitySubmitOperationType type;
  10. public readonly IComponentBuilder[] builders;
  11. public readonly EGID fromID;
  12. public readonly EGID toID;
  13. #if DEBUG && !PROFILE_SVELTO
  14. public System.Diagnostics.StackFrame trace;
  15. #endif
  16. public EntitySubmitOperation(EntitySubmitOperationType operation, EGID from, EGID to,
  17. IComponentBuilder[] builders = null)
  18. {
  19. type = operation;
  20. this.builders = builders;
  21. fromID = from;
  22. toID = to;
  23. #if DEBUG && !PROFILE_SVELTO
  24. trace = default;
  25. #endif
  26. }
  27. public EntitySubmitOperation
  28. (EntitySubmitOperationType operation, ExclusiveGroupStruct @group
  29. , IComponentBuilder[] descriptorComponentsToBuild):this()
  30. {
  31. type = operation;
  32. this.builders = descriptorComponentsToBuild;
  33. fromID = new EGID(0, group);
  34. #if DEBUG && !PROFILE_SVELTO
  35. trace = default;
  36. #endif
  37. }
  38. public static bool operator ==(EntitySubmitOperation obj1, EntitySubmitOperation obj2)
  39. {
  40. return obj1.Equals(obj2);
  41. }
  42. public static bool operator !=(EntitySubmitOperation obj1, EntitySubmitOperation obj2)
  43. {
  44. return obj1.Equals(obj2) == false;
  45. }
  46. public bool Equals(EntitySubmitOperation other)
  47. {
  48. return type == other.type && fromID == other.fromID && toID == other.toID;
  49. }
  50. }
  51. enum EntitySubmitOperationType
  52. {
  53. Swap,
  54. Remove,
  55. RemoveGroup,
  56. SwapGroup
  57. }
  58. }