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.

55 lines
2.8KB

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