public List <Shop> Load() { var shops = new List <Shop>(); var productList = Parse <Node>(Path.Combine(DataRoot, @"Data\Libs\Subsumption\Shops\RetailProductPrices.xml")); var shopRootNode = Parse <ShopLayoutNode>(Path.Combine(DataRoot, @"Data\Libs\Subsumption\Shops\ShopLayouts.xml")); var rentalTemplatesFolder = @"Data\Libs\Subsumption\Shops\Templates"; this.rentalTemplates = new List <RentalTemplate>(); foreach (var templateFilename in Directory.EnumerateFiles(Path.Combine(DataRoot, rentalTemplatesFolder), "*.xml", SearchOption.AllDirectories)) { var rentalTemplateParser = new RentalTemplateParser(); RentalTemplate entity = rentalTemplateParser.Parse(templateFilename); if (entity == null) { continue; } this.rentalTemplates.Add(entity); } foreach (var(shopNode, p) in GetShops(shopRootNode)) { var shop = new Shop { name = GetShopName(shopNode.Name), profitMargin = shopNode.ProfitMargin, acceptsStolenGoods = Convert.ToBoolean(shopNode.AcceptsStolenGoods), reference = shopNode.ID, parent = shopRootNode.ID, containerPath = p }; shop.inventory = GetInventory(productList, shopNode).ToArray(); shops.Add(shop); Console.WriteLine($"{shop.containerPath}: {shop.name}, {shop.inventory.Length} items"); foreach (var i in shop.inventory) { Console.WriteLine($@"{(i.shopBuysThis ? "Buys" : "")} {(i.shopSellsThis ? "Sells" : "")} {i.name} {i.basePrice} {i.basePriceOffsetPercentage:n0}%"); } } File.WriteAllText(Path.Combine(OutputFolder, "shops.json"), JsonConvert.SerializeObject(shops)); return(shops); }
public List <Shop> Load() { var shops = new List <Shop>(); var productList = Parse <Node>(Path.Combine(DataRoot, Path.Combine("Data", "Libs", "Subsumption", "Shops", "RetailProductPrices.xml"))); var shopRootNode = Parse <ShopLayoutNode>(Path.Combine(DataRoot, Path.Combine("Data", "Libs", "Subsumption", "Shops", "ShopLayouts.xml"))); var rentalTemplatesFolder = Path.Combine("Data", "Libs", "Subsumption", "Shops", "Templates"); this.rentalTemplates = new List <RentalTemplate>(); foreach (var templateFilename in Directory.EnumerateFiles(Path.Combine(DataRoot, rentalTemplatesFolder), "*.xml", SearchOption.AllDirectories)) { var rentalTemplateParser = new RentalTemplateParser(); RentalTemplate entity = rentalTemplateParser.Parse(templateFilename); if (entity == null) { continue; } this.rentalTemplates.Add(entity); } foreach (var(shopNode, p) in GetShops(shopRootNode)) { var shop = new Shop { name = GetShopName(shopNode.Name), profitMargin = shopNode.ProfitMargin, acceptsStolenGoods = Convert.ToBoolean(shopNode.AcceptsStolenGoods), reference = shopNode.ID, parent = shopRootNode.ID, containerPath = p }; shop.inventory = GetInventory(productList, shopNode).ToArray(); shops.Add(shop); Console.WriteLine($"ShopLoader: {shop.containerPath}"); } File.WriteAllText(Path.Combine(OutputFolder, "shops.json"), JsonConvert.SerializeObject(shops)); return(shops); }