Beispiel #1
0
        public async ETTask Handle()
        {
            // 发送普通actor消息
            Game.Scene.AddComponent <ActorMessageSenderComponent>();
            // 发送location actor消息
            Game.Scene.AddComponent <ActorLocationSenderComponent>();
            // 访问location server的组件
            Game.Scene.AddComponent <LocationProxyComponent>();
            Game.Scene.AddComponent <ActorMessageDispatcherComponent>();

            Game.Scene.AddComponent <RobotCaseDispatcherComponent>();
            Game.Scene.AddComponent <RobotCaseComponent>();

            Game.Scene.AddComponent <NavmeshComponent>();

            StartProcessConfig processConfig = StartProcessConfigCategory.Instance.Get(Game.Options.Process);

            switch (Game.Options.AppType)
            {
            case AppType.Server:
            {
                Game.Scene.AddComponent <NetInnerComponent, IPEndPoint, int>(processConfig.InnerIPPort, CallbackType.SessionStreamDispatcherServerInner);

                var processScenes = StartSceneConfigCategory.Instance.GetByProcess(Game.Options.Process);
                foreach (StartSceneConfig startConfig in processScenes)
                {
                    await SceneFactory.Create(Game.Scene, startConfig.Id, startConfig.InstanceId, startConfig.Zone, startConfig.Name,
                                              startConfig.Type, startConfig);
                }

                break;
            }

            case AppType.Watcher:
            {
                StartMachineConfig startMachineConfig = WatcherHelper.GetThisMachineConfig();
                WatcherComponent   watcherComponent   = Game.Scene.AddComponent <WatcherComponent>();
                watcherComponent.Start(Game.Options.CreateScenes);
                Game.Scene.AddComponent <NetInnerComponent, IPEndPoint, int>(NetworkHelper.ToIPEndPoint($"{startMachineConfig.InnerIP}:{startMachineConfig.WatcherPort}"), CallbackType.SessionStreamDispatcherServerInner);
                break;
            }

            case AppType.GameTool:
                break;
            }

            if (Game.Options.Console == 1)
            {
                Game.Scene.AddComponent <ConsoleComponent>();
            }
        }
Beispiel #2
0
        public static StartMachineConfig GetThisMachineConfig()
        {
            string[]           localIP            = NetworkHelper.GetAddressIPs();
            StartMachineConfig startMachineConfig = null;

            foreach (StartMachineConfig config in StartMachineConfigCategory.Instance.GetAll().Values)
            {
                if (!WatcherHelper.IsThisMachine(config.InnerIP, localIP))
                {
                    continue;
                }
                startMachineConfig = config;
                break;
            }

            if (startMachineConfig == null)
            {
                throw new Exception("not found this machine ip config!");
            }

            return(startMachineConfig);
        }