Просмотр исходного кода

EntityRef容易绕过GetComponentSysSystem,所以尽量不要去使用,除非GetComponent调用非常频繁,以至于影响了性能。

tanghai 2 лет назад
Родитель
Сommit
2bb272d8ce
32 измененных файлов с 64 добавлено и 109 удалено
  1. 0 39
      Unity/Assets/Scripts/Core/Fiber/Fiber.cs
  2. 1 2
      Unity/Assets/Scripts/Core/Fiber/Module/Actor/ProcessInnerSenderSystem.cs
  3. 0 1
      Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs
  4. 0 1
      Unity/Assets/Scripts/Core/Fiber/Module/Timer/TimerComponent.cs
  5. 1 1
      Unity/Assets/Scripts/Core/Helper/ETCancelationTokenHelper.cs
  6. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_Attack.cs
  7. 3 3
      Unity/Assets/Scripts/Hotfix/Client/Demo/Main/ClientSenderCompnentSystem.cs
  8. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Ping/PingComponentSystem.cs
  9. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterAddressComponentSystem.cs
  10. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterCheckComponentSystem.cs
  11. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterHelper.cs
  12. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Module/Message/ClientSessionErrorComponentSystem.cs
  13. 1 1
      Unity/Assets/Scripts/Hotfix/Client/Module/Message/NetComponentOnReadInvoker_NetClient.cs
  14. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Gate/GateSessionKeyComponentSystem.cs
  15. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Realm/C2R_LoginHandler.cs
  16. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/Console/CreateRobotConsoleHandler.cs
  17. 1 1
      Unity/Assets/Scripts/Hotfix/Server/LockStep/Map/C2Room_ChangeSceneFinishHandler.cs
  18. 5 5
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs
  19. 1 1
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs
  20. 6 6
      Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs
  21. 14 17
      Unity/Assets/Scripts/Hotfix/Server/Module/DB/DBComponentSystem.cs
  22. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/Message/MessageSenderSystem.cs
  23. 3 3
      Unity/Assets/Scripts/Hotfix/Server/Module/Message/ProcessOuterSenderSystem.cs
  24. 3 3
      Unity/Assets/Scripts/Hotfix/Share/Module/AI/AIComponentSystem.cs
  25. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MailBoxType_OrderedMessageHandler.cs
  26. 1 1
      Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MessageHandler.cs
  27. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs
  28. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs
  29. 2 2
      Unity/Assets/Scripts/Hotfix/Share/Module/Move/MoveComponentSystem.cs
  30. 1 1
      Unity/Assets/Scripts/Model/Share/Module/Message/Session.cs
  31. 1 1
      Unity/Assets/Scripts/Model/Share/Module/ObjectWait/ObjectWait.cs
  32. 3 3
      Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesLoaderComponent.cs

+ 0 - 39
Unity/Assets/Scripts/Core/Fiber/Fiber.cs

@@ -48,45 +48,6 @@ namespace ET
         public Mailboxes Mailboxes { get; private set; }
         public ThreadSynchronizationContext ThreadSynchronizationContext { get; }
         public ILog Log { get; }
-        
-        private EntityRef<TimerComponent> timerCompnent;
-        public TimerComponent TimerComponent
-        {
-            get
-            {
-                return this.timerCompnent;
-            }
-            set
-            {
-                this.timerCompnent = value;
-            }
-        }
-        
-        private EntityRef<CoroutineLockComponent> coroutineLockComponent;
-        public CoroutineLockComponent CoroutineLockComponent
-        {
-            get
-            {
-                return this.coroutineLockComponent;
-            }
-            set
-            {
-                this.coroutineLockComponent = value;
-            }
-        }
-        
-        private EntityRef<ProcessInnerSender> processInnerSender;
-        public ProcessInnerSender ProcessInnerSender
-        {
-            get
-            {
-                return this.processInnerSender;
-            }
-            set
-            {
-                this.processInnerSender = value;
-            }
-        }
 
         private readonly Queue<ETTask> frameFinishTasks = new();
         

+ 1 - 2
Unity/Assets/Scripts/Core/Fiber/Module/Actor/ProcessInnerSenderSystem.cs

@@ -20,7 +20,6 @@ namespace ET
         {
             Fiber fiber = self.Fiber();
             MessageQueue.Instance.AddQueue(fiber.Id);
-            fiber.ProcessInnerSender = self;
         }
 
         [EntitySystem]
@@ -167,7 +166,7 @@ namespace ET
             
             async ETTask Timeout()
             {
-                await fiber.TimerComponent.WaitAsync(ProcessInnerSender.TIMEOUT_TIME);
+                await fiber.Root.GetComponent<TimerComponent>().WaitAsync(ProcessInnerSender.TIMEOUT_TIME);
 
                 if (!self.requestCallback.Remove(rpcId, out MessageSenderStruct action))
                 {

+ 0 - 1
Unity/Assets/Scripts/Core/Fiber/Module/CoroutineLock/CoroutineLockComponent.cs

@@ -9,7 +9,6 @@ namespace ET
         [EntitySystem]
         public static void Awake(this CoroutineLockComponent self)
         {
-            self.Fiber.CoroutineLockComponent = self;
         }
         
         [EntitySystem]

+ 0 - 1
Unity/Assets/Scripts/Core/Fiber/Module/Timer/TimerComponent.cs

@@ -43,7 +43,6 @@ namespace ET
         [EntitySystem]
         private static void Awake(this TimerComponent self)
         {
-            self.Fiber().TimerComponent = self;
         }
         
         [EntitySystem]

+ 1 - 1
Unity/Assets/Scripts/Core/Helper/ETCancelationTokenHelper.cs

@@ -9,7 +9,7 @@ namespace ET
                 return;
             }
 
-            await fiber.TimerComponent.WaitAsync(afterTimeCancel);
+            await fiber.Root.GetComponent<TimerComponent>().WaitAsync(afterTimeCancel);
             
             if (self.IsCancel())
             {

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/AI/AI_Attack.cs

@@ -32,7 +32,7 @@ namespace ET.Client
                 Log.Debug($"攻击: {i}次");
 
                 // 因为协程可能被中断,任何协程都要传入cancellationToken,判断如果是中断则要返回
-                await fiber.TimerComponent.WaitAsync(1000, cancellationToken);
+                await fiber.Root.GetComponent<TimerComponent>().WaitAsync(1000, cancellationToken);
                 if (cancellationToken.IsCancel())
                 {
                     return;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Client/Demo/Main/ClientSenderCompnentSystem.cs

@@ -35,7 +35,7 @@ namespace ET.Client
             self.fiberId = await FiberManager.Instance.Create(SchedulerType.ThreadPool, 0, SceneType.NetClient, "");
             self.netClientActorId = new ActorId(self.Fiber().Process, self.fiberId);
 
-            NetClient2Main_Login response = await self.Fiber().ProcessInnerSender.Call(self.netClientActorId, new Main2NetClient_Login()
+            NetClient2Main_Login response = await self.Root().GetComponent<ProcessInnerSender>().Call(self.netClientActorId, new Main2NetClient_Login()
             {
                 OwnerFiberId = self.Fiber().Id, Account = account, Password = password
             }) as NetClient2Main_Login;
@@ -46,14 +46,14 @@ namespace ET.Client
         {
             A2NetClient_Message a2NetClientMessage = A2NetClient_Message.Create();
             a2NetClientMessage.MessageObject = message;
-            self.Fiber().ProcessInnerSender.Send(self.netClientActorId, a2NetClientMessage);
+            self.Root().GetComponent<ProcessInnerSender>().Send(self.netClientActorId, a2NetClientMessage);
         }
 
         public static async ETTask<IResponse> Call(this ClientSenderCompnent self, IRequest request, bool needException = true)
         {
             A2NetClient_Request a2NetClientRequest = A2NetClient_Request.Create();
             a2NetClientRequest.MessageObject = request;
-            A2NetClient_Response a2NetClientResponse = await self.Fiber().ProcessInnerSender.Call(self.netClientActorId, a2NetClientRequest) as A2NetClient_Response;
+            A2NetClient_Response a2NetClientResponse = await self.Root().GetComponent<ProcessInnerSender>().Call(self.netClientActorId, a2NetClientRequest) as A2NetClient_Response;
             IResponse response = a2NetClientResponse.MessageObject;
                         
             if (response.Error == ErrorCore.ERR_MessageTimeout)

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

@@ -46,7 +46,7 @@ namespace ET.Client
                     
                     TimeInfo.Instance.ServerMinusClientTime = response.Time + (time2 - time1) / 2 - time2;
                     
-                    await fiber.TimerComponent.WaitAsync(2000);
+                    await fiber.Root.GetComponent<TimerComponent>().WaitAsync(2000);
                 }
                 catch (RpcException e)
                 {

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterAddressComponentSystem.cs

@@ -41,7 +41,7 @@ namespace ET.Client
         // 等10分钟再获取一次
         public static async ETTask WaitTenMinGetAllRouter(this RouterAddressComponent self)
         {
-            await self.Fiber().TimerComponent.WaitAsync(5 * 60 * 1000);
+            await self.Root().GetComponent<TimerComponent>().WaitAsync(5 * 60 * 1000);
             if (self.IsDisposed)
             {
                 return;

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterCheckComponentSystem.cs

@@ -29,7 +29,7 @@ namespace ET.Client
                     return;
                 }
 
-                await fiber.TimerComponent.WaitAsync(1000);
+                await fiber.Root.GetComponent<TimerComponent>().WaitAsync(1000);
                 
                 if (self.InstanceId != instanceId)
                 {

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Demo/NetClient/Router/RouterHelper.cs

@@ -57,7 +57,7 @@ namespace ET.Client
             sendCache.WriteTo(9, connectId);
             byte[] addressBytes = realAddress.ToString().ToByteArray();
             Array.Copy(addressBytes, 0, sendCache, 13, addressBytes.Length);
-            TimerComponent timerComponent = netComponent.Fiber().TimerComponent;
+            TimerComponent timerComponent = netComponent.Root().GetComponent<TimerComponent>();
             Log.Info($"router connect: {localConn} {remoteConn} {routerAddress} {realAddress}");
 
             long lastSendTimer = 0;

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Module/Message/ClientSessionErrorComponentSystem.cs

@@ -19,7 +19,7 @@
             }
             NetClient2Main_SessionDispose message = NetClient2Main_SessionDispose.Create();
             message.Error = self.GetParent<Session>().Error;
-            fiber.ProcessInnerSender.Send(new ActorId(fiber.Process, ConstFiberId.Main), message);
+            fiber.Root.GetComponent<ProcessInnerSender>().Send(new ActorId(fiber.Process, ConstFiberId.Main), message);
         }
     }
 }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Client/Module/Message/NetComponentOnReadInvoker_NetClient.cs

@@ -27,7 +27,7 @@ namespace ET.Client
                 {
                     // 扔到Main纤程队列中
                     int parentFiberId = fiber.Root.GetComponent<FiberParentComponent>().ParentFiberId;
-                    fiber.ProcessInnerSender.Send(new ActorId(fiber.Process, parentFiberId), iActorMessage);
+                    fiber.Root.GetComponent<ProcessInnerSender>().Send(new ActorId(fiber.Process, parentFiberId), iActorMessage);
                     break;
                 }
                 default:

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

@@ -23,7 +23,7 @@
 
         private static async ETTask TimeoutRemoveKey(this GateSessionKeyComponent self, long key)
         {
-            await self.Fiber().TimerComponent.WaitAsync(20000);
+            await self.Root().GetComponent<TimerComponent>().WaitAsync(20000);
             self.sessionKey.Remove(key);
         }
     }

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Realm/C2R_LoginHandler.cs

@@ -26,7 +26,7 @@ namespace ET.Server
 
 		private async ETTask CloseSession(Session session)
 		{
-			await session.Fiber().TimerComponent.WaitAsync(1000);
+			await session.Root().GetComponent<TimerComponent>().WaitAsync(1000);
 			session.Dispose();
 		}
 	}

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Demo/Robot/Console/CreateRobotConsoleHandler.cs

@@ -27,7 +27,7 @@ namespace ET.Server
                             fiber.Root.GetComponent<RobotManagerComponent>() ?? fiber.Root.AddComponent<RobotManagerComponent>();
 
                     // 创建机器人
-                    TimerComponent timerComponent = fiber.TimerComponent;
+                    TimerComponent timerComponent = fiber.Root.GetComponent<TimerComponent>();
                     for (int i = 0; i < options.Num; ++i)
                     {
                         await robotManagerComponent.NewRobot($"Robot_{i}");

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

@@ -19,7 +19,7 @@ namespace ET.Server
                 return;
             }
             
-            await room.Fiber.TimerComponent.WaitAsync(1000);
+            await room.Fiber.Root.GetComponent<TimerComponent>().WaitAsync(1000);
 
             Room2C_Start room2CStart = new() { StartTime = TimeInfo.Instance.ServerFrameTime() };
             foreach (RoomPlayer rp in roomServerComponent.Children.Values)

+ 5 - 5
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/LocationOneTypeSystem.cs

@@ -36,7 +36,7 @@ namespace ET.Server
         public static async ETTask Add(this LocationOneType self, long key, ActorId instanceId)
         {
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
-            using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
+            using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, key))
             {
                 self.locations[key] = instanceId;
                 Log.Info($"location add key: {key} instanceId: {instanceId}");
@@ -46,7 +46,7 @@ namespace ET.Server
         public static async ETTask Remove(this LocationOneType self, long key)
         {
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
-            using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
+            using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, key))
             {
                 self.locations.Remove(key);
                 Log.Info($"location remove key: {key}");
@@ -56,7 +56,7 @@ namespace ET.Server
         public static async ETTask Lock(this LocationOneType self, long key, ActorId actorId, int time = 0)
         {
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
-            CoroutineLock coroutineLock = await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key);
+            CoroutineLock coroutineLock = await self.Root().GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, key);
 
             LockInfo lockInfo = self.AddChild<LockInfo, ActorId, CoroutineLock>(actorId, coroutineLock);
             self.lockInfos.Add(key, lockInfo);
@@ -68,7 +68,7 @@ namespace ET.Server
                 async ETTask TimeWaitAsync()
                 {
                     long lockInfoInstanceId = lockInfo.InstanceId;
-                    await self.Fiber().TimerComponent.WaitAsync(time);
+                    await self.Root().GetComponent<TimerComponent>().WaitAsync(time);
                     if (lockInfo.InstanceId != lockInfoInstanceId)
                     {
                         return;
@@ -107,7 +107,7 @@ namespace ET.Server
         public static async ETTask<ActorId> Get(this LocationOneType self, long key)
         {
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.Location;
-            using (await self.Fiber().CoroutineLockComponent.Wait(coroutineLockType, key))
+            using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, key))
             {
                 self.locations.TryGetValue(key, out ActorId actorId);
                 Log.Info($"location get key: {key} actorId: {actorId}");

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationHandler.cs

@@ -82,7 +82,7 @@ namespace ET.Server
                     response.Message = exception.ToString();
                 }
                 response.RpcId = rpcId;
-                fiber.ProcessInnerSender.Reply(fromAddress, response);
+                fiber.Root.GetComponent<ProcessInnerSender>().Reply(fromAddress, response);
             }
             catch (Exception e)
             {

+ 6 - 6
Unity/Assets/Scripts/Hotfix/Server/Module/ActorLocation/MessageLocationSenderComponentSystem.cs

@@ -31,13 +31,13 @@ namespace ET.Server
             self.LocationType = locationType;
             // 每10s扫描一次过期的actorproxy进行回收,过期时间是2分钟
             // 可能由于bug或者进程挂掉,导致ActorLocationSender发送的消息没有确认,结果无法自动删除,每一分钟清理一次这种ActorLocationSender
-            self.CheckTimer = self.Fiber().TimerComponent.NewRepeatedTimer(10 * 1000, TimerInvokeType.MessageLocationSenderChecker, self);
+            self.CheckTimer = self.Root().GetComponent<TimerComponent>().NewRepeatedTimer(10 * 1000, TimerInvokeType.MessageLocationSenderChecker, self);
         }
         
         [EntitySystem]
         private static void Destroy(this MessageLocationSenderOneType self)
         {
-            self.Fiber().TimerComponent?.Remove(ref self.CheckTimer);
+            self.Root().GetComponent<TimerComponent>()?.Remove(ref self.CheckTimer);
         }
 
         private static void Check(this MessageLocationSenderOneType self)
@@ -113,7 +113,7 @@ namespace ET.Server
             long instanceId = messageLocationSender.InstanceId;
             
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.MessageLocationSender;
-            using (await root.Fiber.CoroutineLockComponent.Wait(coroutineLockType, entityId))
+            using (await root.Root().GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, entityId))
             {
                 if (messageLocationSender.InstanceId != instanceId)
                 {
@@ -151,7 +151,7 @@ namespace ET.Server
             long instanceId = messageLocationSender.InstanceId;
             
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.MessageLocationSender;
-            using (await root.Fiber.CoroutineLockComponent.Wait(coroutineLockType, entityId))
+            using (await root.GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, entityId))
             {
                 if (messageLocationSender.InstanceId != instanceId)
                 {
@@ -188,7 +188,7 @@ namespace ET.Server
             
             long actorLocationSenderInstanceId = messageLocationSender.InstanceId;
             int coroutineLockType = (self.LocationType << 16) | CoroutineLockType.MessageLocationSender;
-            using (await root.Fiber.CoroutineLockComponent.Wait(coroutineLockType, entityId))
+            using (await root.GetComponent<CoroutineLockComponent>().Wait(coroutineLockType, entityId))
             {
                 if (messageLocationSender.InstanceId != actorLocationSenderInstanceId)
                 {
@@ -264,7 +264,7 @@ namespace ET.Server
                         }
 
                         // 等待0.5s再发送
-                        await root.Fiber.TimerComponent.WaitAsync(500);
+                        await root.GetComponent<TimerComponent>().WaitAsync(500);
                         if (messageLocationSender.InstanceId != instanceId)
                         {
                             throw new RpcException(ErrorCore.ERR_ActorLocationSenderTimeout4, $"{iRequest}");

+ 14 - 17
Unity/Assets/Scripts/Hotfix/Server/Module/DB/DBComponentSystem.cs

@@ -30,7 +30,7 @@ namespace ET.Server
 
 	    public static async ETTask<T> Query<T>(this DBComponent self, long id, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
 		    {
 			    IAsyncCursor<T> cursor = await self.GetCollection<T>(collection).FindAsync(d => d.Id == id);
 
@@ -41,7 +41,7 @@ namespace ET.Server
 	    public static async ETTask<List<T>> Query<T>(this DBComponent self, Expression<Func<T, bool>> filter, string collection = null)
 			    where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
 		    {
 			    IAsyncCursor<T> cursor = await self.GetCollection<T>(collection).FindAsync(filter);
 
@@ -52,7 +52,7 @@ namespace ET.Server
 	    public static async ETTask<List<T>> Query<T>(this DBComponent self, long taskId, Expression<Func<T, bool>> filter, string collection = null)
 			    where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
 		    {
 			    IAsyncCursor<T> cursor = await self.GetCollection<T>(collection).FindAsync(filter);
 
@@ -67,7 +67,7 @@ namespace ET.Server
 			    return;
 		    }
 
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
 		    {
 			    foreach (string collectionName in collectionNames)
 			    {
@@ -87,7 +87,7 @@ namespace ET.Server
 
 	    public static async ETTask<List<T>> QueryJson<T>(this DBComponent self, string json, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
 		    {
 			    FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
 			    IAsyncCursor<T> cursor = await self.GetCollection<T>(collection).FindAsync(filterDefinition);
@@ -97,7 +97,7 @@ namespace ET.Server
 
 	    public static async ETTask<List<T>> QueryJson<T>(this DBComponent self, long taskId, string json, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
 		    {
 			    FilterDefinition<T> filterDefinition = new JsonFilterDefinition<T>(json);
 			    IAsyncCursor<T> cursor = await self.GetCollection<T>(collection).FindAsync(filterDefinition);
@@ -116,7 +116,7 @@ namespace ET.Server
 			    collection = typeof (T).FullName;
 		    }
 		    
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
 		    {
 			    await self.GetCollection(collection).InsertManyAsync(list);
 		    }
@@ -128,7 +128,6 @@ namespace ET.Server
 
 	    public static async ETTask Save<T>(this DBComponent self, T entity, string collection = null) where T : Entity
 	    {
-		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
 			    Log.Error($"save entity is null: {typeof (T).FullName}");
@@ -141,7 +140,7 @@ namespace ET.Server
 			    collection = entity.GetType().FullName;
 		    }
 
-		    using (await fiber.CoroutineLockComponent.Wait(CoroutineLockType.DB, entity.Id % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, entity.Id % DBComponent.TaskCount))
 		    {
 			    await self.GetCollection(collection).ReplaceOneAsync(d => d.Id == entity.Id, entity, new ReplaceOptions { IsUpsert = true });
 		    }
@@ -149,7 +148,6 @@ namespace ET.Server
 
 	    public static async ETTask Save<T>(this DBComponent self, long taskId, T entity, string collection = null) where T : Entity
 	    {
-		    Fiber fiber = self.Fiber();
 		    if (entity == null)
 		    {
 			    Log.Error($"save entity is null: {typeof (T).FullName}");
@@ -162,7 +160,7 @@ namespace ET.Server
 			    collection = entity.GetType().FullName;
 		    }
 
-		    using (await fiber.CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
 		    {
 			    await self.GetCollection(collection).ReplaceOneAsync(d => d.Id == entity.Id, entity, new ReplaceOptions { IsUpsert = true });
 		    }
@@ -170,14 +168,13 @@ namespace ET.Server
 
 	    public static async ETTask Save(this DBComponent self, long id, List<Entity> entities)
 	    {
-		    Fiber fiber = self.Fiber();
 		    if (entities == null)
 		    {
 			    Log.Error($"save entity is null");
 			    return;
 		    }
 
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
 		    {
 			    foreach (Entity entity in entities)
 			    {
@@ -210,7 +207,7 @@ namespace ET.Server
 	    
 	    public static async ETTask<long> Remove<T>(this DBComponent self, long id, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, id % DBComponent.TaskCount))
 		    {
 			    DeleteResult result = await self.GetCollection<T>(collection).DeleteOneAsync(d => d.Id == id);
 
@@ -220,7 +217,7 @@ namespace ET.Server
 
 	    public static async ETTask<long> Remove<T>(this DBComponent self, long taskId, long id, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
 		    {
 			    DeleteResult result = await self.GetCollection<T>(collection).DeleteOneAsync(d => d.Id == id);
 
@@ -230,7 +227,7 @@ namespace ET.Server
 
 	    public static async ETTask<long> Remove<T>(this DBComponent self, Expression<Func<T, bool>> filter, string collection = null) where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, RandomGenerator.RandInt64() % DBComponent.TaskCount))
 		    {
 			    DeleteResult result = await self.GetCollection<T>(collection).DeleteManyAsync(filter);
 
@@ -241,7 +238,7 @@ namespace ET.Server
 	    public static async ETTask<long> Remove<T>(this DBComponent self, long taskId, Expression<Func<T, bool>> filter, string collection = null)
 			    where T : Entity
 	    {
-		    using (await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
+		    using (await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.DB, taskId % DBComponent.TaskCount))
 		    {
 			    DeleteResult result = await self.GetCollection<T>(collection).DeleteManyAsync(filter);
 

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/Message/MessageSenderSystem.cs

@@ -14,7 +14,7 @@ namespace ET.Server
             // 如果发向同一个进程,则扔到消息队列中
             if (actorId.Process == fiber.Process)
             {
-                fiber.ProcessInnerSender.Send(actorId, message);
+                fiber.Root.GetComponent<ProcessInnerSender>().Send(actorId, message);
                 return;
             }
             
@@ -65,7 +65,7 @@ namespace ET.Server
             
             if (fiber.Process == actorId.Process)
             {
-                return await fiber.ProcessInnerSender.Call(actorId, rpcId, request, needException: needException);
+                return await fiber.Root.GetComponent<ProcessInnerSender>().Call(actorId, rpcId, request, needException: needException);
             }
 
             // 发给NetInner纤程
@@ -73,7 +73,7 @@ namespace ET.Server
             a2NetInner_Request.ActorId = actorId;
             a2NetInner_Request.MessageObject = request;
             
-            A2NetInner_Response a2NetInnerResponse = await fiber.ProcessInnerSender.Call(
+            A2NetInner_Response a2NetInnerResponse = await fiber.Root.GetComponent<ProcessInnerSender>().Call(
                 new ActorId(fiber.Process, ConstFiberId.NetInner), a2NetInner_Request) as A2NetInner_Response;
             IResponse response = a2NetInnerResponse.MessageObject;
             

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Server/Module/Message/ProcessOuterSenderSystem.cs

@@ -73,7 +73,7 @@ namespace ET.Server
                     {
                         IRequest request = (IRequest)message;
                         // 注意这里都不能抛异常,因为这里只是中转消息
-                        IResponse response = await fiber.ProcessInnerSender.Call(actorId, request, false);
+                        IResponse response = await fiber.Root.GetComponent<ProcessInnerSender>().Call(actorId, request, false);
                         actorId.Process = fromProcess;
                         self.Send(actorId, response);
                     }
@@ -82,7 +82,7 @@ namespace ET.Server
                 }
                 default:
                 {
-                    fiber.ProcessInnerSender.Send(actorId, (IMessage)message);
+                    fiber.Root.GetComponent<ProcessInnerSender>().Send(actorId, (IMessage)message);
                     break;
                 }
             }
@@ -209,7 +209,7 @@ namespace ET.Server
 
             async ETTask Timeout()
             {
-                await fiber.TimerComponent.WaitAsync(ProcessOuterSender.TIMEOUT_TIME);
+                await fiber.Root.GetComponent<TimerComponent>().WaitAsync(ProcessOuterSender.TIMEOUT_TIME);
                 if (!self.requestCallback.Remove(rpcId, out MessageSenderStruct action))
                 {
                     return;

+ 3 - 3
Unity/Assets/Scripts/Hotfix/Share/Module/AI/AIComponentSystem.cs

@@ -27,13 +27,13 @@ namespace ET
         private static void Awake(this AIComponent self, int aiConfigId)
         {
             self.AIConfigId = aiConfigId;
-            self.Timer = self.Fiber().TimerComponent.NewRepeatedTimer(1000, TimerInvokeType.AITimer, self);
+            self.Timer = self.Root().GetComponent<TimerComponent>().NewRepeatedTimer(1000, TimerInvokeType.AITimer, self);
         }
 
         [EntitySystem]
         private static void Destroy(this AIComponent self)
         {
-            self.Fiber().TimerComponent?.Remove(ref self.Timer);
+            self.Root().GetComponent<TimerComponent>()?.Remove(ref self.Timer);
             self.CancellationToken?.Cancel();
             self.CancellationToken = null;
             self.Current = 0;
@@ -44,7 +44,7 @@ namespace ET
             Fiber fiber = self.Fiber();
             if (self.Parent == null)
             {
-                fiber.TimerComponent.Remove(ref self.Timer);
+                fiber.Root.GetComponent<TimerComponent>().Remove(ref self.Timer);
                 return;
             }
 

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MailBoxType_OrderedMessageHandler.cs

@@ -22,7 +22,7 @@
             }
 
             long instanceId = mailBoxComponent.InstanceId;
-            using (await fiber.CoroutineLockComponent.Wait(CoroutineLockType.Mailbox, mailBoxComponent.ParentInstanceId))
+            using (await fiber.Root.GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.Mailbox, mailBoxComponent.ParentInstanceId))
             {
                 if (mailBoxComponent.InstanceId != instanceId)
                 {

+ 1 - 1
Unity/Assets/Scripts/Hotfix/Share/Module/Actor/MessageHandler.cs

@@ -84,7 +84,7 @@ namespace ET
                 }
                 
                 response.RpcId = rpcId;
-                fiber.ProcessInnerSender.Reply(fromAddress, response);
+                fiber.Root.GetComponent<ProcessInnerSender>().Reply(fromAddress, response);
             }
             catch (Exception e)
             {

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionAcceptTimeoutComponentSystem.cs

@@ -25,13 +25,13 @@ namespace ET
         [EntitySystem]
         private static void Awake(this SessionAcceptTimeoutComponent self)
         {
-            self.Timer = self.Fiber().TimerComponent.NewOnceTimer(TimeInfo.Instance.ServerNow() + 5000, TimerInvokeType.SessionAcceptTimeout, self);
+            self.Timer = self.Root().GetComponent<TimerComponent>().NewOnceTimer(TimeInfo.Instance.ServerNow() + 5000, TimerInvokeType.SessionAcceptTimeout, self);
         }
         
         [EntitySystem]
         private static void Destroy(this SessionAcceptTimeoutComponent self)
         {
-            self.Fiber().TimerComponent?.Remove(ref self.Timer);
+            self.Root().GetComponent<TimerComponent>()?.Remove(ref self.Timer);
         }
         
     }

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Share/Module/Message/SessionIdleCheckerComponentSystem.cs

@@ -25,13 +25,13 @@ namespace ET
         [EntitySystem]
         private static void Awake(this SessionIdleCheckerComponent self)
         {
-            self.RepeatedTimer = self.Fiber().TimerComponent.NewRepeatedTimer(CheckInteral, TimerInvokeType.SessionIdleChecker, self);
+            self.RepeatedTimer = self.Root().GetComponent<TimerComponent>().NewRepeatedTimer(CheckInteral, TimerInvokeType.SessionIdleChecker, self);
         }
         
         [EntitySystem]
         private static void Destroy(this SessionIdleCheckerComponent self)
         {
-            self.Fiber().TimerComponent?.Remove(ref self.RepeatedTimer);
+            self.Root().GetComponent<TimerComponent>()?.Remove(ref self.RepeatedTimer);
         }
 
         private const int CheckInteral = 2000;

+ 2 - 2
Unity/Assets/Scripts/Hotfix/Share/Module/Move/MoveComponentSystem.cs

@@ -182,7 +182,7 @@ namespace ET
             self.StartTime = self.BeginTime;
             self.SetNextTarget();
 
-            self.MoveTimer = self.Fiber().TimerComponent.NewFrameTimer(TimerInvokeType.MoveTimer, self);
+            self.MoveTimer = self.Root().GetComponent<TimerComponent>().NewFrameTimer(TimerInvokeType.MoveTimer, self);
         }
 
         private static void SetNextTarget(this MoveComponent self)
@@ -281,7 +281,7 @@ namespace ET
             self.N = 0;
             self.TurnTime = 0;
             self.IsTurnHorizontal = false;
-            self.Fiber().TimerComponent?.Remove(ref self.MoveTimer);
+            self.Root().GetComponent<TimerComponent>()?.Remove(ref self.MoveTimer);
 
             if (self.tcs != null)
             {

+ 1 - 1
Unity/Assets/Scripts/Model/Share/Module/Message/Session.cs

@@ -107,7 +107,7 @@ namespace ET
             {
                 async ETTask Timeout()
                 {
-                    await self.Fiber().TimerComponent.WaitAsync(time);
+                    await self.Root().GetComponent<TimerComponent>().WaitAsync(time);
                     if (!self.requestCallbacks.TryGetValue(rpcId, out RpcInfo action))
                     {
                         return;

+ 1 - 1
Unity/Assets/Scripts/Model/Share/Module/ObjectWait/ObjectWait.cs

@@ -108,7 +108,7 @@ namespace ET
             ResultCallback<T> tcs = new ResultCallback<T>();
             async ETTask WaitTimeout()
             {
-                await self.Fiber().TimerComponent.WaitAsync(timeout, cancellationToken);
+                await self.Root().GetComponent<TimerComponent>().WaitAsync(timeout, cancellationToken);
                 if (cancellationToken.IsCancel())
                 {
                     return;

+ 3 - 3
Unity/Assets/Scripts/ModelView/Client/Module/Resource/ResourcesLoaderComponent.cs

@@ -52,7 +52,7 @@ namespace ET.Client
 
         public static async ETTask<T> LoadAssetAsync<T>(this ResourcesLoaderComponent self, string location) where T: UnityEngine.Object
         {
-            using CoroutineLock coroutineLock = await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
+            using CoroutineLock coroutineLock = await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
             
             OperationHandleBase handler;
             if (!self.handlers.TryGetValue(location, out handler))
@@ -69,7 +69,7 @@ namespace ET.Client
         
         public static async ETTask<Dictionary<string, T>> LoadAllAssetsAsync<T>(this ResourcesLoaderComponent self, string location) where T: UnityEngine.Object
         {
-            using CoroutineLock coroutineLock = await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
+            using CoroutineLock coroutineLock = await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
 
             OperationHandleBase handler;
             if (!self.handlers.TryGetValue(location, out handler))
@@ -91,7 +91,7 @@ namespace ET.Client
         
         public static async ETTask LoadSceneAsync(this ResourcesLoaderComponent self, string location, LoadSceneMode loadSceneMode)
         {
-            using CoroutineLock coroutineLock = await self.Fiber().CoroutineLockComponent.Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
+            using CoroutineLock coroutineLock = await self.Root().GetComponent<CoroutineLockComponent>().Wait(CoroutineLockType.ResourcesLoader, location.GetHashCode());
 
             OperationHandleBase handler;
             if (self.handlers.TryGetValue(location, out handler))