Пример #1
0
 private void LoadItems()
 {
     try
     {
         _game.ItemManager.AddItems(ItemContentCollection.LoadItemsFrom($"{PackagePath}/Items"));
     }
     catch (DirectoryNotFoundException)
     {
         _logger.Debug($"Package: {PackageName} does not contain any items, skipping...");
     }
 }
Пример #2
0
        public static ItemContentCollection LoadItemsFrom(string directoryPath)
        {
            var result             = new ItemContentCollection();
            var itemDirectoryPaths = Directory.GetDirectories(directoryPath);

            foreach (var location in itemDirectoryPaths)
            {
                var path         = location.Replace('\\', '/');
                var itemName     = path.Split('/').Last();
                var itemDataPath = $"{path}/{itemName}.json";
                result.AddFromPath(itemDataPath);
            }

            return(result);
        }