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.

SveltoOnDOTSHandleCreationEngine.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. #if UNITY_ECS
  2. using System;
  3. using System.Runtime.CompilerServices;
  4. using Unity.Entities;
  5. using Unity.Jobs;
  6. namespace Svelto.ECS.SveltoOnDOTS
  7. {
  8. /// <summary>
  9. /// SubmissionEngine is a dedicated DOTS ECS Svelto.ECS engine that allows using the DOTS ECS
  10. /// EntityCommandBuffer for fast creation of DOTS entities
  11. /// </summary>
  12. public abstract class SveltoOnDOTSHandleCreationEngine
  13. {
  14. protected EntityCommandBufferForSvelto ECB { get; private set; }
  15. protected internal EntityManager entityManager
  16. {
  17. // [Obsolete(
  18. // "<color=orange>Attention: the use of EntityManager directly is deprecated. ECB MUST BE USED INSTEAD</color>")]
  19. get;
  20. internal set;
  21. }
  22. internal EntityCommandBufferForSvelto entityCommandBuffer
  23. {
  24. set => ECB = value;
  25. }
  26. protected EntityArchetype CreateArchetype(params ComponentType[] types)
  27. {
  28. return entityManager.CreateArchetype(types);
  29. }
  30. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  31. protected Entity CreateDOTSEntityOnSvelto(Entity entityComponentPrefabEntity, EGID egid,
  32. bool mustHandleDOTSComponent)
  33. {
  34. return ECB.CreateDOTSEntityOnSvelto(entityComponentPrefabEntity, egid, mustHandleDOTSComponent);
  35. }
  36. [MethodImpl(MethodImplOptions.AggressiveInlining)]
  37. protected Entity CreateDOTSEntityOnSvelto(EntityArchetype archetype, EGID egid, bool mustHandleDOTSComponent)
  38. {
  39. return ECB.CreateDOTSEntityOnSvelto(archetype, egid, mustHandleDOTSComponent);
  40. }
  41. protected internal virtual void OnCreate()
  42. {
  43. }
  44. protected internal virtual JobHandle OnUpdate()
  45. {
  46. return default;
  47. }
  48. public abstract string name { get; }
  49. }
  50. }
  51. #endif