public static void TryAddToVersionManifest(VersionManifest manifest) { foreach (var entryKvp in NewManifestEntries) { var id = entryKvp.Key; var newEntry = entryKvp.Value; if (newEntry.ShouldMergeJSON && manifest.Contains(id, newEntry.Type)) { // read the manifest pointed entry and hash the contents JsonHashToId.Add(File.ReadAllText(manifest.Get(id, newEntry.Type).FilePath).GetHashCode(), id); // The manifest already contains this information, so we need to queue it to be merged var partialJson = File.ReadAllText(newEntry.Path); if (!JsonMerges.ContainsKey(id)) { JsonMerges.Add(id, new List <string>()); } Log($"\tAdding id {id} to JSONMerges"); JsonMerges[id].Add(partialJson); } else { // This is a new definition or a replacement that doesn't get merged, so add or update the manifest Log($"\tAddOrUpdate({id}, {newEntry.Path}, {newEntry.Type}, {DateTime.Now}, {newEntry.AssetBundleName}, {newEntry.AssetBundlePersistent})"); manifest.AddOrUpdate(id, newEntry.Path, newEntry.Type, DateTime.Now, newEntry.AssetBundleName, newEntry.AssetBundlePersistent); } } }
static void Postfix(VersionManifest __result) { ModTek.LogWithDate("VersionManifestUtilities_LoadDefaultManifest_Patch"); // add to the manifest here // TODO: these freaking kvp look so bad foreach (var entryKVP in ModTek.NewManifestEntries) { var id = entryKVP.Key; var newEntry = entryKVP.Value; if (newEntry.ShouldMergeJSON && __result.Contains(id, newEntry.Type)) { // read the manifest pointed entry and hash the contents DoJSONMerge.JSONHashes.Add(File.ReadAllText(__result.Get(id, newEntry.Type).FilePath).GetHashCode()); // The manifest already contains this information, so we need to queue it to be merged var partialJSON = File.ReadAllText(newEntry.Path); if (!DoJSONMerge.JSONMerges.ContainsKey(id)) { DoJSONMerge.JSONMerges.Add(id, new List <string>()); } ModTek.Log("\tAdding id {0} to JSONMerges", id); DoJSONMerge.JSONMerges[id].Add(partialJSON); } else { // This is a new definition or a replacement that doesn't get merged, so add or update the manifest ModTek.Log("\tAddOrUpdate({0}, {1}, {2}, {3}, {4}, {5})", id, newEntry.Path, newEntry.Type, DateTime.Now, newEntry.AssetBundleName, newEntry.AssetBundlePersistent); __result.AddOrUpdate(id, newEntry.Path, newEntry.Type, DateTime.Now, newEntry.AssetBundleName, newEntry.AssetBundlePersistent); } } }