Beispiel #1
0
        public override void Init()
        {
            IoCManager.Resolve <IStatusHost>().SetAczInfo(
                "Content.Client", new [] { "OpenDreamClient", "OpenDreamShared" });

            IComponentFactory componentFactory = IoCManager.Resolve <IComponentFactory>();

            componentFactory.DoAutoRegistrations();

            ServerContentIoC.Register();

            // This needs to happen after all IoC registrations, but before IoC.BuildGraph();
            foreach (var callback in TestingCallbacks)
            {
                var cast = (ServerModuleTestingCallbacks)callback;
                cast.ServerBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();
            IoCManager.InjectDependencies(this);
            componentFactory.GenerateNetIds();

            var cfg = IoCManager.Resolve <IConfigurationManager>();

            cfg.OverrideDefault(CVars.NetLogLateMsg, false);      // Disable since disabling prediction causes timing errors otherwise.
            cfg.OverrideDefault(CVars.GameAutoPauseEmpty, false); // TODO: world.sleep_offline can control this
        }
Beispiel #2
0
        internal static void Main(string[] args)
        {
            IoCManager.InitThread();
            ServerIoC.RegisterIoC();
            IoCManager.BuildGraph();
            SetupLogging();
            InitReflectionManager();
            HandleCommandLineArgs(args);

            var server = IoCManager.Resolve <IBaseServer>();

            Logger.Info("Server -> Starting");

            if (server.Start())
            {
                Logger.Fatal("Server -> Can not start server");
                //Not like you'd see this, haha. Perhaps later for logging.
                //Environment.Exit(0);
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version.ToString();

            Logger.Info("Server Version " + strVersion + " -> Ready");

            IoCManager.Resolve <ISignalHandler>().MaybeStart();

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
    public override void Init()
    {
        base.Init();

        // Configure ACZ correctly.
        IoCManager.Resolve <IStatusHost>().SetAczInfo(
            "Content.Client", new [] { "Content.Client", "Content.Shared" });

        var factory = IoCManager.Resolve <IComponentFactory>();

        factory.DoAutoRegistrations();

        foreach (var ignoreName in IgnoredComponents.List)
        {
            factory.RegisterIgnore(ignoreName);
        }

        ServerContentIoC.Register();

        IoCManager.BuildGraph();

        factory.GenerateNetIds();

        // DEVNOTE: This is generally where you'll be setting up the IoCManager further.
    }
Beispiel #4
0
        public override void Init()
        {
            var factory    = IoCManager.Resolve <IComponentFactory>();
            var prototypes = IoCManager.Resolve <IPrototypeManager>();

            factory.DoAutoRegistrations();

            foreach (var ignoreName in IgnoredComponents.List)
            {
                factory.RegisterIgnore(ignoreName);
            }

            foreach (var ignoreName in IgnoredPrototypes.List)
            {
                prototypes.RegisterIgnore(ignoreName);
            }

            ClientContentIoC.Register();

            IoCManager.BuildGraph();

            // DEVNOTE: This is generally where you'll be setting up the IoCManager further.

            IoCManager.InjectDependencies(this);
        }
Beispiel #5
0
        /// <summary>
        /// Registers all the types into the <see cref="IoCManager"/> with <see cref="IoCManager.Register{TInterface, TImplementation}"/>
        /// </summary>
        private static void RegisterIoC()
        {
            // Shared stuff.
            IoCManager.Register <IComponentManager, ComponentManager>();
            IoCManager.Register <IPrototypeManager, PrototypeManager>();
            IoCManager.Register <IEntitySystemManager, EntitySystemManager>();
            IoCManager.Register <IConfigurationManager, ConfigurationManager>();
            IoCManager.Register <INetManager, NetManager>();
            IoCManager.Register <IGameTiming, GameTiming>();
            IoCManager.Register <IResourceManager, ResourceManager>();

            // Server stuff.
            IoCManager.Register <IEntityManager, ServerEntityManager>();
            IoCManager.Register <IServerEntityManager, ServerEntityManager>();
            IoCManager.Register <ILogManager, ServerLogManager>();
            IoCManager.Register <IServerLogManager, ServerLogManager>();
            IoCManager.Register <IChatManager, ChatManager>();
            IoCManager.Register <IServerNetManager, NetManager>();
            IoCManager.Register <IMapManager, MapManager>();
            IoCManager.Register <IPlacementManager, PlacementManager>();
            IoCManager.Register <IConsoleManager, ConsoleManager>();
            IoCManager.Register <ITileDefinitionManager, TileDefinitionManager>();
            IoCManager.Register <IRoundManager, RoundManager>();
            IoCManager.Register <IBaseServer, BaseServer>();
            IoCManager.Register <ISS14Serializer, SS14Serializer>();
            IoCManager.Register <IEntityNetworkManager, ServerEntityNetworkManager>();
            IoCManager.Register <ICommandLineArgs, CommandLineArgs>();
            IoCManager.Register <IGameStateManager, GameStateManager>();
            IoCManager.Register <IReflectionManager, ServerReflectionManager>();
            IoCManager.Register <IClientConsoleHost, ClientConsoleHost.ClientConsoleHost>();
            IoCManager.Register <IPlayerManager, PlayerManager>();
            IoCManager.Register <IComponentFactory, ServerComponentFactory>();

            IoCManager.BuildGraph();
        }
            private void _clientMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    GameController.RegisterIoC(GameController.DisplayMode.Headless);
                    IoCManager.Register <INetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IClientNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IntegrationNetManager, IntegrationNetManager>(true);
                    _options?.InitIoC?.Invoke();
                    IoCManager.BuildGraph();

                    GameController.RegisterReflection();

                    var client = DependencyCollection.Resolve <IGameControllerInternal>();

                    client.ContentRootDir        = "../../";
                    client.LoadConfigAndUserData = false;
                    _options?.BeforeStart?.Invoke();
                    client.Startup();

                    var gameLoop = new IntegrationGameLoop(DependencyCollection.Resolve <IGameTiming>(),
                                                           _fromInstanceWriter, _toInstanceReader);
                    client.OverrideMainLoop(gameLoop);
                    client.MainLoop(GameController.DisplayMode.Headless);
                }
                catch (Exception e)
                {
                    _fromInstanceWriter.TryWrite(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceWriter.TryWrite(new ShutDownMessage(null));
            }
        public override void Init()
        {
            base.Init();

            var factory    = IoCManager.Resolve <IComponentFactory>();
            var prototypes = IoCManager.Resolve <IPrototypeManager>();

            factory.DoAutoRegistrations();

            foreach (var ignoreName in IgnoredComponents.List)
            {
                factory.RegisterIgnore(ignoreName);
            }

            foreach (var ignoreName in IgnoredPrototypes.List)
            {
                prototypes.RegisterIgnore(ignoreName);
            }

            ServerContentIoC.Register();

            IoCManager.BuildGraph();

            IoCManager.Resolve <IConnectionManager>().Initialize();
            var playerManager = IoCManager.Resolve <IPlayerManager>();

            var logManager = IoCManager.Resolve <ILogManager>();

            logManager.GetSawmill("Storage").Level = LogLevel.Info;

            // DEVNOTE: This is generally where you'll be setting up the IoCManager further.
        }
            private void _serverMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    ServerEntryPoint.RegisterIoC();
                    IoCManager.BuildGraph();
                    ServerEntryPoint.SetupLogging();
                    ServerEntryPoint.InitReflectionManager();

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

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

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

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

                    server.MainLoop();
                }
                catch (Exception e)
                {
                    _fromInstanceChannel.PushMessage(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceChannel.PushMessage(new ShutDownMessage(null));
            }
Beispiel #9
0
        public void IoCTestCatchExceptionFromDisposingService()
        {
            IoCManager.Register <ITestDisposeExceptionCaught, TestDisposeExceptionCaught>();
            IoCManager.BuildGraph();

            IoCManager.Clear(); // should NOT throw an exception
        }
Beispiel #10
0
        public override void Init()
        {
            IoCManager.Resolve <IConfigurationManager>().OverrideDefault(CVars.NetPredict, false);

            IComponentFactory componentFactory = IoCManager.Resolve <IComponentFactory>();

            componentFactory.DoAutoRegistrations();

            ClientContentIoC.Register();

            // This needs to happen after all IoC registrations, but before IoC.BuildGraph();
            foreach (var callback in TestingCallbacks)
            {
                var cast = (ClientModuleTestingCallbacks)callback;
                cast.ClientBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();
            IoCManager.InjectDependencies(this);

            IoCManager.Resolve <DreamUserInterfaceStateManager>().Initialize();

            componentFactory.GenerateNetIds();

            _dreamResource.Initialize();

            // Load localization. Needed for some engine texts, such as the ones in Robust ViewVariables.
            IoCManager.Resolve <ILocalizationManager>().LoadCulture(new CultureInfo("en-US"));

            IoCManager.Resolve <IClyde>().SetWindowTitle("OpenDream");
            IoCManager.Resolve <IUserInterfaceManager>().Stylesheet = DreamStylesheet.Make();
        }
 public void OneTimeSetup()
 {
     //initializing logmanager so it wont error out if nullablehelper logs an error
     IoCManager.InitThread();
     IoCManager.Register <ILogManager, LogManager>();
     IoCManager.BuildGraph();
 }
Beispiel #12
0
        /// <summary>
        /// Registers all the types into the <see cref="IoCManager"/> with <see cref="IoCManager.Register{TInterface, TImplementation}"/>
        /// </summary>
        private static void RegisterIoC()
        {
            // Shared stuff.
            IoCManager.Register <IComponentManager, ComponentManager>();
            IoCManager.Register <IPrototypeManager, PrototypeManager>();
            IoCManager.Register <IEntitySystemManager, EntitySystemManager>();
            IoCManager.Register <IComponentFactory, ComponentFactory>();
            IoCManager.Register <ILogManager, LogManager>();
            IoCManager.Register <IConfigurationManager, ConfigurationManager>();

            // Client stuff.
            IoCManager.Register <IRand, Rand>();
            IoCManager.Register <IStateManager, StateManager>();
            IoCManager.Register <INetworkGrapher, NetworkGrapher>();
            IoCManager.Register <IKeyBindingManager, KeyBindingManager>();
            IoCManager.Register <IUserInterfaceManager, UserInterfaceManager>();
            IoCManager.Register <IGameTimer, GameTimer.GameTimer>();
            IoCManager.Register <ITileDefinitionManager, TileDefinitionManager>();
            IoCManager.Register <IMessageLogger, MessageLogger>();
            IoCManager.Register <ICollisionManager, CollisionManager>();
            IoCManager.Register <IEntityManager, ClientEntityManager>();
            IoCManager.Register <IClientEntityManager, ClientEntityManager>();
            IoCManager.Register <INetworkManager, NetworkManager>();
            IoCManager.Register <IReflectionManager, ClientReflectionManager>();
            IoCManager.Register <IPlacementManager, PlacementManager>();
            IoCManager.Register <ILightManager, LightManager>();
            IoCManager.Register <IResourceManager, ResourceManager>();
            IoCManager.Register <ISS14Serializer, SS14Serializer>();
            IoCManager.Register <IMapManager, MapManager>();
            IoCManager.Register <IEntityNetworkManager, ClientEntityNetworkManager>();
            IoCManager.Register <IPlayerManager, PlayerManager>();
            IoCManager.Register <IGameController, GameController>();

            IoCManager.BuildGraph();
        }
Beispiel #13
0
        public override void Init()
        {
            var factory    = IoCManager.Resolve <IComponentFactory>();
            var prototypes = IoCManager.Resolve <IPrototypeManager>();

            factory.DoAutoRegistrations();

            foreach (var ignoreName in IgnoredComponents.List)
            {
                factory.RegisterIgnore(ignoreName);
            }

            factory.RegisterClass <SharedResearchConsoleComponent>();
            factory.RegisterClass <SharedLatheComponent>();
            factory.RegisterClass <SharedSpawnPointComponent>();
            factory.RegisterClass <SharedVendingMachineComponent>();
            factory.RegisterClass <SharedWiresComponent>();
            factory.RegisterClass <SharedCargoConsoleComponent>();
            factory.RegisterClass <SharedReagentDispenserComponent>();
            factory.RegisterClass <SharedChemMasterComponent>();
            factory.RegisterClass <SharedMicrowaveComponent>();
            factory.RegisterClass <SharedGravityGeneratorComponent>();
            factory.RegisterClass <SharedAMEControllerComponent>();

            prototypes.RegisterIgnore("material");
            prototypes.RegisterIgnore("reaction"); //Chemical reactions only needed by server. Reactions checks are server-side.
            prototypes.RegisterIgnore("gasReaction");
            prototypes.RegisterIgnore("seed");     // Seeds prototypes are server-only.
            prototypes.RegisterIgnore("barSign");
            prototypes.RegisterIgnore("objective");
            prototypes.RegisterIgnore("holiday");
            prototypes.RegisterIgnore("aiFaction");
            prototypes.RegisterIgnore("behaviorSet");

            ClientContentIoC.Register();

            foreach (var callback in TestingCallbacks)
            {
                var cast = (ClientModuleTestingCallbacks)callback;
                cast.ClientBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();

            IoCManager.Resolve <IClientAdminManager>().Initialize();
            IoCManager.Resolve <IParallaxManager>().LoadParallax();
            IoCManager.Resolve <IBaseClient>().PlayerJoinedServer += SubscribePlayerAttachmentEvents;
            IoCManager.Resolve <IStylesheetManager>().Initialize();
            IoCManager.Resolve <IScreenshotHook>().Initialize();
            IoCManager.Resolve <ChangelogManager>().Initialize();

            IoCManager.InjectDependencies(this);

            _escapeMenuOwner.Initialize();

            _baseClient.PlayerJoinedServer += (sender, args) =>
            {
                IoCManager.Resolve <IMapManager>().CreateNewMapEntity(MapId.Nullspace);
            };
        }
            private void _clientMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    GameController.RegisterIoC(GameController.DisplayMode.Headless);
                    IoCManager.BuildGraph();

                    GameController.RegisterReflection();

                    var client = DependencyCollection.Resolve <IGameControllerInternal>();

                    client.ContentRootDir = "../../";

                    client.Startup();

                    var gameLoop = new IntegrationGameLoop(DependencyCollection.Resolve <IGameTiming>(),
                                                           _toInstanceChannel, _fromInstanceChannel);
                    client.OverrideMainLoop(gameLoop);
                    client.MainLoop(GameController.DisplayMode.Headless);
                }
                catch (Exception e)
                {
                    _fromInstanceChannel.PushMessage(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceChannel.PushMessage(new ShutDownMessage(null));
            }
Beispiel #15
0
        private static void ParsedMain(CommandLineArgs args, bool contentStart, ServerOptions options)
        {
            Thread.CurrentThread.Name = "Main Thread";
            IoCManager.InitThread();
            ServerIoC.RegisterIoC();
            IoCManager.BuildGraph();
            SetupLogging();
            InitReflectionManager();

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

            server.ContentStart = contentStart;
            server.SetCommandLineArgs(args);

            Logger.Info("Server -> Starting");

            if (server.Start(options))
            {
                Logger.Fatal("Server -> Can not start server");
                //Not like you'd see this, haha. Perhaps later for logging.
                return;
            }

            string strVersion = Assembly.GetExecutingAssembly().GetName().Version !.ToString();

            Logger.Info("Server Version " + strVersion + " -> Ready");

            server.MainLoop();

            Logger.Info("Goodbye.");

            // Used to dispose of systems that want to be disposed.
            // Such as the log manager.
            IoCManager.Clear();
        }
Beispiel #16
0
        public void IoCTestDuplicateResgisterWithoutBuildingGraph()
        {
            IoCManager.Register <IIoCFailInterface, TestFailImplementation>();
            IoCManager.BuildGraph();

            // cannot overwrite an already built implementation.
            Assert.That(() => IoCManager.Register <IIoCFailInterface, TestFailImplementation>(true), Throws.TypeOf <InvalidOperationException>());
        }
Beispiel #17
0
        public void IoCTestOverwrite()
        {
            IoCManager.Register <IIoCTestPriorities, IoCTestPriorities2>();
            IoCManager.Register <IIoCTestPriorities, IoCTestPriorities1>(true);
            IoCManager.BuildGraph();

            Assert.That(IoCManager.Resolve <IIoCTestPriorities>(), Is.TypeOf <IoCTestPriorities1>());
        }
Beispiel #18
0
        public void TestResolve()
        {
            IoCManager.Register <IDummyMessageFactory, DummyMessageFactory>();
            IoCManager.BuildGraph();
            var messageFactory = IoCManager.Resolve <IDummyMessageFactory>();

            Assert.That(messageFactory, Is.InstanceOf <IDummyMessageFactory>());
        }
Beispiel #19
0
        public void Setup()
        {
            IoCManager.Register <IIoCTestPriories, IoCTestPriorities2>();
            IoCManager.Register <IIoCTestPriories, IoCTestPriorities1>(true);
            IoCManager.Register <TestFieldInjection, TestFieldInjection>();

            IoCManager.BuildGraph();
        }
Beispiel #20
0
        public void IoCTestFieldInjection()
        {
            IoCManager.Register <TestFieldInjection, TestFieldInjection>();
            IoCManager.BuildGraph();
            var tester = IoCManager.Resolve <TestFieldInjection>();

            tester.Test();
        }
Beispiel #21
0
        /// <inheritdoc />
        public override void Init()
        {
            base.Init();

            var factory = IoCManager.Resolve <IComponentFactory>();

            factory.DoAutoRegistrations();

            var registerIgnore = new[]
            {
                "ConstructionGhost",
                "IconSmooth",
                "SubFloorHide",
                "LowWall",
                "ReinforcedWall",
                "Window",
                "CharacterInfo",
                "InteractionOutline",
                "MeleeWeaponArcAnimation",
                "AnimationsTest",
                "ItemStatus",
                "Marker",
                "EmergencyLight",
                "Clickable",
            };

            foreach (var ignoreName in registerIgnore)
            {
                factory.RegisterIgnore(ignoreName);
            }

            ServerContentIoC.Register();

            if (TestingCallbacks != null)
            {
                var cast = (ServerModuleTestingCallbacks)TestingCallbacks;
                cast.ServerBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();

            _gameTicker = IoCManager.Resolve <IGameTicker>();

            IoCManager.Resolve <IServerNotifyManager>().Initialize();
            IoCManager.Resolve <IChatManager>().Initialize();

            var playerManager = IoCManager.Resolve <IPlayerManager>();

            _statusShell = new StatusShell();

            var logManager = IoCManager.Resolve <ILogManager>();

            logManager.GetSawmill("Storage").Level = LogLevel.Info;

            IoCManager.Resolve <IServerPreferencesManager>().StartInit();
            IoCManager.Resolve <INodeGroupFactory>().Initialize();
            IoCManager.Resolve <INodeFactory>().Initialize();
        }
Beispiel #22
0
            private void _clientMain()
            {
                try
                {
                    IoCManager.InitThread(DependencyCollection);
                    ClientIoC.RegisterIoC(GameController.DisplayMode.Headless);
                    IoCManager.Register <INetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IClientNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IntegrationNetManager, IntegrationNetManager>(true);
                    IoCManager.Register <IModLoader, ModLoader>(true);
                    IoCManager.Register <ModLoader, ModLoader>(true);
                    _options?.InitIoC?.Invoke();
                    IoCManager.BuildGraph();

                    GameController.RegisterReflection();

                    var client = DependencyCollection.Resolve <IGameControllerInternal>();

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

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

                    client.LoadConfigAndUserData = false;

                    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);
                        }
                    }

                    client.Startup(() => new TestLogHandler("CLIENT"));

                    var gameLoop = new IntegrationGameLoop(DependencyCollection.Resolve <IGameTiming>(),
                                                           _fromInstanceWriter, _toInstanceReader);
                    client.OverrideMainLoop(gameLoop);
                    client.MainLoop(GameController.DisplayMode.Headless);
                }
                catch (Exception e)
                {
                    _fromInstanceWriter.TryWrite(new ShutDownMessage(e));
                    return;
                }

                _fromInstanceWriter.TryWrite(new ShutDownMessage(null));
            }
Beispiel #23
0
        /// <inheritdoc />
        public override void Init()
        {
            base.Init();

            IoCManager.Resolve <IStatusHost>().SetAczInfo("Content.Client",
                                                          new[] { "Content.Client", "Content.Shared", "Content.Shared.Database" });

            var factory    = IoCManager.Resolve <IComponentFactory>();
            var prototypes = IoCManager.Resolve <IPrototypeManager>();

            factory.DoAutoRegistrations();

            foreach (var ignoreName in IgnoredComponents.List)
            {
                factory.RegisterIgnore(ignoreName);
            }

            prototypes.RegisterIgnore("parallax");

            ServerContentIoC.Register();

            foreach (var callback in TestingCallbacks)
            {
                var cast = (ServerModuleTestingCallbacks)callback;
                cast.ServerBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();
            factory.GenerateNetIds();
            var configManager = IoCManager.Resolve <IConfigurationManager>();
            var dest          = configManager.GetCVar(CCVars.DestinationFile);

            if (string.IsNullOrEmpty(dest)) //hacky but it keeps load times for the generator down.
            {
                _euiManager    = IoCManager.Resolve <EuiManager>();
                _voteManager   = IoCManager.Resolve <IVoteManager>();
                _updateManager = IoCManager.Resolve <ServerUpdateManager>();

                var playerManager = IoCManager.Resolve <IPlayerManager>();

                var logManager = IoCManager.Resolve <ILogManager>();
                logManager.GetSawmill("Storage").Level = LogLevel.Info;
                logManager.GetSawmill("db.ef").Level   = LogLevel.Info;

                IoCManager.Resolve <IAdminLogManager>().Initialize();
                IoCManager.Resolve <IConnectionManager>().Initialize();
                IoCManager.Resolve <IServerDbManager>().Init();
                IoCManager.Resolve <IServerPreferencesManager>().Init();
                IoCManager.Resolve <INodeGroupFactory>().Initialize();
                IoCManager.Resolve <IGamePrototypeLoadManager>().Initialize();
                IoCManager.Resolve <NetworkResourceManager>().Initialize();
                IoCManager.Resolve <GhostKickManager>().Initialize();

                _voteManager.Initialize();
                _updateManager.Initialize();
            }
        }
Beispiel #24
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));
            }
Beispiel #25
0
        public void IoCTestBasic()
        {
            IoCManager.Register <TestFieldInjection, TestFieldInjection>();
            IoCManager.BuildGraph();

            Assert.That(IoCManager.Resolve <TestFieldInjection>(), Is.Not.Null);

            Assert.That(IoCManager.ResolveType(typeof(TestFieldInjection)), Is.Not.Null);
        }
Beispiel #26
0
#pragma warning restore 649

        public override void Init()
        {
            var factory    = IoCManager.Resolve <IComponentFactory>();
            var prototypes = IoCManager.Resolve <IPrototypeManager>();

            factory.DoAutoRegistrations();

            foreach (var ignoreName in IgnoredComponents.List)
            {
                factory.RegisterIgnore(ignoreName);
            }

            factory.Register <SharedResearchConsoleComponent>();
            factory.Register <SharedLatheComponent>();
            factory.Register <SharedSpawnPointComponent>();

            factory.Register <SharedSolutionComponent>();

            factory.Register <SharedVendingMachineComponent>();
            factory.Register <SharedWiresComponent>();
            factory.Register <SharedCargoConsoleComponent>();
            factory.Register <SharedReagentDispenserComponent>();
            factory.Register <SharedChemMasterComponent>();
            factory.Register <SharedMicrowaveComponent>();
            factory.Register <SharedGravityGeneratorComponent>();

            prototypes.RegisterIgnore("material");
            prototypes.RegisterIgnore("reaction"); //Chemical reactions only needed by server. Reactions checks are server-side.
            prototypes.RegisterIgnore("barSign");

            ClientContentIoC.Register();

            if (TestingCallbacks != null)
            {
                var cast = (ClientModuleTestingCallbacks)TestingCallbacks;
                cast.ClientBeforeIoC?.Invoke();
            }

            IoCManager.BuildGraph();

            IoCManager.Resolve <IParallaxManager>().LoadParallax();
            IoCManager.Resolve <IBaseClient>().PlayerJoinedServer += SubscribePlayerAttachmentEvents;
            IoCManager.Resolve <IStylesheetManager>().Initialize();
            IoCManager.Resolve <IScreenshotHook>().Initialize();

            IoCManager.InjectDependencies(this);

            _escapeMenuOwner.Initialize();

            _baseClient.PlayerJoinedServer += (sender, args) =>
            {
                IoCManager.Resolve <IMapManager>().CreateNewMapEntity(MapId.Nullspace);
            };

            _configurationManager.RegisterCVar("outline.enabled", true);
        }
        public void IoCTestConstructorInjection()
        {
            IoCManager.Register <TestFieldInjection, TestFieldInjection>();
            IoCManager.Register <TestConstructorInjection, TestConstructorInjection>();
            IoCManager.BuildGraph();

            var tester = IoCManager.Resolve <TestConstructorInjection>();

            Assert.That(tester.FieldInjection, Is.Not.Null);
        }
Beispiel #28
0
        public void Setup()
        {
            var uiMgr = new Mock <IUserInterfaceManagerInternal>();

            IoCManager.InitThread();
            IoCManager.Clear();
            IoCManager.RegisterInstance <IUserInterfaceManagerInternal>(uiMgr.Object);
            IoCManager.RegisterInstance <IUserInterfaceManager>(uiMgr.Object);
            IoCManager.BuildGraph();
        }
Beispiel #29
0
        public void IoCRegisterFactory()
        {
            var newInstance = new TestFieldInjection();

            IoCManager.Register <TestFieldInjection, TestFieldInjection>(() => newInstance);

            IoCManager.BuildGraph(); // Actually calls the factory

            var result = IoCManager.Resolve <TestFieldInjection>();

            Assert.That(result, Is.EqualTo(newInstance));
        }
            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));
            }