private void LoadCharms() { string charmsFilePath = Path.Combine(dataFolderPath, CharmsFilename); string[] allLines = File.ReadAllLines(charmsFilePath); Dictionary <string, string[]> localizations = LoadLocalizations(CharmsFilename); (int headerIndex, int dataIndex) = FindIndexes(allLines); if (headerIndex < 0) { Console.WriteLine($"[ERROR] Failed to create data loader for charms"); charmsTask = Task.FromResult <ICharm[]>(null); return; } var dataLoader = new DataLoader <CharmPrimitive>(allLines[headerIndex].Substring(1).Split(','), logger); var localCharms = new Dictionary <string, List <ICharmLevel> >(); int[] noSlots = new int[0]; for (int i = dataIndex; i < allLines.Length; i++) { CharmPrimitive charmPrimitive = dataLoader.CreateObject(allLines[i].Split(','), i + dataIndex); if (string.IsNullOrWhiteSpace(charmPrimitive.Name)) { continue; } (string charmName, int level) = DetermineCharmNameAndLevel(charmPrimitive.Name); if (localCharms.TryGetValue(charmName, out List <ICharmLevel> charmLevels) == false) { charmLevels = new List <ICharmLevel>(); localCharms.Add(charmName, charmLevels); } IEvent foundEvent = CreateEvent( charmPrimitive.Material1, charmPrimitive.Material2, charmPrimitive.Material3, charmPrimitive.Material4 ); charmLevels.Add(new CharmLevel( i - dataIndex, level, localizations.ToDictionary(kv1 => kv1.Key, kv2 => $"{kv2.Value[i - dataIndex]}"), charmPrimitive.Acquire, noSlots, ParseAbilities(in charmPrimitive), foundEvent, CreateCraftMaterials(in charmPrimitive) )); } Dictionary <string, string> DetermineCharmsLocalizations(ICharmLevel charmLevel) { var resut = new Dictionary <string, string>(); foreach (KeyValuePair <string, string> kv in charmLevel.Name) { (string charmName, int _) = DetermineCharmNameAndLevel(kv.Value); resut[kv.Key] = charmName; } return(resut); } ICharm[] nonTaskCharms = localCharms .Select((kv, i) => new Charm(i, DetermineCharmsLocalizations(kv.Value[0]), kv.Value.ToArray())) .Cast <ICharm>() .ToArray(); charmsTask = Task.FromResult(nonTaskCharms); }