Beispiel #1
0
        public bool Startup(Func <ILogHandler>?logHandlerFactory = null)
        {
            ReadInitialLaunchState();

            SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler()));

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _configurationManager.OverrideConVars(EnvironmentVariables.GetEnvironmentCVars());

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resourceCache.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{contentRootDir}bin/Content.Client/",
                                                 new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            // Disable load context usage on content start.
            // This prevents Content.Client being loaded twice and things like csi blowing up because of it.
            _modLoader.SetUseLoadContext(!_disableAssemblyLoadContext);

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.PreInit);
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _serializer.Initialize();
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _conGroupController.Initialize();
            _scriptClient.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if ((_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true) &&
                LaunchState.ConnectEndpoint != null)
            {
                _client.ConnectToServer(LaunchState.ConnectEndpoint);
            }

            return(true);
        }
        public bool Startup()
        {
            SetupLogging(_logManager);

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            var contentRootDir = ProgramShared.FindContentRootDir();
            _resourceCache.MountContentDirectory($@"{contentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{contentRootDir}bin/Content.Client/",
                                                 new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{contentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _conGroupController.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Launcher == true)
            {
                _stateManager.RequestStateChange <LauncherConnecting>();
            }
            else
            {
                _stateManager.RequestStateChange <MainScreen>();
            }

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _clyde.Ready();

            if (_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true)
            {
                var addr = _commandLineArgs.ConnectAddress;
                if (!addr.Contains("://"))
                {
                    addr = "udp://" + addr;
                }

                var uri = new Uri(addr);

                if (uri.Scheme != "udp")
                {
                    Logger.Warning($"connect-address '{uri}' does not have URI scheme of udp://..");
                }

                _client.ConnectToServer(uri.Host, (ushort)(uri.IsDefaultPort ? 1212 : uri.Port));
            }

            _checkOpenGLVersion();
            return(true);
        }
Beispiel #3
0
        public bool Startup(Func <ILogHandler>?logHandlerFactory = null)
        {
            ReadInitialLaunchState();

            SetupLogging(_logManager, logHandlerFactory ?? (() => new ConsoleLogHandler()));

            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = GetUserDataDir();

            _configurationManager.Initialize(false);

            // MUST load cvars before loading from config file so the cfg manager is aware of secure cvars.
            // So SECURE CVars are blacklisted from config.
            _configurationManager.LoadCVarsFromAssembly(typeof(GameController).Assembly);        // Client
            _configurationManager.LoadCVarsFromAssembly(typeof(IConfigurationManager).Assembly); // Shared

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _configurationManager.OverrideConVars(EnvironmentVariables.GetEnvironmentCVars());

            if (_commandLineArgs != null)
            {
                _configurationManager.OverrideConVars(_commandLineArgs.CVars);
            }

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

            ProgramShared.DoMounts(_resourceCache, _commandLineArgs?.MountOptions, "Content.Client", _loaderArgs != null);
            if (_loaderArgs != null)
            {
                _stringSerializer.EnableCaching = false;
                _resourceCache.MountLoaderApi(_loaderArgs.FileApi, "Resources/");
                _modLoader.VerifierExtraLoadHandler = VerifierExtraLoadHandler;
            }

            // Bring display up as soon as resources are mounted.
            if (!_clyde.Initialize())
            {
                return(false);
            }

            _clyde.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            // Disable load context usage on content start.
            // This prevents Content.Client being loaded twice and things like csi blowing up because of it.
            _modLoader.SetUseLoadContext(!_disableAssemblyLoadContext);
            _modLoader.SetEnableSandboxing(true);

            if (!_modLoader.TryLoadModulesFrom(new ResourcePath("/Assemblies/"), "Content."))
            {
                Logger.Fatal("Errors while loading content assemblies.");
                return(false);
            }

            foreach (var loadedModule in _modLoader.LoadedModules)
            {
                _configurationManager.LoadCVarsFromAssembly(loadedModule);
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.PreInit);
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            IoCManager.Resolve <INetConfigurationManager>().SetupNetworking();
            _serializer.Initialize();
            _inputManager.Initialize();
            _consoleHost.Initialize();
            _prototypeManager.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();
            _scriptClient.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            if (_commandLineArgs?.Username != null)
            {
                _client.PlayerNameOverride = _commandLineArgs.Username;
            }

            _authManager.LoadFromEnv();

            _clyde.Ready();

            if ((_commandLineArgs?.Connect == true || _commandLineArgs?.Launcher == true) &&
                LaunchState.ConnectEndpoint != null)
            {
                _client.ConnectToServer(LaunchState.ConnectEndpoint);
            }

            return(true);
        }
        public void Startup()
        {
            SetupLogging(_logManager);

            var args = GetCommandLineArgs();

            // Set up custom synchronization context.
            // Sorry Godot.
            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = _getUserDataDir(args);

            if (LoadConfigAndUserData)
            {
                var configFile = Path.Combine(userDataDir, "client_config.toml");
                if (File.Exists(configFile))
                {
                    // Load config from user data if available.
                    _configurationManager.LoadFromFile(configFile);
                }
                else
                {
                    // Else we just use code-defined defaults and let it save to file when the user changes things.
                    _configurationManager.SetSaveFile(configFile);
                }
            }

            _signalHandler.MaybeStart();

            _resourceCache.Initialize(LoadConfigAndUserData ? userDataDir : null);

#if FULL_RELEASE
            _resourceCache.MountContentDirectory(@"Resources/");
#else
            _resourceCache.MountContentDirectory($@"{ContentRootDir}RobustToolbox/Resources/");
            _resourceCache.MountContentDirectory($@"{ContentRootDir}bin/Content.Client/", new ResourcePath("/Assemblies/"));
            _resourceCache.MountContentDirectory($@"{ContentRootDir}Resources/");
#endif

            // Default to en-US.
            // Perhaps in the future we could make a command line arg or something to change this default.
            _localizationManager.LoadCulture(new CultureInfo("en-US"));

            // Bring display up as soon as resources are mounted.
            _displayManager.Initialize();
            _displayManager.SetWindowTitle("Space Station 14");

            _fontManager.Initialize();

            //identical code for server in baseserver
            if (!_modLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.FatalS("eng", "Could not load any Shared DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            if (!_modLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.FatalS("eng", "Could not load any Client DLL.");
                throw new NotSupportedException("Cannot load client without content assembly");
            }

            // Call Init in game assemblies.
            _modLoader.BroadcastRunLevel(ModRunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _lightManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();

            _client.Initialize();
            _discord.Initialize();
            _modLoader.BroadcastRunLevel(ModRunLevel.PostInit);

            _stateManager.RequestStateChange <MainScreen>();

            _clyde?.Ready();

            if (args.Contains("--connect"))
            {
                _client.ConnectToServer("127.0.0.1", 1212);
            }
        }
        private void Startup()
        {
            ThreadUtility.MainThread = Thread.CurrentThread;
            InitIoC();
            SetupLogging();

            // Set up custom synchronization context.
            // Sorry Godot.
            _taskManager.Initialize();

            // Load config.
            _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml"));

            if (Mode == DisplayMode.OpenGL)
            {
                _displayManagerOpenGL = IoCManager.Resolve <IDisplayManagerOpenGL>();
            }

            // Init resources.
            // Doesn't do anything right now because TODO Godot asset management is a bit ad-hoc.
            _resourceCache.LoadBaseResources();
            _resourceCache.LoadLocalResources();

            // Bring display up as soon as resources are mounted.
            _displayManager.Initialize();
            _displayManager.SetWindowTitle("Space Station 14");

            if (Mode == DisplayMode.OpenGL)
            {
                _fontManager = IoCManager.Resolve <IFontManagerInternal>();
                _fontManager.Initialize();
            }

            //identical code for server in baseserver
            if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.Warning($"[ENG] Could not load any Shared DLL.");
            }

            if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.Warning($"[ENG] Could not load any Client DLL.");
            }

            // Call Init in game assemblies.
            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _tileDefinitionManager.Initialize();
            _mapManager.Initialize();
            _placementManager.Initialize();
            _lightManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _overlayManager.Initialize();
            _viewVariablesManager.Initialize();

            _client.Initialize();

            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.PostInit);

            _stateManager.RequestStateChange <MainScreen>();

            if (_displayManagerOpenGL != null)
            {
                _displayManagerOpenGL.Ready();
            }

            var args = GetCommandLineArgs();

            if (args.Contains("--connect"))
            {
                _client.ConnectToServer("127.0.0.1", 1212);
            }
        }
Beispiel #6
0
        public override void Main(Godot.SceneTree tree)
        {
#if !X64
            throw new InvalidOperationException("The client cannot start outside x64.");
#endif
            ThreadUtility.MainThread = Thread.CurrentThread;
            PreInitIoC();
            IoCManager.Resolve <ISceneTreeHolder>().Initialize(tree);
            InitIoC();
            Godot.OS.SetWindowTitle("Space Station 14");
            SetupLogging();

            // Set up custom synchronization context.
            // Sorry Godot.
            _taskManager.Initialize();

            tree.SetAutoAcceptQuit(false);

            // Load config.
            _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml"));

            displayManager.Initialize();

            // Ensure Godot's side of the resources are up to date.
#if DEBUG
            GodotResourceCopy.DoDirCopy("../Resources", "Engine");
#endif

            // Init resources.
            // Doesn't do anything right now because TODO Godot asset management is a bit ad-hoc.
            _resourceCache.LoadBaseResources();
            _resourceCache.LoadLocalResources();

            //identical code for server in baseserver
            if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.Warning($"[ENG] Could not load any Shared DLL.");
            }

            if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.Warning($"[ENG] Could not load any Client DLL.");
            }

            // Call Init in game assemblies.
            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init);

            eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _tileDefinitionManager.Initialize();
            _mapManager.Initialize();
            placementManager.Initialize();
            lightManager.Initialize();
            _entityManager.Initialize();
            gameStateManager.Initialize();
            overlayManager.Initialize();
            _viewVariablesManager.Initialize();

            _client.Initialize();

            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.PostInit);

            _stateManager.RequestStateChange <MainScreen>();

            var args = (ICollection <string>)Godot.OS.GetCmdlineArgs();
            if (args.Contains("--connect"))
            {
                _client.ConnectToServer("127.0.0.1", 1212);
            }
        }
Beispiel #7
0
        private void Startup()
        {
            ThreadUtility.MainThread = Thread.CurrentThread;
            InitIoC();
            SetupLogging();

            var args = GetCommandLineArgs();

            // Set up custom synchronization context.
            // Sorry Godot.
            _taskManager.Initialize();

            // Figure out user data directory.
            var userDataDir = _getUserDataDir(args);

            var configFile = Path.Combine(userDataDir, "client_config.toml");

            if (File.Exists(configFile))
            {
                // Load config from user data if available.
                _configurationManager.LoadFromFile(configFile);
            }
            else
            {
                // Else we just use code-defined defaults and let it save to file when the user changes things.
                _configurationManager.SetSaveFile(configFile);
            }

            if (Mode == DisplayMode.Clyde)
            {
                _clyde = IoCManager.Resolve <IClyde>();
            }

            _resourceCache.Initialize(userDataDir);
            _resourceCache.LoadBaseResources();

            // Bring display up as soon as resources are mounted.
            _displayManager.Initialize();
            _displayManager.SetWindowTitle("Space Station 14");

            if (Mode == DisplayMode.Clyde)
            {
                _fontManager = IoCManager.Resolve <IFontManagerInternal>();
                _fontManager.Initialize();
            }

            //identical code for server in baseserver
            if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared"))
            {
                Logger.Warning($"[ENG] Could not load any Shared DLL.");
            }

            if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client"))
            {
                Logger.Warning($"[ENG] Could not load any Client DLL.");
            }

            // Call Init in game assemblies.
            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init);

            _eyeManager.Initialize();
            _serializer.Initialize();
            _userInterfaceManager.Initialize();
            _networkManager.Initialize(false);
            _inputManager.Initialize();
            _console.Initialize();
            _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/"));
            _prototypeManager.Resync();
            _mapManager.Initialize();
            _lightManager.Initialize();
            _entityManager.Initialize();
            _gameStateManager.Initialize();
            _overlayManager.Initialize();
            _placementManager.Initialize();
            _viewVariablesManager.Initialize();

            _client.Initialize();
            _discord.Connect();
            AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.PostInit);

            _stateManager.RequestStateChange <MainScreen>();

            _clyde?.Ready();

            if (args.Contains("--connect"))
            {
                _client.ConnectToServer("127.0.0.1", 1212);
            }
        }