public static Dictionary <int, T> GetDataFileConvertedIdDictionary <T>(ITupleConverter <T> converter, SaveGameFile savegame, DataFileType type, out List <T> duplicates) where T : class { duplicates = new List <T>(); var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type); var bytes = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize); Dictionary <int, T> dic = new Dictionary <int, T>(); List <T> invalidIds = new List <T>(); foreach (var item in bytes) { var converted = converter.Convert(item); if (converted.Item1 == -1) { invalidIds.Add(converted.Item2 as T); } else { if (dic.ContainsKey(converted.Item1)) { duplicates.Add(converted.Item2 as T); } else { dic.Add(converted.Item1, converted.Item2 as T); } } } return(dic); }
private static List <T> GetDataFileConverted <T>(SaveGameFile savegame, DataFileType type) { var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type); var bytes = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize); var converter = ConverterFactory.CreateConverter <T>(); var collect = ConvertToCMObject <T>(bytes, converter).ToList(); return(collect); }
private static Dictionary <int, string> GetDataFileStringsDictionary(SaveGameFile savegame, DataFileType type) { Dictionary <int, string> fileContents = new Dictionary <int, string>(); var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == type); var fileData = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize); for (int i = 0; i < fileData.Count; i++) { fileContents.Add(i, ByteHandler.GetStringFromBytes(fileData[i], 0, fileFacts.StringLength)); } return(fileContents); }
private static List <PlayerData> GetDataFilePlayerData(SaveGameFile savegame) { var fileFacts = DataFileFacts.GetDataFileFacts().First(x => x.Type == DataFileType.Players); var bytes = DataFileLoaders.GetDataFileBytes(savegame, fileFacts.Type, fileFacts.DataSize); var converter = new PlayerDataConverter(); var collect = new List <PlayerData>(); foreach (var source in bytes) { collect.Add(converter.Convert(source)); } return(collect); }