Scene.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. using System.Diagnostics;
  2. namespace ET
  3. {
  4. [EnableMethod]
  5. [DebuggerDisplay("ViewName,nq")]
  6. [ChildOf]
  7. public sealed class Scene: Entity
  8. {
  9. public int Zone
  10. {
  11. get;
  12. }
  13. public SceneType SceneType
  14. {
  15. get;
  16. }
  17. public string Name
  18. {
  19. get;
  20. }
  21. public Scene(long instanceId, int zone, SceneType sceneType, string name, Entity parent)
  22. {
  23. this.Id = instanceId;
  24. this.InstanceId = instanceId;
  25. this.Zone = zone;
  26. this.SceneType = sceneType;
  27. this.Name = name;
  28. this.IsCreated = true;
  29. this.IsNew = true;
  30. this.Parent = parent;
  31. this.Domain = this;
  32. this.IsRegister = true;
  33. Log.Info($"scene create: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
  34. }
  35. public Scene(long id, long instanceId, int zone, SceneType sceneType, string name, Entity parent)
  36. {
  37. this.Id = id;
  38. this.InstanceId = instanceId;
  39. this.Zone = zone;
  40. this.SceneType = sceneType;
  41. this.Name = name;
  42. this.IsCreated = true;
  43. this.IsNew = true;
  44. this.Parent = parent;
  45. this.Domain = this;
  46. this.IsRegister = true;
  47. Log.Info($"scene create: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
  48. }
  49. public override void Dispose()
  50. {
  51. base.Dispose();
  52. Log.Info($"scene dispose: sceneType={this.SceneType}, name={this.Name}, id={this.Id}, instanceId={this.InstanceId}, zone={this.Zone}");
  53. }
  54. public new Entity Domain
  55. {
  56. get => this.domain;
  57. private set => this.domain = value;
  58. }
  59. public new Entity Parent
  60. {
  61. get
  62. {
  63. return this.parent;
  64. }
  65. private set
  66. {
  67. if (value == null)
  68. {
  69. //this.parent = this;
  70. return;
  71. }
  72. this.parent = value;
  73. this.parent.Children.Add(this.Id, this);
  74. }
  75. }
  76. protected override string ViewName
  77. {
  78. get
  79. {
  80. return $"{this.GetType().Name} ({this.SceneType})";
  81. }
  82. }
  83. }
  84. }