public double requestResource(double amount) { if (isScience) { if (amount < 0) { ScienceSubject subject = getSubject(); if (subject != null) { double cap = subject.scienceCap; double curve_base = (cap - 1) / (cap); double old_science = subject.science; double precurve_amount = -amount * subject.subjectValue; double new_science = (1 - (1 - (old_science / cap)) * Math.Pow(curve_base, precurve_amount)) * cap; rateMultiplier = subject.subjectValue * ((new_science - old_science) / precurve_amount); if (subject.id != subjOwedId) { subjOwed = 0; } subject.science = (float)(new_science + subjOwed); subjOwed = -(((double)subject.science) - new_science - subjOwed); //print("[" + old_science + "/" + cap + "] (+) " + precurve_amount + " == " + new_science + " [" + subject.science + " + " + subjOwed + "]"); subjOwedId = subject.id; amount = -(subject.science - old_science); } else { rateMultiplier = ScienceHelper.getScienceMultiplier(owner.part.vessel); amount *= rateMultiplier; } } else { rateMultiplier = 1; } double sci_before = ResearchAndDevelopment.Instance.Science; /* MKW - Which TransactionReason should we use?? */ ResearchAndDevelopment.Instance.AddScience((float)(-amount + owed), TransactionReasons.ScienceTransmission); owed = (-amount + owed + sci_before) - ((double)ResearchAndDevelopment.Instance.Science); return(sci_before - ResearchAndDevelopment.Instance.Science); } else { rateMultiplier = 1; double produced = owner.part.RequestResource(resource, amount + owed); owed = (amount + owed) - produced; return(produced); } }
public void checkBiomeChange() { double numExposureTime = getResourceAmount("ExposureTime"); //int sciCount = GetScienceCount(); // MKW - what was this for? var subject = ScienceHelper.getScienceSubject(experimentID, vessel); string subjectId = ((subject == null) ? "" : subject.id); if (subjectId != "" && last_subjectId != "" && last_subjectId != subjectId && (numExposureTime > 0)) { biomeChanged(); } last_subjectId = subjectId; }
public ScienceSubject getSubject() { return(ScienceHelper.getScienceSubject(subjectString, owner.part.vessel)); }