public bool GenerateArcMod(List <MusicModBgmEntry> bgmEntries) { if (bgmEntries == null || bgmEntries.Count == 0) { _logger.LogError("No Music Mod BGM Entry."); return(false); } //Prefix if (!ValidateUniqueToneNames(bgmEntries)) { _logger.LogError("The Arc Mod Generation failed. At least two songs have the same tone name."); return(false); } //Get new Game Titles var coreGameTitleEntries = _paracobService.GetCoreDbRootGameTitleEntries(); var coreGameTitleIds = coreGameTitleEntries.Select(p => p.UiGameTitleId).Distinct().ToList(); var newGameTitleIds = bgmEntries.Where(p => !coreGameTitleIds.Contains(p.Song.GameTitle.Id)); //Generate NUS3AUDIO and NUS3BANK _logger.LogInformation("Generate/Copy Nus3Audio and Nus3Bank - {NbrFiles} files", bgmEntries.Count * 2); foreach (var bgmEntry in bgmEntries) { //We always generate a new Nus3Bank as the internal ID might change _nus3AudioService.GenerateNus3Bank(bgmEntry.InternalToneName, _resourceService.GetNusBankTemplateResource(), _workspace.GetWorkspaceOutputForNus3Bank(bgmEntry.InternalToneName)); //Test for audio cache if (_workspace.IsAudioCacheEnabled) { var cachedAudioFile = _workspace.GetCacheForNus3Audio(bgmEntry.InternalToneName); if (!File.Exists(cachedAudioFile)) { _nus3AudioService.GenerateNus3Audio(bgmEntry.InternalToneName, bgmEntry.AudioFilePath, cachedAudioFile); } File.Copy(cachedAudioFile, _workspace.GetWorkspaceOutputForNus3Audio(bgmEntry.InternalToneName)); } else { _nus3AudioService.GenerateNus3Audio(bgmEntry.InternalToneName, bgmEntry.AudioFilePath, _workspace.GetWorkspaceOutputForNus3Audio(bgmEntry.InternalToneName)); } } //Generate PRC UI Title var newGameTitleDbEntries = newGameTitleIds.Select(p => new GameTitleDbNewEntry() { GameTitleId = p.Song.GameTitle.Id, SeriesId = p.Song.GameTitle.SeriesId }).GroupBy(p => p.NameId).Select(p => p.First()).ToList(); _logger.LogInformation("Generate Game Title DB - {Entries} new entries", newGameTitleDbEntries.Count); _paracobService.GenerateGameTitlePrcFile(newGameTitleDbEntries, _workspace.GetWorkspaceOutputForUiGameTitleDbFile()); //Generate PRC UI BGM var newBgmEntries = bgmEntries.Select(p => new BgmDbNewEntry() { ToneName = p.InternalToneName, Rarity = p.Song.SongInfo.Rarity, RecordType = p.Song.SongInfo.RecordType, GameTitleId = p.Song.GameTitle.Id, NameId = p.NameId, Playlists = p.Song.SongInfo.Playlists }).ToList(); _logger.LogInformation("Generate BGM DB - {Entries} new entries", newBgmEntries.Count); _paracobService.GenerateBgmPrcFile(newBgmEntries, _workspace.GetWorkspaceOutputForUiBgmDbFile()); //Generate BGM_Property _logger.LogInformation("Generate BGM Property - {Entries} new entries", bgmEntries.Count); _bgmPropertyService.GenerateBgmProperty(bgmEntries); //Generate MSBT Title Files if (newGameTitleIds != null && newGameTitleIds.Count() > 0) { foreach (var locale in LocaleHelper.ValidLocales) { var newMsbtGameTitles = newGameTitleIds.Select(p => new MsbtNewEntryModel() { Label = $"{Constants.InternalIds.MsbtTitPrefix}{p.Song.GameTitle.Id}", Value = p.Song.GameTitle.Title.ContainsKey(locale) ? p.Song.GameTitle.Title[locale] : p.Song.GameTitle.Title.ContainsKey(Constants.DefaultLocale) ? p.Song.GameTitle.Title[Constants.DefaultLocale] : "MISSING" }).GroupBy(p => p.Label).Select(p => p.First()).ToList(); var inputMsbtFile = _resourceService.GetMsbtTitleResource(locale); if (File.Exists(inputMsbtFile)) { _logger.LogInformation("Generate MSBT GameTitle - {Entries} new entries - {Path}", newMsbtGameTitles.Count, inputMsbtFile); var outputMsbtFile = _workspace.GetWorkspaceOutputForMsbtTitleResource(locale); _msbtService.GenerateNewEntries(newMsbtGameTitles, inputMsbtFile, outputMsbtFile); } } } //Generate MSBT BGM Files foreach (var locale in LocaleHelper.ValidLocales) { var newMsbtTitleBgms = bgmEntries.Select(p => new MsbtNewEntryModel() { Label = $"{Constants.InternalIds.MsbtBgmTitlePrefix}{p.NameId}", Value = p.Song.SongInfo.Title.ContainsKey(locale) ? p.Song.SongInfo.Title[locale] : p.Song.SongInfo.Title.ContainsKey(Constants.DefaultLocale) ? p.Song.SongInfo.Title[Constants.DefaultLocale] : "MISSING" }).ToList(); var newMsbtAuthorBgms = bgmEntries.Select(p => new MsbtNewEntryModel() { Label = $"{Constants.InternalIds.MsbtBgmAuthorPrefix}{p.NameId}", Value = p.Song.SongInfo.Author.ContainsKey(locale) ? p.Song.SongInfo.Author[locale] : p.Song.SongInfo.Author.ContainsKey(Constants.DefaultLocale) ? p.Song.SongInfo.Author[Constants.DefaultLocale] : "MISSING" }); var newMsbtCopyrightBgms = bgmEntries.Select(p => new MsbtNewEntryModel() { Label = $"{Constants.InternalIds.MsbtBgmCopyrightPrefix}{p.NameId}", Value = p.Song.SongInfo.Copyright.ContainsKey(locale) ? p.Song.SongInfo.Copyright[locale] : p.Song.SongInfo.Copyright.ContainsKey(Constants.DefaultLocale) ? p.Song.SongInfo.Copyright[Constants.DefaultLocale] : "MISSING" }); var newMsbtBgms = newMsbtTitleBgms; newMsbtBgms.AddRange(newMsbtAuthorBgms); newMsbtBgms.AddRange(newMsbtCopyrightBgms); var inputMsbtFile = _resourceService.GetMsbtBgmResource(locale); if (File.Exists(inputMsbtFile)) { _logger.LogInformation("Generate MSBT BGM - {Entries} new entries - {Path}", newMsbtBgms.Count, inputMsbtFile); var outputMsbtFile = _workspace.GetWorkspaceOutputForMsbtBgmResource(locale); _msbtService.GenerateNewEntries(newMsbtBgms, inputMsbtFile, outputMsbtFile); } } _logger.LogInformation("Output Folder: {OutputFolder}", _workspace.GetWorkspaceDirectory()); return(true); }