mirror of
https://github.com/sp-tarkov/modules.git
synced 2025-02-13 09:50:43 -05:00
27 lines
963 B
C#
27 lines
963 B
C#
using System.Reflection;
|
|
using HarmonyLib;
|
|
using SPT.Reflection.Patching;
|
|
|
|
namespace SPT.SinglePlayer.Patches.RaidFix
|
|
{
|
|
public class FixKeyAlreadyExistsErrorOnAchievementPatch: ModulePatch
|
|
{
|
|
protected override MethodBase GetTargetMethod()
|
|
{
|
|
return AccessTools.Method(typeof(AbstractAchievementControllerClass), nameof(AbstractAchievementControllerClass.OnConditionalStatusChangedEvent));
|
|
}
|
|
|
|
[PatchPrefix]
|
|
public static bool Prefix(GClass1368 achievement, bool notify, AbstractAchievementControllerClass __instance)
|
|
{
|
|
if (achievement.IsDone() && __instance.Profile.AchievementsData.ContainsKey(achievement.Id))
|
|
{
|
|
// Tries to add same achievement key a second time, throwing a "An item with the same key has already been added" error
|
|
return false; // Skip original
|
|
}
|
|
|
|
return true; // Do original
|
|
}
|
|
}
|
|
}
|