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); }
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); }
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); }
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); }