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.

28 lines
921B

  1. using System;
  2. namespace Svelto.ECS
  3. {
  4. public class GenericEntityDescriptorHolder<T, I>: UnityEngine.MonoBehaviour, IEntityDescriptorHolder where T:EntityDescriptor
  5. {
  6. public EntityDescriptor BuildDescriptorType(object[] externalImplentors)
  7. {
  8. I[] implementors;
  9. if (externalImplentors != null)
  10. {
  11. I[] baseImplentors = gameObject.GetComponents<I>();
  12. implementors = new I[externalImplentors.Length + baseImplentors.Length];
  13. Array.Copy(baseImplentors, implementors, baseImplentors.Length);
  14. Array.Copy(externalImplentors, 0, implementors, baseImplentors.Length, externalImplentors.Length);
  15. }
  16. else
  17. {
  18. implementors = gameObject.GetComponents<I>();
  19. }
  20. return (T)Activator.CreateInstance(typeof(T), implementors);
  21. }
  22. }
  23. }