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.

36 lines
1.3KB

  1. using Svelto.DataStructures;
  2. namespace Svelto.ECS
  3. {
  4. class GenericEntityStreamConsumerFactory : IEntityStreamConsumerFactory
  5. {
  6. public GenericEntityStreamConsumerFactory(EnginesRoot weakReference)
  7. {
  8. _enginesRoot = new WeakReference<EnginesRoot>(weakReference);
  9. }
  10. public Consumer<T> GenerateConsumer<T>(string name, uint capacity)
  11. where T : unmanaged, IEntityComponent
  12. {
  13. return _enginesRoot.Target.GenerateConsumer<T>(name, capacity);
  14. }
  15. public Consumer<T> GenerateConsumer<T>(ExclusiveGroupStruct @group, string name, uint capacity)
  16. where T : unmanaged, IEntityComponent
  17. {
  18. return _enginesRoot.Target.GenerateConsumer<T>(group, name, capacity);
  19. }
  20. //enginesRoot is a weakreference because GenericEntityStreamConsumerFactory can be injected inside
  21. //engines of other enginesRoot
  22. readonly WeakReference<EnginesRoot> _enginesRoot;
  23. }
  24. public interface IEntityStreamConsumerFactory
  25. {
  26. Consumer<T> GenerateConsumer<T>(string name, uint capacity) where T : unmanaged, IEntityComponent;
  27. Consumer<T> GenerateConsumer<T>(ExclusiveGroupStruct @group, string name, uint capacity)
  28. where T : unmanaged, IEntityComponent;
  29. }
  30. }