Closed jiangjiali closed 4 months ago
public class OnCreateScene : AsyncEventSystem<Fantasy.OnCreateScene> { public override async FTask Handler(Fantasy.OnCreateScene self) { // 服务器是以Scene为单位的、所以Scene下有什么组件都可以自己添加定义 // OnCreateScene这个事件就是给开发者使用的 // 比如Address协议这里、我就是做了一个管理Address地址的一个组件挂在到Address这个Scene下面了 // 比如Hall下你需要一些自定义组件、你也可以在这里操作 var scene = self.Scene; switch (scene.SceneType) { case SceneType.Addressable: // 挂载管理Address地址组件 scene.AddComponent<AddressableManageComponent>(); Log.Debug($"创建 Addressable 场景完成 {scene.SceneType}"); break; case SceneType.Chat: scene.AddComponent<ChatUnitManagerComponent>(); Log.Debug($"创建 Chat 场景完成 {scene.SceneType}"); break; case SceneType.Hall: scene.AddComponent<HallUnitManagerComponent>(); Log.Debug($"创建 Hall 场景完成 {scene.SceneType}"); break; case SceneType.Gate: scene.AddComponent<GateUnitManagerComponent>(); Log.Debug($"创建 Gate 场景完成 {scene.SceneType}"); break; } await FTask.CompletedTask; } } public class OnServerStartComplete : AsyncEventSystem<Fantasy.OnServerStartComplete> { public override async FTask Handler(Fantasy.OnServerStartComplete self) { var scene = self.Server.Scene; Log.Debug($"启动服务器完成 {scene.SceneType}"); await FTask.CompletedTask; } }
Active code page: 65001 2024-05-18 17:57:03.6143 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11001 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:20000 2024-05-18 17:57:04.3450 创建 Gate 场景完成 1 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:1025 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11002 2024-05-18 17:57:04.3450 创建 Addressable 场景完成 2 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:2049 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11003 2024-05-18 17:57:04.3450 创建 Hall 场景完成 3 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:3073 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11004 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:4097 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11005 2024-05-18 17:57:04.3450 创建 Chat 场景完成 5 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:5121 is start complete
为什么启动时的地方,SceneType 为 0
Active code page: 65001 2024-05-18 17:57:03.6143 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11001 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:20000 2024-05-18 17:57:04.3450 创建 Gate 场景完成 1 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:1025 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11002 2024-05-18 17:57:04.3450 创建 Addressable 场景完成 2 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:2049 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11003 2024-05-18 17:57:04.3450 创建 Hall 场景完成 3 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:3073 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11004 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:4097 is start complete 2024-05-18 17:57:04.3450 NetworkProtocol:KCP IPEndPoint:127.0.0.1:11005 2024-05-18 17:57:04.3450 创建 Chat 场景完成 5 2024-05-18 17:57:04.3450 启动服务器完成 0 2024-05-18 17:57:04.3450 ServerId:5121 is start complete
为什么启动时的地方,SceneType 为 0