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.

53 lines
1.9KB

  1. using Svelto.ECS.Internal;
  2. #if ENGINE_PROFILER_ENABLED && UNITY_EDITOR
  3. using Svelto.ECS.Profiler;
  4. #endif
  5. namespace Svelto.ECS
  6. {
  7. public partial class EnginesRoot
  8. {
  9. class GenericEntityFactory : IEntityFactory
  10. {
  11. readonly DataStructures.WeakReference<EnginesRoot> _weakEngine;
  12. public GenericEntityFactory(DataStructures.WeakReference<EnginesRoot> weakReference)
  13. {
  14. _weakEngine = weakReference;
  15. }
  16. public void BuildEntity<T>(int entityID, object[] implementors) where T : IEntityDescriptor, new()
  17. {
  18. _weakEngine.Target.BuildEntity<T>(entityID, implementors);
  19. }
  20. public void BuildEntity(int entityID, EntityDescriptorInfo entityDescriptor, object[] implementors = null)
  21. {
  22. _weakEngine.Target.BuildEntity(entityID, entityDescriptor, implementors);
  23. }
  24. public void BuildEntityInGroup<T>(int entityID, int groupID, object[] implementors)
  25. where T : IEntityDescriptor, new()
  26. {
  27. _weakEngine.Target.BuildEntityInGroup<T>(entityID, groupID, implementors);
  28. }
  29. public void BuildEntityInGroup(int entityID, int groupID, EntityDescriptorInfo entityDescriptor,
  30. object[] implementors)
  31. {
  32. _weakEngine.Target.BuildEntityInGroup(entityID, groupID, entityDescriptor, implementors);
  33. }
  34. public void PreallocateEntitySpace<T>(int size) where T : IEntityDescriptor, new()
  35. {
  36. _weakEngine.Target.Preallocate<T>(ExclusiveGroups.StandardEntity, size);
  37. }
  38. public void PreallocateEntitySpaceInGroup<T>(int groupID, int size) where T : IEntityDescriptor, new()
  39. {
  40. _weakEngine.Target.Preallocate<T>(groupID, size);
  41. }
  42. }
  43. }
  44. }