@@ -4,7 +4,7 @@
<OutputType>Exe</OutputType>
<TargetFramework>net5.0</TargetFramework>
<RootNamespace>ET</RootNamespace>
- <LangVersion>7.3</LangVersion>
+ <LangVersion>8</LangVersion>
</PropertyGroup>
<PropertyGroup>
@@ -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>();
@@ -2,7 +2,7 @@
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
@@ -3,6 +3,7 @@
<PropertyGroup Condition=" '$(Configuration)' == 'Debug' ">
@@ -4,6 +4,7 @@
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
@@ -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;
@@ -2,7 +2,7 @@ namespace ET
Game.Scene.AddComponent<TimerComponent>();
Game.Scene.AddComponent<CoroutineLockComponent>();
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>();
@@ -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);
}
public class LoadingFinishEvent_RemoveLoadingUI : AEvent<EventType.LoadingFinish>
- public override async ETTask Run(EventType.LoadingFinish args)
+ protected override async ETTask Run(EventType.LoadingFinish args)
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");
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);
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);
public class LoginFinish_RemoveLoginUI: AEvent<EventType.LoginFinish>
await UIHelper.Remove(args.ZoneScene, UIType.UILogin);
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>();
@@ -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;
@@ -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);
@@ -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)