2024-11-03 21:44:37 +00:00
|
|
|
|
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]
|
2024-12-26 20:21:12 +00:00
|
|
|
|
public static bool Prefix(GClass3685 achievement, bool notify, AbstractAchievementControllerClass __instance)
|
2024-11-03 21:44:37 +00:00
|
|
|
|
{
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|