Пример #1
0
    protected static UrbSubstance[] ArrayToSubstances(UrbFieldArrayData Input)
    {
        UrbSubstance[] Output = new UrbSubstance[Input.Value.Length];

        for (int a = 0; a < Input.Value.Length; a++)
        {
            Output[a] = new UrbSubstance {
                Substance = (UrbSubstanceTag)System.Enum.Parse(typeof(UrbSubstanceTag), Input.Value[a].Name), SubstanceAmount = Input.Value[a].Value
            };
        }
        return(Output);
    }
Пример #2
0
    public UrbSubstance[] GetCompositionIngredients()
    {
        UrbSubstance[] Ingredients = new UrbSubstance[Substances.Keys.Count];

        int i = 0;

        foreach (UrbSubstanceTag tag in Substances.Keys)
        {
            UrbSubstance Ingredient = new UrbSubstance();
            Ingredient.Substance       = tag;
            Ingredient.SubstanceAmount = Substances[tag];

            Ingredients[i] = Ingredient;
            i++;
        }
        return(Ingredients);
    }
Пример #3
0
    public virtual float Drop(UrbSubstance Substance, float Amount)
    {
        if (LastPileTile != mAgent.CurrentTile)
        {
            for (int o = 0; o < mAgent.CurrentTile.Occupants.Count; o++)
            {
                if (mAgent.CurrentTile.Occupants[o].TemplatesMatch(PileAgent))
                {
                    CurrentPile = mAgent.CurrentTile.Occupants[o];
                }
            }
            LastPileTile = mAgent.CurrentTile;
        }
        if (CurrentPile == null)
        {
        }
        float Dropped = Amount;

        return(Dropped);
    }
Пример #4
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);
    }