using System; using System.Collections.Generic; using System.IO; [Serializable] public class DlcManifestFile { public string manifestId; public string manifestVersion = "1"; public List entries = new List(); } [Serializable] public class DlcManifestEntry { public bool enabled = true; public string dlcKey; public string version; public string catalogPath; public bool autoDownloadDependencies = true; public string[] dependencyKeys; public string[] dlcDataLabels; public string[] songLabels; public string[] songContentLabels; public string[] heroSkinLabels; public string[] heroLabels; public string GetSafeDlcKey() { return string.IsNullOrWhiteSpace(dlcKey) ? string.Empty : dlcKey.Trim(); } public string[] GetDlcDataLabels() { return GetResolvedLabels(dlcDataLabels, "dlc:" + GetSafeDlcKey() + ":dlcdata"); } public string[] GetSongLabels() { return GetResolvedLabels(songLabels, "dlc:" + GetSafeDlcKey() + ":songs"); } public string[] GetSongContentLabels() { return GetResolvedLabels(songContentLabels, "dlc:" + GetSafeDlcKey() + ":songcontent"); } public string[] GetHeroSkinLabels() { return GetResolvedLabels(heroSkinLabels, "dlc:" + GetSafeDlcKey() + ":heroskins"); } public string[] GetHeroLabels() { return GetResolvedLabels(heroLabels, "dlc:" + GetSafeDlcKey() + ":heroes"); } public string[] GetDependencyKeys() { List result = new List(); AppendUnique(result, dependencyKeys); AppendUnique(result, GetDlcDataLabels()); AppendUnique(result, GetSongLabels()); AppendUnique(result, GetSongContentLabels()); AppendUnique(result, GetHeroSkinLabels()); AppendUnique(result, GetHeroLabels()); return result.ToArray(); } private static string[] GetResolvedLabels(string[] labels, string fallbackLabel) { List result = new List(); AppendUnique(result, labels); if (result.Count == 0 && !string.IsNullOrWhiteSpace(fallbackLabel)) { result.Add(fallbackLabel.Trim()); } return result.ToArray(); } private static void AppendUnique(List target, string[] values) { if (target == null || values == null) { return; } for (int i = 0; i < values.Length; i++) { string value = values[i]; if (string.IsNullOrWhiteSpace(value)) { continue; } string trimmed = value.Trim(); if (!target.Contains(trimmed)) { target.Add(trimmed); } } } } public sealed class DlcManifestRuntimeEntry { public string manifestId; public string manifestSourcePath; public string manifestDirectory; public DlcManifestEntry entry; public string resolvedCatalogPath; public string GetRuntimePackageId() { string safeManifest = string.IsNullOrWhiteSpace(manifestId) ? "manifest" : manifestId.Trim(); string safeDlc = entry != null ? entry.GetSafeDlcKey() : string.Empty; if (string.IsNullOrWhiteSpace(safeDlc)) { safeDlc = Path.GetFileNameWithoutExtension(manifestSourcePath ?? string.Empty); } return safeManifest + "::" + safeDlc; } }