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.

104 lines
3.8KB

  1. namespace Svelto.ECS
  2. {
  3. public abstract class GenericEntityDescriptor<T> : IEntityDescriptor where T : struct, IEntityComponent
  4. {
  5. internal static readonly IComponentBuilder[] _componentBuilders;
  6. static GenericEntityDescriptor() { _componentBuilders = new IComponentBuilder[] {new ComponentBuilder<T>()}; }
  7. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  8. }
  9. public abstract class GenericEntityDescriptor<T, U> : IEntityDescriptor
  10. where T : struct, IEntityComponent where U : struct, IEntityComponent
  11. {
  12. internal static readonly IComponentBuilder[] _componentBuilders;
  13. static GenericEntityDescriptor()
  14. {
  15. _componentBuilders = new IComponentBuilder[] {new ComponentBuilder<T>(), new ComponentBuilder<U>()};
  16. }
  17. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  18. }
  19. public abstract class GenericEntityDescriptor<T, U, V> : IEntityDescriptor
  20. where T : struct, IEntityComponent where U : struct, IEntityComponent where V : struct, IEntityComponent
  21. {
  22. internal static readonly IComponentBuilder[] _componentBuilders;
  23. static GenericEntityDescriptor()
  24. {
  25. _componentBuilders = new IComponentBuilder[]
  26. {
  27. new ComponentBuilder<T>(),
  28. new ComponentBuilder<U>(),
  29. new ComponentBuilder<V>()
  30. };
  31. }
  32. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  33. }
  34. public abstract class GenericEntityDescriptor<T, U, V, W> : IEntityDescriptor
  35. where T : struct, IEntityComponent where U : struct, IEntityComponent where V : struct, IEntityComponent
  36. where W : struct, IEntityComponent
  37. {
  38. static readonly IComponentBuilder[] _componentBuilders;
  39. static GenericEntityDescriptor()
  40. {
  41. _componentBuilders = new IComponentBuilder[]
  42. {
  43. new ComponentBuilder<T>(),
  44. new ComponentBuilder<U>(),
  45. new ComponentBuilder<V>(),
  46. new ComponentBuilder<W>()
  47. };
  48. }
  49. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  50. }
  51. public abstract class GenericEntityDescriptor<T, U, V, W, X> : IEntityDescriptor
  52. where T : struct, IEntityComponent where U : struct, IEntityComponent where V : struct, IEntityComponent
  53. where W : struct, IEntityComponent where X : struct, IEntityComponent
  54. {
  55. static readonly IComponentBuilder[] _componentBuilders;
  56. static GenericEntityDescriptor()
  57. {
  58. _componentBuilders = new IComponentBuilder[]
  59. {
  60. new ComponentBuilder<T>(),
  61. new ComponentBuilder<U>(),
  62. new ComponentBuilder<V>(),
  63. new ComponentBuilder<W>(),
  64. new ComponentBuilder<X>()
  65. };
  66. }
  67. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  68. }
  69. public abstract class GenericEntityDescriptor<T, U, V, W, X, Y> : IEntityDescriptor
  70. where T : struct, IEntityComponent where U : struct, IEntityComponent where V : struct, IEntityComponent
  71. where W : struct, IEntityComponent where X : struct, IEntityComponent where Y : struct, IEntityComponent
  72. {
  73. static readonly IComponentBuilder[] _componentBuilders;
  74. static GenericEntityDescriptor()
  75. {
  76. _componentBuilders = new IComponentBuilder[]
  77. {
  78. new ComponentBuilder<T>(),
  79. new ComponentBuilder<U>(),
  80. new ComponentBuilder<V>(),
  81. new ComponentBuilder<W>(),
  82. new ComponentBuilder<X>(),
  83. new ComponentBuilder<Y>()
  84. };
  85. }
  86. public IComponentBuilder[] componentsToBuild => _componentBuilders;
  87. }
  88. }