public PVFactorioItemContainer(IFactorioAssembly assembly, int level, PVSettings settings, List <IPVFactorioItemContainer> factorioItemContainers) { this.m_assembly = assembly; this.Level = level; this.m_settings = settings; this.m_FactotioItemContainers = factorioItemContainers; }
/// <summary> /// build the tree structure out of the given assembly /// </summary> /// <param name="assembly"></param> /// <param name="position"></param> /// <param name="level"></param> private PVFactorioItemContainer buildTreeStructure(IFactorioAssembly assembly, int position = 0, int level = 0) { PVFactorioItemContainer container = new PVFactorioItemContainer(assembly, level, this.Settings, this.FactorioItemContainers); if (level == 0) { m_rootContainer = container; } container.Left = position; container.SubTreeWidth = 0; PVFactorioItemContainer firstSubContainer = null; PVFactorioItemContainer lastSubContainer = null; for (int i = 0; i < container.Assembly.SubAssembly.Count; i++) { // Build a branch for the current subassembly and position it right to the last subassembly PVFactorioItemContainer currentSubContainer = buildTreeStructure( container.Assembly.SubAssembly[i], container.Left + container.SubTreeWidth, level + 1); if (firstSubContainer == null) { firstSubContainer = currentSubContainer; } lastSubContainer = currentSubContainer; Lines.Add(new PVLine(container, currentSubContainer)); container.SubTreeWidth += currentSubContainer.SubTreeWidth; } if (firstSubContainer != null) { container.Left = (lastSubContainer.Left - firstSubContainer.Left) / 2 + firstSubContainer.Left; } else { container.SubTreeWidth = this.Settings.ItemContainerWidth + this.Settings.WidthOffset; } FactorioItemContainers.Add(container); return(container); }
/// <summary> /// Constructor for subassemblies /// </summary> /// <param name="assemblyItem"></param> /// <param name="topAssembly"></param> /// <param name="quantity"></param> public FactorioAssembly(FactorioItem assemblyItem, FactorioAssembly topAssembly, int quantity) { AssemblyItem = assemblyItem; ItemQuantity = quantity; m_topAssembly = topAssembly; Quantity = (quantity * ((topAssembly.Quantity * topAssembly.AssemblyItem.Productivity)) / (assemblyItem.Productivity * topAssembly.AssemblyItem.CraftingOutput)); Quantity *= topAssembly.CraftingSpeed / CraftingSpeed; if (assemblyItem.Recipe != null) { foreach (var item in assemblyItem.Recipe) { SubAssembly.Add(new FactorioAssembly(item.Key, this, item.Value)); } } }
/// <summary> /// Create a new tree structior for the production viewer and use the data from the parameter /// </summary> /// <param name="assembly">Build a tree structure from this data</param> public PVTreeStructure(IFactorioAssembly assembly) { buildTreeStructure(assembly); }