public override void Main(Godot.SceneTree tree) { #if !X64 throw new InvalidOperationException("The client cannot start outside x64."); #endif PreInitIoC(); IoCManager.Resolve <ISceneTreeHolder>().Initialize(tree); InitIoC(); Godot.OS.SetWindowTitle("Space Station 14"); SetupLogging(); tree.SetAutoAcceptQuit(false); // Load config. _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml")); displayManager.Initialize(); // 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") && !AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Sandbox.Shared")) { Logger.Warning($"[ENG] Could not load any Shared DLL."); } if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client") && !AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Sandbox.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(); _tileDefinitionManager.Initialize(); _networkManager.Initialize(false); inputManager.Initialize(); _console.Initialize(); _prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes/")); _prototypeManager.Resync(); _mapManager.Initialize(); placementManager.Initialize(); lightManager.Initialize(); _entityManager.Initialize(); gameStateManager.Initialize(); overlayManager.Initialize(); _client.Initialize(); _stateManager.RequestStateChange <MainScreen>(); }
public override void Main(Godot.SceneTree tree) { PreInitIoC(); IoCManager.Resolve <ISceneTreeHolder>().Initialize(tree); InitIoC(); Godot.OS.SetWindowTitle("Space Station 14"); tree.SetAutoAcceptQuit(false); // Load config. _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml")); displayManager.Initialize(); // 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")) { if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Sandbox.Shared")) { Logger.Warning($"[ENG] Could not load any Shared DLL."); } } if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client")) { if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Sandbox.Client")) { Logger.Warning($"[ENG] Could not load any Client DLL."); } } // Call Init in game assemblies. AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init); eyeManager.Initialize(); inputManager.Initialize(); _serializer.Initialize(); _userInterfaceManager.Initialize(); _tileDefinitionManager.Initialize(); _networkManager.Initialize(false); _console.Initialize(); _prototypeManager.LoadDirectory(@"./Prototypes/"); _prototypeManager.Resync(); _mapManager.Initialize(); placementManager.Initialize(); lightManager.Initialize(); _entityManager.Initialize(); _networkManager.RegisterNetMessage <MsgFullState>(MsgFullState.NAME, message => IoCManager.Resolve <IGameStateManager>().HandleFullStateMessage((MsgFullState)message)); _networkManager.RegisterNetMessage <MsgStateUpdate>(MsgStateUpdate.NAME, message => IoCManager.Resolve <IGameStateManager>().HandleStateUpdateMessage((MsgStateUpdate)message)); _client.Initialize(); _stateManager.RequestStateChange <MainScreen>(); }
/// <inheritdoc /> public bool Start() { //Sets up the configMgr _config.LoadFromFile(_commandLine.ConfigFile); //Sets up Logging _config.RegisterCVar("log.path", "logs", CVar.ARCHIVE); _config.RegisterCVar("log.format", "log_%(date)s-%(time)s.txt", CVar.ARCHIVE); _config.RegisterCVar("log.level", LogLevel.Info, CVar.ARCHIVE); var logPath = _config.GetCVar <string>("log.path"); var logFormat = _config.GetCVar <string>("log.format"); var logFilename = logFormat.Replace("%(date)s", DateTime.Now.ToString("yyyyMMdd")).Replace("%(time)s", DateTime.Now.ToString("hhmmss")); var fullPath = Path.Combine(logPath, logFilename); if (!Path.IsPathRooted(fullPath)) { logPath = PathHelpers.ExecutableRelativeFile(fullPath); } fileLogHandler = new FileLogHandler(logPath); _log.RootSawmill.Level = _config.GetCVar <LogLevel>("log.level"); _log.RootSawmill.AddHandler(fileLogHandler); // Has to be done early because this guy's in charge of the main thread Synchronization Context. _taskManager.Initialize(); LoadSettings(); var netMan = IoCManager.Resolve <IServerNetManager>(); try { netMan.Initialize(true); netMan.StartServer(); } catch (Exception e) { var port = netMan.Port; Logger.Fatal("Unable to setup networking manager. Check port {0} is not already in use and that all binding addresses are correct!\n{1}", port, e); return(true); } // Set up the VFS _resources.Initialize(); #if RELEASE _resources.MountContentDirectory(@"./Resources/"); #else // Load from the resources dir in the repo root instead. // It's a debug build so this is fine. _resources.MountContentDirectory(@"../../Resources/"); _resources.MountContentDirectory(@"../../../bin/Content.Server/", new ResourcePath("/Assemblies/")); #endif //mount the engine content pack // _resources.MountContentPack(@"EngineContentPack.zip"); //mount the default game ContentPack defined in config // _resources.MountDefaultContentPack(); //identical code in game controller for client if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resources, $"Content.Shared")) { Logger.Warning($"[ENG] Could not load any Shared DLL."); } if (!AssemblyLoader.TryLoadAssembly <GameServer>(_resources, $"Content.Server")) { Logger.Warning($"[ENG] Could not load any Server DLL."); } // HAS to happen after content gets loaded. // Else the content types won't be included. // TODO: solve this properly. _serializer.Initialize(); // Initialize Tier 2 services _stateManager.Initialize(); _entities.Initialize(); IoCManager.Resolve <IChatManager>().Initialize(); IoCManager.Resolve <IPlayerManager>().Initialize(MaxPlayers); _mapManager.Initialize(); IoCManager.Resolve <IPlacementManager>().Initialize(); IoCManager.Resolve <IViewVariablesHost>().Initialize(); // Call Init in game assemblies. AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init); // because of 'reasons' this has to be called after the last assembly is loaded // otherwise the prototypes will be cleared var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); prototypeManager.LoadDirectory(new ResourcePath(@"/Prototypes")); prototypeManager.Resync(); IoCManager.Resolve <ITileDefinitionManager>().Initialize(); IoCManager.Resolve <IConsoleShell>().Initialize(); IoCManager.Resolve <IConGroupController>().Initialize(); AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.PostInit); _entities.Startup(); IoCManager.Resolve <IStatusHost>().Start(); return(false); }
public void Run() { Logger.Debug("Initializing GameController."); _configurationManager.LoadFromFile(PathHelpers.ExecutableRelativeFile("client_config.toml")); _resourceCache.LoadBaseResources(); // Load resources used by splash screen and main menu. LoadSplashResources(); ShowSplashScreen(); _resourceCache.LoadLocalResources(); //identical code for server in baseserver if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Content.Shared")) { if (!AssemblyLoader.TryLoadAssembly <GameShared>(_resourceManager, $"Sandbox.Shared")) { Logger.Warning($"[ENG] Could not load any Shared DLL."); } } if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Content.Client")) { if (!AssemblyLoader.TryLoadAssembly <GameClient>(_resourceManager, $"Sandbox.Client")) { Logger.Warning($"[ENG] Could not load any Client DLL."); } } IoCManager.Resolve <ILightManager>().Initialize(); // Call Init in game assemblies. AssemblyLoader.BroadcastRunLevel(AssemblyLoader.RunLevel.Init); //Setup Cluwne first, as the rest depends on it. SetupCluwne(); CleanupSplashScreen(); //Initialization of private members _tileDefinitionManager.InitializeResources(); _serializer.Initialize(); var prototypeManager = IoCManager.Resolve <IPrototypeManager>(); prototypeManager.LoadDirectory(@"Prototypes"); prototypeManager.Resync(); _networkManager.Initialize(false); _console.Initialize(); _netGrapher.Initialize(); _userInterfaceManager.Initialize(); _mapManager.Initialize(); _placementManager.Initialize(); _entityManager.Initialize(); _networkManager.RegisterNetMessage <MsgFullState>(MsgFullState.NAME, message => IoCManager.Resolve <IGameStateManager>().HandleFullStateMessage((MsgFullState)message)); _networkManager.RegisterNetMessage <MsgStateUpdate>(MsgStateUpdate.NAME, message => IoCManager.Resolve <IGameStateManager>().HandleStateUpdateMessage((MsgStateUpdate)message)); _client.Initialize(); _stateManager.RequestStateChange <MainScreen>(); #region GameLoop // maximum number of ticks to queue before the loop slows down. const int maxTicks = 5; _time.ResetRealTime(); var maxTime = TimeSpan.FromTicks(_time.TickPeriod.Ticks * maxTicks); while (CluwneLib.IsRunning) { var accumulator = _time.RealTime - _lastTick; // If the game can't keep up, limit time. if (accumulator > maxTime) { // limit accumulator to max time. accumulator = maxTime; // pull lastTick up to the current realTime // This will slow down the simulation, but if we are behind from a // lag spike hopefully it will be able to catch up. _lastTick = _time.RealTime - maxTime; // announce we are falling behind if ((_time.RealTime - _lastKeepUpAnnounce).TotalSeconds >= 15.0) { Logger.Warning("[ENG] MainLoop: Cannot keep up!"); _lastKeepUpAnnounce = _time.RealTime; } } _time.StartFrame(); var realFrameEvent = new FrameEventArgs((float)_time.RealFrameTime.TotalSeconds); // process Net/KB/Mouse input Process(realFrameEvent); _time.InSimulation = true; // run the simulation for every accumulated tick while (accumulator >= _time.TickPeriod) { accumulator -= _time.TickPeriod; _lastTick += _time.TickPeriod; // only run the sim if unpaused, but still use up the accumulated time if (!_time.Paused) { // update the simulation var simFrameEvent = new FrameEventArgs((float)_time.FrameTime.TotalSeconds); Update(simFrameEvent); _time.CurTick++; } } // if not paused, save how close to the next tick we are so interpolation works if (!_time.Paused) { _time.TickRemainder = accumulator; } _time.InSimulation = false; // render the simulation Render(realFrameEvent); } #endregion GameLoop _networkManager.ClientDisconnect("Client disconnected from game."); CluwneLib.Terminate(); Logger.Info("GameController terminated."); IoCManager.Resolve <IConfigurationManager>().SaveToFile(); }
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); } }
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); } }
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); } }