Skip to content

Commit

Permalink
Split config cost query into a separate method
Browse files Browse the repository at this point in the history
  • Loading branch information
siimav committed Aug 14, 2024
1 parent 4b775e0 commit d8e6dda
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/RealAntennasProject/ModuleRealAntenna.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/// <summary>
/// NOTE: Harmony-patched from RP-1 to factor in unlock credit.
/// </summary>
/// <param name="cost"></param>
/// <returns></returns>
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);
Expand Down

0 comments on commit d8e6dda

Please sign in to comment.