Exemple #1
0
        public void AutoSatisfyNodeDemand(ProductionNode node, Item item)
        {
            if (node.InputLinks.Any(l => l.Item == item))               //Increase throughput of existing node link
            {
                NodeLink link = node.InputLinks.First(l => l.Item == item);
                //link.Amount += node.GetExcessDemand(item);
            }
            else if (Nodes.Any(n => n.Outputs.Contains(item)))                  //Add link from existing node
            {
                ProductionNode existingNode = Nodes.Find(n => n.Outputs.Contains(item));
                NodeLink.Create(existingNode, node, item);
            }
            else if (item.Recipes.Any(r => !CyclicRecipes.Contains(r)))                 //Create new recipe node and link from it
            {
                RecipeNode newNode = RecipeNode.Create(item.Recipes.First(r => !CyclicRecipes.Contains(r)), this);
                NodeLink.Create(newNode, node, item);
            }
            else                //Create new supply node and link from it
            {
                SupplyNode newNode = SupplyNode.Create(item, this);
                NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
            }

            ReplaceCycles();
        }
Exemple #2
0
		public void CreateSupplyNodeToSatisfyItemDemand(ProductionNode node, Item item)
		{
			SupplyNode newNode = SupplyNode.Create(item, node.Graph);
			NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
		}
Exemple #3
0
		public void CreateRecipeNodeToSatisfyItemDemand(ProductionNode node, Item item, Recipe recipe)
		{
			RecipeNode newNode = RecipeNode.Create(recipe, this);
			NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
		}
Exemple #4
0
		public void AutoSatisfyNodeDemand(ProductionNode node, Item item)
		{
			if (node.InputLinks.Any(l => l.Item == item))	//Increase throughput of existing node link
			{
				NodeLink link = node.InputLinks.First(l => l.Item == item);
				//link.Amount += node.GetExcessDemand(item);
			}
			else if (Nodes.Any(n => n.Outputs.Contains(item)))	//Add link from existing node
			{
				ProductionNode existingNode = Nodes.Find(n => n.Outputs.Contains(item));
				NodeLink.Create(existingNode, node, item);
			}
			else if (item.Recipes.Any(r => !CyclicRecipes.Contains(r)))	//Create new recipe node and link from it
			{
				RecipeNode newNode = RecipeNode.Create(item.Recipes.First(r => !CyclicRecipes.Contains(r)), this);
				NodeLink.Create(newNode, node, item);
			}
			else	//Create new supply node and link from it
			{
				SupplyNode newNode = SupplyNode.Create(item, this);
				NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
			}

			ReplaceCycles();
		}
Exemple #5
0
        public void CreateSupplyNodeToSatisfyItemDemand(ProductionNode node, Item item)
        {
            SupplyNode newNode = SupplyNode.Create(item, node.Graph);

            NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
        }
Exemple #6
0
        public void CreateRecipeNodeToSatisfyItemDemand(ProductionNode node, Item item, Recipe recipe)
        {
            RecipeNode newNode = RecipeNode.Create(recipe, this);

            NodeLink.Create(newNode, node, item, node.GetUnsatisfiedDemand(item));
        }