private void Research() { if (m_node.state == RDTech.State.Available) { throw new KOSException("Node is already purchased"); } var host = ResearchAndDevelopment.Instance; if (host != null) { if (!CurrencyModifierQuery.RunQuery(TransactionReasons.RnDTechResearch, 0f, -m_node.scienceCost, 0f).CanAfford(delegate(Currency c) { throw new KOSException("Not enough science to research this node"); })) { throw new KOSException("Not enough funds"); } float scienceCostLimit = GameVariables.Instance.GetScienceCostLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.ResearchAndDevelopment)); if ((float)m_node.scienceCost > scienceCostLimit) { throw new KOSException("Node exceeds science cost limit"); } host.AddScience(-m_node.scienceCost, TransactionReasons.RnDTechResearch); } ResearchAndDevelopment.Instance.UnlockProtoTechNode(m_node); m_node = ResearchAndDevelopment.Instance.GetTechState(m_node.techID); }
/// <summary> /// Updates the research on the team's current part /// </summary> /// <returns>The amount of du added to the part this update.</returns> public float UpdateResearch(float normalizedTime, float currentPartData) { if (PartInResearch != "" && ResearchActive) { float pointsForTick = Points * normalizedTime * PartRnDRate; pointsForTick = Mathf.Min(pointsForTick, MaxData - currentPartData); float costForTick = Cost * normalizedTime * PartRnDCost; Log("Points " + pointsForTick + ", Cost " + costForTick); if (HighLogic.CurrentGame.Mode == Game.Modes.CAREER) { CurrencyModifierQuery query = CurrencyModifierQuery.RunQuery(TransactionReasons.RnDPartPurchase, -costForTick, 0f, 0f); float totalCost = query.GetInput(Currency.Funds) + query.GetEffectDelta(Currency.Funds); Log("Total cost " + totalCost); if (totalCost < Funding.Instance.Funds) { Log("Subtracting cost..."); Funding.Instance.AddFunds(totalCost, TransactionReasons.RnDPartPurchase); return(pointsForTick); } else { return(0f); } } else { return(pointsForTick); } } return(0f); }
private void contractRewards(Contract c) { CurrencyModifierQuery currencyQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.ContractReward, (float)c.FundsCompletion, c.ScienceCompletion, c.ReputationCompletion); fundsReward = c.FundsCompletion; fundsRew = "+ " + fundsReward.ToString("N0"); fundsRewStrat = currencyQuery.GetEffectDelta(Currency.Funds); if (fundsRewStrat != 0f) { fundsRew = string.Format("+ {0:N0} ({1:N0})", fundsReward + fundsRewStrat, fundsRewStrat); } repReward = c.ReputationCompletion; repRew = "+ " + repReward.ToString("N0"); repRewStrat = currencyQuery.GetEffectDelta(Currency.Reputation); if (repRewStrat != 0f) { repRew = string.Format("+ {0:N0} ({1:N0})", repReward + repRewStrat, repRewStrat); } scienceReward = c.ScienceCompletion; sciRew = "+ " + scienceReward.ToString("N0"); sciRewStrat = currencyQuery.GetEffectDelta(Currency.Science); if (sciRewStrat != 0f) { sciRew = string.Format("+ {0:N0} ({1:N0})", scienceReward + sciRewStrat, sciRewStrat); } }
private static float NextKerbalHireCost() { if (GameVariables.Instance == null || HighLogic.CurrentGame == null) { return(1.0f); } CurrencyModifierQuery currencyModifierQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.CrewRecruited, -GameVariables.Instance.GetRecruitHireCost(HighLogic.CurrentGame.CrewRoster.GetActiveCrewCount()) * HighLogic.CurrentGame.Parameters.Career.FundsLossMultiplier, 0.0f, 0.0f); return(-(currencyModifierQuery.GetInput(Currency.Funds) + currencyModifierQuery.GetEffectDelta(Currency.Funds))); }
private void contractRewards() { CurrencyModifierQuery currencyQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.ContractReward, (float)root.FundsCompletion, root.ScienceCompletion, root.ReputationCompletion); fundsRew = (float)root.FundsCompletion; fundsRewStrat = currencyQuery.GetEffectDelta(Currency.Funds); if (fundsRewStrat != 0) { fundsRewString = string.Format("+ {0:N0} ({1:N0})", fundsRew + fundsRewStrat, fundsRewStrat); } else if (fundsRew != 0) { fundsRewString = "+ " + fundsRew.ToString("N0"); } else { fundsRewString = ""; } repRew = root.ReputationCompletion; repRewStrat = currencyQuery.GetEffectDelta(Currency.Reputation); if (repRewStrat != 0) { repRewString = string.Format("+ {0:N0} ({1:N0})", repRew + repRewStrat, repRewStrat); } else if (repRew != 0) { repRewString = "+ " + repRew.ToString("N0"); } else { repRewString = ""; } sciRew = root.ScienceCompletion; sciRewStrat = currencyQuery.GetEffectDelta(Currency.Science); if (sciRewStrat != 0) { sciRewString = string.Format("+ {0:N0} ({1:N0})", sciRew + sciRewStrat, sciRewStrat); } else if (sciRew != 0) { sciRewString = "+ " + sciRew.ToString("N0"); } else { sciRewString = ""; } }
internal void paramPenalties(ContractParameter cP) { CurrencyModifierQuery currencyQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.ContractPenalty, (float)cP.FundsFailure, 0f, cP.ReputationFailure); fundsPenalty = cP.FundsFailure; fundsPen = "- " + fundsPenalty.ToString("N0"); fundsPenStrat = currencyQuery.GetEffectDelta(Currency.Funds); if (fundsPenStrat != 0f) { fundsPen = string.Format("- {0:N0} ({1:N0})", fundsPenalty + fundsPenStrat, fundsPenStrat); } repPenalty = cP.ReputationFailure; repPen = "- " + repPenalty.ToString("N0"); repPenStrat = currencyQuery.GetEffectDelta(Currency.Reputation); if (repPenStrat != 0f) { repPen = string.Format("- {0:N0} ({1:N0})", repPenalty + repPenStrat, repPenStrat); } }
private void contractAdvance() { CurrencyModifierQuery currencyQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.ContractAdvance, (float)root.FundsAdvance, 0, 0); fundsAdv = (float)root.FundsAdvance; fundsAdvStrat = currencyQuery.GetEffectDelta(Currency.Funds); if (fundsAdvStrat != 0) { fundsAdvString = string.Format("- {0:N0} ({1:N0})", fundsAdv + fundsAdvStrat, fundsAdvStrat); } else if (fundsAdv != 0) { fundsAdvString = fundsAdv.ToString("N0"); } else { fundsAdvString = ""; } }
private void Upgrade() { var protoFacility = ProtoFacility; if (protoFacility.GetLevel() == protoFacility.GetLevelCount()) { throw new KOSException("Facility is already max level"); } var upgradeableFacility = protoFacility.facilityRefs[0]; var upgradeCost = upgradeableFacility.GetUpgradeCost(); if (!CurrencyModifierQuery.RunQuery(TransactionReasons.StructureConstruction, -upgradeCost, 0f, 0f).CanAfford()) { throw new KOSException("Insufficient funds"); } Funding.Instance.AddFunds(-upgradeCost, TransactionReasons.StructureConstruction); upgradeableFacility.SetLevel(upgradeableFacility.FacilityLevel + 1); }
private void contractPenalties() { CurrencyModifierQuery currencyQuery = CurrencyModifierQuery.RunQuery(TransactionReasons.ContractPenalty, (float)root.FundsFailure, 0f, root.ReputationFailure); fundsPen = (float)root.FundsFailure; fundsPenStrat = currencyQuery.GetEffectDelta(Currency.Funds); if (fundsPenStrat != 0) { fundsPenString = string.Format("- {0:N0} ({1:N0})", fundsPen + fundsPenStrat, fundsPenStrat); } else if (fundsPen != 0) { fundsPenString = "- " + fundsPen.ToString("N0"); } else { fundsPenString = ""; } repPen = root.ReputationFailure; repPenStrat = currencyQuery.GetEffectDelta(Currency.Reputation); if (repPenStrat != 0) { repPenString = string.Format("- {0:N0} ({1:N0})", repPen + repPenStrat, repPenStrat); } else if (repPen != 0) { repPenString = "- " + repPen.ToString("N0"); } else { repPenString = ""; } }