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