List <ManufacturerIndexEntry> Load(string entityFolder) { var index = new List <ManufacturerIndexEntry>(); var parser = new ManufacturerParser(); foreach (var entityFilename in Directory.EnumerateFiles(Path.Combine(DataRoot, entityFolder), "*.xml", SearchOption.AllDirectories)) { if (verbose) { Console.WriteLine(entityFilename); } var manufacturer = parser.Parse(entityFilename); if (manufacturer == null) { continue; } var indexEntry = new ManufacturerIndexEntry { name = localisationService.GetText(manufacturer.Localization.Name), code = manufacturer.Code, reference = manufacturer.__ref }; index.Add(indexEntry); } return(index); }
public StandardisedItem BuildItem(EntityClassDefinition entity) { var stdItem = new StandardisedItem { ClassName = entity.ClassName, Size = entity.Components.SAttachableComponentParams?.AttachDef.Size ?? 0, Grade = entity.Components.SAttachableComponentParams?.AttachDef.Grade ?? 0, Type = BuildTypeName(entity.Components.SAttachableComponentParams?.AttachDef.Type, entity.Components.SAttachableComponentParams?.AttachDef.SubType), Name = localisationSvc.GetText(entity.Components.SAttachableComponentParams?.AttachDef.Localization.Name, entity.ClassName), Description = localisationSvc.GetText(entity.Components.SAttachableComponentParams?.AttachDef.Localization.Description), Manufacturer = manufacturerSvc.GetManufacturer(entity.Components.SAttachableComponentParams?.AttachDef.Manufacturer, entity.ClassName), Ports = BuildPortList(entity), Tags = BuildTagList(entity) }; stdItem.Shield = BuildShieldInfo(entity); stdItem.QuantumDrive = BuildQuantumDriveInfo(entity); stdItem.PowerPlant = BuildPowerPlantInfo(entity); stdItem.Cooler = BuildCoolerInfo(entity); stdItem.Durability = BuildDurabilityInfo(entity); stdItem.Thruster = BuildThrusterInfo(entity); stdItem.CargoGrid = BuildCargoGridInfo(entity); stdItem.QuantumFuelTank = BuildQuantumFuelTankInfo(entity); stdItem.HydrogenFuelTank = BuildHydrogenFuelTankInfo(entity); stdItem.HydrogenFuelIntake = BuildHydrogenFuelIntakeInfo(entity); stdItem.Armour = BuildArmourInfo(entity); stdItem.Emp = BuildEmpInfo(entity); stdItem.MissileRack = BuildMissileRackInfo(entity); stdItem.QuantumInterdiction = BuildQigInfo(entity); stdItem.Ifcs = BuildIfcsInfo(entity); stdItem.HeatConnection = BuildHeatConnectionInfo(entity); stdItem.PowerConnection = BuildPowerConnectionInfo(entity); stdItem.Weapon = BuildWeaponInfo(entity); stdItem.Ammunition = BuildAmmunitionInfo(entity); stdItem.Missile = BuildMissileInfo(entity); stdItem.Scanner = BuildScannerInfo(entity); stdItem.Radar = BuildRadarInfo(entity); stdItem.Ping = BuildPingInfo(entity); stdItem.WeaponRegenPool = BuildWeaponRegenInfo(entity); return(stdItem); }
List <StarmapIndexEntry> Load(string entityFolder) { var index = new List <StarmapIndexEntry>(); foreach (var entityFilename in Directory.EnumerateFiles(Path.Combine(DataRoot, entityFolder), "*.xml", SearchOption.AllDirectories)) { if (verbose) { Console.WriteLine($"StarmapLoader: {entityFilename}"); } var parser = new StarmapParser(); var entity = parser.Parse(entityFilename); if (entity == null) { continue; } var indexEntry = new StarmapIndexEntry { name = localisationService.GetText(entity.name), description = localisationService.GetText(entity.description), callout1 = localisationService.GetText(entity.callout1), callout2 = localisationService.GetText(entity.callout2), callout3 = localisationService.GetText(entity.callout3), type = entity.type, navIcon = entity.navIcon, hideInStarmap = entity.hideInStarmap, jurisdiction = entity.jurisdiction, parent = entity.parent, size = entity.size, reference = entity.__ref, path = entity.__path }; index.Add(indexEntry); } return(index); }
List <ShopItem> GetInventory(Node prices, ShopLayoutNode shopNode) { var items = new List <ShopItem>(); if (shopNode?.ShopInventoryNodes.Length > 0) { foreach (var itemNode in shopNode.ShopInventoryNodes) { var product = FindInventoryNode(prices, itemNode.InventoryID); if (product == null) { Console.WriteLine($"ShopLoader: Can't find product {itemNode.Name} ({itemNode.InventoryID}) "); } else { var entity = entitySvc.GetByFilename(Path.Combine(DataRoot, product.Filename)); var item = new ShopItem { name = itemNode.Name.ToLower(), basePriceOffsetPercentage = itemNode.BasePriceOffsetPercentage, maxDiscountPercentage = itemNode.MaxDiscountPercentage, maxPremiumPercentage = itemNode.MaxPremiumPercentage, inventory = itemNode.Inventory, optimalInventoryLevel = itemNode.OptimalInventoryLevel, maxInventory = itemNode.MaxInventory, autoRestock = Convert.ToBoolean(itemNode.AutoRestock), autoConsume = Convert.ToBoolean(itemNode.AutoConsume), refreshRatePercentagePerMinute = itemNode.RefreshRatePercentagePerMinute, shopBuysThis = itemNode.TransactionTypes.Any(x => x.Data == "Sell"), shopSellsThis = itemNode.TransactionTypes.Any(x => x.Data == "Buy"), shopRentThis = itemNode.TransactionTypes.Any(x => x.Data == "Rent"), basePrice = product.BasePrice, filename = product.Filename, node_reference = itemNode.ID, item_reference = itemNode.InventoryID, rentalTemplates = new List <ShopRentalTemplate>() }; foreach (var rentalTemplate in itemNode.RentalTemplates) { var template = rentalTemplates.Find(y => y.ShopRentalTemplate.ID == rentalTemplate.Data); if (template != null) { item.rentalTemplates.Add(template.ShopRentalTemplate); } } if (entity?.Components.SAttachableComponentParams != null) { item.displayName = localisationService.GetText(entity.Components.SAttachableComponentParams.AttachDef.Localization.Name); item.tags = entity.Components.SAttachableComponentParams.AttachDef.Tags.Split(" "); item.type = entity.Components.SAttachableComponentParams.AttachDef.Type; item.subType = entity.Components.SAttachableComponentParams.AttachDef.SubType; } if (entity?.Components.CommodityComponentParams != null) { item.displayName = localisationService.GetText(entity.Components.CommodityComponentParams.name); } items.Add(item); } } } return(items); }