0%

ET-热重载

CodeLoader.Start()依赖Init.cs中的Start生命周期触发。
无论是否启用热重载流程,必不可少的是需要触发游戏Entry流程,CodeLoader.cs中触发代码如下:

1
2
IStaticMethod start = new StaticMethod(this.model, "ET.Entry", "Start");
start.Run();

而在CodeLoader.StartAsync()代码中,又对游戏一些必要模块进行了初始化,同时触发相关事件进行Publish:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
private static async ETTask StartAsync()
{
WinPeriod.Init();

MongoHelper.Init();
ProtobufHelper.Init();

Game.AddSingleton<NetServices>();
Game.AddSingleton<Root>();
Game.AddSingleton<CDSystem>();
await Game.AddSingleton<ConfigComponent>().LoadAsync();

await EventSystem.Instance.PublishAsync(Root.Instance.Scene, new EventType.EntryEvent1());
await EventSystem.Instance.PublishAsync(Root.Instance.Scene, new EventType.EntryEvent2());
await EventSystem.Instance.PublishAsync(Root.Instance.Scene, new EventType.EntryEvent3());
}