public int Extract(Nutrients nutrient, int energy) { MediaNutrient mediaNutrient = GetNutrient(nutrient); if (mediaNutrient == null) { Debug.LogError(nutrient + " does not exist"); return(0); } int extraction = GetExtractionVolume(mediaNutrient, energy); Debug.Log("Extractin " + extraction); return(mediaNutrient.Extract(extraction)); }
void MakeWaste() { MediaNutrient C = GetNutrient(Nutrients.C); data.waste += C.Extract(C.CurrentValue / 4); MediaNutrient N = GetNutrient(Nutrients.N); data.waste += N.Extract(C.CurrentValue / 3); MediaNutrient AA = GetNutrient(Nutrients.AA); data.waste += AA.Extract(AA.CurrentValue / 2); }
public void CauseDiffusion(NutrientState[] others) { int nNutrients = nutrients.Count; int nOthers = others.Length; for (int i = 0; i < nNutrients; i++) { int own = nutrients[i].Extract(diffusionFactor); int ownPerOther = own / 6; for (int j = 0; j < nOthers; j++) { MediaNutrient otherNutrient = others[j].GetNutrient(nutrients[i].nutrient); int surplus = 0; nutrients[i].Deposit(otherNutrient.Extract(diffusionFactor / 6), out surplus); otherNutrient.Deposit(ownPerOther + surplus, out surplus); } } }
void CreateEnergy() { MediaNutrient C = GetNutrient(Nutrients.C, true); MediaNutrient N = GetNutrient(Nutrients.N, true); MediaNutrient AA = GetNutrient(Nutrients.AA, true); int cFactor = 5; int nFactor = 2; int aFactor = 1; int production = Mathf.Min( C.CurrentValue / cFactor, N.CurrentValue / nFactor, AA.CurrentValue / aFactor); C.Extract(production * cFactor); N.Extract(production * nFactor); AA.Extract(production * aFactor); data.energy += production * 10; }