public IEnumerable <ProjectResourceUpdate> ImportFile(ArchiveFileImporterContext context, IArchiveFile archiveFile) { return(Enumerable.Empty <ProjectResourceUpdate>()); }
public IEnumerable <ProjectResourceUpdate> ImportFile(ArchiveFileImporterContext context, IArchiveFile archiveFile) { var update = context.AuthorUpdate(archiveFile.FullName); object content; if (archiveFile.FullName.Contains("buildings")) { update.ImporterTags.Add("type-building"); var loaded = Load <BuildingTemplate>(archiveFile.FullName, archiveFile); update.Dependencies.Register(loaded.PackIdentifier); if (loaded.Recipe != null) { var alreadyRegistered = new List <string>(); foreach (string resource in loaded.Recipe) { if (string.IsNullOrEmpty(resource)) { continue; } if (!alreadyRegistered.Contains(resource)) { update.Dependencies.Register(resource); alreadyRegistered.Add(resource); } } } content = loaded; } else if (archiveFile.FullName.Contains("resources")) { update.ImporterTags.Add("type-resource"); content = LoadJObject(archiveFile); } else if (archiveFile.FullName.Contains("building-packs")) { update.ImporterTags.Add("type-buildingpack"); content = LoadJObject(archiveFile); } else if (archiveFile.FullName.Contains("gamerules")) { update.ImporterTags.Add("type-gamerules"); var loaded = Load <GameRulesTemplate>(archiveFile.FullName, archiveFile); var alreadyRegistered = new List <string>(); foreach (string resource in loaded.SharedCards.Concat(loaded.PlayerCards)) { if (string.IsNullOrEmpty(resource)) { continue; } if (!alreadyRegistered.Contains(resource)) { update.Dependencies.Register(resource); alreadyRegistered.Add(resource); } } content = loaded; } else { content = LoadJObject(archiveFile); } var jsonContentWriter = new JsonContentWriter(content); update.WithContent(jsonContentWriter); yield return(update); }