Exemple #1
0
 private static void InitEcfConfigData()
 {
     ConfigEcfAccess = new ConfigEcfAccess();
     ConfigEcfAccess.ReadConfigEcf(
         ModApi.Application?.GetPathFor(AppFolder.Content),
         CurrentScenario,
         Path.Combine(ModApi.Application?.GetPathFor(AppFolder.SaveGame), "blocksmap.dat"), ModApi);
     ItemInfos = new ItemInfos(ConfigEcfAccess, Localization);
 }
 public ItemInfos(ConfigEcfAccess configAccess, Localization localization)
 {
     try
     {
         Localization = localization;
         ItemInfo     = GetAllItems(configAccess).ToDictionary(I => I.Id, I => I);
     }
     catch (Exception error)
     {
         EmpyrionScripting.Log($"ReadAllItemData:{error}", EmpyrionNetAPIDefinitions.LogLevel.Error);
     }
 }
 public IEnumerable <ItemInfo> GetAllItems(ConfigEcfAccess configAccess) =>
 configAccess.ConfigBlockById
 .Select(I =>
         new ItemInfo()
 {
     Id  = I.Key,
     Key = I.Value.Attr.FirstOrDefault(A => A.Name == "Id")?.AddOns?.FirstOrDefault(A => A.Key == "Name").Value?.ToString(),
 }
         )
 .Select(I =>
 {
     I.Name = Localization.GetName(I.Key, "English");
     return(I);
 })
 .ToArray();