private async Task <ProcessEx> StartSubnauticaAsync() { string subnauticaPath = Config.SubnauticaPath; string subnauticaLaunchArguments = Config.SubnauticaLaunchArguments; string subnauticaExe = Path.Combine(subnauticaPath, GameInfo.Subnautica.ExeName); IGamePlatform platform = GamePlatforms.GetPlatformByGameDir(subnauticaPath); // Start game & gaming platform if needed. using ProcessEx game = platform switch { Steam s => await s.StartGameAsync(subnauticaExe, GameInfo.Subnautica.SteamAppId, subnauticaLaunchArguments), EpicGames e => await e.StartGameAsync(subnauticaExe, subnauticaLaunchArguments), MSStore m => await m.StartGameAsync(subnauticaExe), DiscordStore d => await d.StartGameAsync(subnauticaExe, subnauticaLaunchArguments), _ => throw new Exception($"Directory '{subnauticaPath}' is not a valid {GameInfo.Subnautica.Name} game installation or the game's platform is unsupported by Nitrox.") }; return(game ?? throw new Exception($"Unable to start game through {platform.Name}")); }
public string GetPlatform(GamePlatforms platform) { return(platformList[platform]); }
public void SaveGame(Game game) { game.user_id = (int)HttpContext.Session.GetInt32("user_id"); if (game.expansions != null) { foreach (var expansion in game.expansions) { expansion.cover.expansion_id = expansion.id; expansion.cover.gameId = expansion.id; } } dbContext.Games.Add(game); if (game.genres != null) { foreach (var genre in game.genres) { if (dbContext.Genres.All(g => g.genre_id != genre.genre_id)) { dbContext.Genres.Add(genre); } var gameGenre = new GameGenres(); gameGenre.gameId = game.gameId; gameGenre.genre_id = genre.genre_id; dbContext.GameGenres.Add(gameGenre); } } if (game.involved_companies != null) { foreach (var involComp in game.involved_companies) { if (dbContext.Companies.All(comp => comp.company_id != involComp.company.company_id)) { dbContext.Companies.Add(involComp.company); } var gameCompany = new GameCompanies(); gameCompany.company_id = involComp.company.company_id; gameCompany.gameId = game.gameId; dbContext.GameCompanies.Add(gameCompany); } } if (game.platforms != null) { foreach (var platform in game.platforms) { if (dbContext.Platforms.All(p => p.platform_id != platform.platform_id)) { dbContext.Platforms.Add(platform); } var gamePlatform = new GamePlatforms(); gamePlatform.gameId = game.gameId; gamePlatform.platform_id = platform.platform_id; dbContext.GamePlatforms.Add(gamePlatform); } } dbContext.SaveChanges(); }