From 9c44ba1474933f8675f54ccc7d4b311b57fac56d Mon Sep 17 00:00:00 2001 From: siimav Date: Wed, 14 Aug 2024 19:09:17 +0300 Subject: [PATCH] Split config cost query into a separate method --- Source/ModuleROHeatshield.cs | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Source/ModuleROHeatshield.cs b/Source/ModuleROHeatshield.cs index dd2482a..bb4648e 100644 --- a/Source/ModuleROHeatshield.cs +++ b/Source/ModuleROHeatshield.cs @@ -353,8 +353,7 @@ public bool IsConfigUnlocked(string configName) public 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); @@ -464,7 +463,7 @@ private PartResource EnsureAblatorResource(string name) } /// - /// Called from RP0KCT + /// Called from RP-1 /// /// /// @@ -497,7 +496,7 @@ public virtual bool Validate(out string validationError, out bool canBeResolved, } /// - /// Called from RP0KCT + /// Called from RP-1 /// /// public virtual bool ResolveValidationError() @@ -508,6 +507,17 @@ public virtual bool ResolveValidationError() return PurchaseConfig(upgd); } + /// + /// 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(); + } + #endregion Custom Methods } }