2024-05-21 19:10:17 +01:00
|
|
|
|
using SPT.Reflection.Patching;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
using HarmonyLib;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Reflection;
|
2023-12-27 17:10:25 +02:00
|
|
|
|
using EFT;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
|
2024-05-21 19:10:17 +01:00
|
|
|
|
namespace SPT.SinglePlayer.Patches.RaidFix
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
public class PostRaidHealingPricePatch : ModulePatch
|
|
|
|
|
{
|
|
|
|
|
protected override MethodBase GetTargetMethod()
|
|
|
|
|
{
|
2024-01-13 22:08:29 +00:00
|
|
|
|
return AccessTools.Method(typeof(Profile.TraderInfo), nameof(Profile.TraderInfo.UpdateLevel));
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
[PatchPrefix]
|
2024-08-02 16:57:59 +01:00
|
|
|
|
public static void PatchPrefix(Profile.TraderInfo __instance)
|
2023-03-03 18:52:31 +00:00
|
|
|
|
{
|
|
|
|
|
if (__instance.Settings == null)
|
|
|
|
|
{
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var loyaltyLevel = __instance.Settings.GetLoyaltyLevel(__instance);
|
|
|
|
|
var loyaltyLevelSettings = __instance.Settings.GetLoyaltyLevelSettings(loyaltyLevel);
|
|
|
|
|
|
|
|
|
|
if (loyaltyLevelSettings == null)
|
|
|
|
|
{
|
|
|
|
|
throw new IndexOutOfRangeException($"Loyalty level {loyaltyLevel} not found.");
|
|
|
|
|
}
|
|
|
|
|
|
2023-12-27 21:45:33 +02:00
|
|
|
|
// Backing field of the "CurrentLoyalty" property
|
2024-01-13 22:08:29 +00:00
|
|
|
|
// Traverse.Create(__instance).Field("<CurrentLoyalty>k__BackingField").SetValue(loyaltyLevelSettings.Value);
|
|
|
|
|
__instance.CurrentLoyalty = loyaltyLevelSettings.Value;
|
2023-03-03 18:52:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|