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.

37 lines
1.4KB

  1. using System;
  2. using Svelto.DataStructures;
  3. namespace Svelto.ECS
  4. {
  5. public struct DynamicEntityDescriptorInfo<TType>:IEntityDescriptor where TType : IEntityDescriptor, new()
  6. {
  7. public DynamicEntityDescriptorInfo(FasterList<IEntityBuilder> extraEntities) : this()
  8. {
  9. DBC.ECS.Check.Require(extraEntities.Count > 0,
  10. "don't use a DynamicEntityDescriptorInfo if you don't need to use extra EntityViews");
  11. var defaultEntities = EntityDescriptorTemplate<TType>.descriptor.entitiesToBuild;
  12. var length = defaultEntities.Length;
  13. entitiesToBuild = new IEntityBuilder[length + extraEntities.Count + 1];
  14. Array.Copy(defaultEntities, 0, entitiesToBuild, 0, length);
  15. Array.Copy(extraEntities.ToArrayFast(), 0, entitiesToBuild, length, extraEntities.Count);
  16. var _builder = new EntityBuilder<EntityInfoView>
  17. {
  18. _initializer = new EntityInfoView { entitiesToBuild = entitiesToBuild }
  19. };
  20. entitiesToBuild[entitiesToBuild.Length - 1] = _builder;
  21. }
  22. public IEntityBuilder[] entitiesToBuild { get; private set; }
  23. }
  24. public struct EntityInfoView : IEntityStruct
  25. {
  26. public EGID ID { get; set; }
  27. public IEntityBuilder[] entitiesToBuild;
  28. }
  29. }