Ver código fonte

VProcess改成Entity

tanghai 2 anos atrás
pai
commit
f524f9308c
67 arquivos alterados com 169 adições e 1330 exclusões
  1. 0 1
      Unity/Assets/Scripts/Core/MainVProcessInit.cs
  2. 0 7
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonAwake.cs
  3. 0 11
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonAwake.cs.meta
  4. 0 7
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLateUpdate.cs
  5. 0 11
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLateUpdate.cs.meta
  6. 0 7
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLoad.cs
  7. 0 11
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLoad.cs.meta
  8. 0 7
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonUpdate.cs
  9. 0 11
      Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonUpdate.cs.meta
  10. 2 1
      Unity/Assets/Scripts/Core/VProcess/Module/CoroutineLock/CoroutineLockComponent.cs
  11. 52 33
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/Entity.cs
  12. 2 7
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/EntityHelper.cs
  13. 2 2
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/EntitySceneFactory.cs
  14. 0 1
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/IScene.cs
  15. 0 32
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/Root.cs
  16. 0 11
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/Root.cs.meta
  17. 13 0
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/SingletonEntity.cs
  18. 3 0
      Unity/Assets/Scripts/Core/VProcess/Module/Entity/SingletonEntity.cs.meta
  19. 1 1
      Unity/Assets/Scripts/Core/VProcess/Module/EntitySystem/EntitySystem.cs
  20. 12 6
      Unity/Assets/Scripts/Core/VProcess/Module/IdGenerater/IdGenerater.cs
  21. 2 2
      Unity/Assets/Scripts/Core/VProcess/Module/Synchronization/MainThreadSynchronizationContext.cs
  22. 4 4
      Unity/Assets/Scripts/Core/VProcess/Module/Time/TimeHelper.cs
  23. 3 3
      Unity/Assets/Scripts/Core/VProcess/Module/Time/TimeInfo.cs
  24. 2 1
      Unity/Assets/Scripts/Core/VProcess/Module/Timer/TimerComponent.cs
  25. 5 4
      Unity/Assets/Scripts/Core/VProcess/Module/VProcessActor/VProcessActor.cs
  26. 25 164
      Unity/Assets/Scripts/Core/VProcess/VProcess.cs
  27. 0 48
      Unity/Assets/Scripts/Core/VProcess/VProcessSingleton.cs
  28. 0 11
      Unity/Assets/Scripts/Core/VProcess/VProcessSingleton.cs.meta
  29. 3 2
      Unity/Assets/Scripts/Core/World/Module/Network/NetServices.cs
  30. 2 6
      Unity/Assets/Scripts/Core/World/Module/VProcess/VProcessManager.cs
  31. 1 1
      Unity/Assets/Scripts/Core/World/Module/WorldActor/WorldActor.cs
  32. 12 7
      Unity/Assets/Scripts/Core/World/World.cs
  33. 0 8
      Unity/Assets/Scripts/Editor/EntityTreeWindow.meta
  34. 0 8
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu.meta
  35. 0 9
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/AEntityMenuHandler.cs
  36. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/AEntityMenuHandler.cs.meta
  37. 0 76
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityContextMenu.cs
  38. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityContextMenu.cs.meta
  39. 0 16
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityMenuAttribute.cs
  40. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityMenuAttribute.cs.meta
  41. 0 15
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/MenuExample.cs
  42. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/MenuExample.cs.meta
  43. 0 8
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity.meta
  44. 0 199
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/EditorLayout.cs
  45. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/EditorLayout.cs.meta
  46. 0 133
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/SerializationTypeExtension.cs
  47. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/SerializationTypeExtension.cs.meta
  48. 0 8
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree.meta
  49. 0 118
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeView.cs
  50. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeView.cs.meta
  51. 0 73
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeViewItem.cs
  52. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeViewItem.cs.meta
  53. 0 114
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeWindow.cs
  54. 0 11
      Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeWindow.cs.meta
  55. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/Ping/PingComponentSystem.cs
  56. 2 2
      Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/SceneFactory.cs
  57. 2 2
      Unity/Assets/Scripts/Hotfix/Server/Demo/EntryEvent2_InitServer.cs
  58. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs
  59. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs
  60. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs
  61. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs
  62. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Robot/RobotCaseSystem.cs
  63. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Demo/EntryEvent1_InitShare.cs
  64. 2 2
      Unity/Assets/Scripts/HotfixView/Client/Demo/EntryEvent3_InitClient.cs
  65. 1 1
      Unity/Assets/Scripts/HotfixView/Client/Demo/Opera/OperaComponentSystem.cs
  66. 1 1
      Unity/Assets/Scripts/Loader/GlobalComponent.cs
  67. 7 10
      Unity/Assets/Scripts/Model/Share/Entry.cs

+ 0 - 1
Unity/Assets/Scripts/Core/MainVProcessInit.cs

@@ -4,7 +4,6 @@
     {
         public static void Init(VProcess vProcess)
         {
-            vProcess.AddSingleton<Root>();
         }
     }
 }

+ 0 - 7
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonAwake.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public interface IVProcessSingletonAwake
-    {
-        void Awake();
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonAwake.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: cdacacdfc7d291048915bfb54ed78d66
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 7
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLateUpdate.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public interface IVProcessSingletonLateUpdate
-    {
-        void LateUpdate();
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLateUpdate.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: fe7050fa85a0c334c9541129261fd210
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 7
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLoad.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public interface IVProcessSingletonLoad
-    {
-        void Load();
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonLoad.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 8383caff721f0c444b146664bb2e0929
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 7
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonUpdate.cs

@@ -1,7 +0,0 @@
-namespace ET
-{
-    public interface IVProcessSingletonUpdate
-    {
-        void Update();
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/IVProcessSingletonUpdate.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 417f1246226376142ae4042a29ac6c3b
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 2 - 1
Unity/Assets/Scripts/Core/VProcess/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -3,7 +3,8 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    public class CoroutineLockComponent: VProcessSingleton<CoroutineLockComponent>, IVProcessSingletonUpdate
+    [ComponentOf(typeof(VProcess))]
+    public class CoroutineLockComponent: SingletonEntity<CoroutineLockComponent>, IAwake
     {
         private readonly Dictionary<int, CoroutineLockQueueType> dictionary = new();
         private readonly Queue<(int, long, int)> nextFrameRun = new Queue<(int, long, int)>();

+ 52 - 33
Unity/Assets/Scripts/Core/VProcess/Module/Entity/Entity.cs

@@ -15,6 +15,16 @@ namespace ET
         IsNew = 1 << 4,
     }
 
+    public interface IEntitySystem
+    {
+        EntitySystem EntitySystem { get; }
+    }
+    
+    public interface IIdGenerater
+    {
+        IdGenerater IdGenerater { get; }
+    }
+
     public partial class Entity: DisposeObject, IPool
     {
 #if ENABLE_VIEW && UNITY_EDITOR
@@ -26,7 +36,8 @@ namespace ET
 
         public ActorId GetActorId()
         {
-            return new ActorId(this.VProcess().Process, this.VProcess().Id, this.InstanceId);
+            VProcess root = this.Root();
+            return new ActorId(root.Process, (int)root.Id, this.InstanceId);
         }
 
         protected Entity()
@@ -94,9 +105,19 @@ namespace ET
             }
         }
 
+        private EntitySystem GetEntitySystem()
+        {
+            return (this.iScene.Root as IEntitySystem).EntitySystem;
+        }
+        
+        private IdGenerater GetIdGenerater()
+        {
+            return (this.iScene.Root as IIdGenerater).IdGenerater;
+        }
+
         protected virtual void RegisterSystem()
         {
-            EntitySystem.Instance.RegisterSystem(this);
+            this.GetEntitySystem().RegisterSystem(this);
         }
 
         protected virtual string ViewName
@@ -206,7 +227,6 @@ namespace ET
                 if (this is IScene scene)
                 {
                     scene.Root = this.parent.iScene.Root;
-                    scene.VProcess = this.parent.iScene.VProcess;
                     this.IScene = scene;
                 }
                 else
@@ -271,7 +291,6 @@ namespace ET
                 if (this is IScene scene)
                 {
                     scene.Root = this.parent.iScene.Root;
-                    scene.VProcess = this.parent.iScene.VProcess;
                     this.IScene = scene;
                 }
                 else
@@ -321,7 +340,7 @@ namespace ET
                 {
                     if (this.InstanceId == 0)
                     {
-                        this.InstanceId = IdGenerater.Instance.GenerateInstanceId();
+                        this.InstanceId = this.GetIdGenerater().GenerateInstanceId();
                     }
 
                     this.IsRegister = true;
@@ -368,7 +387,7 @@ namespace ET
                 if (!this.IsCreated)
                 {
                     this.IsCreated = true;
-                    EntitySystem.Instance.Deserialize(this);
+                    this.GetEntitySystem().Deserialize(this);
                 }
             }
         }
@@ -505,7 +524,7 @@ namespace ET
             // 触发Destroy事件
             if (this is IDestroy)
             {
-                EntitySystem.Instance.Destroy(this);
+                this.GetEntitySystem().Destroy(this);
             }
 
             this.iScene = null;
@@ -665,7 +684,7 @@ namespace ET
             // 如果有IGetComponent接口,则触发GetComponentSystem
             if (this is IGetComponent)
             {
-                EntitySystem.Instance.GetComponent(this, component);
+                this.GetEntitySystem().GetComponent(this, component);
             }
 
             return (K) component;
@@ -687,7 +706,7 @@ namespace ET
             // 如果有IGetComponent接口,则触发GetComponentSystem
             if (this is IGetComponent)
             {
-                EntitySystem.Instance.GetComponent(this, component);
+                this.GetEntitySystem().GetComponent(this, component);
             }
 
             return component;
@@ -724,7 +743,7 @@ namespace ET
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component;
@@ -740,11 +759,11 @@ namespace ET
             Entity component = Create(type, isFromPool);
             component.Id = this.Id;
             component.ComponentParent = this;
-            EntitySystem.Instance.Awake(component);
+            this.GetEntitySystem().Awake(component);
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component;
@@ -761,11 +780,11 @@ namespace ET
             Entity component = Create(type, isFromPool);
             component.Id = id;
             component.ComponentParent = this;
-            EntitySystem.Instance.Awake(component);
+            this.GetEntitySystem().Awake(component);
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component as K;
@@ -782,11 +801,11 @@ namespace ET
             Entity component = Create(type, isFromPool);
             component.Id = id;
             component.ComponentParent = this;
-            EntitySystem.Instance.Awake(component, p1);
+            this.GetEntitySystem().Awake(component, p1);
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component as K;
@@ -803,11 +822,11 @@ namespace ET
             Entity component = Create(type, isFromPool);
             component.Id = id;
             component.ComponentParent = this;
-            EntitySystem.Instance.Awake(component, p1, p2);
+            this.GetEntitySystem().Awake(component, p1, p2);
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component as K;
@@ -824,11 +843,11 @@ namespace ET
             Entity component = Create(type, isFromPool);
             component.Id = id;
             component.ComponentParent = this;
-            EntitySystem.Instance.Awake(component, p1, p2, p3);
+            this.GetEntitySystem().Awake(component, p1, p2, p3);
 
             if (this is IAddComponent)
             {
-                EntitySystem.Instance.AddComponent(this, component);
+                this.GetEntitySystem().AddComponent(this, component);
             }
 
             return component as K;
@@ -864,10 +883,10 @@ namespace ET
         {
             Type type = typeof (T);
             T component = (T) Entity.Create(type, isFromPool);
-            component.Id = IdGenerater.Instance.GenerateId();
+            component.Id = this.GetIdGenerater().GenerateId();
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component);
+            this.GetEntitySystem().Awake(component);
             return component;
         }
 
@@ -875,10 +894,10 @@ namespace ET
         {
             Type type = typeof (T);
             T component = (T) Entity.Create(type, isFromPool);
-            component.Id = IdGenerater.Instance.GenerateId();
+            component.Id = this.GetIdGenerater().GenerateId();
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a);
+            this.GetEntitySystem().Awake(component, a);
             return component;
         }
 
@@ -886,10 +905,10 @@ namespace ET
         {
             Type type = typeof (T);
             T component = (T) Entity.Create(type, isFromPool);
-            component.Id = IdGenerater.Instance.GenerateId();
+            component.Id = this.GetIdGenerater().GenerateId();
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a, b);
+            this.GetEntitySystem().Awake(component, a, b);
             return component;
         }
 
@@ -897,10 +916,10 @@ namespace ET
         {
             Type type = typeof (T);
             T component = (T) Entity.Create(type, isFromPool);
-            component.Id = IdGenerater.Instance.GenerateId();
+            component.Id = this.GetIdGenerater().GenerateId();
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a, b, c);
+            this.GetEntitySystem().Awake(component, a, b, c);
             return component;
         }
 
@@ -910,7 +929,7 @@ namespace ET
             T component = Entity.Create(type, isFromPool) as T;
             component.Id = id;
             component.Parent = this;
-            EntitySystem.Instance.Awake(component);
+            this.GetEntitySystem().Awake(component);
             return component;
         }
 
@@ -921,7 +940,7 @@ namespace ET
             component.Id = id;
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a);
+            this.GetEntitySystem().Awake(component, a);
             return component;
         }
 
@@ -932,7 +951,7 @@ namespace ET
             component.Id = id;
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a, b);
+            this.GetEntitySystem().Awake(component, a, b);
             return component;
         }
 
@@ -943,13 +962,13 @@ namespace ET
             component.Id = id;
             component.Parent = this;
 
-            EntitySystem.Instance.Awake(component, a, b, c);
+            this.GetEntitySystem().Awake(component, a, b, c);
             return component;
         }
 
         public override void BeginInit()
         {
-            EntitySystem.Instance.Serialize(this);
+            this.GetEntitySystem().Serialize(this);
             
             this.componentsDB?.Clear();
             if (this.components != null && this.components.Count != 0)

+ 2 - 7
Unity/Assets/Scripts/Core/VProcess/Module/Entity/EntityHelper.cs

@@ -12,14 +12,9 @@ namespace ET
             return entity.IScene as Scene;
         }
         
-        public static Scene Root(this Entity entity)
+        public static VProcess Root(this Entity entity)
         {
-            return entity.IScene.Root as Scene;
-        }
-        
-        public static VProcess VProcess(this Entity entity)
-        {
-            return entity.IScene.VProcess;
+            return entity.IScene.Root as VProcess;
         }
     }
 }

+ 2 - 2
Unity/Assets/Scripts/Core/VProcess/Module/Entity/EntitySceneFactory.cs

@@ -2,7 +2,7 @@
 {
     public static class EntitySceneFactory
     {
-        public static Scene CreateScene(long id, long instanceId, int zone, SceneType sceneType, string name, Entity parent = null)
+        public static Scene CreateScene(long id, long instanceId, int zone, SceneType sceneType, string name, Entity parent)
         {
             Scene scene = new(id, instanceId, zone, sceneType, name);
             parent?.AddChild(scene);
@@ -11,7 +11,7 @@
 
         public static Scene CreateScene(int zone, SceneType sceneType, string name, Entity parent = null)
         {
-            long instanceId = IdGenerater.Instance.GenerateInstanceId();
+            long instanceId = parent.Root().IdGenerater.GenerateInstanceId();
             Scene scene = new(zone, instanceId, zone, sceneType, name);
             parent?.AddChild(scene);
             return scene;

+ 0 - 1
Unity/Assets/Scripts/Core/VProcess/Module/Entity/IScene.cs

@@ -3,7 +3,6 @@
     public interface IScene
     {
         IScene Root { get; set; }
-        VProcess VProcess { get; set; }
         SceneType SceneType { get; set; }
     }
 }

+ 0 - 32
Unity/Assets/Scripts/Core/VProcess/Module/Entity/Root.cs

@@ -1,32 +0,0 @@
-using System.Collections.Generic;
-
-namespace ET
-{
-    // 管理根部的Scene
-    [EnableMethod]
-    public class Root: VProcessSingleton<Root>
-    {
-        private readonly Dictionary<long, Entity> mailboxEntities = new();
-        
-        public Scene Scene { get; private set; }
-
-        public Root()
-        {
-            this.Scene = EntitySceneFactory.CreateScene(IdGenerater.Instance.GenerateId(), IdGenerater.Instance.GenerateInstanceId(), 0, SceneType.Root, "Root");
-        }
-
-        public override void Dispose()
-        {
-            if (this.IsDisposed)
-            {
-                return;
-            }
-            
-            base.Dispose();
-
-            Scene scene = this.Scene;
-            this.Scene = null;
-            scene.Dispose();
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/Module/Entity/Root.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 0fc9be97bbcd0a04498f9a1792cb09b2
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 13 - 0
Unity/Assets/Scripts/Core/VProcess/Module/Entity/SingletonEntity.cs

@@ -0,0 +1,13 @@
+namespace ET
+{
+    public class SingletonEntity<T>: Entity where T: SingletonEntity<T>
+    {
+        public static T Instance
+        {
+            get
+            {
+                return VProcess.Instance.GetComponent<T>();
+            }
+        }
+    }
+}

+ 3 - 0
Unity/Assets/Scripts/Core/VProcess/Module/Entity/SingletonEntity.cs.meta

@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 937fcae73be34d13ae7946b632e1ab52
+timeCreated: 1687330710

+ 1 - 1
Unity/Assets/Scripts/Core/VProcess/Module/EntitySystem/EntitySystem.cs

@@ -3,7 +3,7 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    public class EntitySystem: VProcessSingleton<EntitySystem>, ISingletonAwake, IVProcessSingletonUpdate, IVProcessSingletonLateUpdate, IVProcessSingletonLoad
+    public class EntitySystem
     {
         private readonly Queue<EntityRef<Entity>>[] queues = new Queue<EntityRef<Entity>>[InstanceQueueIndex.Max];
         

+ 12 - 6
Unity/Assets/Scripts/Core/VProcess/Module/IdGenerater/IdGenerater.cs

@@ -62,7 +62,7 @@ namespace ET
 
         public InstanceIdStruct(uint time, uint value)
         {
-            this.Time = (uint)time;
+            this.Time = time;
             this.Value = value;
         }
 
@@ -80,7 +80,7 @@ namespace ET
         }
     }
 
-    public class IdGenerater: VProcessSingleton<IdGenerater>
+    public class IdGenerater
     {
         public const int MaxZone = 1024;
         
@@ -88,14 +88,20 @@ namespace ET
         public const int Mask30bit = 0x3fffffff;
         public const int Mask20bit = 0xfffff;
         
-        private long epoch2022;
+        private readonly long epoch2022;
         private uint value;
         private uint lastIdTime;
+
+        private readonly TimeInfo timeInfo;
+        private readonly int process;
         
         private uint instanceIdValue;
         
-        public IdGenerater()
+        public IdGenerater(int process, TimeInfo timeInfo)
         {
+            this.process = process;
+            this.timeInfo = timeInfo;
+            
             long epoch1970tick = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks / 10000;
             this.epoch2022 = new DateTime(2022, 1, 1, 0, 0, 0, DateTimeKind.Utc).Ticks / 10000 - epoch1970tick;
             this.lastIdTime = TimeSince2022();
@@ -108,7 +114,7 @@ namespace ET
 
         private uint TimeSince2022()
         {
-            uint a = (uint)((TimeInfo.Instance.FrameTime - this.epoch2022) / 1000);
+            uint a = (uint)((this.timeInfo.FrameTime - this.epoch2022) / 1000);
             return a;
         }
         
@@ -123,7 +129,7 @@ namespace ET
             }
             this.value = IdValueGenerater.Instance.Value;
 
-            IdStruct idStruct = new(this.lastIdTime, (short)this.VProcess.Process, value);
+            IdStruct idStruct = new(this.lastIdTime, (short)this.process, value);
             return idStruct.ToLong();
         }
         

+ 2 - 2
Unity/Assets/Scripts/Core/VProcess/Module/Synchronization/MainThreadSynchronizationContext.cs

@@ -3,8 +3,8 @@ using System.Threading;
 
 namespace ET
 {
-
-    public class MainThreadSynchronizationContext: VProcessSingleton<MainThreadSynchronizationContext>, IVProcessSingletonUpdate
+    [ComponentOf(typeof(VProcess))]
+    public class MainThreadSynchronizationContext: SingletonEntity<MainThreadSynchronizationContext>, IAwake
     {
         private readonly ThreadSynchronizationContext threadSynchronizationContext = new();
 

+ 4 - 4
Unity/Assets/Scripts/Core/VProcess/Module/Time/TimeHelper.cs

@@ -14,7 +14,7 @@ namespace ET
         /// <returns></returns>
         public static long ClientNow()
         {
-            return TimeInfo.Instance.ClientNow();
+            return VProcess.Instance.TimeInfo.ClientNow();
         }
 
         public static long ClientNowSeconds()
@@ -29,17 +29,17 @@ namespace ET
 
         public static long ServerNow()
         {
-            return TimeInfo.Instance.ServerNow();
+            return VProcess.Instance.TimeInfo.ServerNow();
         }
 
         public static long ClientFrameTime()
         {
-            return TimeInfo.Instance.ClientFrameTime();
+            return VProcess.Instance.TimeInfo.ClientFrameTime();
         }
         
         public static long ServerFrameTime()
         {
-            return TimeInfo.Instance.ServerFrameTime();
+            return VProcess.Instance.TimeInfo.ServerFrameTime();
         }
     }
 }

+ 3 - 3
Unity/Assets/Scripts/Core/VProcess/Module/Time/TimeInfo.cs

@@ -2,7 +2,7 @@ using System;
 
 namespace ET
 {
-    public class TimeInfo: VProcessSingleton<TimeInfo>, IVProcessSingletonUpdate
+    public class TimeInfo
     {
         private int timeZone;
         
@@ -54,7 +54,7 @@ namespace ET
         
         public long ServerNow()
         {
-            return ClientNow() + Instance.ServerMinusClientTime;
+            return ClientNow() + this.ServerMinusClientTime;
         }
         
         public long ClientFrameTime()
@@ -64,7 +64,7 @@ namespace ET
         
         public long ServerFrameTime()
         {
-            return this.FrameTime + Instance.ServerMinusClientTime;
+            return this.FrameTime + this.ServerMinusClientTime;
         }
         
         public long Transition(DateTime d)

+ 2 - 1
Unity/Assets/Scripts/Core/VProcess/Module/Timer/TimerComponent.cs

@@ -53,7 +53,8 @@ namespace ET
         public object Args;
     }
 
-    public class TimerComponent: VProcessSingleton<TimerComponent>, IVProcessSingletonUpdate
+    [ComponentOf(typeof(VProcess))]
+    public class TimerComponent: SingletonEntity<TimerComponent>, IAwake
     {
         /// <summary>
         /// key: time, value: timer id

+ 5 - 4
Unity/Assets/Scripts/Core/VProcess/Module/VProcessActor/VProcessActor.cs

@@ -2,7 +2,8 @@
 
 namespace ET
 {
-    public class VProcessActor: VProcessSingleton<VProcessActor>, IVProcessSingletonAwake
+    [ComponentOf(typeof(VProcess))]
+    public class VProcessActor: SingletonEntity<VProcessActor>, IAwake
     {
         private readonly Dictionary<int, ETTask<IResponse>> requestCallbacks = new();
 
@@ -19,18 +20,18 @@ namespace ET
             
             base.Dispose();
             
-            WorldActor.Instance.RemoveActor(this.VProcess.Id);
+            WorldActor.Instance.RemoveActor((int)this.Root().Id);
         }
 
         public void Awake()
         {
-            WorldActor.Instance.AddActor(this.VProcess.Id);
+            WorldActor.Instance.AddActor((int)this.Root().Id);
         }
 
         public void Update()
         {
             this.list.Clear();
-            WorldActor.Instance.Fetch(this.VProcess.Id, 1000, this.list);
+            WorldActor.Instance.Fetch((int)this.Root().Id, 1000, this.list);
             foreach (ActorMessageInfo actorMessageInfo in this.list)
             {
                 this.HandleMessage(actorMessageInfo.ActorId, actorMessageInfo.MessageObject);    

+ 25 - 164
Unity/Assets/Scripts/Core/VProcess/VProcess.cs

@@ -3,208 +3,69 @@ using System.Collections.Generic;
 
 namespace ET
 {
-    public class VProcess: IDisposable
+    public class VProcess: Entity, IScene, IEntitySystem, IIdGenerater
     {
         [ThreadStatic]
         [StaticField]
-        public static VProcess Instance;    
+        public static VProcess Instance;
+        
+        public IScene Root { get; set; }
+        public SceneType SceneType { get; set; }
         
-        public int Id { get; private set; }
-
         public int Process { get; private set; }
+        
+        public EntitySystem EntitySystem { get; }
+        public TimeInfo TimeInfo { get; }
+        public IdGenerater IdGenerater { get; }
 
         public bool IsRuning;
-
-        // 保存虚拟进程中的Instance,方便快速获取
-        private readonly Dictionary<Type, object> instances = new();
-
-        private readonly Stack<IVProcessSingleton> singletons = new();
-
-        private readonly Queue<IVProcessSingleton> updates = new();
-
-        private readonly Queue<IVProcessSingleton> lateUpdates = new();
-
-        private readonly Queue<ETTask> frameFinishTask = new();
         
+        // actor
+        private readonly Dictionary<long, Entity> actors = new();
+
         public VProcess(int process, int id)
         {
             this.Id = id;
             this.Process = process;
+            this.Root = this;
+            this.EntitySystem = new EntitySystem();
+            this.TimeInfo = new TimeInfo();
+            this.IdGenerater = new IdGenerater(process, this.TimeInfo);
         }
 
-        private void Register()
-        {
-            this.IsRuning = true;
-            Instance = this;
-        }
-        
-        public T AddSingleton<T>() where T: IVProcessSingleton, new()
-        {
-            T singleton = new T();
-            AddSingleton(singleton);
-            return singleton;
-        }
-
-        public void AddSingleton(IVProcessSingleton singleton)
-        {
-            singleton.VProcess = this;
-            
-            this.AddInstance(singleton);
-            
-            singletons.Push(singleton);
-
-            if (singleton is IVProcessSingletonAwake awake)
-            {
-                awake.Awake();
-            }
-            
-            if (singleton is IVProcessSingletonUpdate)
-            {
-                updates.Enqueue(singleton);
-            }
-            
-            if (singleton is IVProcessSingletonLateUpdate)
-            {
-                lateUpdates.Enqueue(singleton);
-            }
-        }
-
-        public void AddInstance(object obj)
-        {
-            this.instances.Add(obj.GetType(), obj);
-        }
-
-        public void RemoveInstance(Type type)
-        {
-            this.instances.Remove(type);
-        }
-        
-        public object GetInstance(Type type)
-        {
-            this.instances.TryGetValue(type, out var instance);
-            return instance;
-        }
-        
-        public T GetInstance<T>() where T: class
-        {
-            this.instances.TryGetValue(typeof(T), out var instance);
-            return instance as T;
-        }
-
-        public async ETTask WaitFrameFinish()
-        {
-            ETTask task = ETTask.Create(true);
-            frameFinishTask.Enqueue(task);
-            await task;
-        }
-        
         public void Update()
         {
-            this.Register();
+            this.TimeInfo.Update();
             
-            int count = updates.Count;
-            while (count-- > 0)
-            {
-                IVProcessSingleton singleton = updates.Dequeue();
-
-                if (singleton.IsDisposed)
-                {
-                    continue;
-                }
-
-                if (singleton is not IVProcessSingletonUpdate update)
-                {
-                    continue;
-                }
-                
-                updates.Enqueue(singleton);
-                try
-                {
-                    update.Update();
-                }
-                catch (Exception e)
-                {
-                    Log.Error(e);
-                }
-            }
+            this.EntitySystem.Update();
         }
         
         public void LateUpdate()
         {
-            this.Register();
-            
-            int count = lateUpdates.Count;
-            while (count-- > 0)
-            {
-                IVProcessSingleton singleton = lateUpdates.Dequeue();
-                
-                if (singleton.IsDisposed)
-                {
-                    continue;
-                }
-
-                if (singleton is not IVProcessSingletonLateUpdate lateUpdate)
-                {
-                    continue;
-                }
-                
-                lateUpdates.Enqueue(singleton);
-                try
-                {
-                    lateUpdate.LateUpdate();
-                }
-                catch (Exception e)
-                {
-                    Log.Error(e);
-                }
-            }
+            this.EntitySystem.LateUpdate();
 
             FrameFinishUpdate();
         }
 
-        public void Load()
+        public async ETTask WaitFrameFinish()
         {
-            foreach (IVProcessSingleton singleton in this.singletons)
-            {
-                if (singleton is IVProcessSingletonLoad singletonLoad)
-                {
-                    singletonLoad.Load();
-                }
-            }
+            
         }
 
         private void FrameFinishUpdate()
         {
-            this.Register();
-            
-            while (frameFinishTask.Count > 0)
-            {
-                ETTask task = frameFinishTask.Dequeue();
-                task.SetResult();
-            }
-            
-            this.IsRuning = false;
         }
 
-        public void Dispose()
+        public override void Dispose()
         {
-            int id = this.Id;
-            
-            if (id == 0)
+            if (this.IsDisposed)
             {
                 return;
             }
             
-            this.Id = 0;
-
-            this.IsRuning = false;
+            base.Dispose();
             
-            // 顺序反过来清理
-            while (singletons.Count > 0)
-            {
-                IVProcessSingleton iSingleton = singletons.Pop();
-                iSingleton.Dispose();
-            }
+            this.IsRuning = false;
         }
     }
 }

+ 0 - 48
Unity/Assets/Scripts/Core/VProcess/VProcessSingleton.cs

@@ -1,48 +0,0 @@
-using System;
-
-namespace ET
-{
-    public interface IVProcessSingleton: IDisposable
-    {
-        VProcess VProcess { get; set; }
-        bool IsDisposed { get; }
-    }
-    
-    public abstract class VProcessSingleton<T>: IVProcessSingleton where T: VProcessSingleton<T>, new()
-    {
-        public VProcess VProcess { get; set; }
-
-        public static T Instance
-        {
-            get
-            {
-                return VProcess.Instance.GetInstance<T>();
-            }
-        }
-
-        public void Register()
-        {
-            this.VProcess.AddInstance(this);
-        }
-
-        public bool IsDisposed
-        {
-            get
-            {
-                return this.VProcess == null;
-            }
-        }
-
-        public virtual void Dispose()
-        {
-            if (this.VProcess == null)
-            {
-                return;
-            }
-            
-            this.VProcess.RemoveInstance(typeof(T));
-            
-            this.VProcess = null;
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Core/VProcess/VProcessSingleton.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: cedc4d05b6540084ab53a7ea50910ff2
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 3 - 2
Unity/Assets/Scripts/Core/World/Module/Network/NetServices.cs

@@ -14,7 +14,8 @@ namespace ET
         Websocket,
     }
 
-    public class NetServices: VProcessSingleton<NetServices>, IVProcessSingletonUpdate
+    [ComponentOf(typeof(VProcess))]
+    public class NetServices: SingletonEntity<NetServices>, IAwake
     {
         private readonly Dictionary<int, Action<long, IPEndPoint>> acceptCallback = new();
         private readonly Dictionary<int, Action<long, ActorId, object>> readCallback = new();
@@ -69,7 +70,7 @@ namespace ET
             if (service != null)
             {
                 // 同一进程
-                if (actorId.Process == this.VProcess.Process)
+                if (actorId.Process == this.Root().Process)
                 {
                     VProcessActor.Instance.Send(actorId, message);
                     return;

+ 2 - 6
Unity/Assets/Scripts/Core/World/Module/VProcess/VProcessManager.cs

@@ -20,12 +20,8 @@ namespace ET
                     processId = --this.idGenerator;
                 }
                 VProcess vProcess = new(Options.Instance.Process, processId);
-                vProcess.AddSingleton<TimeInfo>();
-                vProcess.AddSingleton<IdGenerater>();
-                vProcess.AddSingleton<EntitySystem>();
-                vProcess.AddSingleton<VProcessActor>();
-                vProcess.AddSingleton<Root>();
-                this.vProcesses.TryAdd(vProcess.Id, vProcess);
+                vProcess.AddComponent<VProcessActor>();
+                this.vProcesses.Add((int)vProcess.Id, vProcess);
                 return processId;
             }
         }

+ 1 - 1
Unity/Assets/Scripts/Core/World/Module/WorldActor/WorldActor.cs

@@ -10,7 +10,7 @@ namespace ET
         public MessageObject MessageObject;
     }
     
-    public class WorldActor: Singleton<WorldActor>, ISingletonAwake, IVProcessSingletonLoad
+    public class WorldActor: Singleton<WorldActor>, ISingletonAwake
     {
         private readonly Dictionary<Type, List<IProcessActorHandler>> handlers = new();
 

+ 12 - 7
Unity/Assets/Scripts/Core/World/World.cs

@@ -9,11 +9,19 @@ namespace ET
         [StaticField]
         public static World Instance = new();
 
+        private readonly ConcurrentDictionary<Type, ISingleton> singletons = new();
+        
         private World()
         {
         }
-
-        private readonly ConcurrentDictionary<Type, ISingleton> singletons = new();
+        
+        public void Dispose()
+        {
+            foreach (ISingleton singleton in this.singletons.Values)
+            {
+                singleton.Dispose();
+            }
+        }
 
         public T AddSingleton<T>() where T : Singleton<T>, ISingletonAwake, new()
         {
@@ -57,12 +65,9 @@ namespace ET
             singleton.Register();
         }
 
-        public void Dispose()
+        public void Load()
         {
-            foreach (ISingleton singleton in this.singletons.Values)
-            {
-                singleton.Dispose();
-            }
+            
         }
     }
 }

+ 0 - 8
Unity/Assets/Scripts/Editor/EntityTreeWindow.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 7cd7e41297e5ca44e9ff7c58c0da7af4
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: 169de76bd06b34fc088e863464d8416e
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 9
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/AEntityMenuHandler.cs

@@ -1,9 +0,0 @@
-namespace ET
-{
-    public abstract class AEntityMenuHandler
-    {
-        internal string menuName;
-
-        public abstract void OnClick(Entity entity);
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/AEntityMenuHandler.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: c808d888c71fa42a58eee31bc99771dc
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 76
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityContextMenu.cs

@@ -1,76 +0,0 @@
-using System;
-using System.Reflection;
-using UnityEditor;
-using UnityEngine;
-
-namespace ET
-{
-    public static class EntityContextMenu
-    {
-        private static MultiMap<string, AEntityMenuHandler> ACTIONS = new();
-
-        private static GenericMenu menu;
-
-        static EntityContextMenu()
-        {
-            var types = TypeCache.GetTypesWithAttribute<EntityMenuAttribute>();
-
-            foreach(var type in types)
-            {
-                var menu = type.GetCustomAttribute<EntityMenuAttribute>();
-
-                if(menu is null)
-                {
-                    continue;
-                }
-
-                if(Activator.CreateInstance(type) is not AEntityMenuHandler action)
-                {
-                    continue;
-                }
-
-                action.menuName = menu.menu_name;
-                ACTIONS.Add(menu.bind_to.Name, action);
-            }
-        }
-
-        public static void Show(object entity)
-        {
-            if(entity is null)
-            {
-                return;
-            }
-
-            string name = entity.GetType().Name;
-
-            ACTIONS.TryGetValue(name, out var actions);
-
-            if(actions is null)
-            {
-                return;
-            }
-
-            menu = new GenericMenu();
-
-            foreach(var action in actions)
-            {
-                menu.AddItem(
-                    new GUIContent(action.menuName),
-                    false,
-                    delegate(object data)
-                    {
-                        if(data is not Entity callback_data)
-                        {
-                            return;
-                        }
-
-                        action.OnClick(callback_data);
-                    },
-                    entity
-                );
-            }
-
-            menu.ShowAsContext();
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityContextMenu.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 5772cbaee6225405983b3a40a4031a7c
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 16
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityMenuAttribute.cs

@@ -1,16 +0,0 @@
-using System;
-
-namespace ET
-{
-    public class EntityMenuAttribute : Attribute
-    {
-        public readonly Type   bind_to;
-        public readonly string menu_name;
-
-        public EntityMenuAttribute(Type bind_to, string menu_name)
-        {
-            this.bind_to   = bind_to;
-            this.menu_name = menu_name;
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/EntityMenuAttribute.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 27184ef12a8b34e6babdb7e9bdf6fcef
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 15
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/MenuExample.cs

@@ -1,15 +0,0 @@
-namespace ET
-{
-#if !ENABLE_DLL
-    [EntityMenu(typeof (Unit), "打开属性菜单")]
-    public class UnitNumericWindowMenu: AEntityMenuHandler
-    {
-        public override void OnClick(Entity entity)
-        {
-            var unit = entity as Unit;
-
-            Log.Debug(unit.Config.Name);
-        }
-    }
-#endif
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/ContextMenu/MenuExample.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d55e90d5e4c8f435494683f0df653500
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: af3c0ee7e83ae6d4f9026eee04fd877c
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 199
Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/EditorLayout.cs

@@ -1,199 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-using UnityEditor;
-using UnityEngine;
-
-namespace ET
-{
-    public static class Styles
-    {
-        private static GUIStyle _sectionHeader;
-        private static GUIStyle _sectionContent;
-
-        public static GUIStyle sectionHeader
-        {
-            get
-            {
-                if (Styles._sectionHeader == null)
-                    Styles._sectionHeader = new GUIStyle((GUIStyle) "OL Title");
-                return Styles._sectionHeader;
-            }
-        }
-
-        public static GUIStyle sectionContent
-        {
-            get
-            {
-                if (Styles._sectionContent == null)
-                {
-                    Styles._sectionContent = new GUIStyle((GUIStyle) "OL Box");
-                    Styles._sectionContent.stretchHeight = false;
-                }
-
-                return Styles._sectionContent;
-            }
-        }
-    }
-
-    public static class EditorLayout
-    {
-        private const int DEFAULT_FOLDOUT_MARGIN = 11;
-
-        public static T GetWindow<T>(string title, Vector2 size) where T : EditorWindow
-        {
-            T window = EditorWindow.GetWindow<T>(true, title);
-            window.minSize = window.maxSize = size;
-            return window;
-        }
-
-        public static Texture2D LoadTexture(string label)
-        {
-            string[] assets = AssetDatabase.FindAssets(label);
-            if (assets.Length != 0)
-            {
-                string guid = assets[0];
-                if (guid != null)
-                    return AssetDatabase.LoadAssetAtPath<Texture2D>(AssetDatabase.GUIDToAssetPath(guid));
-            }
-
-            return (Texture2D) null;
-        }
-
-        public static Rect DrawTexture(Texture2D texture)
-        {
-            if (!((UnityEngine.Object) texture != (UnityEngine.Object) null))
-                return new Rect();
-            Rect aspectRect = GUILayoutUtility.GetAspectRect((float) ((double) texture.width / (double) texture.height),
-                new GUILayoutOption[1] { GUILayout.ExpandWidth(true) });
-            GUI.DrawTexture(aspectRect, (Texture) texture, ScaleMode.ScaleAndCrop);
-            return aspectRect;
-        }
-
-        public static bool ObjectFieldButton(string label, string buttonText)
-        {
-            EditorGUILayout.BeginHorizontal();
-            EditorGUILayout.LabelField(label, new GUILayoutOption[1] { GUILayout.Width(146f) });
-            if (buttonText.Length > 24)
-                buttonText = "..." + buttonText.Substring(buttonText.Length - 24);
-            int num = GUILayout.Button(buttonText, EditorStyles.objectField, new GUILayoutOption[0])? 1 : 0;
-            EditorGUILayout.EndHorizontal();
-            return num != 0;
-        }
-
-        public static string ObjectFieldOpenFolderPanel(string label, string buttonText, string defaultPath)
-        {
-            if (!EditorLayout.ObjectFieldButton(label, buttonText))
-                return (string) null;
-            string str = defaultPath ?? "Assets/";
-            if (!Directory.Exists(str))
-                str = "Assets/";
-            return EditorUtility.OpenFolderPanel(label, str, string.Empty).Replace(Directory.GetCurrentDirectory() + "/", string.Empty);
-        }
-
-        public static string ObjectFieldOpenFilePanel(string label, string buttonText, string defaultPath)
-        {
-            if (!EditorLayout.ObjectFieldButton(label, buttonText))
-                return (string) null;
-            string str = defaultPath ?? "Assets/";
-            if (!File.Exists(str))
-                str = "Assets/";
-            return EditorUtility.OpenFilePanel(label, str, "dll").Replace(Directory.GetCurrentDirectory() + "/", string.Empty);
-        }
-
-        public static bool MiniButton(string c)
-        {
-            return EditorLayout.miniButton(c, EditorStyles.miniButton);
-        }
-
-        public static bool MiniButtonLeft(string c)
-        {
-            return EditorLayout.miniButton(c, EditorStyles.miniButtonLeft);
-        }
-
-        public static bool MiniButtonMid(string c)
-        {
-            return EditorLayout.miniButton(c, EditorStyles.miniButtonMid);
-        }
-
-        public static bool MiniButtonRight(string c)
-        {
-            return EditorLayout.miniButton(c, EditorStyles.miniButtonRight);
-        }
-
-        private static bool miniButton(string c, GUIStyle style)
-        {
-            GUILayoutOption[] guiLayoutOptionArray1;
-            if (c.Length != 1)
-                guiLayoutOptionArray1 = new GUILayoutOption[0];
-            else
-                guiLayoutOptionArray1 = new GUILayoutOption[1] { GUILayout.Width(19f) };
-            GUILayoutOption[] guiLayoutOptionArray2 = guiLayoutOptionArray1;
-            int num = GUILayout.Button(c, style, guiLayoutOptionArray2)? 1 : 0;
-            if (num == 0)
-                return num != 0;
-            GUI.FocusControl((string) null);
-            return num != 0;
-        }
-
-        public static bool Foldout(bool foldout, string content, int leftMargin = 11)
-        {
-            return EditorLayout.Foldout(foldout, content, EditorStyles.foldout, leftMargin);
-        }
-
-        public static bool Foldout(bool foldout, string content, GUIStyle style, int leftMargin = 11)
-        {
-            EditorGUILayout.BeginHorizontal();
-            GUILayout.Space((float) leftMargin);
-            foldout = EditorGUILayout.Foldout(foldout, content, style);
-            EditorGUILayout.EndHorizontal();
-            return foldout;
-        }
-
-        public static string SearchTextField(string searchString)
-        {
-            bool changed = GUI.changed;
-            GUILayout.BeginHorizontal();
-            searchString = GUILayout.TextField(searchString, GUI.skin.FindStyle("ToolbarSeachTextField"), new GUILayoutOption[0]);
-            if (GUILayout.Button(string.Empty, GUI.skin.FindStyle("ToolbarSeachCancelButton"), new GUILayoutOption[0]))
-                searchString = string.Empty;
-            GUILayout.EndHorizontal();
-            GUI.changed = changed;
-            return searchString;
-        }
-
-        public static bool MatchesSearchString(string str, string search)
-        {
-            string[] strArray = search.Split(new char[1] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
-            if (strArray.Length != 0)
-                return ((IEnumerable<string>) strArray).Any<string>(new Func<string, bool>(str.Contains));
-            return true;
-        }
-
-        public static bool DrawSectionHeaderToggle(string header, bool value)
-        {
-            return GUILayout.Toggle(value, header, Styles.sectionHeader, new GUILayoutOption[0]);
-        }
-
-        public static void BeginSectionContent()
-        {
-            EditorGUILayout.BeginVertical(Styles.sectionContent, new GUILayoutOption[0]);
-        }
-
-        public static void EndSectionContent()
-        {
-            EditorGUILayout.EndVertical();
-        }
-
-        public static Rect BeginVerticalBox()
-        {
-            return EditorGUILayout.BeginVertical(GUI.skin.box, new GUILayoutOption[0]);
-        }
-
-        public static void EndVerticalBox()
-        {
-            EditorGUILayout.EndVertical();
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/EditorLayout.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 9c97b611a98d6684c8a9d65597fe806c
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 133
Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/SerializationTypeExtension.cs

@@ -1,133 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reflection;
-using System.Text.RegularExpressions;
-
-namespace ET
-{
-    public static class SerializationTypeExtension
-    {
-        private static readonly Dictionary<string, string> _builtInTypesToString = new Dictionary<string, string>()
-        {
-            { "System.Boolean", "bool" },
-            { "System.Byte", "byte" },
-            { "System.SByte", "sbyte" },
-            { "System.Char", "char" },
-            { "System.Decimal", "decimal" },
-            { "System.Double", "double" },
-            { "System.Single", "float" },
-            { "System.Int32", "int" },
-            { "System.UInt32", "uint" },
-            { "System.Int64", "long" },
-            { "System.UInt64", "ulong" },
-            { "System.Object", "object" },
-            { "System.Int16", "short" },
-            { "System.UInt16", "ushort" },
-            { "System.String", "string" },
-            { "System.Void", "void" }
-        };
-
-        private static readonly Dictionary<string, string> _builtInTypeStrings = new Dictionary<string, string>()
-        {
-            { "bool", "System.Boolean" },
-            { "byte", "System.Byte" },
-            { "sbyte", "System.SByte" },
-            { "char", "System.Char" },
-            { "decimal", "System.Decimal" },
-            { "double", "System.Double" },
-            { "float", "System.Single" },
-            { "int", "System.Int32" },
-            { "uint", "System.UInt32" },
-            { "long", "System.Int64" },
-            { "ulong", "System.UInt64" },
-            { "object", "System.Object" },
-            { "short", "System.Int16" },
-            { "ushort", "System.UInt16" },
-            { "string", "System.String" },
-            { "void", "System.Void" }
-        };
-
-        public static string ToCompilableString(this Type type)
-        {
-            if (SerializationTypeExtension._builtInTypesToString.ContainsKey(type.FullName))
-                return SerializationTypeExtension._builtInTypesToString[type.FullName];
-            if (type.IsGenericType)
-            {
-                string str1 = type.FullName.Split('`')[0];
-                string[] array = ((IEnumerable<Type>) type.GetGenericArguments())
-                        .Select<Type, string>((Func<Type, string>) (argType => argType.ToCompilableString())).ToArray<string>();
-                string str2 = "<";
-                string str3 = string.Join(", ", array);
-                string str4 = ">";
-                return str1 + str2 + str3 + str4;
-            }
-
-            if (type.IsArray)
-                return type.GetElementType().ToCompilableString() + "[" + new string(',', type.GetArrayRank() - 1) + "]";
-            if (type.IsNested)
-                return type.FullName.Replace('+', '.');
-            return type.FullName;
-        }
-
-        public static Type ToType(this string typeString)
-        {
-            string typeString1 = SerializationTypeExtension.generateTypeString(typeString);
-            Type type1 = Type.GetType(typeString1);
-            if (type1 != null)
-                return type1;
-            foreach (Assembly assembly in AppDomain.CurrentDomain.GetAssemblies())
-            {
-                Type type2 = assembly.GetType(typeString1);
-                if (type2 != null)
-                    return type2;
-            }
-
-            return (Type) null;
-        }
-
-        public static string ShortTypeName(this string fullTypeName)
-        {
-            string[] strArray = fullTypeName.Split('.');
-            return strArray[strArray.Length - 1];
-        }
-
-        public static string RemoveDots(this string fullTypeName)
-        {
-            return fullTypeName.Replace(".", string.Empty);
-        }
-
-        private static string generateTypeString(string typeString)
-        {
-            if (SerializationTypeExtension._builtInTypeStrings.ContainsKey(typeString))
-            {
-                typeString = SerializationTypeExtension._builtInTypeStrings[typeString];
-            }
-            else
-            {
-                typeString = SerializationTypeExtension.generateGenericArguments(typeString);
-                typeString = SerializationTypeExtension.generateArray(typeString);
-            }
-
-            return typeString;
-        }
-
-        private static string generateGenericArguments(string typeString)
-        {
-            string[] separator = new string[1] { ", " };
-            typeString = Regex.Replace(typeString, "<(?<arg>.*)>", (MatchEvaluator) (m =>
-            {
-                string typeString1 = SerializationTypeExtension.generateTypeString(m.Groups["arg"].Value);
-                return "`" + (object) typeString1.Split(separator, StringSplitOptions.None).Length + "[" + typeString1 + "]";
-            }));
-            return typeString;
-        }
-
-        private static string generateArray(string typeString)
-        {
-            typeString = Regex.Replace(typeString, "(?<type>[^\\[]*)(?<rank>\\[,*\\])",
-                (MatchEvaluator) (m => SerializationTypeExtension.generateTypeString(m.Groups["type"].Value) + m.Groups["rank"].Value));
-            return typeString;
-        }
-    }
-}

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/Entity/SerializationTypeExtension.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 7eb5385243eeedf49b9f13c4ac0ca482
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 8
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree.meta

@@ -1,8 +0,0 @@
-fileFormatVersion: 2
-guid: e01001106eb09483d8d5eeb6bcba9a12
-folderAsset: yes
-DefaultImporter:
-  externalObjects: {}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 118
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeView.cs

@@ -1,118 +0,0 @@
-#if ENABLE_VIEW
-using System.Collections.Generic;
-using UnityEditor;
-using UnityEditor.IMGUI.Controls;
-using UnityEngine;
-
-namespace ET
-{
-    public class EntityTreeView: TreeView
-    {
-        private EntityTreeViewItem root;
-        private int                id;
-
-        private readonly Dictionary<int, Entity> all             = new();
-        private readonly Dictionary<Entity, int> entityHistoryID = new();
-
-        public EntityTreeView(TreeViewState state): base(state)
-        {
-            Reload();
-            useScrollView = true;
-        }
-
-        public void Refresh()
-        {
-            this.root = BuildRoot() as EntityTreeViewItem;
-            BuildRows(this.root);
-
-            this.Repaint();
-        }
-
-        protected override TreeViewItem BuildRoot()
-        {
-            this.id = 0;
-
-            this.root       = PreOrder(Root.Instance.Scene);
-            this.root.depth = -1;
-
-            SetupDepthsFromParentsAndChildren(this.root);
-
-            return this.root;
-        }
-
-        private EntityTreeViewItem PreOrder(Entity root)
-        {
-            if(root is null)
-            {
-                return null;
-            }
-
-            if(!this.entityHistoryID.TryGetValue(root, out var itemID))
-            {
-                this.id++;
-                itemID = this.id;
-
-                this.entityHistoryID[root] = itemID;
-            }
-
-            EntityTreeViewItem item = new(root, itemID);
-
-            this.all[itemID] = root;
-
-            if(root.Components.Count > 0)
-            {
-                foreach(var component in root.Components.Values)
-                {
-                    item.AddChild(PreOrder(component));
-                }
-            }
-
-            if(root.Children.Count > 0)
-            {
-                foreach(var child in root.Children.Values)
-                {
-                    item.AddChild(PreOrder(child));
-                }
-            }
-
-            return item;
-        }
-
-        /// <summary>
-        /// 处理右键内容
-        /// </summary>
-        /// <param name="id"></param>
-        protected override void ContextClickedItem(int id)
-        {
-            if(Event.current.button != 1)
-            {
-                return;
-            }
-
-            SingleClickedItem(id);
-
-            EntityContextMenu.Show(EntityTreeWindow.VIEW_MONO.Component);
-        }
-
-        /// <summary>
-        /// 处理左键内容
-        /// </summary>
-        /// <param name="id"></param>
-        protected override void SingleClickedItem(int id)
-        {
-            this.all.TryGetValue(id, out Entity entity);
-
-            if(entity is null)
-            {
-                return;
-            }
-
-            EntityTreeWindow.VIEW_MONO.Component = entity;
-            Selection.activeObject               = null;
-
-            // 刷新 Inspector 显示
-            EditorApplication.delayCall += () => { Selection.activeObject = EntityTreeWindow.VIEW_MONO; };
-        }
-    }
-}
-#endif

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeView.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: e1fe41ca5c4554eceb23f9a7d6eeacf6
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 73
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeViewItem.cs

@@ -1,73 +0,0 @@
-#if ENABLE_VIEW
-
-using System;
-using System.Runtime.CompilerServices;
-using Microsoft.CSharp.RuntimeBinder;
-using UnityEditor.IMGUI.Controls;
-
-namespace ET
-{
-    public class EntityTreeViewItem: TreeViewItem
-    {
-        public Entity entity;
-
-        public EntityTreeViewItem(Entity entity, int id)
-        {
-            this.entity = entity;
-            base.id     = id;
-        }
-
-        public override string displayName
-        {
-            get
-            {
-                if(!string.IsNullOrEmpty(_displayName))
-                {
-                    return _displayName;
-                }
-
-                string name = this.entity.GetType().Name;
-
-                string debugger_name = ReadDebuggerDisplay(entity);
-
-                _displayName = string.IsNullOrEmpty(debugger_name)? name : $"{name}{debugger_name}";
-
-                return _displayName;
-            }
-        }
-
-        private string _displayName;
-
-        // https://stackoverflow.com/a/13650728/37055
-        private static object ReadProperty(object target, string propertyName)
-        {
-            var args = new[] { CSharpArgumentInfo.Create(0, null) };
-            var binder = Binder.GetMember(
-                0,
-                propertyName,
-                target.GetType(),
-                args
-            );
-            var site = CallSite<Func<CallSite, object, object>>.Create(binder);
-            return site.Target(site, target);
-        }
-
-        private static string ReadDebuggerDisplay(object target, string propertyName = "ViewGoName")
-        {
-            string debuggerDisplay = string.Empty;
-            try
-            {
-                var value = ReadProperty(target, propertyName) ?? string.Empty;
-
-                debuggerDisplay = value as string ?? value.ToString();
-            }
-            catch(Exception)
-            {
-                // ignored
-            }
-
-            return debuggerDisplay;
-        }
-    }
-}
-#endif

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeViewItem.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: d8e39e236d1e54f468beb9e8a688df36
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 0 - 114
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeWindow.cs

@@ -1,114 +0,0 @@
-#if ENABLE_VIEW
-using System;
-using UnityEditor;
-using UnityEditor.IMGUI.Controls;
-using UnityEngine;
-
-namespace ET
-{
-    public class EntityTreeWindow: EditorWindow
-    {
-        internal static ComponentView VIEW_MONO;
-
-        private static EntityTreeWindow WINDOW;
-
-        private EntityTreeView treeView;
-        private SearchField    searchField;
-
-        [MenuItem("ET/Entity Tree Window")]
-        private static void OpenWindow()
-        {
-            if(!Application.isPlaying)
-            {
-                EditorUtility.DisplayDialog("警告", "运行后才可使用", "确定");
-                return;
-            }
-
-            VIEW_MONO = new GameObject("View").AddComponent<ComponentView>();
-            DontDestroyOnLoad(VIEW_MONO);
-
-            WINDOW              = GetWindow<EntityTreeWindow>(DockDefine.Types);
-            WINDOW.titleContent = new GUIContent("Entity Tree Window");
-            WINDOW.Show();
-        }
-
-        private void OnEnable()
-        {
-            this.treeView                            =  new EntityTreeView(new TreeViewState());
-            this.searchField                         =  new SearchField();
-            this.searchField.downOrUpArrowKeyPressed += this.treeView.SetFocusAndEnsureSelectedItem;
-            EditorApplication.playModeStateChanged   += OnPlayModeStateChange;
-        }
-
-        private void OnPlayModeStateChange(PlayModeStateChange state)
-        {
-            if(state != PlayModeStateChange.ExitingPlayMode)
-            {
-                return;
-            }
-
-            WINDOW.Close();
-        }
-
-        private void OnDestroy()
-        {
-            EditorApplication.playModeStateChanged -= OnPlayModeStateChange;
-            DestroyImmediate(VIEW_MONO.gameObject);
-            VIEW_MONO = null;
-        }
-
-        private void OnInspectorUpdate()
-        {
-            this.treeView?.Refresh();
-        }
-
-        private void OnGUI()
-        {
-            this.treeView.searchString = this.searchField.OnGUI(
-                new Rect(
-                    0,
-                    0,
-                    position.width - 40f,
-                    20f
-                ),
-                this.treeView.searchString
-            );
-
-            this.treeView.OnGUI(
-                new Rect(
-                    0,
-                    20f,
-                    position.width,
-                    position.height - 40f
-                )
-            );
-
-
-            GUILayout.BeginArea(
-                new Rect(
-                    20f,
-                    position.height - 18f,
-                    position.width  - 40f,
-                    16f
-                )
-            );
-
-            using(new EditorGUILayout.HorizontalScope())
-            {
-                string style = "miniButton";
-                if(GUILayout.Button("Expand all", style))
-                {
-                    this.treeView.ExpandAll();
-                }
-
-                if(GUILayout.Button("Collapse all", style))
-                {
-                    this.treeView.CollapseAll();
-                }
-            }
-
-            GUILayout.EndArea();
-        }
-    }
-}
-#endif

+ 0 - 11
Unity/Assets/Scripts/Editor/EntityTreeWindow/Tree/EntityTreeWindow.cs.meta

@@ -1,11 +0,0 @@
-fileFormatVersion: 2
-guid: 938ac429663ab420d97f87fea3317bff
-MonoImporter:
-  externalObjects: {}
-  serializedVersion: 2
-  defaultReferences: []
-  executionOrder: 0
-  icon: {instanceID: 0}
-  userData: 
-  assetBundleName: 
-  assetBundleVariant: 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/Ping/PingComponentSystem.cs

@@ -42,7 +42,7 @@ namespace ET.Client
                     long time2 = TimeHelper.ClientNow();
                     self.Ping = time2 - time1;
                     
-                    TimeInfo.Instance.ServerMinusClientTime = response.Time + (time2 - time1) / 2 - time2;
+                    self.Root().TimeInfo.ServerMinusClientTime = response.Time + (time2 - time1) / 2 - time2;
                     
                     await TimerComponent.Instance.WaitAsync(2000);
                 }

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Client/Demo/Scene/SceneFactory.cs

@@ -2,7 +2,7 @@ namespace ET.Client
 {
     public static partial class SceneFactory
     {
-        public static async ETTask<Scene> CreateClientScene(Scene scene, int zone, SceneType sceneType, string name)
+        public static async ETTask<Scene> CreateClientScene(VProcess scene, int zone, SceneType sceneType, string name)
         {
             await ETTask.CompletedTask;
             
@@ -17,7 +17,7 @@ namespace ET.Client
         
         public static Scene CreateCurrentScene(long id, int zone, string name, CurrentScenesComponent currentScenesComponent)
         {
-            Scene currentScene = EntitySceneFactory.CreateScene(id, IdGenerater.Instance.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);
+            Scene currentScene = EntitySceneFactory.CreateScene(id, VProcess.Instance.IdGenerater.GenerateInstanceId(), zone, SceneType.Current, name, currentScenesComponent);
             currentScenesComponent.Scene = currentScene;
             
             EventSystem.Instance.Publish(currentScene, new EventType.AfterCreateCurrentScene());

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

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

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Benchmark/BenchmarkClientComponentSystem.cs

@@ -19,7 +19,7 @@ namespace ET.Server
         {
             await TimerComponent.Instance.WaitAsync(1000);
 
-            Scene scene = await SceneFactory.CreateServerScene(self, IdGenerater.Instance.GenerateId(), IdGenerater.Instance.GenerateInstanceId(),
+            Scene scene = await SceneFactory.CreateServerScene(self, VProcess.Instance.IdGenerater.GenerateId(), VProcess.Instance.IdGenerater.GenerateInstanceId(),
                 self.DomainZone(), "bechmark", SceneType.Benchmark);
             
             Client.NetClientComponent netClientComponent = scene.AddComponent<Client.NetClientComponent, AddressFamily>(AddressFamily.InterNetwork);

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_EnterMapHandler.cs

@@ -9,7 +9,7 @@
 
 			// 在Gate上动态创建一个Map Scene,把Unit从DB中加载放进来,然后传送到真正的Map中,这样登陆跟传送的逻辑就完全一样了
 			GateMapComponent gateMapComponent = player.AddComponent<GateMapComponent>();
-			gateMapComponent.Scene = await SceneFactory.CreateServerScene(gateMapComponent, player.Id, IdGenerater.Instance.GenerateInstanceId(), gateMapComponent.DomainZone(), "GateMap", SceneType.Map);
+			gateMapComponent.Scene = await SceneFactory.CreateServerScene(gateMapComponent, player.Id, VProcess.Instance.IdGenerater.GenerateInstanceId(), gateMapComponent.DomainZone(), "GateMap", SceneType.Map);
 
 			Scene scene = gateMapComponent.Scene;
 			

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Gate/C2G_LoginGateHandler.cs

@@ -56,7 +56,7 @@ namespace ET.Server
 
         private static async ETTask CheckRoom(Player player, Session session)
         {
-            await player.VProcess().WaitFrameFinish();
+            await player.Root().WaitFrameFinish();
             
             Room2G_Reconnect room2GateReconnect = await ActorMessageSenderComponent.Instance.Call(
                 player.GetComponent<PlayerRoomComponent>().RoomActorId,

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Map/Transfer/TransferHelper.cs

@@ -7,7 +7,7 @@ namespace ET.Server
     {
         public static async ETTask TransferAtFrameFinish(Unit unit, ActorId sceneInstanceId, string sceneName)
         {
-            await unit.VProcess().WaitFrameFinish();
+            await unit.Root().WaitFrameFinish();
 
             await TransferHelper.Transfer(unit, sceneInstanceId, sceneName);
         }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Scenes/Robot/RobotCaseSystem.cs

@@ -8,7 +8,7 @@ namespace ET.Server
         [EntitySystem]
         private static void Destroy(this RobotCase self)
         {
-            Scene root = self.Root();
+            VProcess root = self.Root();
             if (root.Id == 0)
             {
                 return;

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

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

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

@@ -4,9 +4,9 @@ using System.IO;
 namespace ET.Client
 {
     [Event(SceneType.Process)]
-    public class EntryEvent3_InitClient: AEvent<Scene, ET.EventType.EntryEvent3>
+    public class EntryEvent3_InitClient: AEvent<VProcess, ET.EventType.EntryEvent3>
     {
-        protected override async ETTask Run(Scene scene, ET.EventType.EntryEvent3 args)
+        protected override async ETTask Run(VProcess scene, ET.EventType.EntryEvent3 args)
         {
             // 加载配置
             scene.AddComponent<ResourcesComponent>();

+ 1 - 1
Unity/Assets/Scripts/HotfixView/Client/Demo/Opera/OperaComponentSystem.cs

@@ -29,7 +29,7 @@ namespace ET.Client
 
             if (Input.GetKeyDown(KeyCode.R))
             {
-                self.VProcess().Load();
+                World.Instance.Load();
                 Log.Debug("hot reload success!");
             }
         

+ 1 - 1
Unity/Assets/Scripts/Loader/GlobalComponent.cs

@@ -2,7 +2,7 @@ using UnityEngine;
 
 namespace ET
 {
-    public class GlobalComponent: VProcessSingleton<GlobalComponent>, ISingletonAwake
+    public class GlobalComponent: SingletonEntity<GlobalComponent>, ISingletonAwake
     {
         public Transform Global;
         public Transform Unit { get; set; }

+ 7 - 10
Unity/Assets/Scripts/Model/Share/Entry.cs

@@ -45,20 +45,17 @@ namespace ET
             
             VProcess vProcess = VProcess.Instance;
             
-            vProcess.AddSingleton<MainThreadSynchronizationContext>();
-            vProcess.AddSingleton<TimeInfo>();
-            vProcess.AddSingleton<IdGenerater>();
-            vProcess.AddSingleton<TimerComponent>();
-            vProcess.AddSingleton<CoroutineLockComponent>();
+            vProcess.AddComponent<MainThreadSynchronizationContext>();
+            vProcess.AddComponent<TimerComponent>();
+            vProcess.AddComponent<CoroutineLockComponent>();
             
-            vProcess.AddSingleton<NetServices>();
-            Root root = vProcess.AddSingleton<Root>();
+            vProcess.AddComponent<NetServices>();
 
             await World.Instance.AddSingleton<ConfigComponent>().LoadAsync();
 
-            await EventSystem.Instance.PublishAsync(root.Scene, new EventType.EntryEvent1());
-            await EventSystem.Instance.PublishAsync(root.Scene, new EventType.EntryEvent2());
-            await EventSystem.Instance.PublishAsync(root.Scene, new EventType.EntryEvent3());
+            await EventSystem.Instance.PublishAsync(vProcess, new EventType.EntryEvent1());
+            await EventSystem.Instance.PublishAsync(vProcess, new EventType.EntryEvent2());
+            await EventSystem.Instance.PublishAsync(vProcess, new EventType.EntryEvent3());
         }
     }
 }