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.

67 lines
3.1KB

  1. using System;
  2. using System.Collections.Generic;
  3. namespace Svelto.ECS
  4. {
  5. /// <summary>
  6. /// Entities are always built in group. Where the group is not specificed, a special standard group is used
  7. /// ID can be reused within groups
  8. /// an EnginesRoot reference cannot be held by anything else than the Composition Root
  9. /// where it has been created. IEntityFactory and IEntityFunctions allow a weakreference
  10. /// of the EnginesRoot to be passed around.
  11. ///
  12. /// ExclusiveGroups must be used in your game like:
  13. /// static class GameExclusiveGroup
  14. ///{
  15. /// public static readonly ExclusiveGroups PlayerEntitiesGroup = new ExclusiveGroups();
  16. ///}
  17. ///
  18. /// </summary>
  19. public interface IEntityFactory
  20. {
  21. /// <summary>
  22. /// where performance is critical, you may wish to pre allocate the space needed
  23. /// to store the entities
  24. /// </summary>
  25. /// <typeparam name="T"></typeparam>
  26. /// <param name="groupStructId"></param>
  27. /// <param name="size"></param>
  28. void PreallocateEntitySpace<T>(ExclusiveGroupStruct groupStructId, uint size)
  29. where T : IEntityDescriptor, new();
  30. /// <summary>
  31. /// The EntityDescriptor doesn't need to be ever instantiated. It just describes the Entity
  32. /// itself in terms of EntityComponents to build. The Implementors are passed to fill the
  33. /// references of the EntityComponents components. Please read the articles on my blog
  34. /// to understand better the terminologies
  35. /// Using this function is like building a normal entity, but the entity components
  36. /// are grouped by groupID to be more efficiently processed inside engines and
  37. /// improve cache locality. Either class entityComponents and struct entityComponents can be
  38. /// grouped.
  39. /// </summary>
  40. /// <param name="entityID"></param>
  41. /// <param name="groupStructId"></param>
  42. /// <param name="ed"></param>
  43. /// <param name="implementors"></param>
  44. EntityComponentInitializer BuildEntity<T>(uint entityID, BuildGroup groupStructId,
  45. IEnumerable<object> implementors = null)
  46. where T : IEntityDescriptor, new();
  47. EntityComponentInitializer BuildEntity<T>(EGID egid, IEnumerable<object> implementors = null)
  48. where T : IEntityDescriptor, new();
  49. EntityComponentInitializer BuildEntity<T>(uint entityID, BuildGroup groupStructId,
  50. T descriptorEntity, IEnumerable<object> implementors = null)
  51. where T : IEntityDescriptor;
  52. EntityComponentInitializer BuildEntity<T>(EGID egid, T entityDescriptor, IEnumerable<object> implementors = null)
  53. where T : IEntityDescriptor;
  54. EntityComponentInitializer BuildEntity
  55. (EGID egid, IComponentBuilder[] componentsToBuild, Type type, IEnumerable<object> implementors = null);
  56. #if UNITY_NATIVE
  57. NativeEntityFactory ToNative<T>(string memberName) where T : IEntityDescriptor, new();
  58. #endif
  59. }
  60. }