0
0
mirror of https://github.com/sp-tarkov/modules.git synced 2025-02-13 09:50:43 -05:00
modules/project/SPT.SinglePlayer/Patches/RaidFix/PostRaidHealingPricePatch.cs

37 lines
1.2 KiB
C#
Raw Normal View History

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()
{
return AccessTools.Method(typeof(Profile.TraderInfo), nameof(Profile.TraderInfo.UpdateLevel));
2023-03-03 18:52:31 +00:00
}
[PatchPrefix]
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
// Traverse.Create(__instance).Field("<CurrentLoyalty>k__BackingField").SetValue(loyaltyLevelSettings.Value);
__instance.CurrentLoyalty = loyaltyLevelSettings.Value;
2023-03-03 18:52:31 +00:00
}
}
}