Browse Source

publish改成并发调用

tanghai 4 years ago
parent
commit
b7c51deac6

+ 1 - 1
Server/App/Server.App.csproj

@@ -4,7 +4,7 @@
     <OutputType>Exe</OutputType>
     <TargetFramework>net5.0</TargetFramework>
     <RootNamespace>ET</RootNamespace>
-    <LangVersion>7.3</LangVersion>
+    <LangVersion>8</LangVersion>
   </PropertyGroup>
 
   <PropertyGroup>

+ 1 - 1
Server/Hotfix/AppStart_Init.cs

@@ -6,7 +6,7 @@ namespace ET
 {
     public class AppStart_Init: AEvent<EventType.AppStart>
     {
-        public override async ETTask Run(EventType.AppStart args)
+        protected override async ETTask Run(EventType.AppStart args)
         {
             Game.Scene.AddComponent<ConfigComponent>();
             

+ 1 - 1
Server/Hotfix/Server.Hotfix.csproj

@@ -2,7 +2,7 @@
   <PropertyGroup>
     <TargetFramework>net5.0</TargetFramework>
     <RootNamespace>ET</RootNamespace>
-    <LangVersion>7.3</LangVersion>
+    <LangVersion>8</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

+ 1 - 1
Server/Model/Server.Model.csproj

@@ -2,7 +2,7 @@
   <PropertyGroup>
     <TargetFramework>net5.0</TargetFramework>
     <RootNamespace>ET</RootNamespace>
-    <LangVersion>7.3</LangVersion>
+    <LangVersion>8</LangVersion>
   </PropertyGroup>
   <PropertyGroup>
     <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>

+ 1 - 0
Server/ThirdParty/Server.ThirdParty.csproj

@@ -3,6 +3,7 @@
     <PropertyGroup>
         <TargetFramework>net5.0</TargetFramework>
         <RootNamespace>ET</RootNamespace>
+        <LangVersion>8</LangVersion>
     </PropertyGroup>
 
     <PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">

+ 1 - 0
Tools/ExcelExporter/ExcelExporter.csproj

@@ -4,6 +4,7 @@
         <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
         <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
         <RootNamespace>ET</RootNamespace>
+        <LangVersion>8</LangVersion>
     </PropertyGroup>
     
     <PropertyGroup>

+ 1 - 0
Tools/Proto2CS/Proto2CS.csproj

@@ -4,6 +4,7 @@
         <AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
         <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
         <SatelliteResourceLanguages>en</SatelliteResourceLanguages>
+        <LangVersion>8</LangVersion>
     </PropertyGroup>
 
     <PropertyGroup>

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

@@ -3,7 +3,7 @@
 	// 分发数值监听
 	public class NumericChangeEvent_NotifyWatcher: AEvent<EventType.NumbericChange>
 	{
-		public override async ETTask Run(EventType.NumbericChange args)
+		protected override async ETTask Run(EventType.NumbericChange args)
 		{
 			NumericWatcherComponent.Instance.Run(args.NumericType, args.Parent.Id, args.New);
 			await ETTask.CompletedTask;

+ 1 - 1
Unity/Assets/HotfixView/AppStart_Init.cs

@@ -2,7 +2,7 @@ namespace ET
 {
     public class AppStart_Init: AEvent<EventType.AppStart>
     {
-        public override async ETTask Run(EventType.AppStart args)
+        protected override async ETTask Run(EventType.AppStart args)
         {
             Game.Scene.AddComponent<TimerComponent>();
             Game.Scene.AddComponent<CoroutineLockComponent>();

+ 1 - 1
Unity/Assets/HotfixView/Scene/AfterCreateZoneScene_AddComponent.cs

@@ -2,7 +2,7 @@ namespace ET
 {
     public class AfterCreateZoneScene_AddComponent: AEvent<EventType.AfterCreateZoneScene>
     {
-        public override async ETTask Run(EventType.AfterCreateZoneScene args)
+        protected override async ETTask Run(EventType.AfterCreateZoneScene args)
         {
             Scene zoneScene = args.ZoneScene;
             zoneScene.AddComponent<ResourcesComponent>();

+ 1 - 1
Unity/Assets/HotfixView/UI/UILoading/LoadingBeginEvent_CreateLoadingUI.cs

@@ -4,7 +4,7 @@ namespace ET
 {
     public class LoadingBeginEvent_CreateLoadingUI : AEvent<EventType.LoadingBegin>
     {
-        public override async ETTask Run(EventType.LoadingBegin args)
+        protected override async ETTask Run(EventType.LoadingBegin args)
         {
             await UIHelper.Create(args.Scene, UIType.UILoading);
         }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILoading/LoadingFinishEvent_RemoveLoadingUI.cs

@@ -2,7 +2,7 @@
 {
     public class LoadingFinishEvent_RemoveLoadingUI : AEvent<EventType.LoadingFinish>
     {
-        public override async ETTask Run(EventType.LoadingFinish args)
+        protected override async ETTask Run(EventType.LoadingFinish args)
         {
             await UIHelper.Create(args.Scene, UIType.UILoading);
         }

+ 1 - 1
Unity/Assets/HotfixView/UI/UILobby/EnterMapFinish_RemoveLobbyUI.cs

@@ -2,7 +2,7 @@
 {
 	public class EnterMapFinish_RemoveLobbyUI: AEvent<EventType.EnterMapFinish>
 	{
-		public override async ETTask Run(EventType.EnterMapFinish args)
+		protected override async ETTask Run(EventType.EnterMapFinish args)
 		{
 			// 加载场景资源
 			await Game.Scene.GetComponent<ResourcesComponent>().LoadBundleAsync("map.unity3d");

+ 1 - 1
Unity/Assets/HotfixView/UI/UILobby/LoginFinish_CreateLobbyUI.cs

@@ -4,7 +4,7 @@ namespace ET
 {
 	public class LoginFinish_CreateLobbyUI: AEvent<EventType.LoginFinish>
 	{
-		public override async ETTask Run(EventType.LoginFinish args)
+		protected override async ETTask Run(EventType.LoginFinish args)
 		{
 			await UIHelper.Create(args.ZoneScene, UIType.UILobby);
 		}

+ 1 - 1
Unity/Assets/HotfixView/UI/UILogin/AppStartInitFinish_CreateLoginUI.cs

@@ -4,7 +4,7 @@ namespace ET
 {
 	public class AppStartInitFinish_RemoveLoginUI: AEvent<EventType.AppStartInitFinish>
 	{
-		public override async ETTask Run(EventType.AppStartInitFinish args)
+		protected override async ETTask Run(EventType.AppStartInitFinish args)
 		{
 			await UIHelper.Create(args.ZoneScene, UIType.UILogin);
 		}

+ 1 - 1
Unity/Assets/HotfixView/UI/UILogin/LoginFinish_RemoveLoginUI.cs

@@ -4,7 +4,7 @@ namespace ET
 {
 	public class LoginFinish_RemoveLoginUI: AEvent<EventType.LoginFinish>
 	{
-		public override async ETTask Run(EventType.LoginFinish args)
+		protected override async ETTask Run(EventType.LoginFinish args)
 		{
 			await UIHelper.Remove(args.ZoneScene, UIType.UILogin);
 		}

+ 1 - 1
Unity/Assets/HotfixView/Unit/AfterUnitCreate_CreateUnitView.cs

@@ -4,7 +4,7 @@ namespace ET
 {
     public class AfterUnitCreate_CreateUnitView: AEvent<EventType.AfterUnitCreate>
     {
-        public override async ETTask Run(EventType.AfterUnitCreate args)
+        protected override async ETTask Run(EventType.AfterUnitCreate args)
         {
             // Unit View层
             ResourcesComponent resourcesComponent = Game.Scene.GetComponent<ResourcesComponent>();

+ 17 - 0
Unity/Assets/Model/Core/Async/ETTaskHelper.cs

@@ -108,5 +108,22 @@ namespace ET
                 await coroutineBlocker.WaitAsync();
             }
         }
+        
+        public static async ETTask WaitAll(List<ETTask> tasks)
+        {
+            CoroutineBlocker coroutineBlocker = new CoroutineBlocker(tasks.Count + 1);
+            foreach (ETTask task in tasks)
+            {
+                RunOneTask(task).Coroutine();
+            }
+
+            await coroutineBlocker.WaitAsync();
+
+            async ETVoid RunOneTask(ETTask task)
+            {
+                await task;
+                await coroutineBlocker.WaitAsync();
+            }
+        }
     }
 }

+ 13 - 1
Unity/Assets/Model/Core/Event/IEvent.cs

@@ -15,6 +15,18 @@ namespace ET
 			return typeof (A);
 		}
 
-		public abstract ETTask Run(A a);
+		protected abstract ETTask Run(A a);
+
+		public async ETTask Handle(A a)
+		{
+			try
+			{
+				await Run(a);
+			}
+			catch (Exception e)
+			{
+				Log.Error(e);
+			}
+		}
 	}
 }

+ 6 - 1
Unity/Assets/Model/Core/Object/EventSystem.cs

@@ -617,12 +617,17 @@ namespace ET
 			{
 				try
 				{
+					using var list = ListComponent<ETTask>.Create();
+					
 					if (!(obj is AEvent<T> aEvent))
 					{
 						Log.Error($"event error: {obj.GetType().Name}");
 						continue;
 					}
-					await aEvent.Run(a);
+
+					list.List.Add(aEvent.Handle(a));
+
+					await ETTaskHelper.WaitAll(list.List);
 				}
 				catch (Exception e)
 				{