LSEntity.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using System;
  2. namespace ET
  3. {
  4. public class LSEntity: Entity
  5. {
  6. public new K AddComponent<K>(bool isFromPool = false) where K : LSEntity, IAwake, new()
  7. {
  8. return this.AddComponentWithId<K>(this.GetId(), isFromPool);
  9. }
  10. public new K AddComponent<K, P1>(P1 p1, bool isFromPool = false) where K : LSEntity, IAwake<P1>, new()
  11. {
  12. return this.AddComponentWithId<K, P1>(this.GetId(), p1, isFromPool);
  13. }
  14. public new K AddComponent<K, P1, P2>(P1 p1, P2 p2, bool isFromPool = false) where K : LSEntity, IAwake<P1, P2>, new()
  15. {
  16. return this.AddComponentWithId<K, P1, P2>(this.GetId(), p1, p2, isFromPool);
  17. }
  18. public new K AddComponent<K, P1, P2, P3>(P1 p1, P2 p2, P3 p3, bool isFromPool = false) where K : LSEntity, IAwake<P1, P2, P3>, new()
  19. {
  20. return this.AddComponentWithId<K, P1, P2, P3>(this.GetId(), p1, p2, p3, isFromPool);
  21. }
  22. public new T AddChild<T>(bool isFromPool = false) where T : LSEntity, IAwake
  23. {
  24. return this.AddChildWithId<T>(this.GetId(), isFromPool);
  25. }
  26. public new T AddChild<T, A>(A a, bool isFromPool = false) where T : LSEntity, IAwake<A>
  27. {
  28. return this.AddChildWithId<T, A>(this.GetId(), a, isFromPool);
  29. }
  30. public new T AddChild<T, A, B>(A a, B b, bool isFromPool = false) where T : LSEntity, IAwake<A, B>
  31. {
  32. return this.AddChildWithId<T, A, B>(this.GetId(), a, b, isFromPool);
  33. }
  34. public new T AddChild<T, A, B, C>(A a, B b, C c, bool isFromPool = false) where T : LSEntity, IAwake<A, B, C>
  35. {
  36. return this.AddChildWithId<T, A, B, C>(this.GetId(), a, b, c, isFromPool);
  37. }
  38. public override void Dispose()
  39. {
  40. base.Dispose();
  41. this.Id = 0;
  42. }
  43. public override IScene Domain
  44. {
  45. get
  46. {
  47. return this.domain;
  48. }
  49. protected set
  50. {
  51. bool oldIsRegister = this.IsRegister;
  52. base.Domain = value;
  53. bool newIsRegister = this.IsRegister;
  54. if (oldIsRegister == newIsRegister)
  55. {
  56. return;
  57. }
  58. LSWorld lsWorld = this.DomainScene();
  59. if (newIsRegister)
  60. {
  61. lsWorld.RegisterSystem(this);
  62. }
  63. }
  64. }
  65. }
  66. }