示例#1
0
    public float MixRecipeInto(UrbComposition Target, UrbRecipe Recipe, float Amount)
    {
        float Result = (Target.Emptiness < Amount) ? Target.Emptiness : Amount;

        Result = MixRecipe(Recipe, Result);

        return(TransferTo(Target, Recipe.Product, Result));
    }
示例#2
0
    public float DecomposeRecipeInto(UrbComposition Target, UrbRecipe Recipe, float Amount)
    {
        float Result = (Target.Emptiness < Amount) ? Target.Emptiness : Amount;

        TransferTo(Target, Recipe.Product, Result);

        Result = Target.DecomposeRecipe(Recipe, Result);

        Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result));

        return(Result);
    }
示例#3
0
    protected void InitializeGrowthRecipes()
    {
        ReserveToGrowth = new UrbRecipe[BodyGrowthRecipe.Length];

        for (int g = 0; g < BodyGrowthRecipe.Length; g++)
        {
            UrbRecipe Recipe = new UrbRecipe();
            Recipe.Ingredients = new UrbSubstance[1];
            Recipe.Product     = BodyGrowthRecipe[g].Substance;

            Recipe.Ingredients[0]                 = new UrbSubstance();
            Recipe.Ingredients[0].Substance       = BodyEnergyReserveStorage;
            Recipe.Ingredients[0].SubstanceAmount = 1.0f;

            ReserveToGrowth[g] = Recipe;
        }
    }
示例#4
0
    protected void InitializeReserveRecipes()
    {
        FoodToReserves = new UrbRecipe[Eater.FoodSubstances.Length];

        for (int e = 0; e < Eater.FoodSubstances.Length; e++)
        {
            UrbRecipe Recipe = new UrbRecipe();
            Recipe.Ingredients = new UrbSubstance[1];
            Recipe.Product     = BodyEnergyReserveStorage;

            //TODO: Define Nutrition requirements somewhere.
            Recipe.Ingredients[0]                 = new UrbSubstance();
            Recipe.Ingredients[0].Substance       = Eater.FoodSubstances[e];
            Recipe.Ingredients[0].SubstanceAmount = 2.0f;

            FoodToReserves[e] = Recipe;
        }
    }
示例#5
0
    public float MixRecipe(UrbRecipe Recipe, float Amount)
    {
        if (Amount > UsedCapacity)
        {
            Amount = UsedCapacity;
        }

        UrbSubstance[] Proportions = UrbSubstances.GetIngredientProportions(Recipe);

        float Result = Amount;

        for (int r = 0; r < Proportions.Length; r++)
        {
            float PossibleAmount = this[Proportions[r].Substance] / Proportions[r].SubstanceAmount;
            if (PossibleAmount < Result)
            {
                Result = PossibleAmount;
            }
        }

        if (Result > 0.0f)
        {
            for (int c = 0; c < Proportions.Length; c++)
            {
                RemoveSubstance(Proportions[c].Substance, Proportions[c].SubstanceAmount * Result);
            }

            AddSubstance(Recipe.Product, Result);
        }
        else
        {
            Result = 0.0f;
        }

        Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result));

        return(Result);
    }
示例#6
0
    public float DecomposeRecipe(UrbRecipe Recipe, float Amount)
    {
        if (Amount > UsedCapacity)
        {
            Amount = UsedCapacity;
        }
        float Result = Amount;

        Result = RemoveSubstance(Recipe.Product, Result);

        if (Result > 0)
        {
            UrbSubstance[] Proportions = UrbSubstances.GetIngredientProportions(Recipe);
            for (int r = 0; r < Proportions.Length; r++)
            {
                AddSubstance(Proportions[r].Substance, Proportions[r].SubstanceAmount * Result);
            }
        }

        Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result));

        return(Result);
    }
示例#7
0
    public static UrbSubstance[] GetIngredientProportions(UrbRecipe Recipe)
    {
        UrbSubstance[] Proportions = new UrbSubstance[Recipe.Ingredients.Length];
        float          Quantity    = 0;

        for (int i = 0; i < Recipe.Ingredients.Length; i++)
        {
            Quantity += Recipe.Ingredients[i].SubstanceAmount;
        }

        Assert.IsFalse(float.IsInfinity(Quantity));
        Assert.IsFalse(float.IsNaN(Quantity));

        for (int i = 0; i < Recipe.Ingredients.Length; i++)
        {
            Proportions[i].Substance       = Recipe.Ingredients[i].Substance;
            Proportions[i].SubstanceAmount = Recipe.Ingredients[i].SubstanceAmount / Quantity;

            Assert.IsFalse(float.IsInfinity(Proportions[i].SubstanceAmount));
            Assert.IsFalse(float.IsNaN(Proportions[i].SubstanceAmount));
        }

        return(Proportions);
    }