public override bool SetComponentData(UrbComponentData Data) { FoodSubstances = UrbEncoder.GetEnumArray <UrbSubstanceTag>("FoodSubstances", Data); FoodScents = UrbEncoder.GetEnumArray <UrbScentTag>("FoodScents", Data); Stomach = new UrbComposition(UrbEncoder.GetSubstancesFromArray("StomachContents", Data)); return(true); }
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)); }
public float Impact(UrbComposition ImpactSource, UrbSubstanceTag ImpactSubstance, float Force) { float Result = ImpactSource[ImpactSubstance]; Result = PenetrationCheck(ImpactSubstance, Result, Force); return(Result); }
public override void Awake() { Stomach = new UrbComposition(); FoodScents = UrbSubstances.Scent(FoodSubstances); DetectedFood = new List <UrbBody>(); base.Awake(); }
public override bool SetComponentData(UrbComponentData Data) { Height = UrbEncoder.GetField("Height", Data); BodyRecipe = UrbEncoder.GetSubstancesFromArray("BodyRecipe", Data); SkinRecipe = UrbEncoder.GetEnumArray <UrbSubstanceTag>("SkinRecipe", Data); BodyComposition = new UrbComposition(UrbEncoder.GetSubstancesFromArray("BodyContents", Data)); CriticalBodyPartAmounts = UrbEncoder.GetSubstancesFromArray("CriticalBodyPartAmounts", Data); return(true); }
public bool RemoveComposition(UrbComposition input) { if (Compositions.Contains(input)) { UsedCapacity -= input.UsedCapacity; input.Membrane.ChangeComposition(input); input.ContainingComposition = null; } return(Compositions.Remove(input)); }
public override void Awake() { if (_bodyComposition == null) { _bodyComposition = new UrbComposition(BodyRecipe); _bodyComposition.Membrane.Layers = SkinRecipe; HasComposition = true; } base.Awake(); }
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); }
public bool ContainsLessThan(UrbComposition composition) { foreach (UrbSubstanceTag tag in Substances.Keys) { if (composition.Substances.ContainsKey(tag)) { if (Substances[tag] >= composition[tag]) { return(false); } } } return(true); }
public void AddComposition(UrbComposition input) { input.ContainingComposition = this; input.Membrane.ChangeComposition(this); input.MaxCapacity = input.UsedCapacity + AvailableCapacity; Assert.IsFalse(float.IsInfinity(input.MaxCapacity) || float.IsNaN(input.MaxCapacity)); UsedCapacity += input.UsedCapacity; Assert.IsFalse(float.IsInfinity(UsedCapacity) || float.IsNaN(UsedCapacity)); Compositions.Add(input); }
public void ChangeComposition(UrbComposition Composition) { if (Composition == null) { Debug.LogError("Illegal Assignment: Cannot Change Composition to Null on UrbMembrane"); return; } if (MembraneLayers != null) { for (int i = 0; i < MembraneLayers.Length; i++) { ContainingComposition.TransferTo(Composition, MembraneLayers[i], float.MaxValue); } } ContainingComposition = Composition; }
//TODO: Optimize this public bool ContainsEqualTo(UrbComposition composition) { foreach (UrbSubstanceTag tag in Substances.Keys) { if (composition.Substances.ContainsKey(tag)) { if (Substances[tag] != composition[tag]) { return(false); } } else { return(false); } } return(true); }
public float EmptyInto(UrbComposition Target) { float Result = 0; UrbSubstanceTag[] tags = new UrbSubstanceTag[Substances.Keys.Count]; int i = 0; foreach (UrbSubstanceTag tag in Substances.Keys) { tags[i] = tag; i++; } for (int t = 0; t < tags.Length; t++) { float Amount = Substances[tags[t]]; Result += TransferTo(Target, tags[t], Amount); } Assert.IsFalse(float.IsInfinity(Result) || float.IsNaN(Result)); return(Result); }
public float TransferTo(UrbComposition Target, UrbSubstanceTag Tag, float Amount) { if (Amount <= 0.0f) { return(0.0f); } //float TransferAmount = Mathf.Min(Amount, Target.AvailableCapacity); float TransferAmount = RemoveSubstance(Tag, Amount); if (TransferAmount > 0) { Target.AddSubstance(Tag, TransferAmount); } else { //Debug.Log( Tag.ToString() + " Not Available to Transfer."); } Assert.IsFalse(float.IsInfinity(TransferAmount) || float.IsNaN(TransferAmount)); return(TransferAmount); }
public UrbMembrane(UrbComposition Composition) { ContainingComposition = Composition; }
public override void Awake() { HeldComposition = new UrbComposition(); base.Awake(); }