-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Harmony-patch ROHS config can afford query to factor in unlock credit.
Also change other Harmony patches to use the same format.
- Loading branch information
Showing
4 changed files
with
52 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
using HarmonyLib; | ||
using System; | ||
using System.Reflection; | ||
|
||
namespace RP0.Harmony | ||
{ | ||
[HarmonyPatch] | ||
internal class ROHSPartModulePatcher | ||
{ | ||
internal static readonly Type _type = AccessTools.TypeByName("ROHeatshields.ModuleROHeatshield"); | ||
internal static MethodInfo _mi; | ||
|
||
internal static MethodBase TargetMethod() => _mi; | ||
|
||
[HarmonyPrepare] | ||
internal static bool Prepare() | ||
{ | ||
if (_type != null) | ||
{ | ||
_mi ??= AccessTools.Method(_type, "CanAffordEntryCost", new Type[] { typeof(float) }); | ||
} | ||
return _mi != null; | ||
} | ||
|
||
[HarmonyPrefix] | ||
internal static bool Prefix_CanAffordEntryCost(float cost, ref bool __result) | ||
{ | ||
var cmq = CurrencyModifierQueryRP0.RunQuery(TransactionReasonsRP0.PartOrUpgradeUnlock, -cost, 0d, 0d); | ||
double postCMQcost = -cmq.GetTotal(CurrencyRP0.Funds, false); | ||
double credit = UnlockCreditHandler.Instance.TotalCredit; | ||
cmq.AddPostDelta(CurrencyRP0.Funds, credit, true); | ||
__result = cmq.CanAfford(); | ||
|
||
return false; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters