Пример #1
0
            private void _serverMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    ServerIoC.RegisterIoC();
                    IoCManager.Register <INetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IServerNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IntegrationNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <ISystemConsoleManager, SystemConsoleManagerDummy>(true);
                    IoCManager.Register <IModLoader, ModLoader>(true);
                    IoCManager.Register <ModLoader, ModLoader>(true);
                    IoCManager.RegisterInstance <IStatusHost>(new Mock <IStatusHost>().Object, true);
                    _options?.InitIoC?.Invoke();
                    IoCManager.BuildGraph();
                    //ServerProgram.SetupLogging();
                    ServerProgram.InitReflectionManager();

                    var server = DependencyCollection.Resolve <IBaseServerInternal>();

                    if (_options?.ServerContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().ServerContentAssembly = _options.ServerContentAssembly;
                    }

                    if (_options?.SharedContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().SharedContentAssembly = _options.SharedContentAssembly;
                    }

                    if (_options != null)
                    {
                        _options.BeforeStart?.Invoke();
                        IoCManager.Resolve <IConfigurationManager>()
                        .OverrideConVars(_options.CVarOverrides.Select(p => (p.Key, p.Value)));
                    }

                    if (server.Start(() => new TestLogHandler("SERVER")))
                    {
                        throw new Exception("Server failed to start.");
                    }

                    var gameLoop = new IntegrationGameLoop(
                        DependencyCollection.Resolve <IGameTiming>(),
                        _fromInstanceWriter, _toInstanceReader);
                    server.OverrideMainLoop(gameLoop);

                    server.MainLoop();
                }
                catch (Exception e)
                {
                    _fromInstanceWriter.TryWrite(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceWriter.TryWrite(new ShutDownMessage(null));
            }
Пример #2
0
            private void _serverMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    ServerIoC.RegisterIoC();
                    IoCManager.Register <INetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IServerNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IntegrationNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <ISystemConsoleManager, SystemConsoleManagerDummy>(true);
                    IoCManager.Register <IModLoader, ModLoader>(true);
                    IoCManager.Register <ModLoader, ModLoader>(true);
                    _options?.InitIoC?.Invoke();
                    IoCManager.BuildGraph();
                    ServerProgram.SetupLogging();
                    ServerProgram.InitReflectionManager();

                    var server = DependencyCollection.Resolve <IBaseServerInternal>();

                    if (_options?.ServerContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().ServerContentAssembly = _options.ServerContentAssembly;
                    }

                    if (_options?.SharedContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().SharedContentAssembly = _options.SharedContentAssembly;
                    }

                    server.ContentRootDir = "../../";

                    _options?.BeforeStart?.Invoke();
                    if (server.Start())
                    {
                        throw new Exception("Server failed to start.");
                    }

                    var gameLoop = new IntegrationGameLoop(
                        DependencyCollection.Resolve <IGameTiming>(),
                        _fromInstanceWriter, _toInstanceReader);
                    server.OverrideMainLoop(gameLoop);

                    server.MainLoop();
                }
                catch (Exception e)
                {
                    _fromInstanceWriter.TryWrite(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceWriter.TryWrite(new ShutDownMessage(null));
            }
Пример #3
0
            private void _serverMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    ServerIoC.RegisterIoC();
                    IoCManager.Register <INetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IServerNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IntegrationNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <ISystemConsoleManager, SystemConsoleManagerDummy>(true);
                    IoCManager.Register <IModLoader, ModLoader>(true);
                    IoCManager.Register <ModLoader, ModLoader>(true);
                    IoCManager.RegisterInstance <IStatusHost>(new Mock <IStatusHost>().Object, true);
                    _options?.InitIoC?.Invoke();
                    IoCManager.BuildGraph();
                    //ServerProgram.SetupLogging();
                    ServerProgram.InitReflectionManager();

                    var server = DependencyCollection.Resolve <IBaseServerInternal>();

                    server.LoadConfigAndUserData = false;

                    if (_options?.ServerContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().ServerContentAssembly = _options.ServerContentAssembly;
                    }

                    if (_options?.SharedContentAssembly != null)
                    {
                        IoCManager.Resolve <ModLoader>().SharedContentAssembly = _options.SharedContentAssembly;
                    }

                    if (_options != null)
                    {
                        _options.BeforeStart?.Invoke();
                        IoCManager.Resolve <IConfigurationManager>()
                        .OverrideConVars(_options.CVarOverrides.Select(p => (p.Key, p.Value)));

                        if (_options.ExtraPrototypes != null)
                        {
                            IoCManager.Resolve <IResourceManagerInternal>()
                            .MountString("/Prototypes/__integration_extra.yml", _options.ExtraPrototypes);
                        }
                    }

                    IoCManager.Resolve <IConfigurationManager>()
                    .OverrideConVars(new [] { ("log.runtimelog", "false") });