From d8e6dda9440b442140a90884b10de0c9db665f12 Mon Sep 17 00:00:00 2001 From: siimav Date: Mon, 29 Jul 2024 16:49:48 +0300 Subject: [PATCH] Split config cost query into a separate method --- src/RealAntennasProject/ModuleRealAntenna.cs | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/RealAntennasProject/ModuleRealAntenna.cs b/src/RealAntennasProject/ModuleRealAntenna.cs index 6bf760d..d0fc912 100644 --- a/src/RealAntennasProject/ModuleRealAntenna.cs +++ b/src/RealAntennasProject/ModuleRealAntenna.cs @@ -487,14 +487,24 @@ public virtual bool ResolveValidationError() private static bool PurchaseConfig(PartUpgradeHandler.Upgrade upgd) { - CurrencyModifierQuery cmq = CurrencyModifierQuery.RunQuery(TransactionReasons.RnDPartPurchase, -upgd.entryCost, 0, 0); - if (!cmq.CanAfford()) + if (!CanAffordEntryCost(upgd.entryCost)) return false; PartUpgradeManager.Handler.SetUnlocked(upgd.name, true); GameEvents.OnPartUpgradePurchased.Fire(upgd); return true; } + /// + /// NOTE: Harmony-patched from RP-1 to factor in unlock credit. + /// + /// + /// + private static bool CanAffordEntryCost(float cost) + { + CurrencyModifierQuery cmq = CurrencyModifierQuery.RunQuery(TransactionReasons.RnDPartPurchase, -cost, 0, 0); + return cmq.CanAfford(); + } + private static PartUpgradeHandler.Upgrade GetUpgradeForTL(int techLevel) { TechLevelInfo tlInf = TechLevelInfo.GetTechLevel(techLevel);