Explorar el Código

1.增加IScene接口,只要继承了IScene,就代表这是一个Scene,很多地方得到了简化
2.publish事件第一个参数是范型Scene,必须实现IScene接口
3.domain也必须是IScene
4.LSScene实现IScene接口

tanghai hace 2 años
padre
commit
340bd6a998
Se han modificado 34 ficheros con 67 adiciones y 110 borrados
  1. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs
  2. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LSSceneFactory.cs
  3. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs
  4. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs
  5. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitEnterSightRange_NotifyClient.cs
  6. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitLeaveSightRange_NotifyClient.cs
  7. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Router/HttpGetRouterHandler.cs
  8. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetInnerComponentOnReadEvent.cs
  9. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetServerComponentOnReadEvent.cs
  10. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/RoomManagerComponentSystem.cs
  11. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Http/HttpComponentSystem.cs
  12. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/Demo/EntryEvent1_InitShare.cs
  13. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/UnitF/UnitFFactory.cs
  14. 1 1
      Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs
  15. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/EntryEvent3_InitClient.cs
  16. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/AfterCreateClientScene_AddComponent.cs
  17. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/AfterCreateCurrentScene_AddComponent.cs
  18. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/SceneChangeStart_AddComponent.cs
  19. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UIHelp/SceneChangeFinishEvent_CreateUIHelp.cs
  20. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs
  21. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILogin/AppStartInitFinish_CreateLoginUI.cs
  22. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs
  23. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/AfterUnitCreate_CreateUnitView.cs
  24. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/ChangePosition_SyncGameObjectPos.cs
  25. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/ChangeRotation_SyncGameObjectRotation.cs
  26. 2 2
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepAfterUnitCreate_CreateUnitFView.cs
  27. 1 1
      Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs
  28. 1 1
      Unity/Assets/Scripts/Codes/Model/Server/Module/Http/IHttpHandler.cs
  29. 1 1
      Unity/Assets/Scripts/Core/LockStep/LSEntity.cs
  30. 17 46
      Unity/Assets/Scripts/Core/LockStep/LSScene.cs
  31. 10 23
      Unity/Assets/Scripts/Core/Module/Entity/Entity.cs
  32. 2 3
      Unity/Assets/Scripts/Core/Module/Entity/Scene.cs
  33. 4 4
      Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs
  34. 4 4
      Unity/Assets/Scripts/Core/Module/EventSystem/IEvent.cs

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/Demo/Session/NetClientComponentOnReadEvent.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Process)]
-    public class NetClientComponentOnReadEvent: AEvent<NetClientComponentOnRead>
+    public class NetClientComponentOnReadEvent: AEvent<Scene, NetClientComponentOnRead>
     {
         protected override async ETTask Run(Scene scene, NetClientComponentOnRead args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Client/LockStep/LSSceneFactory.cs

@@ -7,7 +7,7 @@ namespace ET.Client
             Scene currentScene = EntitySceneFactory.CreateScene(id, IdGenerater.Instance.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);
             currentScenesComponent.Scene = currentScene;
             BattleComponent battleComponent = currentScene.AddComponent<BattleComponent>();
-            battleComponent.LSScene = new LSScene(1, currentScene.DomainZone(), SceneType.LockStepClient, "LockStepClient");
+            battleComponent.LSScene = new LSScene(SceneType.LockStepClient);
             EventSystem.Instance.Publish(currentScene, new EventType.AfterCreateCurrentScene());
             return currentScene;
         }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/EntryEvent2_InitServer.cs

@@ -3,7 +3,7 @@ using System.Net;
 namespace ET.Server
 {
     [Event(SceneType.Process)]
-    public class EntryEvent2_InitServer: AEvent<ET.EventType.EntryEvent2>
+    public class EntryEvent2_InitServer: AEvent<Scene, ET.EventType.EntryEvent2>
     {
         protected override async ETTask Run(Scene scene, ET.EventType.EntryEvent2 args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/AOI/ChangePosition_NotifyAOI.cs

@@ -3,7 +3,7 @@
 namespace ET.Server
 {
     [Event(SceneType.Map)]
-    public class ChangePosition_NotifyAOI: AEvent<ET.EventType.ChangePosition>
+    public class ChangePosition_NotifyAOI: AEvent<Scene, ET.EventType.ChangePosition>
     {
         protected override async ETTask Run(Scene scene, ET.EventType.ChangePosition args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitEnterSightRange_NotifyClient.cs

@@ -2,7 +2,7 @@
 {
     // 进入视野通知
     [Event(SceneType.Map)]
-    public class UnitEnterSightRange_NotifyClient: AEvent<EventType.UnitEnterSightRange>
+    public class UnitEnterSightRange_NotifyClient: AEvent<Scene, EventType.UnitEnterSightRange>
     {
         protected override async ETTask Run(Scene scene, EventType.UnitEnterSightRange args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Map/Unit/UnitLeaveSightRange_NotifyClient.cs

@@ -2,7 +2,7 @@
 {
     // 离开视野
     [Event(SceneType.Map)]
-    public class UnitLeaveSightRange_NotifyClient: AEvent<EventType.UnitLeaveSightRange>
+    public class UnitLeaveSightRange_NotifyClient: AEvent<Scene, EventType.UnitLeaveSightRange>
     {
         protected override async ETTask Run(Scene scene, EventType.UnitLeaveSightRange args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Scenes/Router/HttpGetRouterHandler.cs

@@ -8,7 +8,7 @@ namespace ET.Server
     [HttpHandler(SceneType.RouterManager, "/get_router")]
     public class HttpGetRouterHandler : IHttpHandler
     {
-        public async ETTask Handle(Entity domain, HttpListenerContext context)
+        public async ETTask Handle(Scene scene, HttpListenerContext context)
         {
             HttpGetRouterResponse response = new HttpGetRouterResponse();
             response.Realms = new List<string>();

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetInnerComponentOnReadEvent.cs

@@ -3,7 +3,7 @@
 namespace ET.Server
 {
     [Event(SceneType.Process)]
-    public class NetInnerComponentOnReadEvent: AEvent<NetInnerComponentOnRead>
+    public class NetInnerComponentOnReadEvent: AEvent<Scene, NetInnerComponentOnRead>
     {
         protected override async ETTask Run(Scene scene, NetInnerComponentOnRead args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Demo/Session/NetServerComponentOnReadEvent.cs

@@ -1,7 +1,7 @@
 namespace ET.Server
 {
     [Event(SceneType.Process)]
-    public class NetServerComponentOnReadEvent: AEvent<NetServerComponentOnRead>
+    public class NetServerComponentOnReadEvent: AEvent<Scene, NetServerComponentOnRead>
     {
         protected override async ETTask Run(Scene scene, NetServerComponentOnRead args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/LockStep/Map/RoomManagerComponentSystem.cs

@@ -14,7 +14,7 @@ namespace ET.Server
             
             scene.AddComponent<RoomServerComponent, Match2Map_GetRoom>(request);
             BattleComponent battleComponent = scene.AddComponent<BattleComponent>();
-            battleComponent.LSScene = new LSScene(1, scene.DomainZone(), SceneType.LockStepClient, "LockStepServer");
+            battleComponent.LSScene = new LSScene(SceneType.LockStepClient);
             return scene;
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Server/Module/Http/HttpComponentSystem.cs

@@ -117,7 +117,7 @@ namespace ET.Server
                 IHttpHandler handler;
                 if (self.dispatcher.TryGetValue(context.Request.Url.AbsolutePath, out handler))
                 {
-                    await handler.Handle(self.Domain, context);
+                    await handler.Handle(self.DomainScene(), context);
                 }
             }
             catch (Exception e)

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Demo/EntryEvent1_InitShare.cs

@@ -1,7 +1,7 @@
 namespace ET
 {
     [Event(SceneType.Process)]
-    public class EntryEvent1_InitShare: AEvent<EventType.EntryEvent1>
+    public class EntryEvent1_InitShare: AEvent<Scene, EventType.EntryEvent1>
     {
         protected override async ETTask Run(Scene scene, EventType.EntryEvent1 args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/LockStep/UnitF/UnitFFactory.cs

@@ -2,7 +2,7 @@
 {
     public static class UnitFFactory
     {
-        public static UnitF Init(Scene lsScene, LockStepUnitInfo unitInfo)
+        public static UnitF Init(LSScene lsScene, LockStepUnitInfo unitInfo)
         {
 	        UnitFComponent unitComponent = lsScene.AddComponent<UnitFComponent>();
 	        UnitF unit = unitComponent.AddChildWithId<UnitF>(unitInfo.PlayerId);

+ 1 - 1
Unity/Assets/Scripts/Codes/Hotfix/Share/Module/Numeric/NumericChangeEvent_NotifyWatcher.cs

@@ -2,7 +2,7 @@
 {
 	// 分发数值监听
 	[Event(SceneType.All)]  // 服务端Map需要分发, 客户端CurrentScene也要分发
-	public class NumericChangeEvent_NotifyWatcher: AEvent<EventType.NumbericChange>
+	public class NumericChangeEvent_NotifyWatcher: AEvent<Scene, EventType.NumbericChange>
 	{
 		protected override async ETTask Run(Scene scene, EventType.NumbericChange args)
 		{

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/EntryEvent3_InitClient.cs

@@ -4,7 +4,7 @@ using System.IO;
 namespace ET.Client
 {
     [Event(SceneType.Process)]
-    public class EntryEvent3_InitClient: AEvent<ET.EventType.EntryEvent3>
+    public class EntryEvent3_InitClient: AEvent<Scene, ET.EventType.EntryEvent3>
     {
         protected override async ETTask Run(Scene scene, ET.EventType.EntryEvent3 args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/AfterCreateClientScene_AddComponent.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Client)]
-    public class AfterCreateClientScene_AddComponent: AEvent<EventType.AfterCreateClientScene>
+    public class AfterCreateClientScene_AddComponent: AEvent<Scene, EventType.AfterCreateClientScene>
     {
         protected override async ETTask Run(Scene scene, EventType.AfterCreateClientScene args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/AfterCreateCurrentScene_AddComponent.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Current)]
-    public class AfterCreateCurrentScene_AddComponent: AEvent<EventType.AfterCreateCurrentScene>
+    public class AfterCreateCurrentScene_AddComponent: AEvent<Scene, EventType.AfterCreateCurrentScene>
     {
         protected override async ETTask Run(Scene scene, EventType.AfterCreateCurrentScene args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Scene/SceneChangeStart_AddComponent.cs

@@ -3,7 +3,7 @@ using UnityEngine.SceneManagement;
 namespace ET.Client
 {
     [Event(SceneType.Client)]
-    public class SceneChangeStart_AddComponent: AEvent<EventType.SceneChangeStart>
+    public class SceneChangeStart_AddComponent: AEvent<Scene, EventType.SceneChangeStart>
     {
         protected override async ETTask Run(Scene scene, EventType.SceneChangeStart args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UIHelp/SceneChangeFinishEvent_CreateUIHelp.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Current)]
-    public class SceneChangeFinishEvent_CreateUIHelp : AEvent<EventType.SceneChangeFinish>
+    public class SceneChangeFinishEvent_CreateUIHelp : AEvent<Scene, EventType.SceneChangeFinish>
     {
         protected override async ETTask Run(Scene scene, EventType.SceneChangeFinish args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILobby/LoginFinish_CreateLobbyUI.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
 	[Event(SceneType.Client)]
-	public class LoginFinish_CreateLobbyUI: AEvent<EventType.LoginFinish>
+	public class LoginFinish_CreateLobbyUI: AEvent<Scene, EventType.LoginFinish>
 	{
 		protected override async ETTask Run(Scene scene, EventType.LoginFinish args)
 		{

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILogin/AppStartInitFinish_CreateLoginUI.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
 	[Event(SceneType.Client)]
-	public class AppStartInitFinish_CreateLoginUI: AEvent<EventType.AppStartInitFinish>
+	public class AppStartInitFinish_CreateLoginUI: AEvent<Scene, EventType.AppStartInitFinish>
 	{
 		protected override async ETTask Run(Scene scene, EventType.AppStartInitFinish args)
 		{

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/UI/UILogin/LoginFinish_RemoveLoginUI.cs

@@ -1,7 +1,7 @@
 namespace ET.Client
 {
 	[Event(SceneType.Client)]
-	public class LoginFinish_RemoveLoginUI: AEvent<EventType.LoginFinish>
+	public class LoginFinish_RemoveLoginUI: AEvent<Scene, EventType.LoginFinish>
 	{
 		protected override async ETTask Run(Scene scene, EventType.LoginFinish args)
 		{

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/AfterUnitCreate_CreateUnitView.cs

@@ -3,7 +3,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Current)]
-    public class AfterUnitCreate_CreateUnitView: AEvent<EventType.AfterUnitCreate>
+    public class AfterUnitCreate_CreateUnitView: AEvent<Scene, EventType.AfterUnitCreate>
     {
         protected override async ETTask Run(Scene scene, EventType.AfterUnitCreate args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/ChangePosition_SyncGameObjectPos.cs

@@ -3,7 +3,7 @@
 namespace ET.Client
 {
     [Event(SceneType.Current)]
-    public class ChangePosition_SyncGameObjectPos: AEvent<EventType.ChangePosition>
+    public class ChangePosition_SyncGameObjectPos: AEvent<Scene, EventType.ChangePosition>
     {
         protected override async ETTask Run(Scene scene, EventType.ChangePosition args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/Demo/Unit/ChangeRotation_SyncGameObjectRotation.cs

@@ -3,7 +3,7 @@ using UnityEngine;
 namespace ET.Client
 {
     [Event(SceneType.Current)]
-    public class ChangeRotation_SyncGameObjectRotation: AEvent<EventType.ChangeRotation>
+    public class ChangeRotation_SyncGameObjectRotation: AEvent<Scene, EventType.ChangeRotation>
     {
         protected override async ETTask Run(Scene scene, EventType.ChangeRotation args)
         {

+ 2 - 2
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepAfterUnitCreate_CreateUnitFView.cs

@@ -4,9 +4,9 @@ using UnityEngine;
 namespace ET.Client
 {
     [Event(SceneType.LockStepClient)]
-    public class LockStepAfterUnitCreate_CreateUnitFView: AEvent<LSAfterUnitCreate>
+    public class LockStepAfterUnitCreate_CreateUnitFView: AEvent<LSScene, LSAfterUnitCreate>
     {
-        protected override async ETTask Run(Scene lsScene, LSAfterUnitCreate args)
+        protected override async ETTask Run(LSScene lsScene, LSAfterUnitCreate args)
         {
             Scene currentScene = lsScene.Parent.DomainScene();
             UnitFViewComponent unitFViewComponent = currentScene.GetComponent<UnitFViewComponent>();

+ 1 - 1
Unity/Assets/Scripts/Codes/HotfixView/Client/LockStep/LockStepSceneChangeStart_AddComponent.cs

@@ -3,7 +3,7 @@ using UnityEngine.SceneManagement;
 namespace ET.Client
 {
     [Event(SceneType.Client)]
-    public class LockStepSceneChangeStart_AddComponent: AEvent<EventType.LockStepSceneChangeStart>
+    public class LockStepSceneChangeStart_AddComponent: AEvent<Scene, EventType.LockStepSceneChangeStart>
     {
         protected override async ETTask Run(Scene clientScene, EventType.LockStepSceneChangeStart args)
         {

+ 1 - 1
Unity/Assets/Scripts/Codes/Model/Server/Module/Http/IHttpHandler.cs

@@ -4,6 +4,6 @@ namespace ET.Server
 {
     public interface IHttpHandler
     {
-        ETTask Handle(Entity domain, HttpListenerContext context);
+        ETTask Handle(Scene domain, HttpListenerContext context);
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Core/LockStep/LSEntity.cs

@@ -44,7 +44,7 @@ namespace ET
             return this.AddChildWithId<T, A, B, C>(this.GetId(), a, b, c, isFromPool);
         }
 
-        public override Entity Domain
+        public override IScene Domain
         {
             get
             {

+ 17 - 46
Unity/Assets/Scripts/Core/LockStep/LSScene.cs

@@ -7,6 +7,15 @@ namespace ET
 {
     public static class LSSceneSystem
     {
+        [ObjectSystem]
+        public class LSSceneAwakeSystem: AwakeSystem<LSScene>
+        {
+            protected override void Awake(LSScene self)
+            {
+                self.Updater.Parent = self;
+            }
+        }
+        
         public class DeserializeSystem: DeserializeSystem<LSScene>
         {
             protected override void Deserialize(LSScene self)
@@ -33,62 +42,22 @@ namespace ET
 
     [EnableMethod]
     [ChildOf]
-    public class LSScene: Scene, IDeserialize
+    public class LSScene: LSEntity, IAwake, IScene, IDeserialize
     {
         public LSScene()
         {
         }
         
-        public LSScene(long id, int zone, SceneType sceneType, string name): base(id, IdGenerater.Instance.GenerateInstanceId(), zone, sceneType, name)
+        public LSScene(SceneType sceneType)
         {
+            this.Id = this.GetId();
+
+            this.SceneType = sceneType;
+            
             this.Updater.Parent = this;
             
             Log.Info($"LSScene create: {this.Id} {this.InstanceId}");
         }
-
-        #region AddComponent And AddChild
-
-        public new K AddComponent<K>(bool isFromPool = false) where K : LSEntity, IAwake, new()
-        {
-            return this.AddComponentWithId<K>(this.GetId(), isFromPool);
-        }
-
-        public new K AddComponent<K, P1>(P1 p1, bool isFromPool = false) where K : LSEntity, IAwake<P1>, new()
-        {
-            return this.AddComponentWithId<K, P1>(this.GetId(), p1, isFromPool);
-        }
-
-        public new K AddComponent<K, P1, P2>(P1 p1, P2 p2, bool isFromPool = false) where K : LSEntity, IAwake<P1, P2>, new()
-        {
-            return this.AddComponentWithId<K, P1, P2>(this.GetId(), p1, p2, isFromPool);
-        }
-
-        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()
-        {
-            return this.AddComponentWithId<K, P1, P2, P3>(this.GetId(), p1, p2, p3, isFromPool);
-        }
-
-        public new T AddChild<T>(bool isFromPool = false) where T : LSEntity, IAwake
-        {
-            return this.AddChildWithId<T>(this.GetId(), isFromPool);
-        }
-
-        public new T AddChild<T, A>(A a, bool isFromPool = false) where T : LSEntity, IAwake<A>
-        {
-            return this.AddChildWithId<T, A>(this.GetId(), a, isFromPool);
-        }
-
-        public new T AddChild<T, A, B>(A a, B b, bool isFromPool = false) where T : LSEntity, IAwake<A, B>
-        {
-            return this.AddChildWithId<T, A, B>(this.GetId(), a, b, isFromPool);
-        }
-
-        public new T AddChild<T, A, B, C>(A a, B b, C c, bool isFromPool = false) where T : LSEntity, IAwake<A, B, C>
-        {
-            return this.AddChildWithId<T, A, B, C>(this.GetId(), a, b, c, isFromPool);
-        }
-
-        #endregion
         
         private readonly Dictionary<long, LSEntity> allLSEntities = new();
 
@@ -133,5 +102,7 @@ namespace ET
         }
 
         public TSRandom Random { get; set; }
+        
+        public SceneType SceneType { get; set; }
     }
 }

+ 10 - 23
Unity/Assets/Scripts/Core/Module/Entity/Entity.cs

@@ -13,7 +13,11 @@ namespace ET
         IsComponent = 1 << 2,
         IsCreated = 1 << 3,
         IsNew = 1 << 4,
-        IsScene = 1 << 5,
+    }
+
+    public interface IScene
+    {
+        SceneType SceneType { get; set; }
     }
 
     public partial class Entity: DisposeObject
@@ -48,23 +52,6 @@ namespace ET
                 }
             }
         }
-        
-        [BsonIgnore]
-        protected bool IsScene
-        {
-            get => (this.status & EntityStatus.IsScene) == EntityStatus.IsScene;
-            set
-            {
-                if (value)
-                {
-                    this.status |= EntityStatus.IsScene;
-                }
-                else
-                {
-                    this.status &= ~EntityStatus.IsScene;
-                }
-            }
-        }
 
         [BsonIgnore]
         protected bool IsRegister
@@ -216,7 +203,7 @@ namespace ET
                 this.IsComponent = false;
                 this.parent.AddToChildren(this);
 
-                this.Domain = this.IsScene? this : this.parent.domain;
+                this.Domain = this is IScene? this as IScene : this.parent.domain;
 
 #if ENABLE_VIEW && UNITY_EDITOR
                 this.viewGO.GetComponent<ComponentView>().Component = this;
@@ -284,13 +271,13 @@ namespace ET
         [BsonDefaultValue(0L)]
         [BsonElement]
         [BsonId]
-        public long Id { get; set; }
+        public long Id { get; protected set; }
 
         [BsonIgnore]
-        protected Entity domain;
+        protected IScene domain;
 
         [BsonIgnore]
-        public virtual Entity Domain
+        public virtual IScene Domain
         {
             get
             {
@@ -308,7 +295,7 @@ namespace ET
                     return;
                 }
 
-                Entity preDomain = this.domain;
+                IScene preDomain = this.domain;
                 this.domain = value;
 
                 if (preDomain == null)

+ 2 - 3
Unity/Assets/Scripts/Core/Module/Entity/Scene.cs

@@ -4,7 +4,7 @@ namespace ET
 {
     [EnableMethod]
     [ChildOf]
-    public class Scene: Entity
+    public class Scene: Entity, IScene
     {
         public int Zone
         {
@@ -14,6 +14,7 @@ namespace ET
         public SceneType SceneType
         {
             get;
+            set;
         }
 
         public string Name
@@ -23,7 +24,6 @@ namespace ET
 
         public Scene()
         {
-            
         }
 
         public Scene(long id, long instanceId, int zone, SceneType sceneType, string name)
@@ -35,7 +35,6 @@ namespace ET
             this.Name = name;
             this.IsCreated = true;
             this.IsNew = true;
-            this.IsScene = true;
             this.IsRegister = true;
             this.domain = this;
             Log.Info($"scene create: {this.SceneType} {this.Name} {this.Id} {this.InstanceId} {this.Zone}");

+ 4 - 4
Unity/Assets/Scripts/Core/Module/EventSystem/EventSystem.cs

@@ -597,7 +597,7 @@ namespace ET
             }
         }
 
-        public async ETTask PublishAsync<T>(Scene scene, T a) where T : struct
+        public async ETTask PublishAsync<S, T>(S scene, T a) where S: class, IScene where T : struct
         {
             List<EventInfo> iEvents;
             if (!this.allEvents.TryGetValue(typeof(T), out iEvents))
@@ -614,7 +614,7 @@ namespace ET
                     continue;
                 }
                     
-                if (!(eventInfo.IEvent is AEvent<T> aEvent))
+                if (!(eventInfo.IEvent is AEvent<S, T> aEvent))
                 {
                     Log.Error($"event error: {eventInfo.IEvent.GetType().Name}");
                     continue;
@@ -633,7 +633,7 @@ namespace ET
             }
         }
 
-        public void Publish<T>(Scene scene, T a) where T : struct
+        public void Publish<S, T>(S scene, T a) where S: class, IScene where T : struct
         {
             List<EventInfo> iEvents;
             if (!this.allEvents.TryGetValue(typeof (T), out iEvents))
@@ -650,7 +650,7 @@ namespace ET
                 }
 
                 
-                if (!(eventInfo.IEvent is AEvent<T> aEvent))
+                if (!(eventInfo.IEvent is AEvent<S, T> aEvent))
                 {
                     Log.Error($"event error: {eventInfo.IEvent.GetType().Name}");
                     continue;

+ 4 - 4
Unity/Assets/Scripts/Core/Module/EventSystem/IEvent.cs

@@ -7,7 +7,7 @@ namespace ET
 		Type Type { get; }
 	}
 	
-	public abstract class AEvent<A>: IEvent where A: struct
+	public abstract class AEvent<S, A>: IEvent where S: class, IScene where A: struct
 	{
 		public Type Type
 		{
@@ -17,13 +17,13 @@ namespace ET
 			}
 		}
 
-		protected abstract ETTask Run(Scene scene, A a);
+		protected abstract ETTask Run(S scene, A a);
 
-		public async ETTask Handle(Scene scene, A a)
+		public async ETTask Handle(IScene scene, A a)
 		{
 			try
 			{
-				await Run(scene, a);
+				await Run(scene as S, a);
 			}
 			catch (Exception e)
 			{