Mirror of Svelto.ECS because we're a fan of it
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

61 řádky
1.7KB

  1. #if UNITY_ECS
  2. using Unity.Entities;
  3. namespace Svelto.ECS.SveltoOnDOTS
  4. {
  5. /// <summary>
  6. /// If for some reason the user needs the DOTS entities to be grouped like the Svelto Entities, then this descriptor can be extended
  7. /// which will automatically enable the SveltoOnDOTSHandleLifeTimeEngine synchronization.
  8. /// This will also handle entities destruction.
  9. /// </summary>
  10. public class SveltoOnDotsSynchedEntityDescriptor: GenericEntityDescriptor<DOTSEntityComponent> { }
  11. public interface IEntityComponentForDOTS: IEntityComponent
  12. {
  13. public Entity dotsEntity { get; set; }
  14. }
  15. public struct DOTSEntityComponent:IEntityComponentForDOTS
  16. {
  17. public DOTSEntityComponent(Entity entity)
  18. {
  19. dotsEntity = entity;
  20. }
  21. public Entity dotsEntity { get; set; }
  22. }
  23. //DOTS COMPONENTS:
  24. /// <summary>
  25. /// DOTS component to keep track of the associated Svelto.ECS entity
  26. /// </summary>
  27. public struct DOTSSveltoReference: IComponentData
  28. {
  29. public EntityReference entityReference;
  30. public DOTSSveltoReference(EntityReference eEntityReference)
  31. {
  32. entityReference = eEntityReference;
  33. }
  34. }
  35. /// <summary>
  36. /// DOTS component to be able to query all the DOTS entities found in a Svelto.ECS group
  37. /// </summary>
  38. public readonly struct DOTSSveltoGroupID: ISharedComponentData
  39. {
  40. readonly ExclusiveGroupStruct group;
  41. public DOTSSveltoGroupID(ExclusiveGroupStruct exclusiveGroup)
  42. {
  43. @group = exclusiveGroup;
  44. }
  45. public static implicit operator ExclusiveGroupStruct(DOTSSveltoGroupID group)
  46. {
  47. return group.@group;
  48. }
  49. }
  50. }
  51. #endif