Files
Fishing2Server/Hotfix/OnSceneCreate_Init.cs

71 lines
2.3 KiB
C#

using Fantasy;
using Fantasy.Async;
using Fantasy.Event;
using NB.Authentication;
using NB.Chat;
using NB.Game;
using NB.Gate;
using NB.Map;
namespace NB;
public class OnSceneCreate_Init : AsyncEventSystem<OnCreateScene>
{
protected override async FTask Handler(OnCreateScene self)
{
var scene = self.Scene;
switch (scene.SceneType)
{
case SceneType.Authentication:
{
// 用于鉴权服务器注册和登录相关逻辑的组件
scene.AddComponent<AuthenticationComponent>().UpdatePosition();
// 用于颁发ToKen证书相关的逻辑。
scene.AddComponent<AuthenticationJwtComponent>();
break;
}
case SceneType.Gate:
{
// 用于管理网关所有连接的组件
scene.AddComponent<GateUnitManageComponent>();
// 用于验证JWT是否合法的组件
scene.AddComponent<GateJWTComponent>();
break;
}
case SceneType.Game:
{
//用于管理玩家的组件
scene.AddComponent<PlayerManageComponent>();
scene.AddComponent<PlayerBasicCacheManageComponent>();
break;
}
case SceneType.Social:
{
//用于管理玩家的组件
scene.AddComponent<SocialUnitManageComponent>();
scene.AddComponent<ChatChannelCenterComponent>();
scene.AddComponent<MailManageComponent>();
break;
}
case SceneType.Map:
{
Log.Info("创建地图场景===");
scene.AddComponent<MapUnitManageComponent>();
var roomManageComponent = scene.AddComponent<RoomManageComponent>();
scene.AddComponent<MapManageComponent>();
var room = roomManageComponent.Create(361499030775398402);
if (room != null)
{
roomManageComponent.TestRoomCode = room.Code;
Log.Info($"测试房间代码 = {room.Code}");
}
break;
}
}
await FTask.CompletedTask;
}
}