1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- using System;
- using System.Net;
- using ET;
- namespace ET.Server
- {
- [Event(SceneType.Process)]
- public class EntryEvent2_InitServer: BEvent<EventType.EntryEvent2>
- {
- protected override async ETTask OnEvent(EventType.EntryEvent2 args)
- {
- Root.Instance.Scene.AddComponent<AIDispatcherComponent>();
- // 发送普通actor消息
- Root.Instance.Scene.AddComponent<ActorMessageSenderComponent>();
- // 发送location actor消息
- Root.Instance.Scene.AddComponent<ActorLocationSenderComponent>();
- // 访问location server的组件
- Root.Instance.Scene.AddComponent<LocationProxyComponent>();
- Root.Instance.Scene.AddComponent<ActorMessageDispatcherComponent>();
- Root.Instance.Scene.AddComponent<ServerSceneManagerComponent>();
- Root.Instance.Scene.AddComponent<RobotCaseComponent>();
- // 访问mongodb数据库组件
- Root.Instance.Scene.AddComponent<DBManagerComponent>();
- StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Options.Instance.Process);
- Log.Debug($"AppType: {Options.Instance.AppType}");
- switch (Options.Instance.AppType)
- {
- case AppType.Server:
- {
- Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(
- processConfig.InnerIPPort
- );
- var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Options.Instance.Process);
- foreach (StartSceneConfig startConfig in processScenes)
- {
- await SceneFactory.CreateServerScene(
- ServerSceneManagerComponent.Instance, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
- startConfig.Type, startConfig);
- }
- break;
- }
- case AppType.Watcher:
- {
- StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
- WatcherComponent watcherComponent = Root.Instance.Scene.AddComponent<WatcherComponent>();
- watcherComponent.Start(Options.Instance.CreateScenes);
- Root.Instance.Scene.AddComponent<NetInnerComponent, IPEndPoint>(
- NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}")
- );
- break;
- }
- case AppType.GameTool:
- break;
- }
- if (Options.Instance.Console == 1)
- {
- Root.Instance.Scene.AddComponent<ConsoleComponent>();
- }
- }
- }
- }
|