public override void Hotload(List <string> changedFiles) { // First try to load the index in case any files were added or removed. var newIndex = ReadFile(INDEX_FILENAME); if (newIndex == null) { Configs.LogError($"Index file is missing at Resources path {INDEX_FILENAME}."); return; } if (newIndex.Checksum != indexFile.Checksum) { // Index has changed, possibly have added or removed files from the index. // TODO Smart update, don't just toss the whole list and start from scratch. Preload(); changedFiles.AddRange(filesList); } else { // Index hasn't changed. Check each file. foreach (string file in filesList) { var newFile = ReadFile(file); if (newFile.Checksum == AllFiles[file].Checksum) { continue; } AllFiles[file] = newFile; changedFiles.Add(file); } } }
public override void Preload() { AllFiles.Clear(); filesList.Clear(); // Load the index file. indexFile = ReadFile(INDEX_FILENAME); if (indexFile == null) { Configs.LogError($"Index file is missing at Resources path {INDEX_FILENAME}."); return; } // Load all the files. foreach (var nameNode in indexFile.Parsed.Values) { string filename = nameNode.StringValue; filesList.Add(filename); if (filename != "index") { AllFiles[filename] = ReadFile(filename); } } }